Advertisement

04.23.2008 at 12:52PM PDT, ID: 23348088
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Preloading External SWF's

Asked by poweraddict in Macromedia Flash

Tags: ,

I have several swf's in a folder.

For the first swf I have the following:
ActionScript Code:

myProgressBarListener = new Object();

/* Create a listener object event function. When the Progress Bar is complete and has preloaded this Movie, the listener will call and run this code below:   */
myProgressBarListener = function (eventObject) {

// Hide the Progress Bar - we dont need it any more as the Movie has now loaded
myProgressBar._visible = false;

// Remove the listener
myProgressBar.removeEventListener("complete", myProgressBarListener);

// Ends the function
};

// Declares a listener. This detects when the Progress Component has loaded the Movie. Then when the preloading is complete it calls the function myProgressBarListener
myProgressBar.addEventListener("complete", myProgressBarListener);

// Set up the Progress Bar Component to polled when loading the Movie. This will give a polled look to the Progress Bar as it loads. It has to be set to polled to work
myProgressBar.mode = "polled";

// Set the location to load as this Movie.
myProgressBar.source = "_root";




very next frame I have
ActionScript Code:
// Create a Movie Clip to load the swf Movie into
this.createEmptyMovieClip("myExternallyLoadedSWFMovieHolder", 0);


// A variable to hold the name and location of where the external swf Movie is located
var myVariable = "Quiz_02.swf";

// Set the Movie's location on the Stage
myExternallyLoadedSWFMovieHolder._x = 0;
myExternallyLoadedSWFMovieHolder._y = 0;

/* Set the Progress Bar to manual mode so that we can reset its value back to 0. We don't want it staring from 100 ! */
myProgressBar.mode = "manual";
// Reset the Progress Bar back to zero
myProgressBar.setProgress(0, 100);

// Show the Progress Bar
myProgressBar._visible = true;

// Create a listener object event.
myProgressBarListener = new Object();

// When the Progress Bar is complete and has preloaded the Movie, the listener will call and run this code below:
myProgressBarListener = function (eventObject) {

// Hide the Progress Bar now the Movie is loaded
myProgressBar._visible = false;

// This next section is optional.
// If you wish to remain on Frame 2 and view the External Movie do nothing
// Otherwise un-comment any of the options bellow:
// Plays the Movie from Frame 2 onwards:
// play();
// Go to the next Frame:
// nextFrame();
// Go to the next scene but may not automatically play beyond the Frame 1 in the next scene:
// nextScene();
// Goes to a Frame Label or Frame number and Play:
// gotoAndPlay("myFrameLabel");
// gotoAndPlay(10);
// Go to and stop at the Frame Label or Frame number:
// gotoAndStop("myFrameLabel");
// gotoAndStop(10);

// closes the function
};

// Declares a listener that detects when the Progress Component has loaded the external Movie and is complete.
// It will call the function myProgressBarListener when the external swf Movie has loaded
myProgressBar.addEventListener("complete", myProgressBarListener);

// Set up the Progress Bar Component variables
// Set up the Progress Bar Component to polled when loading the Movie. It has to be set to polled to work
myProgressBar.mode = "polled";


// Set the preloader source to show the progress of the loader Component as it loads the external swf Movie
myProgressBar.source = "myExternallyLoadedSWFMovieHolder";

/* This is how we automatically load the external swf Movie. We call the load Movie Clip event and load the external swf Movie into the Movie Clip we created through ActionScript */
stop();


Same frame but layer under I have
ActionScript Code:

unloadMovieNum(53);
loadMovie(_root.myVariable, _root.myExternallyLoadedSWFMovieHolder);
stop();




Then a user clicks a button and this code runs:
ActionScript Code:

_root.myExternallyLoadedSWFMovieHolder.gotoAndPlay(2);
unloadMovieNum(53);
stop();





That works great.

Problem is on the next SWF I have pretty much the same code:

1st frame:
ActionScript Code:
myProgressBarListener = new Object();
myProgressBarListener = function (eventObject) {
myProgressBar._visible = false;
myProgressBar.removeEventListener("complete", myProgressBarListener);
};
myProgressBar.addEventListener("complete", myProgressBarListener);
myProgressBar.mode = "polled";
myProgressBar.source = "_root";



2nd frame:
ActionScript Code:

var myVariable2 = "Quiz_03.swf";
this.createEmptyMovieClip("quiz3holder", 0);

quiz3holder._x = 0;
quiz3holder._y = 0;
myProgressBar.mode = "manual";
myProgressBar.setProgress(0, 100);
myProgressBar._visible = true;
myProgressBarListener = new Object();
myProgressBarListener = function (eventObject) {
myProgressBar._visible = false;
};
myProgressBar.addEventListener("complete", myProgressBarListener);
myProgressBar.mode = "polled";
myProgressBar.source = "quiz3holder";

stop();



same frame bottom layer I have:
ActionScript Code:

unloadMovieNum(53); l
oadMovie(_root.myVariable2, _root.quiz3holder);
stop();



Last frame I have:

ActionScript Code:

_root.quiz3holder.gotoAndPlay(2); //unloadMovieNum(53); //unloadMovieNum(54); stop();



This works great when I test the SWF's on my hard drive, when I upload them to the web server, the first swf works and loads the 2nd swf, then when the user clicks the button in the 2nd swf is restarts from the beginning....

Any ideas?Start Free Trial
[+][-]04.26.2008 at 04:56PM PDT, ID: 21447230

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Macromedia Flash
Tags: Actionscript, Flash, All
Sign Up Now!
Solution Provided By: tagit
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628