dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: passing variables (noob)

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Posts
    9

    passing variables (noob)

    I'm stuck...

    I want to set a variable somewhere (root or mc) and access it from somewhere else (other mc).

    How is this done in as3?

  2. #2
    Member
    Join Date
    Jun 2008
    Posts
    30
    var something:int = 5;
    or
    mc.something = 5;

  3. #3
    Junior Member
    Join Date
    Mar 2007
    Posts
    9
    I set the variable at the root timeline:

    var MyVar:Number = 5

    and then

    Trace(MyVar) returns 5

    but when I try to access MyVar from an Mc I get:

    1120: Access of undefined property MyVar

    What to do?

  4. #4
    Member
    Join Date
    Jun 2008
    Posts
    30
    Trace(stage.MyVar);

  5. #5
    Junior Member
    Join Date
    Mar 2007
    Posts
    9
    I think this works...

    on the root level:
    MyMc.MyVar = 5

    In MyMc
    var MyVar:Number = MyVar;
    trace(MyVar)

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