PDA

View Full Version : variables, does this work?


PowerSerge
06-09-2004, 03:37 PM
currentclip="skeleton_mc";
currentclip.onEnterFrame = moveStuff;


if I were to have that, would it be the equivelant of...

skeleton_mc.onEnterFrame = moveStuff;

?

JEBoothjr
06-09-2004, 03:53 PM
no it would be:


_root[currentClip].onEnterFrame=moveStuff;

PowerSerge
06-09-2004, 03:56 PM
thanks.

so _root[currentclip]

is equivelant to _root.skeleton_mc then?

do the []'s work like the . ?

petefs
06-09-2004, 03:56 PM
or:

currentclip=skeleton_mc;
currentclip.onEnterFrame=moveStuff;

^_^

JEBoothjr
06-09-2004, 03:59 PM
Yes, _root[currentclip] would be the same as _root.skeleton_mc

The []'s evaluate the variable 'currentclip'. If you just use _root.currentclip, Flash would look for a clip called "currentclip", which is not what you want. You are using a variable clip name.

PowerSerge
06-09-2004, 04:12 PM
Thanks :)

one more thing....
I have all the code in the first frame, and so it repeats 31 times each seconds... what do I do if I just want it to declare a variable once when the movie starts? What I'm trying is....

if(firstrun!==false)
{
currentclip="skeleton_mc";
firstrun=false;
}

but I don't think it's working.

tg
06-09-2004, 04:14 PM
if(firstrun!=false)

loose one of the = signs.

petefs
06-09-2004, 04:17 PM
hm, shouldn't a strict inequality work with a simple boolean comparison?

I mean, it's unnecessary, but maybe I'm just confused... ^_^ A good explanation would help me learn the error of my ways.

PowerSerge
06-09-2004, 04:18 PM
Nevermind ;) I just used the first frame for variables and then stopped the animation on the second and used the main code there.

tg
06-09-2004, 04:44 PM
how/where are you initializing your variable?

JEBoothjr
06-09-2004, 04:46 PM
There must be something else wrong with your code. I can get it to work with or without strict equality. Can you post a little more of it, or the fla?

PowerSerge
06-09-2004, 04:46 PM
But... new problem.

I have it so an animation runs. When the movie clip is done running I need the program to change it to something else, so I put a bit of code on the last frame of the movie clip... but the code in the movie clip doesnt run. The movie clip does, but the code doesn't.

Any thoughts?

JEBoothjr
06-09-2004, 04:53 PM
Can you post the fla?

PowerSerge
06-09-2004, 05:03 PM
This link should be right:
http://s94450126.onlinehome.us/game.fla

by the way, as you'll notice, I'm having other problems with it... for some reason the movie clip isn't appearing at the right x and y.... they were working before O_o