# Stuck with AS3 migration

**URL:** https://forum.kirupa.com/t/stuck-with-as3-migration/307064
**Category:** flash
**Created:** [March 27, 2010, 11:19am UTC](https://forum.kirupa.com/t/stuck-with-as3-migration/307064 "2010-03-27T11:19:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Availor](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@Availor](https://forum.kirupa.com/u/Availor)
#### Post date: [March 27, 2010, 11:19am UTC](https://forum.kirupa.com/t/stuck-with-as3-migration/307064/1 "2010-03-27T11:19:01Z")

</div>

Hello everyone, I am stuck with AS3 migration:

I’ve defined a variable outside my function, then I want to call the variable to become a certain movie clip, but it doesn’t work.  
Here is a simple example of my code:

```auto

//setting playClip variable to be movieclip
var [COLOR="red"]playClip[/COLOR]:MovieClip;

mybtn.addEventListener(MouseEvent.CLICK, playAnim);

function playAnim(e:MouseEvent):void {
[COLOR="red"]playClip [/COLOR]= myClip;
myClip_animator.play();
}

//the function should be executed on playClip 
//this is a long function I didn't paste it in
var myClip_animator:Animator = new Animator(myClip_xml, [COLOR="Red"]playClip[/COLOR]);

```

If I set the variable outside the function it will work. How do I set the variable to work outside the function?

Thanks
