Hi;
I have this code:

public class Preloader extends MovieClip
{
var loader:Loader = new Loader();
var loader2:Loader = new Loader();
var loader3:Loader = new Loader();
private var myTextField:TextField = new TextField();
var imgFlag1:Boolean = new Boolean(false);
var imgFlag2:Boolean = new Boolean(false);

public function Preloader()
{
addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
 private function init(e:Event)
{
var clientName:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = 'Arial';
format.size = 35;
clientName.textColor = 0x023048;
clientName.text = 'Client Name';
clientName.autoSize = TextFieldAutoSize.LEFT;
clientName.setTextFormat(format);
var nameSprite:Sprite = new Sprite();
nameSprite.x = stage.stageWidth/2 - 140;
nameSprite.y = stage.stageHeight/2 - 40;
nameSprite.alpha = 0;
TweenLite.to(nameSprite, 2, {alpha:1});
addChild(nameSprite);
nameSprite.addChild(clientName);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.load(new URLRequest("images/logo.png"));
loader2.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded2);
loader2.load(new URLRequest("images/graphic.png"));
loader2.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
removeEventListener(Event.ADDED_TO_STAGE, init);
addChild(myTextField);
myTextField.width = 250;
myTextField.x = stage.stageWidth/2;
myTextField.y = stage.stageHeight/2;
myTextField.selectable = false;
myTextField.border = false;
myTextField.borderColor = 0xAA0000;
myTextField.autoSize = TextFieldAutoSize.LEFT;
var myFormat:TextFormat = new TextFormat();
myFormat.color = 0x023048;
myFormat.size = 24;
myFormat.italic = true;
myTextField.defaultTextFormat = myFormat;
}

private function imageLoaded(event:Event):void
{
imgFlag1 = true;
if (imgFlag2 == true)
{
completePreloader();
}
}
 private function imageLoaded2(event:Event):void
{
imgFlag2 = true;
if (imgFlag1 == true)
{
completePreloader();
}
}
 function completePreloader()
{
var req:URLRequest = new URLRequest('index.py');
navigateToURL(req, '_self');
}
 function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded/e.bytesTotal;
myTextField.text = Math.ceil(perc*100).toString() + "%";
}
}
}

Now, this does exactly what I want in that it loads the two graphics before
going to my page that has two swf files, one of which is a splash page. The
problem is that it *always* loads those images without, apparently,
bothering to check to see if they're already cached. I wonder if this is
because I never add them to the stage (addChild). How do I get the script to
check and see if the images are already cached?
TIA,
Victor
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to