A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Can't get another MC to play from within another MC

  1. #1
    Junior Member
    Join Date
    Mar 2005
    Posts
    20

    [F8] Can't get another MC to play from within another MC

    I have a movie clip named "mainPageMC" that I use to group a button and another MC named "mainPageMCGroup". That mainPageMCGroup movie clip has a bunch of movie clips inside of it.

    I am trying to get the button to play a specific movie clip inside the mainPageMCGroup movie clip. Specifically that movie clip's name is called "path1-5".

    I've put this code in the button:

    _level0.instance1.path1-5.gotoAndPlay(2);

    I've even tried:

    _root.mainPageMC.mainPageMCGroup.path1-5.gotoAndPlay(2);

    and they both give me this error:

    **Error** Symbol=mainPageMC, layer=buttons, frame=1:Line 3: Syntax error.
    _level0.instace1.path1-5.gotoAndPlay(2);


    This seems soooo silly that I can't reference movie clips properly and it's probably something I'm doing that's stupid.

    Question 1: How can I reference this movie clip to play?

    Questions 2: Shouldn't I be able to get to items via the _root? I've tried simple things like _root.whateverMC.gotoAndPlay() and that doesn't work, and when I call a trace(this) it gives me that _level0.instance1... what's up with that?

    Thanks!

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    path1-5 is an invalid instance name. instance names should not:
    - contain signs // your case
    - contain spaces
    - start with numbers

    gparis

  3. #3
    Junior Member
    Join Date
    Mar 2005
    Posts
    20
    Thanks! That was the problem causing the syntax error.

    It did not solve the referencing problem however...

    I changed that movie clip's name to "path15" (removed the dash) to make it valid. Then I tried the two versions of the gotoAndPlay() above and none of them caused that MC to play. That is physically where the movie clip is so why isn't it working?

    On a side note, I did get it to play the MC however. I realized I could use a on (release) { trace(this); } inside of the path15 mc itself. I then ran the movie and clicked the path15 mc and it said "_level0.instance1.instance2.instance5". I used that to call this when the button was clicked:

    _level0.instance1.instance2.instance5.gotoAndPlay( 2);

    It worked... BUT WHY?!? Why can't I reference it with the _root syntax and travel down the movie clip path from the root? That makes much more sense to me than these random instance names that I have to figure out! Please explain someone

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    you do not target movieclips by their names, but by their instance names given via the object properties window. Your trace just reveals that none of your mcs have instance names.

    gparis

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