Hi I have a seemingly simple problem, that I’m just no able to figure out…I have a preloader written in AS 3, and I want the movie that it loads to open up in a fixed size window. How do I do this??
Here is the code for my preloader:
// Import all necessary Classes – //
import flash.display.;
import flash.events.;
// Note: though all of the classes are not need for this application
// it would be helpful if using the preloader in a linear Flash project.
import flash.net.URLRequest;
stop();
// Instances of the preload Sprite to be used in the loader
var preload:Sprite = new Sprite();
// Create the loader and add it to the display list
var imageLoader:Loader = new Loader();
addChild(imageLoader);
// Add event listeners to handle specific events during the loading process
imageLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
imageLoader.load(new URLRequest(“ex4.swf”));
imageLoader.x = -168.3;
imageLoader.y = -222;
// This is typically going to be something like “gallery.swf” or “main.swf”
//
// Note: make sure you’ve got the relative path correct in the URLRequest.
// For example, (“http://localhost/swfs/main.swf”) or ("/swfs/main.swf")
function showPreloader(evt:Event):void {
trace(“open”);
addChild(preload);
}
function showProgress(evt:ProgressEvent):void {
var percent:Number = Math.round((evt.bytesLoaded / evt.bytesTotal )*100 );
loadingText.htmlText = percent + “% loaded”;
// Create preloading bar graphic with white background, width of 260.9
// and height of 14.5
preload.graphics.beginFill(0xFF0033);
preload.graphics.drawRoundRect(0, 0, 260.9, 10, 18, 18);
preload.x = 172;
preload.y = 135.7;
preload.width = (percent / 100) * 260.9;
addChild(preload);
trace("progress, percent = " + percent);
}
function onComplete(evt:Event):void {
removeChild(preload);
gotoAndPlay(currentFrame + 1);
// Note: for linear Flash application this implimentation works very basically
// More advanced applications may want to incorporate more dynamic content loading
// with more eventListeners and Loaders.
trace(“complete”);
}