0
votes

I am trying to make a simple dress up game.

I have a movie clip called shirts, in which I have:

I have an AS3 action of stop() on key frame 1; I have a shirts layer were I put all my shirts in key frames. Each key frame for a shirt. I have a labels layer were I put the labels for shirts. Please note that all labels are like:

shirt1

I also have an items movie clip, in which I have 3 movie clips (pictures of the actual shirts). Each of these movie clips have instance name of...shirt1 etc.

In my AS3 layer from items movie clip, I have something like:

var shirtsArray = [shirt1, shirt2];

for each (var shirtItem in shirtsArray) 
{
    shirtItem.addEventListener(MouseEvent.CLICK, onShirtClick);
shirtItem.buttonMode = true;
}

function onShirtClick (event:MouseEvent):void 
{
    MovieClip(parent).shirts.gotoAndStop(event.target.name);
}

When I run the file and click on one of the shirts, I get this:

ArgumentError: Error #2109: Frame label instance229 not found in scene instance229. at flash.display::MovieClip/gotoAndStop() at sportbarbie_fla::Symbol3_101/onShirtClick()

Any thoughts?

1

1 Answers

0
votes

According to the error message, it seems that event.target is the same MC as MovieClip(parent).shirts (as both have the same auto-assigned instance name instance229). It's hard to guess the reason without knowing the layout of your scene.

Note: it's not necessary to add click listener to each of the MCs, you can just add it to their parent MC if it doesn't contain items of other types. This is called event bubbling (see this article).