# gotoAndPlay wont work with an addChild movieclip

**URL:** <https://forum.kirupa.com/t/gotoandplay-wont-work-with-an-addchild-movieclip/248519>\
**Category:** flash\
**Created:** [January 9, 2008, 5:20am UTC](https://forum.kirupa.com/t/gotoandplay-wont-work-with-an-addchild-movieclip/248519 "2008-01-09T05:20:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuri05](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@samuri05](https://forum.kirupa.com/u/samuri05)\
**Post date:** [January 9, 2008, 5:20am UTC](https://forum.kirupa.com/t/gotoandplay-wont-work-with-an-addchild-movieclip/248519/1 "2008-01-09T05:20:16Z")

</div>

Hello community! New to the forums but use the site a bunch for a great resource. This has been racking my brain being new to AS3. Can anyone help with this code. Just a simple experiment, first I click on the purplebutton to load the redshape. Then I click on the bluebutton to try a gotoAndPlay within the redshape movieclip but my code doesn’t recognize the redshape. Any help?

bluebutton.buttonMode = true;  
purplebutton.buttonMode = true;

bluebutton.addEventListener(MouseEvent.CLICK, clickbutton);  
purplebutton.addEventListener(MouseEvent.CLICK, appear);

function appear(event:MouseEvent):void {  
var redshape:shape = new shape();  
redshape.x = 200;  
redshape.y = 200;  
this.addChild(redshape);  
}

function clickbutton(event:MouseEvent):void {  
var redshape:shape = new shape();  
redshape.gotoAndPlay(2);  
}
