Skip to main content
Inspiring
March 20, 2019
Answered

from as2 to as3

  • March 20, 2019
  • 1 reply
  • 670 views

function standUp(target:MovieClip,delay:Number):Void{

target.interval=function(){

target._visible=true;

clearInterval(target.intervalID);

this.onEnterFrame=function(){

target._xscale=target._yscale-=25;

target._y-=(target._y-target.startY)/3;

if(Math.abs(target._y-target.startY)<1){

target._y=target.startY;

delete target.onEnterFrame;

}

};

};

target.intervalID=setInterval(target,"interval",delay);

target._xscale=target._yscale=400;

target.startY=target._y;

target._y=0;

target._visible=false;

};

/*function typewriter(target:MovieClip,delay:Number):Void{

target.interval=function(){

target._visible=true;

keyHit.start(0,1);

clearInterval(target.intervalID);

};

target.intervalID=setInterval(target,"interval",delay);

target._visible=false;

}

*/

function placeText(target:MovieClip,x:Number,y:Number,

  banner:String,tFormat:TextFormat,effectFunction:Function,delay:Number):Void{

//for each character

for(var i=0;i<banner.length;i++){

//create clip put each character in it

var char:MovieClip=target.attachMovie("letter","char"+i,target.getNextHighestDepth());

char.field.text=banner.substr(i,1);

char._x=x;

char._y=y;

//add the width of current text character to next char's x position-

x+=tFormat.getTextExtent(char.field.text).width;

//effect function call-passed in as a param

effectFunction(char,i*delay);

//delay between typing here-

//var timer=i*200+Math.round(Math.random()*200);

//typewriter(char,timer);

}

}

//var keyHit=new Sound(this);

//keyHit.attachSound("click");

var format:TextFormat=new TextFormat;

format.font="Arial";

format.size=24;

placeText(this,100,100,"Create EASY text animations",format,standUp,100);

placeText(this,100,120,"using only actionscript",format,standUp,100);

nextFrame();

Above how do I change this to Actionscript 3.0 from Actionscript 2.0  In bold I want a change to but how do I that. So please help me with it.

This topic has been closed for replies.
Correct answer kglad

instead of onEnterFrame and delete onEnterFrame use addEventListener(Event.ENTER_FRAME,functionname) and removeEventListener(Event.ENTER_FRAME,functionname)

setInterval you can use with as3, but like as2, you should clear the interval before creating to prevent duplicate/runaway intervals.

instead of attachMovie, use the 'new' constuctor:

var char:MovieClip=new letter();

addChild(char)

car.field.text-banner.substr(i,1);

there's no direct conversion for getTextExtent.  you could create a custom function that would return what you want though that would require intermediate to advanced coding skills.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 8, 2019

instead of onEnterFrame and delete onEnterFrame use addEventListener(Event.ENTER_FRAME,functionname) and removeEventListener(Event.ENTER_FRAME,functionname)

setInterval you can use with as3, but like as2, you should clear the interval before creating to prevent duplicate/runaway intervals.

instead of attachMovie, use the 'new' constuctor:

var char:MovieClip=new letter();

addChild(char)

car.field.text-banner.substr(i,1);

there's no direct conversion for getTextExtent.  you could create a custom function that would return what you want though that would require intermediate to advanced coding skills.

peorAuthor
Inspiring
May 13, 2019

Thanks for answering my help and this correctly

kglad
Community Expert
Community Expert
May 13, 2019

you're welcome.