A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: variable question

  1. #1
    Senior Member
    Join Date
    Mar 2002
    Posts
    270

    variable question

    I want to change the value of a variable within a movieclip from the main timeline. How would I do this?

    My variable is "visited" and I want to set it to "true" or "1" from the main timeline.

    My variable is located on the timeline within this movie: _root.newButtonMC.button1

    I thought this might work:
    Code:
    _root.newButtonMC.button1.visited = 1
    Thanks for you help!
    Erik Peterson
    Project o3

  2. #2
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Its correct if button1 also is a moviclip. ( the names has to be instance names ).
    All instances has to be present in the timeline when you set the variable though.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  3. #3
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    You should use true instead of 1.
    That (will) matter(s) in AS 2.0.

  4. #4
    Senior Member
    Join Date
    Mar 2002
    Posts
    270
    hmm... I must have a problem somewhere else. I doesn't seem to be working...
    Erik Peterson
    Project o3

  5. #5
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    If newButton is a movie clip.
    If button1 is a movie clip.

    If you attach your code to a timeline and the buttons are both on the stage, it should be ok.

    Try this, to help you debug:
    code:

    trace(_root.newButtonMC); // shouldn't be undefined
    trace(_root.newButtonMC.button1); // shouldn't be undefined
    trace(_root.newButtonMC.button1.visited); // probably is undefined
    _root.newButtonMC.button1.visited = true;
    trace(_root.newButtonMC.button1.visited); // shouldn't be undefined


  6. #6
    Senior Member
    Join Date
    Mar 2002
    Posts
    270
    I used this code:
    Code:
    trace("newButtonMC = " + newButtonMC); // shouldn't be undefined
    trace("newButtonMC.button1" + newButtonMC.button1); // shouldn't be undefined
    trace("newButtonMC.button1.visited = " + newButtonMC.button1.visited); // probably is undefined
    newButtonMC.button1.visited = 1;
    trace("newButtonMC.button1.visited = " + newButtonMC.button1.visited); // shouldn't be undefined
    This is what was returned:
    newButtonMC = _level0.butMovie.square_3.button1holder
    newButtonMC.button1_level0.butMovie.square_3.butto n1holder.button1
    newButtonMC.button1.visited =
    newButtonMC.button1.visited = 1

    So it looks like my problem is elsewhere... Hmm looks like I gotta do some diggin...
    Erik Peterson
    Project o3

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