Hi,
I am a newbie in ActionScript 3.0. I want to make flash application that will zoom in object when on mouse over and write same text on the screen and zoom out object a clear text when the mouse is roll out.
I have a probelm, when I roll over the object it zoom in the text appers and when I roll out the object returns to the default position. But when I roll over then I rool out and roll over again (not wait until zooming out is completed) the addEventListener does not stop and text is mixed (part pf the text is from first zooming in a nd part of the text ist from second zooming in).
Could you please help me?
This is my code:
//import the tweenlite packages.
import com.greensock.TweenLite;
text_podklad.visible=false;
var pozicia_x=LTE.x;
var pozicia_y=LTE.y;
//Add the roll over/out event listeners to the fish movie clip.
LTE.addEventListener(MouseEvent.ROLL_OVER, zoomIn);
LTE.addEventListener(MouseEvent.ROLL_OUT, zoomOut);
//This function increases the scale of the fish by a factor of two in one second.
function zoomIn(event:MouseEvent):void {
LTE.x=pozicia_x;
LTE.y=pozicia_y;
TweenLite.to(LTE, 1, {x:LTE.x-150, y:LTE.y-70, scaleX:2, scaleY:2});
text_podklad.visible=true;
text_field.text="";
text_field.visible=true;
var myString:String="";
myString="My text";
var myArray:Array=myString.split("");
addEventListener(Event.ENTER_FRAME, function(e:Event){frameLooper(e,myArray);});
}
function frameLooper(event:Event, myArray:Array):void {
if (myArray.length>0) {
text_field.appendText(myArray.shift());
} else {
removeEventListener(Event.ENTER_FRAME, frameLooper);
}
}
//This function decreases the scale of the fish by a factor of one in one second.
function zoomOut(event:MouseEvent):void {
text_field.visible=false;
text_podklad.visible=false;
removeEventListener(Event.ENTER_FRAME, frameLooper);
TweenLite.to(LTE, 1, {x:LTE.x+150,y:LTE.y+70, scaleX:1, scaleY:1});
}