flash on 2010-3-2
♥0 |
Line 68 |
Modified 2010-03-03 00:43:51 |
MIT License
archived:2017-03-20 12:52:18
ActionScript3 source code
/**
* Copyright hacker_9p8x8mco ( http://wonderfl.net/user/hacker_9p8x8mco )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/w8Fv
*/
package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.URLRequest;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
[SWF(width="480",height="360",frameRate="25")]
public class FlashTest extends Sprite {
public var ldr_titlepng:Loader = new Loader();
public var ldr_jikipng:Loader = new Loader();
public var timer:Timer = new Timer(40);
public function FlashTest() {
// write as3 code here..
var url:String = "http://www.neologismer.com/test/image_001.jpg";
var urlReq:URLRequest = new URLRequest(url);
this.ldr_titlepng.contentLoaderInfo.addEventListener(Event.COMPLETE,this.loadCompleted01);
this.ldr_titlepng.load(urlReq);
}
public function loadCompleted01(event:Event):void{
this.addChild(this.ldr_titlepng);
var url:String = "http://www.neologismer.com/test/img/new2.gif";
var urlReq:URLRequest = new URLRequest(url);
this.ldr_jikipng.contentLoaderInfo.addEventListener(Event.COMPLETE,this.loadCompleted02);
this.ldr_jikipng.load(urlReq);
}
public function loadCompleted02(event:Event):void{
this.addChild(this.ldr_jikipng);
this.ldr_jikipng.x = -32;
this.ldr_jikipng.y = 216;
this.timer.addEventListener(TimerEvent.TIMER,tick01);
this.timer.start();
}
public function tick01(event:TimerEvent):void{
this.ldr_jikipng.x += 4;
if(this.ldr_jikipng.x > 960) this.ldr_jikipng.x = -32;
}
}
}
import flash.display.Loader;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLRequest;
class LoadManager extends EventDispatcher{
public var requests:Array = new Array();
public var bitmaps:Array = new Array();
public var numcomplete:int = 0;
public var loader:Loader = new Loader();
public function addRequest(url:String):void{
var urlreq:URLRequest = new URLRequest(url);
this.requests.push(urlreq);
}
public function startLoading():void{
this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.completed);
if(this.requests.length > 0){
this.loader.load(this.requests[0]);
}
}
public function completed(event:Event):void{
this.bitmaps.push(this.loader.content);
this.numcomplete++;
if(this.requests.length > this.numcomplete){
this.loader.load(this.requests[this.numcomplete]);
}else{
var event:Event = new Event(Event.COMPLETE);
this.dispatchEvent(event);
}
}
}