2 Replies Latest reply on Feb 26, 2016 8:57 AM by rosebudd

    Help needed to convert ActionScript 3 to javascript for HTML5

    stevegershen Level 1

      I am looking for some help converting actionscript 3 code to javascript for a HTML5 platform.  I am a flash developer by trade but I am unfamiliar on how to "translate AS code to js.  I had recently downloaded Animate CC thinking it take the existing .fla file and republishes it out to a html5 format.  Well I was wrong.  All my code that I used in flash is giving me hundreds of errors & I don't even no where to begin. the issue that I have is:  All my flash documents that I have created over the years now have to be converted to html5.  Where do I go, who can help? is there a easy way to do this? is there an online converter..  I need help!! thank you.  Below is an exsisting actionscript code that I need to convert:  Sorry for the copy and past of the script.


      actionscript code below



      import flash.utils.Timer;

      // this is where the string of numbers comes in (rootLoader.parameters)

      var generatedNums:String = MovieClip(parent.parent).WinningNumbers;

      // creates an array out of generated numbers

      var chosenNums:Array = generatedNums.split("-");

      // convert text to numbers

      var n=chosenNums.length;

      while (n--) {



      // call funtion to remove 0 from list of numbers

      function remove(list:Array,callback:Function):Array {

          for(var i:int = list.length - 1; i >= 0; i--) {

              if(!callback(list[i])) {




          return list;


      //remove 0 from list of numbers

      function removeCallback(item:Number):Boolean {

          return item >= 1;



      // keeps track of which element of the array to use to create balls

      // (first then second then third)

      var chosenNumsIndex:uint = 0;

      // creates array of coordinates of numbers on the board.

      var kNum:Array = new Array();

      var bottomArray:Array = new Array("", "", "", "", "", "", "", "", "", "","", "","", "","", "","", "","", "","");

      // kNum[0] is a dummy because there's no 0 on the board.

      kNum[0] = {x:0, y:0};


      //array of movieclips

      var mcArray:Array = new Array();

      mcArray.push(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21, n22, n23, n24, n25, n26, n27, n28, n29, n30, n31, n32, n33, n34, n35, n36, n37, n38, n39, n40, n41, n42, n43, n44, n45, n46, n47, n48, n49, n50, n51, n52, n53, n54, n55, n56, n57, n58, n59, n60, n61, n62, n63, n64, n65, n66, n67, n68, n69, n70, n71, n72, n73, n74, n75, n76, n77, n78, n79, n80);

      // creates timer that runs every 3 seconds.  Number of times it runs

      // is determined by the length of chosenNums array (which is the number

      // of numbers chosen)

      var timer:Timer = new Timer(3000, chosenNums.length);

      // timer is listening for itself to trigger, calls chuckBall()

      timer.addEventListener(TimerEvent.TIMER, chuckBall);

      timer.addEventListener(TimerEvent.TIMER_COMPLETE, ballChuckingComplete);


      // chuckBall generates coins

      function chuckBall(event:TimerEvent):void



        // generates new Coin - Coin is the name of MovieClip in Library

        // remember to export for Actionscript

        var c1:Coin = new Coin();



        // coin is placed at appropriate x and y coords

        c1.x = kNum[chosenNums[chosenNumsIndex]].x;

        c1.y = kNum[chosenNums[chosenNumsIndex]].y;




        // addChild tells main timeline to display coin once it's generated.





        // pull appropriate movieclip out of array and play to darken.

        mcArray[chosenNums[chosenNumsIndex] - 1].play();


          // fill in bottom numbers



        // increments chosenNumsIndex so the next time chuckBall runs

        // it pulls the next element of the chosenNums array.

        //chosenNumsIndex ++;


      bottomArray[chosenNumsIndex - 1] = chosenNums[chosenNumsIndex- 1];

      trace("bottomArray value " +bottomArray[chosenNumsIndex]);

      firstWinningNumB.text = bottomArray[0];

      twoWinningNumB.text = bottomArray[1];

      threeWinningNumB.text = bottomArray[2];

      fourWinningNumB.text = bottomArray[3];

      fiveWinningNumB.text = bottomArray[4];

      sixWinningNumB.text = bottomArray[5];

      sevenWinningNumB.text = bottomArray[6];

      eightWinningNumB.text = bottomArray[7];

      nineWinningNumB.text = bottomArray[8];

      tenWinningNumB.text = bottomArray[9];

      elevenWinningNumB.text = bottomArray[10];

      twelveWinningNumB.text = bottomArray[11];

      thirteenWinningNumB.text = bottomArray[12];

      fourteenWinningNumB.text = bottomArray[13];

      fifteenWinningNumB.text = bottomArray[14];

      sixteenWinningNumB.text = bottomArray[15];

      seventeenWinningNumB.text = bottomArray[16];

      eighteenWinningNumB.text = bottomArray[17];

      nineteenWinningNumB.text = bottomArray[18];

      //twentyWinningNumB.text = bottomArray[19];

      var lastNumber:Timer = new Timer(60000, 1);

      lastNumber.addEventListener(TimerEvent.TIMER, lastNumDone);




        // increments chosenNumsIndex so the next time chuckBall runs

        // it pulls the next element of the chosenNums array.

        chosenNumsIndex ++;



      function ballChuckingComplete(event:TimerEvent):void


        //trace("ballchuckingcomplete is working");


        var thirtySeconds:Timer = new Timer(15000, 1);

        thirtySeconds.addEventListener(TimerEvent.TIMER, thirtyDone);






      function thirtyDone(event:TimerEvent):void


        trace("thirty seconds up");






      function lastNumDone(event:TimerEvent):void


        trace("last number done");

        twentyWinningNumB.text = chosenNums[19];




        // fill in bottom numbers


      // manually starts the timer.