package LoadGame
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.Font;
/**
* ...
* @author david
*/
[SWF(width = "640", height = "480",
frameRate = "30", backgroundColor = "#000000")]
public class Main extends Sprite
{
public var loader:Loader;
public var loadText:TextField;
public var loadFormat:TextFormat;
public var array:Array;
public function Main():void
{
loadText = new TextField();
loadFormat = new TextFormat();
array = new Array();
loadText.text = "";
loadText.background = false;
loadText.border = false;
loadFormat.color = 0xFFFFFF;
loadFormat.size = 10;
loadFormat.font = "Arial";
loadText.x = 300;
loadText.y = 220;
loadText.width = 160;
loadText.defaultTextFormat = loadFormat;
addChild(loadText);
var request:URLRequest = new URLRequest("yourFileToLoad.swf");
var loader:Loader = new Loader();
loader.load(request);
array.push(loader);
loader.contentLoaderInfo.addEventListener
(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener
(Event.COMPLETE, loadComplete);
}
private function loadProgress(event:ProgressEvent):void
{
loadText.text = event.bytesLoaded + " bytes loaded!";
}
private function loadComplete(event:Event):void
{
addLoader();
}
private function addLoader():void
{
var loader:Loader = array[0];
addChild(loader);
}
}
}
petek, 17. september 2010
Actionscript 3 preloader (in Flash Develop)
So yea, this is the full source of my Commando preloader (1,6 kB). It basically loads instantly starting the actual load of the game.
Oznake:
action script,
actionscript 3,
flash,
flash develop,
flashdevelop,
loader,
preload,
seperate,
source
Naročite se na:
Objavi komentarje (Atom)
Ni komentarjev:
Objavite komentar