Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables to a loaded movie

Status
Not open for further replies.

bscene

Programmer
Aug 25, 2004
5
CA
I have a navigation bar that I have loaded into level3 of my main movie. When the user clicks one of the navigation buttons they should be taken to a specific point on the timeline of a movie that I have loaded into level2 of my main movie. Currently it will only go to the specified frame if the button is pressed a second time.

Here is the action I have for the buttons...

on (release) {
frame = "af"; // this value is different for each button
unloadMovieNum (2);
loadMovieNum ("globes.swf", 2, "GET");
}

On the first frame of my level2 movie (globes.swf), I have the following action to check for the value of "frame" and then take the appropriate action

if (frame != "") {
gotoAndPlay(frame);
} else {
gotoAndPlay("rotate");
}

I am really puzzled on how to accomplish this.
Any help is greatly appreciated.
 
You can't direct a external loaded movie to a specific frame, until you're sure it's fully loaded...
Code:
on (release) {
// this value is different for each button    
    _global.frame = "af"; 
    //unloadMovieNum (2);
    // If you keep loading your movies
    // on the same level, there's no need
    // to unload the previous movie...
    loadMovieNum ("globes.swf", 2);
    // no need for "GET"...
}

Next, on the loaded movies' first frame, try this...

Code:
stop();
this.onEnterFrame = function(){
    if(_global.frame != undefined){
        this.gotoAndPlay(_global.frame);
        delete this.onEnterFrame;
    } else {
        this.gotoAndPlay("rotate");
    }
};
 
Thanks very much, that solved my problem. I have one more small problem in that I need the Flash movie to be able to read the value of the "frame" variable from my query string so that the movie can start on a specified frame.

eg. index.php?frame=sp
 
Yes. The main movie loads into and because "frame" is undefined, globes.swf on level2 shoould stop at the frame labelled 'rotate'. If I load index.php?frame=sp, globes.swf should advance the frame labelled 'sp'.

I almost have it working now. In my PHP page I have the following code:
<param name="m1" value="main.swf?<?= "frame=".$frame ?>" />

Then on the first frame of the main movie I have the following code:
stop();

this.onEnterFrame = function(){
if(_global.frame == undefined){
_global.frame = frame;
}
};

loadMovieNum ("nav.swf", 3);
loadMovieNum ("globes.swf", 2);

It is working fine except that the first time the page loads, globes.swf does not load. This happens regardless of whether 'frames' is defined in the query string or not.
 
If you switch the loading, which one doesn't load the first time around?

loadMovieNum ("globes.swf", 2);
loadMovieNum ("nav.swf", 3);

 
I switched it around and it is still globes.swf that does not load. All I need to do is refresh the page and then it loads. Needless to say I am making sure that I am not viewing a cached version each time.
 
Wait a minute...
What does a trace ouput here...
Code:
this.onEnterFrame = function(){
    if(_global.frame == undefined){
        _global.frame = frame;
        [b]trace(_global.frame);[/b]
    }
};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top