Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
pizza0502

preloader with loadermax

Recommended Posts

Hi,

 

I've work around with loadermax that I've learn it this few days.

I found a preloader file at here and i try to reuse it.

but the preloader is not working, here is my code:

 

stop();

import com.greensock.*;
import com.greensock.loading.*;
import com.greensock.loading.display.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.SWFLoader;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

var _tf:TextField;
var _tfFormat:TextFormat;
var _loadingBar:LoadingBar;
function Loader2()
{
init();
}

function init():void
{
_tfFormat = new TextFormat  ;
_tfFormat.font = "Arial";
_tfFormat.size = 15;
_tfFormat.color = 0x000000;
_tfFormat.bold = true;
_tf = new TextField  ;
_tf.autoSize = TextFieldAutoSize.CENTER;
_tf.text = "Loading Interface...";
_tf.setTextFormat(_tfFormat);
addChild(_tf);
_tf.x = (stage.stageWidth / 2) - (_tf.width / 2);
_tf.y = (stage.stageHeight / 2) - (_tf.height / 2)
;
_loadingBar = new LoadingBar  ;
addChild(_loadingBar);
_loadingBar.x = (stage.stageWidth / 2) - (_loadingBar.width / 2);
_loadingBar.y = (stage.stageHeight / 2) - (_loadingBar.height / 2) + 20;
var queue:LoaderMax = new LoaderMax({name:"mainQueue",onProgress:progressHandler,onComplete:completeHandler,onError:errorHandler});

//append several loaders;
queue.append( new SWFLoader("main.swf", {name:"contentClip", estimatedBytes:930000, container:this, visible:true, autoPlay:true}) );

//start loading;
queue.load();
}

function progressHandler(event:LoaderEvent):void
{
_loadingBar.loadingPerc.scaleX = Number(event.target.progress);
trace("progress: " + event.target.progress);
}

function completeHandler(event:LoaderEvent):void
{
addChild(LoaderMax.getContent("main"));
_tf.text = "SWF LOADED";
_tf.setTextFormat(_tfFormat);
trace(event.target + " is complete!");
}

function errorHandler(event:LoaderEvent):void
{
trace("error occured with " + event.target + ": " + event.text);
}

 

btw, the main.swf i loading is containing 2 more swf loaded from external. is it i need to put the code requireWithRoot at here or the main.swf or the subpage.swf?

Link to comment
Share on other sites

Could you explain what you mean by "preloader is not working"? You see nothing on the screen? The progress doesn't advance? The files don't load? Please be as specific as possible.

 

As far as the requireWithRoot issue, yes, you put that in the subloaded swfs. If you create a loader that should be loaded as a part of that swf's root, you set the requireWithRoot to that swf's root. Feel free to look at the source files of the examples that are available on the site. http://www.LoaderMax.com (in the FAQ section).

 

The fastest/best way to get help here is to post an FLA example that we can publish ourselves and see exactly what the problem is. It doesn't need to be your production files - just the simplest possible example that reproduces the issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×