ECcoding
ECcoding

Reputation: 45

Adding movieclip inside movieclip AS3

Currently I am trying to figure out code to add a movieclip to the stage after clicking an externally loaded image inside a movieclip.

Basically what I want to achieve is that when the external image that is loaded in the movieclip is clicked, another movieclip (a big X) is loaded on top of it. Currently I am trying this code, but the movieclip X doesn't show up. I don't get errors however.

Does anybody know how to resolve this? Thanks in advance!

Here's the current code:

var wronganswer1:Loader = new Loader();
var myImageLocation1:URLRequest = new URLRequest("Monthly Topic/img1.jpg");
var xClip:MovieClip = new MovieClip;

wronganswer1.load(myImageLocation1);
addChild(wronganswer1);

wronganswer1.addEventListener(MouseEvent.CLICK, wa1);

function wa1 (event:MouseEvent):void
{
    MovieClip(this.parent).SCORE -= 1   
    MovieClip(this.parent).addChild(xClip);
    wronganswer1.removeEventListener(MouseEvent.MOUSE_UP, wa1);
}

stop();

Upvotes: 1

Views: 138

Answers (1)

Organis
Organis

Reputation: 7316

Your xClip does not contain any graphics, it is just an empty MovieClip instance:

var xClip:MovieClip = new MovieClip;

So it is added to the appointed target as intended, you just can't see it because there's nothing to see.

Upvotes: 1

Related Questions