Weird Variable Problem
March 14th, 2010This does work:
onClipEvent(enterFrame) {
_root.background.picture._x += .5;
}
It moves the MC .5 pixels everytime the playhead enters the frame.
Now, I'm trying to simply change the .5 to a _global variable that I have. So I'm using:
onClipEvent(enterFrame) {
_root.background.picture._x += _global.xspeed;
}
For whatever reason, this causes my MC to disappear. I've even traced the _global.xspeed to see that the variable is even there and it is. The only thing that I can possibly see is that when I traced the variable _global.xspeed, the first thing for a nano second was "undefined". After that it was all numbers.
How can I fix this? Is there a way to say "if _global.xspeed is a number then do this else don't do anything"?
Here's the code I use:
onClipEvent(enterFrame) {
if (isNaN(_global.xspeed)) {
//nothing
}
else{
_root.background.picture._x += _global.xspeed;
}
//trace(_root.background.picture._x+" and "+_global.xspeed);
}
onClipEvent(enterFrame) {
xyz = (_global.xspeed/1);
if (isNaN(xyz)) {
//nothing
}
else{
_root.background.picture._x += xyz;
trace(_root.background.picture._x+" and "+ xyz);
}
}
I just added that bit in red, and it did the trick. Very strange I think.
#If you have any other info about this subject , Please add it free.# |