Scoprite come convertire i codici di FrameScript in ActionScript in codici Javascript in HTML5 Canvas.

Mappatura di ActionScript agli snippet di codice HTML5

Di seguito è riportato l'elenco degli snippet di codice equivalenti in JavaScript/HTML5 per i codici FrameScript/ActionScript:

Azione

ActionScript

HTML5

Interruzione sul fotogramma visualizzato

stop();

this.stop();

Fate clic per andare al fotogramma specificato e interrompere la riproduzione

gotoAndStop(5);

this.gotoAndStop(5);

Fate clic per andare al fotogramma specificato e avviare la riproduzione

gotoAndPlay(5);

this.gotoAndPlay(5);

Fate clic per aprire una pagina Web

navigateToURL(new URLRequest("http://www.adobe.com"), "_blank");

 

window.open("http://www.adobe.com", "_blank");

Cursore mouse personalizzato

function fl_CustomMouseCursor(event:Event)

{

               instance_name_here.x = stage.mouseX;

               instance_name_here.y = stage.mouseY;

}

Mouse.hide();

 

function fl_CustomMouseCursor() {

               this.btnNavigate.x = stage.mouseX;

               this.btnNavigate.y = stage.mouseY;          this.instance_name_here.y = stage.mouseY;

Riproduzione di un clip filmato

instance_name_here.play();

this.instance_name_here.play();

Interruzione di un clip filmato

instance_name_here.stop();

this.instance_name_here.stop();

Fate clic per nascondere un oggetto

instance_name_here.addEventListener(MouseEvent.CLICK, fl_ClickToHide);

 

function fl_ClickToHide(event:MouseEvent):void

{

               instance_name_here.visible = false;

}

this.instance_name_here.addEventListener("click", fl_ClickToHide.bind(this));

 

function fl_ClickToHide()fl_ClickToHide ()

{

               this.instance_name_here.visible = false;

}

Visualizzazione di un oggetto

instance_name_here.visible = true;

this.instance_name_here.visible = true;

Fare clic per posizionare un oggetto

instance_name_here.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

 

function fl_ClickToPosition(event:MouseEvent):void

{

               instance_name_here.x = 200;

               instance_name_here.y = 100;

}

this.instance_name_here.addEventListener("click", fl_ClickToPosition.bind(this));

 

function fl_ClickToPosition()

{

               this.instance_name_here.x = 200;

               this.instance_name_here.y = 100;

}

 

Fate clic per visualizzare un campo di testo

instance_name_here.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

 

var fl_TF:TextField;

var fl_TextToDisplay:String = "Lorem ipsum dolor sit amet.";

 

function fl_ClickToPosition(event:MouseEvent):void

{

               fl_TF = new TextField();

               fl_TF.autoSize = TextFieldAutoSize.LEFT;

               fl_TF.background = true;

               fl_TF.border = true;

               fl_TF.x = 200;

               fl_TF.y = 100;

               fl_TF.text = fl_TextToDisplay;

               addChild(fl_TF);

}

this.instance_name_here.addEventListener("click", fl_ClickToPosition.bind(this));

 

var fl_TF = new createjs.Text();

var fl_TextToDisplay = "Lorem ipsum dolor sit amet.";

 

function fl_ClickToPosition()

{

              

               fl_TF.x = 200;

               fl_TF.y = 100;

               fl_TF.color = "#ff7700";

               fl_TF.font = "20px Arial";

               fl_TF.text = fl_TextToDisplay;

               this.addChild(fl_TF);

}

Evento clic del mouse

instance_name_here.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

 

function fl_MouseClickHandler(event:MouseEvent):void

this.instance_name_here.addEventListener("click", fl_MouseClickHandler.bind(this));

 

function fl_MouseClickHandler()

Evento passaggio del mouse

instance_name_here.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);

 

function fl_MouseOverHandler(event:MouseEvent):void

frequenza di var = 3;

stage.enableMouseOver(frequency);

this.instance_name_here.addEventListener("mouseover", fl_MouseOverHandler);

 

function fl_MouseOverHandler()

Evento allontanamento del mouse

instance_name_here.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);

 

function fl_MouseOutHandler(event:MouseEvent):void

frequenza di var = 3;

stage.enableMouseOver(frequency);

this.instance_name_here.addEventListener("mouseout", fl_MouseOutHandler);

 

function fl_MouseOutHandler()

 

Spostamento orizzontale

instance_name_here.x + = 100;

this.instance_name_here.x + = 100;

Spostamento verticale

instance_name_here.y + = 100;

this.instance_name_here.y + = 100;

Rotazione singola

instance_name_here.rotation + = 45;

this.instance_name_here.rotation + = 45;

Rotazione continua

instance_name_here.addEventListener(Event.ENTER_FRAME, fl_RotateContinuously);

 

function fl_RotateContinuously(event:Event)

{

               instance_name_here.rotation += 10;

}

this.addEventListener("tick",fl_RotateContinuously.bind(this));

 

function fl_RotateContinuously(){

               this.instance_name_here.rotation+=10;

}

Animazione orizzontale

instance_name_here.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally);

 

function fl_AnimateHorizontally(event:Event)

{

               instance_name_here.x += 10;

}

this.addEventListener("tick", fl_AnimateHorizontally.bind(this));

 

function fl_AnimateHorizontally()

{

               this.instance_name_here.x+=10;

}

Animazione verticale

instance_name_here.addEventListener(Event.ENTER_FRAME, fl_AnimateVertically);

 

function fl_AnimateVertically(event:Event)

{

               instance_name_here.y += 10;

}

this.addEventListener("tick", fl_AnimateVertically.bind(this));

 

function fl_AnimateVertically()

{

               this.instance_name_here.y+=10;

}

Dissolvenza in entrata di un clip filmato

instance_name_here.addEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);

instance_name_here.alpha = 0;

 

function fl_FadeSymbolIn(event:Event)

{

               instance_name_here.alpha += 0.01;

               if(instance_name_here.alpha >= 1)

               {

                              instance_name_here.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolIn);

               }

}

this.addEventListener('tick', fl_FadeSymbolIn.bind(this));

this.instance_name_here.alpha = 0;

 

function fl_FadeSymbolIn()

{

               this.instance_name_here.alpha += 0.01;

               if(this.instance_name_here.alpha >= 1)

               {

                              this.removeEventListener('tick', fl_FadeSymbolIn.bind(this));

               }

}

Dissolvenza in uscita di un clip filmato

instance_name_here.addEventListener(Event.ENTER_FRAME, fl_FadeSymbolOut);

instance_name_here.alpha = 1;

 

function fl_FadeSymbolOut(event:Event)

{

               instance_name_here.alpha -= 0.01;

               if(instance_name_here.alpha <= 0)

               {

                              instance_name_here.removeEventListener(Event.ENTER_FRAME, fl_FadeSymbolOut);

               }

}

this.addEventListener('tick', fl_FadeSymbolOut.bind(this));

this.instance_name_here.alpha = 1;

 

function fl_FadeSymbolOut()

{

               this.instance_name_here.alpha -= 0.01;

               if(this.instance_name_here.alpha <= 1)

               {

                              this.removeEventListener('tick', fl_FadeSymbolOut.bind(this));

               }

}

Fate clic per caricare un'immagine dalla libreria

instance_name_here.addEventListener(MouseEvent.CLICK, fl_ClickToLoadImageFromLibrary);

 

function fl_ClickToLoadImageFromLibrary(event:MouseEvent):void

{

               // Se volete aggiungere un'immagine diversa dalla libreria,

               // immettete un nome differente nel campo di testo Classe al punto 4 riportato sopra e nel codice seguente.

               var libImage:MyImage = new MyImage();

 

               var holder:Bitmap = new Bitmap(libImage);

               addChild(holder);

}

this.instance_name_here.addEventListener («click», fl_ClickToLoadImageFromLibrary.bind (this));

 

function fl_ClickToLoadImageFromLibrary()

{

              

               var libImage = new lib.MyImage();

               this.addChild(libImage);

}

 

Aggiunta istanza dalla libreria

var fl_MyInstance:LibrarySymbol = new LibrarySymbol();

addChild(fl_MyInstance);

var fl_MyInstance = new lib.LibrarySymbol();

this.addChild(fl_MyInstance);

 

Questo prodotto è concesso in licenza in base alla licenza di Attribuzione-Non commerciale-Condividi allo stesso modo 3.0 Unported di Creative Commons.  I post su Twitter™ e Facebook non sono coperti dai termini di Creative Commons.

Note legali   |   Informativa sulla privacy online