Jareish
10-14-2008, 08:35 AM
In my panorama shots, I often call upon Still images or flashfiles, between 500-1500 kb. I don't want my users to stare upon I blanco panorama, waiting for the still to load, so I decided to create a preloader plugin, specially for external assets. I used the flvplayer plugin as the base.
xml:
<box id="still" url="images/loader.swf?file=still.png" salign="CC" align="CC" static="1" />
the plugin - loader.swf:
import fl.controls.ProgressBar;
var movie:Sprite;
var hotspot:Object;
var hotspots:Object;
var myLoader:Loader = new Loader();
var toLoad:String;
var my_pb:ProgressBar = new ProgressBar();
my_pb.source = myLoader.contentLoaderInfo;
my_pb.x = 100;
my_pb.y = 200;
if (loaderInfo.parameters.file==null) {
toLoad = "images/blanco.png";
} else {
toLoad = loaderInfo.parameters.file;
}
loaderInfo.addEventListener(Event.INIT, initHandler);
function initHandler (event:Event) {
if (loaderInfo.loader!=null)
{
trace("initiated");
myLoader.load(new URLRequest(toLoad));
addChild(my_pb);
movie = loaderInfo.loader.movie;
hotspot = loaderInfo.loader.hotspot; // get link to hotspot control object:
hotspots = loaderInfo.loader.hotspots; // get link to hotspots plugin object:
}
}
myLoader.contentLoaderInfo.addEventListener(Event. COMPLETE, finishLoading);
function finishLoading(e:Event):void
{
trace("finished loading");
addChild(myLoader);
removeChild(my_pb);
my_pb = null;
}
Basicly, as soon as it initialized, it will add a progressbar from the library to the stage and add the file in the loader. As soon as its done, add the file to the stage and remove the progressbar.
But it doesn't work. The trace output is clean, no errors, it loads loader.swf and it gets the right path to the file. It just doesn't seem to add it to the stage. I've tried different settings (dynamic/with frames/components/just text etc)
Anyone got an idea?
xml:
<box id="still" url="images/loader.swf?file=still.png" salign="CC" align="CC" static="1" />
the plugin - loader.swf:
import fl.controls.ProgressBar;
var movie:Sprite;
var hotspot:Object;
var hotspots:Object;
var myLoader:Loader = new Loader();
var toLoad:String;
var my_pb:ProgressBar = new ProgressBar();
my_pb.source = myLoader.contentLoaderInfo;
my_pb.x = 100;
my_pb.y = 200;
if (loaderInfo.parameters.file==null) {
toLoad = "images/blanco.png";
} else {
toLoad = loaderInfo.parameters.file;
}
loaderInfo.addEventListener(Event.INIT, initHandler);
function initHandler (event:Event) {
if (loaderInfo.loader!=null)
{
trace("initiated");
myLoader.load(new URLRequest(toLoad));
addChild(my_pb);
movie = loaderInfo.loader.movie;
hotspot = loaderInfo.loader.hotspot; // get link to hotspot control object:
hotspots = loaderInfo.loader.hotspots; // get link to hotspots plugin object:
}
}
myLoader.contentLoaderInfo.addEventListener(Event. COMPLETE, finishLoading);
function finishLoading(e:Event):void
{
trace("finished loading");
addChild(myLoader);
removeChild(my_pb);
my_pb = null;
}
Basicly, as soon as it initialized, it will add a progressbar from the library to the stage and add the file in the loader. As soon as its done, add the file to the stage and remove the progressbar.
But it doesn't work. The trace output is clean, no errors, it loads loader.swf and it gets the right path to the file. It just doesn't seem to add it to the stage. I've tried different settings (dynamic/with frames/components/just text etc)
Anyone got an idea?