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

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!

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)?

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?

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.

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.