View Full Version : Passing frame label as expression to GotoandPlay...
Slash
05-09-2002, 12:32 PM
Hello,
I got a funny problem.
I have a movie with labeled frames and I use a random function to randomly go to one of them. Frame labels are loaded into array and then selected randomly like in example below:
// Example:
var frame_array = new Array();
frame_array[0] = "Frame label 1";
frame_array[1] = "Frame label 2";
rnd_element = random(frame_array.length);
rnd_frame = frame_array[rnd_element];
// Now when I say:
GotoAndPlay(rnd_frame); // This doesn't work
GotoAndPlay("\"" + rnd_frame + "\""); // Doesn't work either
It only works when I load frame numbers into array instead of frame labels. Does anyone know how to pass frame label as expression to GotoAndPlay command?
mad_A
05-09-2002, 01:08 PM
you need to use gotoAndPlay() not GotoAndPlay()
Slash
05-10-2002, 04:51 AM
That is what I used. I just made a typo in my previous message.
As I said, it works perfectly when you pass frame numbers in exactly the same manner, but not with frame labels.
JHallam
05-10-2002, 01:52 PM
Make a function of the rnd element, the array looks fine just make sure the paths are positive.
pinkaboo
05-10-2002, 02:12 PM
or just use:
gotoAndPlay((rnd_frame));
or who needs rnd_frame at all?
gotoAndPlay(frame_array[rnd_element]);
just did a quick test and both seem to work fine
although *scratches head* I just got it to work using gotoAndPlay(rnd_frame); too, maybe the problem is your pathing?
K
Slash,
Mabye another mis-type mabye not but you have two extra quotes in your Goto action.
And this works for me as well (5 & MX).
I can post an e.g. if you realy need it. ;)
HTH :),
--FADE
Slash
05-10-2002, 10:21 PM
Thanks for all your replies, guys.
I played with the code a bit and find it rather strange.
---- Case 1: ----
gotoAndPlay ("Frame Label");
// The result is what it should be, it goes to the entered frame label and plays it
---- Case 2: ----
rnd_prompt = "Frame Label";
gotoAndPlay (rnd_prompt);
// Thinking logically, this should do the same thing. But it doesn't go and play that frame. I quadruple-checked all the code (there is not much code here anyway) and it still doesn't work. I even tried adding extra quotes, brackets... no luck.
Slash,
Three things:
1) See if you can recreate the problem in a test FLA.
2) If you cann't, find the difference between the test and your real proj. If you can't find the difference zip and post your proj. file and I'll see what I can do.
3) If you can, zip and post the test FLA and I'll try and figure out what's wrong with it.
In any of these cases I or other members of the board are ready to help you fix this delima! ;)
UYNP :D,
--FADE
jhakooz
11-18-2004, 08:45 PM
I ran into this same problem and I found the solution. I'm using MX.
Slash's code:
rnd_prompt = "Frame Label";
gotoAndPlay (rnd_prompt);
My Code (Doesn't work):
_root.myVar = "myFrameLabel";
gotoAndPlay (_root.myVar);
The solution, for me at least, was to make the gotoAndPlay an absolute path.
So correct code is:
_root.myVar = "myFrameLabel";
_root.gotoAndPlay (_root.myVar);
Again, for me this fixed the problem. Not sure why but it would only work when the gotoAndPlay used an absolute path.
Hope this helps someone stuck in the same "simple" rut.
Joe
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.