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

variables 1

Status
Not open for further replies.

QTip

Programmer
Mar 7, 2001
66
BE
can I send variables from one swf to another?
Ex.
I have 2 swf's. swf1 loads swf2. If the variable i in swf1 equals 5, then frame 10 of swf2 has to be loaded.
Someone has an idea?
 
Supposing swf1 is a 12 frames movie... And swf2 has a stop() action on it's frame 1, when you hit enter, swf1 will cycle through 5 times and then tell swf2 (which is already loaded in emptymc and stopped) to go to frame 10 and stop if there's also a stop() action on frame 10.

Frame 1 of swf1:

_level0.myvar = 0;
loadMovie ("swf2.swf", "_root.emptymc");
stop ();

Frame 12 of swf1:

_level0.myvar += 1;
if ( _level0.myvar == 5 ) {
_root.emptymc.gotoAndStop(10);
stop();
}
else{
gotoAndPlay(2);
}
mywink2.gif
ldnewbie
 
You can send variables as you load the second movie too.

on(release){
_root.variable2send=_root.i;
loadMovie("secondMovie.swf","","GET");
}


...would create a variable to send between the two movies which is equal to your variable i. A handling script in your second movie such as...

onClipEvent(load){
if (_root.variable2send==5){
_myMovieClip.gotoAndStop(10);
}


... will catch this variable and act on it - in this case sending a movieClip to frame 10.
 
Can't get away from that onClipEvent can you? LOL
mywink2.gif
ldnewbie
 
What can I say? I'm an object-oriented kinda guy...;-)

Mind you it means that none of my movies are more than one frame long which makes debugging a breeze.
 
thnx guys!

Offcourse I have another question :)

I do this in the first swf file (in button1):
on (release) {
var i=1;
loadMovieNum ("test2.swf", 0, "GET");
}

When I test this swf, and I click on button1 then, then it's says:
Error opening URL "file:///C|/Temp/test2.swf?i=1"

but I have a swf called test2 and it's also in the Temp directory, so why can't he find it?
 
Nat,
Is this still for your side menu? like testgigforum?
mywink2.gif
ldnewbie
 
the 2 files are in the same directory. The first is called test1.swf and the second is called test2.swf

So does anybody know why he can't find test2.swf?
 
Sorry for my previous post... Wrong thread!

As for you Qtip, I can't get Wangbar's code to work either!
Although it does work when I use POST rather than GET.
You must also target a holder clip to hold the second movie.

Code in swf1 is:

_root.variable2send = 10;
loadMovie ("swf2.swf", "_root.emptymc", "POST");
stop ();

Code in swf2 is:

if (_root.variable2send == 10) {
gotoAndStop (10);
} else {
gotoAndStop (14);
}
stop ();

If variable2send equals anything but 10, swf2 goes to frame 14 rather than 10.

Regards,
mywink2.gif
ldnewbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top