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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading external movie and jumping to pre-defined frame. 1

Status
Not open for further replies.

cu92

Technical User
Feb 11, 2003
6
GB
Can anyone help with this piece of scripting?

At the end of an animated sequence of my 1st movie I would like to load in a 2nd external .swf file that replaces the 1st movie completely and at the same time jumps to a pre-defined frame of the new 2nd movie. Hope that makes sense..

I have found this related script that was suggested to another forum member (thanks to Benjer)

This goes into a blank movie clip onstage:

onClipEvent(load){
loadMovieNum("second_movie.swf",4);
targetFrame=94;
}
onClipEvent(enterFrame){
trace(_level4.getBytesLoaded());
if(_level4.getBytesLoaded()==_level4.getBytesTotal() && _level4.getBytesLoaded()>4){
_level4.gotoAndPlay(targetFrame);
}
}

I can't get this to work where it replaces the first movie completely and jumps to the required frame. Can anyone give me an idea of what I should do? I tried changing the levels to 0 but this doesn't seem to work - it just plays the imported movie from the beginning each time.

Thanks for any help.
 
the problem is making sure the movie is loaded first before trying to jump to a frame...this is a workaround but it works
Imagine 3 buttons each of which are to load the same swf but jump to different frames. Attach a variable to the loadmovie action as so

loadMovieNum ("2.swf?vars=button1", 1);
loadMovieNum ("2.swf?vars=button2", 1);
loadMovieNum ("2.swf?vars=button3", 1);

Now all you need is to check the variable in 2.swf and based on result
do stuff , so in first frame of the movie I would set preloader
than right after the preloader the following frame action :

if (vars == "button1") {
// some action here , gotoAndPlay("frame") ; etc..
} else if (vars == "button2") { // some action here , gotoAndPlay("Frame") etc..
} else if (vars == "button2") { // some action here , gotoAndPlay ()
}


There may be a much simpler way to do this but the above at least works...waits till the movie is loaded, checks a variable and then goes to a frame or whatever.
 
Thanks Bill

I understand the logic but I'm quite new to Flash so I'm a bit rusty with the practice.

I have tried what you suggested and can't get it working at the mo - if I quickly spell out what I am doing perhaps you could tell me where I'm going wrong?

Movie 1 has the 2.swf preloader script on frame 1. On frame 2 it has three buttons each with the button 1,2,3 action:

on (release) {
loadMovieNum ("2.swf?vars=button1", 1);
}


The code ' if (vars == "button") { ' - does that sit in frame 2 of the 1st Movie?

If that is the right idea I will persevere - if not I would very much appreciate a little nudge in the right direction..

Many thanks in advance.
 
let me try and make it clearer

the buttons lie in movie one

the preloader and the if statements lie in movie 2
if movie 2 is quite small you might want to try just omitting the preloader.
the if statements in movie 2 come on the first frame after the preloader. you want movie 2 to load and then do something depending on the variable you have passed

it look s like in your case (just read the first post again) that you just want to load movie 2 from the last frame of movie 1 and go to a particular frame in movie 2.
so in the last frame of movie 1 add the code to load movie 2 then as above preloader in first frame of movie 2 and if statement on next available frame.

hope that a bit clearer.
 
Any particular reason you want to get rid of the first movie completely, as opposed to simply hiding it?
Do you have access to the second movie's .fla?
Will the frame this second movies goes to allways be the same, or might it change? Regards,

oldman3.gif
 
Hello Bill

Thanks for making that clearer - I've sorted it out now and very much appreciate the help.

In answer to Oldnewbies questions:

The reason why I wanted to get rid of the old movie was that it was a view once movie and I just wanted it out the way once the 2nd movie was there.

I do have access to the 2nd movie and the frame will always be the same.

Thanks for your interest
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top