# Trouble with gotoAndPlay and movieclips

**URL:** <https://forum.kirupa.com/t/trouble-with-gotoandplay-and-movieclips/327942>\
**Category:** flash\
**Created:** [April 7, 2012, 4:18am UTC](https://forum.kirupa.com/t/trouble-with-gotoandplay-and-movieclips/327942 "2012-04-07T04:18:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IDdaniel](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@IDdaniel](https://forum.kirupa.com/u/IDdaniel)\
**Post date:** [April 7, 2012, 4:18am UTC](https://forum.kirupa.com/t/trouble-with-gotoandplay-and-movieclips/327942/1 "2012-04-07T04:18:05Z")

</div>

hello,

I have been working on a product design portfolio in flash CS5.5, and have run into some trouble with my AS. I managed to eventually fix the problem, but was hoping to get some feedback as to why it wasn’t working in the first place.

I have a movieclip  
I have a button([LEFT]btn\_01)[/LEFT] and a movieclip(P\_01) on the main timeline. The P\_01 movieclip contains an empty stop frame on frame 1. From frame 2 to 20 an image fades in and stops at 20, then 20 to 40 the image fades out:  
[LEFT]  
This works:  
this.btn\_01.onRelease = function (){  
if(this.P\_01.\_currentFrame \<= 20){P\_01.gotoAndPlay(21)}else{P\_01.gotoAndStop(20)}

This Doesn’t:  
this.btn\_01.onRelease = function (){  
if(this.P\_01.\_currentFrame \<= 20){\*\*[COLOR=#a52a2a]this.[/COLOR]**P\_01.gotoAndPlay(21)}else{**[COLOR=#a52a2a]this.[/COLOR]\*\*P\_01.gotoAndStop(20)}

I would prefer to keep the scripting relative to its location with the “this.” function, as I want to keep all the scripting contained within the movieclip.

thanks in advance,[/LEFT]  
Daniel
