A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Getting a set "Var" from a MC

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    2

    Getting a set "Var" from a MC

    Hey guys, so here is my problem

    In my main timelime, I have a code for:
    "if (page == 1)
    {
    gotoAndPlay(249);
    }
    if (page == 2)
    {
    gotoAndPlay(275);" etc


    where page is set from within a MC by a button

    I attempted to use this:
    "MovieClip(root).var page:Number = 1
    MovieClip(root).play();"

    This plays the main timelime, but doesn't set the var
    I'm pretty stumped, can anyone help out?

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You only use the 'var' keyword when you originally declare the variable. From then on you simple refer to it by name.
    For instance, in the main timeline (frame 1):
    Code:
    var page:Number; // you don't need to assign a default value. Number types happen to default to 0
    then later, provided your object can "see" that variable.

    Code:
    scope.of.the.var.page = 1;

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