How to convert Actionscript 2 to actionscript 3
I am developing a flash website by utilizing the free template from one of my favorite website, This website is all about the solar system to teach kids. Now I have collected some of the flash movies from the national geographic website which I want to put on my favorite website. Now the problem is when I am opening an editor of that website, As soon as I add those flash video it prompts me saying that the "This file uses Actionscript 2, please convert to Actionscript 3 and upload again." Can somebody tell me that how can I convert Actionscript 2 into Actionscript 3?
Re: How to convert Actionscript 2 to actionscript 3
Now my question is simple, I want to convert a code As2 into As3...could anyone help me?
Code:
Stage.align = "LT";
Stage.scaleMode = "noScale";
listenerObject var: Object = new Object ();
listenerObject. onResize = function (Void) {Void
reposionner ();
}
reposionner function () {
text. _x = (Stage.width / 2) - (text. _width / 2)
text. _y = (Stage.height / 2) - (text. _height / 2);
}
Stage.addListener (listenerObject);
So is a code that allows me to have my flash that takes all the space in a browser and have an element that automatically repositions itself at the center of the navigation area. I am a shit As3 and it is something quite urgent for me to come ask for your help. Someone would it be how to convert this code in AS3 or give me references to make exactly the same thing with a brand-new code in As3?
Thank you in advance
Re: How to convert Actionscript 2 to actionscript 3
You have rightly pointed out the principle of the Event (new in AS3) already present in AS2 and in the example you gave. So in AS3 it is no longer necessary to create an object that will be used as a listener, but suffice to say to an object (any) listen to an event. So I'll give you a hint, and to prove to me that you were able to understand (to give you the ready solution was too easy), you'll give me your code with the solution I'll explain. To create an event listener, simply do as follows:
Code:
ObjectAEcouter.addEventListener (Event.EvenementAEcouter, FonctionADeclencher);
FonctionADeclencher function (evt: Event): void {/ / event is an "alias" referring to the listener that triggered the function
}
Theoretically, with it you better draw. So I'm waiting for your self-modified code;)
Re: How to convert Actionscript 2 to actionscript 3
Here I have provided the code for the Actionscript 3 as follows. You can grasp whatever is needed for your script to convert it from AS2 to AS3. But make sure that this is not the code that automatically converts the AS2 to AS3.
Code:
Stage.scaleMode = StageScaleMode.NO_SCALE;
Stage.align = StageAlign.TOP_LEFT;
stage.addEventListener (Event.RESIZE, __onStageResized)
__onStageResized function (event: Event): void
{
var w: int = stage.stageWidth, h: int = stage.stageHeight;
/ / Resizes here or replace your items according to the new size of the course
}
Re: How to convert Actionscript 2 to actionscript 3
Only in AS3, there are the properties _y, _height not. The hot now only y or height. (As far as I can remember)
Code:
runter_btn . addEventListener ( MouseEvent . CLICK , fun_runter );
function fun_runter ( event : MouseEvent ): void {
if( dein_mc . y > maske . height - dein_mc . height )
dein_mc . y = dein_mc . y - 10 ;
}
hoch_btn . addEventListener ( MouseEvent . CLICK , fun_hoch );
function fun_hoch ( event : MouseEvent ): void {
if( dein_mc . y <= maske . y )
dein_mc . y = dein_mc . y + 10 ;
}