A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: global or root?

  1. #1
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215

    global or root?

    hello,

    For most of my flash scripts, i have been using _root. for variables that being used by different scripts in different areas,

    but i have recently noticed that _root. does not affect scripts in different scenes,

    say that i have have _root.hello = 10; in scene 1, and I also have that in scene 2,
    now if i change _root.hello in scene 1, my _root.hello in scene 2 will not change

    I experimented on using _global but it doesnt work either,

    is there a similar script to _root. that might be able to change variables in between scenes? (im using MX7)

    thx a bunch!
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  2. #2
    Member
    Join Date
    Aug 2005
    Location
    Vienna, Austria
    Posts
    56
    huh?

    both _root and _global should work in different scenes...

  3. #3
    n00b LeechmasterB's Avatar
    Join Date
    May 2004
    Location
    Switzerland
    Posts
    1,067
    From what you say it is logical that it works the way it does.

    If you define the variable in both scenes new and only chance it in one scene it will still be redefined in the other scene and therefore be another value.
    So what you should do is define the variable and then only change it in the scenes but not redefine it all the time.

    example:

    you have this code in

    scene 1: _root.hello=10;

    scene 2:_root.hello++;

    scene 3: trace(_root.hello);

    whenever you go to scene 1 it will be reset to 10
    whenever you go to scene 2 it will be increased by one
    and it will be traced as the current number in scene three
    I do stuff that does stuff...

    J-Force

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center