RSS
email

Preloading in FlashCS3



Started learning flash CS3..so i sharing what i learnt...
this is to preloading in cs3...

full code:
import flash.display.Loader;
import flash.net.URLRequest;
var url:String='http://greetings.visualenc.com/shockwave/friends3.swf?cachebusters='+new Date().getTime();
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.OPEN,loadinit);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loading);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completes);
loader.load(new URLRequest(url))
addChild(loader)
function loadinit(event:Event){
trace("::::Started::::");
}
function loading(event:ProgressEvent) {
trace((event.bytesLoaded/event.bytesTotal)*100);
}
function completes(event:Event){
trace("::::complete::::")
}



import flash.display.Loader;
import flash.net.URLRequest;

This is loading the necessary packages...for loader class and url request



var url:String='http://greetings.visualenc.com/shockwave/friends3.swf?cachebusters='+new Date().getTime();

string contains the url to be loaded..

that new Date().getTime()..is not new feature. when added to url files will not be cached...or no need to clear cache for new updated file..



var loader:Loader=new Loader();
Creating Object for loader class...Loader class is to load image and swf files into flashCS3



loader.contentLoaderInfo.addEventListener(Event.OPEN,loadinit);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loading);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completes);

Adding listeners ..similar to MovieClipLoader in flash8.




loader.load(new URLRequest(url))

loading external content into loader object via url request class...



trace((event.bytesLoaded/event.bytesTotal)*100);

here we calculate the bytes loaded...

Bookmark and Share
 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.