Resources: ActionScript 3

Copy and paste this code into the first frame of your AS3 Flash document to create a preloader.

Note: Remember you will need to target the right movieclips in order for the percentage bar to display!

    // HALT!
    stop();
    
    /* =========================== PRELOADER === */
    /* ========================================= */
    
    stage.addEventListener(Event.ENTER_FRAME, loading)
    
    // EVERY FRAME
    function loading(evt){
    
     // CALCULATE PERCENTAGE
     var loaded = stage.loaderInfo.bytesLoaded;
     var total = stage.loaderInfo.bytesTotal;
     var loadProgress = loaded / total;
     var loadProgressPercent = Math.round(loadProgress * 100);
    
     // CREATE DISPLAY
     mcLoader.mcLoaderBar.width = loadProgressPercent;
    
     // IF 100% SEND TO MAIN ANIMATION
     if (loadProgress == 1){
      gotoAndPlay('PLAY');
      stage.removeEventListener(Event.ENTER_FRAME, loading);
     }
    
    }

Flash is capable of loading external textual content at run time using the ActionScript 3 URLLoader Class. Loading external text at run time is a technique used to create Flash movies which can be easily updated without the need to go back to the FLA. The URLLoader Class is responsible for loading all textual content and that include in addition to regular text files, XML, HTML, and CSS.

This tutorial is sourced from the Republic of Code: http://www.republicofcode.com/tutorials/flash/as3externaltext/

Actionscript:

ExternalInterface.call("functionNameHere(anyVariable)");

Javascript:

function functionNameHere(anyVariable){
alert('Flash says hello! And ' + anyVariable);
}

Go to URL with AS3

27 September 2012

Actionscript 3 uses a very different approach to sending a user to a URL, and you can implement this with the following code:

var url:String = "http://site";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_blank'); // second argument is target
} catch (e:Error) {
trace("Error occurred!");
}
Let's work together