A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [AS3] Changing stage variables from within a movie clip

  1. #1
    Senior Member craziumdude's Avatar
    Join Date
    Sep 2005
    Location
    Fort Wayne, IN
    Posts
    109

    [AS3] Changing stage variables from within a movie clip

    I'm brand new at as3, just switched from as2. I want to change variables on the main stage's code from within a movie clip.

    Say for example, I want to change a variable called 'chair'

    In AS2, this is how I would do it:

    (on the main stage)
    Code:
    chair = 2;
    (in the movie clip)
    Code:
    _root.chair = 1;
    So in AS3 I have:
    (stage)
    Code:
    var chair:Number = 2;
    (movie clip)
    Code:
    _root.chair = 1;
    But all I get is a 1119 error saying 'Access of possibly undefined property chair through a reference with static type flash.displayisplayObject.'

    I tried googling this problem but I couldn't quite word it right. Help?

  2. #2
    AKA [ Paul Bainbridge] webdreamer's Avatar
    Join Date
    Aug 2001
    Location
    Glasgow, Scotland, UK
    Posts
    3,320
    Actionscript Code:
    MovieClip(root).chair=1
    .: To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Twitter - Linkedin
    bringmadeleinehome.com

  3. #3
    Senior Member craziumdude's Avatar
    Join Date
    Sep 2005
    Location
    Fort Wayne, IN
    Posts
    109
    Thank you very much

    I do have one more minor question

    My movie clip is set to stop at frame 1. I set a var to trigger my movie clip to gotoAndPlay (2);

    It just goes to 2 and stops. I tried adding play(); to frame 2 in the movie clip but it still gets stuck on frame 2. :/

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Could you post the code or possibly even the FLA file?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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