# How to use gotoAndPlay() in actionscript file to target object on stage?

**URL:** <https://forum.kirupa.com/t/how-to-use-gotoandplay-in-actionscript-file-to-target-object-on-stage/268121>\
**Category:** flash\
**Created:** [August 10, 2008, 8:14am UTC](https://forum.kirupa.com/t/how-to-use-gotoandplay-in-actionscript-file-to-target-object-on-stage/268121 "2008-08-10T08:14:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hizuka007](https://avatars.discourse-cdn.com/v4/letter/h/e480ec/32.png) [@hizuka007](https://forum.kirupa.com/u/hizuka007)\
**Post date:** [August 10, 2008, 8:14am UTC](https://forum.kirupa.com/t/how-to-use-gotoandplay-in-actionscript-file-to-target-object-on-stage/268121/1 "2008-08-10T08:14:27Z")

</div>

Good day!

Im new to actionscript 3, and id like to know how to use gotoAndPlay to target an object (drawn from hand to stage) on the stage using actionscript file?  
My code is this:

```auto

package
{
    import flash.display.MovieClip;
       
    public class moveframe extends MovieClip
    {
        public function moveframe()
        {
              
            **parent.getChildByName("stick").gotoAndPlay(2);**
        }
        
    }
}

```

It will only generate an error message saying: “Call to possibly undefined method gotoAndPlay through a reference with static type flash.display:DisplayObject.  
parent.getChildByName(“stick”).gotoAndPlay(2);”

I dont know what this error message means, but does anyone knows what the problem is?  
I tried to trace the X position of the child named “stick” using: traced(parent.getChildByname(“stick”).x); to make sure that the object is already existed, but it produce the X position of my “stick” object which means that it is present. but when i try to use gotoAndPlay(2) it will make an error.

does anyone knows any alternative way to refference the movieclip object that has been put to stage?

thank you…
