# $100 to you or charity/candidate of your choice! Desperate! Need to update AS2 to AS3 or otherwise play/pause Swiffy

**URL:** <https://forum.kirupa.com/t/100-to-you-or-charity-candidate-of-your-choice-desperate-need-to-update-as2-to-as3-or-otherwise-play-pause-swiffy/634617>\
**Category:** flash\
**Created:** [May 13, 2016, 1:38am UTC](https://forum.kirupa.com/t/100-to-you-or-charity-candidate-of-your-choice-desperate-need-to-update-as2-to-as3-or-otherwise-play-pause-swiffy/634617 "2016-05-13T01:38:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicole555](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@nicole555](https://forum.kirupa.com/u/nicole555)\
**Post date:** [May 13, 2016, 1:38am UTC](https://forum.kirupa.com/t/100-to-you-or-charity-candidate-of-your-choice-desperate-need-to-update-as2-to-as3-or-otherwise-play-pause-swiffy/634617/1 "2016-05-13T01:38:04Z")

</div>

I’m creating animations in Flash and using Google Swiffy to convert them to HTML5 animations. I controlled them with Actionsript 2 method below but now they need it as AS3 and I just can’t get it to work.

I don’t know if I need to simply change the AS2 to AS3 or if I should look into new methods, but I’m literally about to cry.

Javascript placed within HTML5 animation:

```
 <script>
   function playMovie(){
     stage.setFlashVars('myresponse=play');
     return false;
   }

   function stopMovie(){
     stage.setFlashVars('myresponse=pause');
     return false;  
   }	
 </script>

```

Actionscript:

```
_root.onEnterFrame = function(){

switch(_level0.myresponse){

case 'play':
    _root.play();
    break;

case 'pause':
    _root.stop();
    break;

default :
    break;
}
_level0.myresponse = undefined;
}

```

Any help is appreciated or even a push in the right direction, and I’m definitely serious about paying or donating.

Thank you SO MUCH!

---

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [May 13, 2016, 9:44am UTC](https://forum.kirupa.com/t/100-to-you-or-charity-candidate-of-your-choice-desperate-need-to-update-as2-to-as3-or-otherwise-play-pause-swiffy/634617/2 "2016-05-13T09:44:46Z")

</div>

> [@nicole555](#):
>
> I’m creating animations in Flash and using Google Swiffy to convert them to HTML5 animations. I controlled them with Actionsript 2 method below but now they need it as AS3 and I just can’t get it to work.
> 
> I don’t know if I need to simply change the AS2 to AS3 or if I should look into new methods, but I’m literally about to cry.

The onEnterFrame function is not as3, you want to change that to something like this:

```
this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

function enterFrameHandler(event:Event):void
{
    //var target:MovieClip = MovieClip(event.target);
}

```

For the \_level0 thingy, I think they changed that to `root.loaderInfo.parameters`?  
And `_root` could possibly be `MovieClip(root)`?

---

<div class="post-metadata">

**Author:** ![nicole555](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@nicole555](https://forum.kirupa.com/u/nicole555)\
**Post date:** [May 13, 2016, 11:11am UTC](https://forum.kirupa.com/t/100-to-you-or-charity-candidate-of-your-choice-desperate-need-to-update-as2-to-as3-or-otherwise-play-pause-swiffy/634617/3 "2016-05-13T11:11:13Z")

</div>

Thanks for your reply.

Yeah I tried translating it as follows with the three things I found being the removal of “\_” naming, “\_root” being either “root” or “stage”, event for enter frame, root.parameters._variable sent in with JavaScript_

```
addEventListener(Event.ENTER_FRAME,myEnterFrame);
function myEnterFrame(event:Event) {
switch(root.loaderInfo.parameters.myresponse){
    case 'play':
        root.play();
        break;

    case 'pause':
        root.stop();
        break;

    default :
        break;
}
root.loaderInfo.parameters.myresponse = undefined;
}

```

Tried the above with stage.play() and stage.stop() as well, and a few other tweaks hours before even asking.  
So it’s MovieClip(root).play & MovieClip(root).stop, correct? I’m definitely up to donate as stated if this leads to a solution.

Two biggest problems are

- I don’t understand the switch operation - can that be put in another way?

- I can’t really use trace to see how far I’m getting: if the variable I pass in is getting passed, etc.

Is there a way to see more what’s going on? with Javascript maybe?

---

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [May 14, 2016, 5:06pm UTC](https://forum.kirupa.com/t/100-to-you-or-charity-candidate-of-your-choice-desperate-need-to-update-as2-to-as3-or-otherwise-play-pause-swiffy/634617/4 "2016-05-14T17:06:33Z")

</div>

Did you fix this or are you still trying to figure it out?

You can replace the switch statement with if else statements instead.

```
if(root.loaderInfo.parameters.myresponse == 'play'){
}else if(root.loaderInfo.parameters.myresponse == 'pause'){}

```

ect…

I’m not sure why you need as3? Swiffy will convert the swf to html5 in any case.

There should be a document that list supported functions and classes for as2 and as3 respectively, but i couldn’t find it.

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [May 15, 2016, 9:22pm UTC](https://forum.kirupa.com/t/100-to-you-or-charity-candidate-of-your-choice-desperate-need-to-update-as2-to-as3-or-otherwise-play-pause-swiffy/634617/5 "2016-05-15T21:22:28Z")

</div>

> [@linusj](#):
>
> There should be a document that list supported functions and classes for as2 and as3 respectively, but i couldn’t find it.

Hmm yeah, there used to be an AS1/2 to AS3 syntax migration guide in one of the AS3LR appendixes… but I can’t find it in the current version online. Weird.
