Skip to content
March 30, 2012 / Danii Oliver

Figuring out AS2 after mastering AS3

Building Banner Ads that are to be hosted by a none AS3 compliant process?
Then the seasoned AS3 developer will need to revert down to AS2 in order to keep their job.
It sucks having to go backward. This is especially true since we have come so far – built an OOP Actionscript, went through a Flash is Dead false hype & grown to flash Player 11 – to now turn around and hear “AS3 is not acceptable”.

Well if your one of the developers who have been caught in the crossfire here are a few AS2 tips:

  • All properties must begin with an _ (underscore) mc._x, mc._alpha
  • scaleX & scaleY are _xscale & _yscale
  • Any property that accepts floating point numbers 0 -1 in AS2 should be whole numbers as in the whole % value of without the % symbol. Thus mc.alpha =1 is  mc._alpha = 100 for a 100% alpha value.
  • If targeting Flash Player 7 be sure that any vector shapes do not have a stroke on them.
  • Can’t write document classes. AS2 is timeline based and not an OOP language.
  • Must add button code directly to buttons, not in the top level action but on the button symbol itself as you would do for nested Movie Clips.

Note* There may be more but this is what was relevant to the code below.

Here is some code I have translated:

AS3

package {

import flash.display.MovieClip;
import com.greensock.TweenNano;
import flash.events.Event;
import com.greensock.easing.Strong;

public class BannerEEG extends MovieClip {

public function BannerEEG() {

mc_e.alpha = 0;
mc_f.alpha = 0;
mc_g.alpha = 0;
mc_h.alpha = 0;
mc_g.scaleX = mc_g.scaleY =4,
TweenNano.to(mc_c, .5,{scaleX:.68, scaleY:.68, y:45.55, x:23.85});
TweenNano.from(mc_d, 1,{delay:.5, x:182, y:115.85, onComplete:frameiii});

}
public function frameiii(e:Event = null):void
{
TweenNano.to(mc_d, .2,{delay:1, alpha:0});
TweenNano.to(mc_b, .2,{delay:1, alpha:0});
TweenNano.to(mc_e, .5,{delay:1.05, ease:Strong.easeOut, scaleX:1.5, scaleY:1.5, alpha:1, x:mc_e.x-50, onComplete:frameiv});
}
public function frameiv(e:Event = null):void
{
TweenNano.to(mc_e, .1,{delay:.2, scaleX:1, scaleY:1});
TweenNano.to(mc_a, 1,{delay:.2, x:10, y:50});
TweenNano.to(mc_a.nook, 1,{delay:.2, x:0});
TweenNano.to(mc_c, 1,{delay:.2, scaleX:.53, scaleY:.53, x:223.85, y:90.55});
TweenNano.to(mc_e, 1,{delay:.2, scaleX:.63, scaleY:.63, x:10, y:127});
TweenNano.to(mc_f, 1,{delay:.2, alpha:1});
TweenNano.to(mc_g, .2,{delay:1.5, scaleX:1, scaleY:1, alpha:1, onComplete:framev});
}
public function framev(e:Event = null):void
{
mc_h.alpha = 1;
TweenNano.from(mc_h, 2,{delay:0, x:-150, ease:Strong.easeInOut});
}
}

}


AS2

import com.greensock.TweenNano;
import com.greensock.easing.Strong;

mc_e._alpha = 0;
mc_f._alpha = 0;
mc_g._alpha = 0;
mc_h._alpha = 0;
mc_g.__xscale = mc_g.__yscale =400,
TweenNano.to(mc_c, .5,{_xscale:68, _yscale:68, _y:45.55, _x:23.85});
TweenNano.from(mc_d, 1,{delay:.5, _x:182, _y:115.85, onComplete:frameiii});

function frameiii():Void
{
TweenNano.to(mc_d, .2,{delay:1, _alpha:0});
TweenNano.to(mc_b, .2,{delay:1, _alpha:0});
TweenNano.to(mc_e, .5,{delay:1.05, ease:Strong.easeOut, _xscale:150, _yscale:150, _alpha:100, _x:mc_e._x-50, onComplete:frameiv});
}
function frameiv():Void
{
TweenNano.to(mc_e, .1,{delay:.2, _xscale:100, _yscale:100});
TweenNano.to(mc_a, 1,{delay:.2, _x:10, _y:50});
TweenNano.to(mc_a.nook, 1,{delay:.2, _x:0});
TweenNano.to(mc_c, 1,{delay:.2, _xscale:53, _yscale:53, _x:223.85, _y:90.55});
TweenNano.to(mc_e, 1,{delay:.2, _xscale:63, _yscale:63, _x:10, _y:127});
TweenNano.to(mc_f, 1,{delay:.2, _alpha:100});
TweenNano.to(mc_g, .2,{delay:1.5, _xscale:100, _yscale:100, _alpha:100, onComplete:framev});
}
function framev():Void
{
mc_h._alpha = 100;
TweenNano.from(mc_h, 2,{delay:0, _x:-150, ease:Strong.easeInOut});
//TweenNano.from(mc_g, .2,{delay:.1, _xscale:2, _yscale:2, ease:Bounce.easeOut}); Too much Bounce
}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: