February 22nd, 2003, 05:35 AM
Internal variable through the frames
I have a small issue and just wonder if somebody faced the same problem and knows how to solve it.
I need to perform some operations on the internal variable and have persistence through the frames in timeline. But for some reasons either because my variable is not global or any other I can't achieve situation when my next frame accesses variable that has been modified in the previous frame. In other words my variable become constant and I can perform operations only within a frame.
If somebody knows how to change variable content through frames and monitor this changes I will appreciate that.
Comments on this post
February 24th, 2003, 10:47 AM
as a work around, just make the variable global
add _global to the front of it:
_global.myVar = "something";
and when you refer to it, just sa "myVar". you only need the _global in the declaration.
February 25th, 2003, 05:44 AM
Global variable is not accessible
Thank You bret,
but it doesn't work with me.
I had first frame with global declaration but on the next keyframe when I try to access the variable I can't do it.
Is it only declaration I can make? _global.myVar = "test";
February 25th, 2003, 08:59 AM
if you say (on any line of code/frame before you need the variable):
_global.myVar = "test";
//at any point after that, you should be able to reference myVar:
trace("myVar :" + myVar);
or whatever you want to do with that... i know that script executes like it should... copy and paste into your movie and then adapt it to the variable you need... one thing to keep in mind is that you can't have *any* local variables named the same thing... If the variable overwrites the _global variable, it will fail silently...