1 Reply Latest reply on Feb 1, 2009 1:32 PM by clbeech

    could someone help me "translate" as2 to as3

    russellbaylis
      Hi, this is my first post i am sorry if this is in the wrong cattegory

      Here is the problem. i basically am quite familiar with as2, but im not sure how to convert this into as3. Here are the problems

      AS2:
      stop();

      AS2 Version:

      this.x_mc.onRelease = function(){
      gotoAndPlay ("x");
      }

      AS2:

      this.x_mc.onPress= function(){
      gotoAndPlay ("x");
      }

      AS2:

      this.x_mc.onRollOver= function(){
      gotoAndPlay ("x");
      }

      AS2:
      this.x_mc.onRollOut = function(){
      gotoAndPlay ("x");
      }

      Hopefully someone could provide me with the Actionscript 3 versions of these please. Your help is greatly appreciated, its for a Portfolio.
        • 1. Re: could someone help me "translate" as2 to as3
          clbeech Level 3
          under 3 we use the event listener model, so you have to set up mouse handlers like this:

          function methodname(e:MouseEvent):void {
          //actions
          }
          instancename.addEventListener(MouseEvent.CLICK, methodname);

          set up one event listener and one corresponding handler method for each type of mouse event:

          MouseEvent.ROLL_OVER = onRollOver
          MouseEvent.ROLL_OUT = onRollOut
          MouseEvent.MOUSE_DOWN = onPress
          MouseEvent.MOUSE_UP = onRelease

          stop() and gotoAndPlay() remain the same as under 2

          but there is an additional advantage, you can set up a 'single' event handler for multiple buttons, and then you can use the properties of the event Object (ie. 'e' in the above example) to access the instance that sent the event notification. for instance, say you wanted to change the alpha property of the button on rollover you can target the instance using:

          function methodname(e:MouseEvent):void {
          e.target.alpha = 0.5;
          }