Skip to main content
August 29, 2009
Question

Can't get movie clip to communicate with its parent...

  • August 29, 2009
  • 2 replies
  • 528 views

Hi everyone,

So, I am making a Flash website, and we'll say that the movie is called ninja.swf.

Within ninja.swf, there are six scenes, and in the later 5 scenes, there is an movie clip (consule2)with has a halfdozen buttons (of which one is home_btn) that serve as the navigation across the site. So, in the consule2, I set up an Actions layer, and for Home_btn, have created this piece of code:

//Home Button
function gotodsHome(event:MouseEvent):void{
            MovieClip(root).gotoAndPlay("FullLoaded","01_Landing_Page");
}
Home_btn.addEventListener(MouseEvent.CLICK, gotodsHome);

...with "FullLoaded" being a labeled frame within "01_Landing_Page" (the first scene of ninja.swf).

But, when I test the movie, and click on the link, it gives me the following error:

ArgumentError: Error #2108: Scene 01_Landing_Page was not found.
at flash.display::MovieClip/gotoAndPlay()
at ninja_02_Paris_fla::consule2_6/gotodsHome()

...Note that "02_Paris" is the second scene, where I'm testing from.

Any suggestions on what I'm doing wrong here?

Thanks!

This topic has been closed for replies.

2 replies

Inspiring
August 29, 2009

Are you sure that when you refer to root it refers to the clip that has "FullLoaded" scene?

As a side note, it is much more scalable and reliable to use events as opposed to chasing parents (like in your case).

August 29, 2009

Thanks for the response, Andrei,

I just double checked, and yeah, there is a labeled frame in the first scene called "FullLoaded." And, I'm pretty sure I'm labelling things right, since I've been able to set up buttons (within the same movieclip) that are linking fine to other labeled frames.

I don't think I necessarily follow with you comment about Events. But, that is probably my problem since this is my first stab at working with AS3, and I'm afraid I don't have my head fully around a lot of it. Is this something I can easily switch to do at this late stage of the game? Or, is it something that I have to account for when doing my initial build?

Inspiring
August 29, 2009

If you do the following in the move that throws the error, what will it trace?

for (var i:uint = 0; i < root.scenes.length; i++) {
    var scene:Scene = root.scenes;
    trace("scene " + scene.name);
}

As for the Events, they provide an awesome way to use loose object coupling - making them self sufficient. In your case it could be  reverse info exchange. Instead of relying on the existance of root in your consule2 you can just dispatch an event that will be listened wherever (including root) and act accordingly.

function gotodsHome(event:MouseEvent):void{

     dispatchEvent(new Event("move_on"));    
}

On the timeline of your top move you could write (considering that counsul2 is the name of the clip):

consul2.addEventListener("move_on", moveOnHandler, true);

function moveOnHandler(e:Event):void{

     gotoAndPlay("FullLoaded","01_Landing_Page");

}

This way consul2 is not dependent on root and root, in turn, is just sitting and waiting when something will give an order to do something. There are many nice extensibility opportunities with this approach. For instance, several different clips can tell the root to go somewhere not having even a slightest idea what root is and, for that matter, not caring about outside world at all. Like "I let everyone know that this thing happened and I don't give a damn what you do with this information."

Ned Murphy
Legend
August 29, 2009

Try to not use numbers to begin your scene names and see if that helps

August 29, 2009

Thanks Ned,

I just tried that, but still get the same error message when I try clicking on the "home" link (well, except minus the "02" part).  Still thanks for the suggestion. I went ahead and removed all the numbers form the scenes, just to be on the safe side.