#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    4
    Rep Power
    0

    Internal variable through the frames


    Hello!
    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.
    Regards, Leo

    Comments on this post

    • Gran Roguismo agrees
  2. #2
  3. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    hello,

    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.

    cheers,

    bret
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    4
    Rep Power
    0

    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";
    Regards, Leo
  6. #4
  7. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    hum...

    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);
    //or
    if(myVar=="test"){
    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...

    cheers,

    bret

IMN logo majestic logo threadwatch logo seochat tools logo