The following article assumes you have a solid understanding of Flash AS2 and the Flash interface, and skips all basic Flash setup instructions and explanations in effort to provide you with quick, concise information. It also assumes you have images ready to be loaded into your swf.
The AS2 refresher series aims to consolidate basic, everyday snippets for the most common tasks used by Flash developers working with legacy files. Basic explanations are included in the comments, since after all, who wants to read through a bunch of crap when you are just after the code? Enjoy.
AS2 sendAndLoad with LoadVars Snippet:
-
// variables
-
//——————————————————————————————————————————-
-
-
// create a var to hold the name of the bitmap we want to load
-
var imageName:String = "image1.jpg";
-
-
// set a reference to the folder your images are in ›› the slash (images/) is added below when we assemble the path
-
var imagePath:String = "images";
-
-
// set a new MovieClipLoader and immediately load the image into a movieclip on the stage named ‘container_mc’
-
var mcLoader:MovieClipLoader = new MovieClipLoader();
-
mcLoader.addListener(this);
-
mcLoader.loadClip(imagePath + "/" + imageName, container_mc);
-
-
// functions
-
//——————————————————————————————————————————-
-
-
// when the image has loaded, begin the ad unit animation
-
function onLoadComplete(mc:MovieClip) {
-
-
trace("image loaded from: " + imagePath + "/" + imageName);
-
trace("image loaded into: " + mc);
-
-
// load has completed, call init() and start the app
-
init();
-
}
-
-
// called while image is loading ›› insert preloading actions here
-
function onLoadProgress():Void {
-
-
trace("image loading…");
-
}
-
-
function init():Void {
-
-
// start your app
-
-
// for additional progress event listeners associated with loading external bitmaps,
-
// visit: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001381.html
-
}
Category: Flash AS2 | Tags: ActionScript, AS2, Flash
Leave a Reply



