A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: variables as mc names

  1. #1
    so i have this problem. i am trying to use a variable to tell my movie which movie clip to play--each nav button sets the variable determining which movie clip plays. after clicking a button, several animation type things happen to rearrange the page before the content for the specific section appears.

    i have this code on a button in the first frame:

    on (release) {
    gotoAndPlay(2);
    section = "about";
    }

    then around frame 30 this is in the frame:

    section.gotoAndStop(2);
    stop();
    trace (section);

    but then the section never appears. i did a trace and the right variable (about) is showing up. i tried putting the contents of the movie clips in their own frames, and that works, but it would be easier if they were in movie clips instead.

    any thoughts on why that isn't working?

  2. #2
    Member
    Join Date
    Nov 2001
    Posts
    96
    Looks like an address issue. If the code you`ve posted is within a button and therefore nested within the main timeline, then you`ve got to point the player back to parent timeline before before it targets the right MC. So...


    on (release) {
    gotoAndPlay(2);
    _root.section = "about";
    }

    And then in frame 30...

    _root.section.gotoAndStop(2);
    stop();
    trace (_root.section);

    This assumes that the "section" variable is associated with the root timeline, and the same for the "about" MC.

    Hope it helps. These problems are easier to solve than they are to explain.

    Cheers

  3. #3
    the usual
    Join Date
    Jul 2000
    Posts
    1,482
    Code:
    on (release) { 
    gotoAndPlay(2); 
    _root.section = "about"; 
    }
    heres what you need

    Code:
    _root[_root.section].gotoAndStop(2); 
    stop(); 
    trace (_root.section);

  4. #4
    Member
    Join Date
    Nov 2001
    Posts
    96
    Not meaning to inslt your intelligence, apollo1, it usually takes me hours to figure out why my stuff isn`t working, and then I find out that I simply haven`t named my MC. D`oh. So try that too.

  5. #5
    many many thanks. i was about to do something drastic. . . but that worked like a charm!

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