-
external loaded swf plays while loading
Hi
I'm loading an external swf file but it starts playing while it's busy loading, I put a stop(); in the external but that doesn't work at all. Is there another way of playing the swf only when it is visible to the user.
Thanx for any help
Code:
PHP Code:
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("main.swf"));
import gs.TweenMax;
ent.alpha = 0;
ent.useHandCursor = true;
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
bar.scaleX = perc;
}
function done(e:Event):void
{
TweenMax.multiSequence([
{target:bar, time:1, alpha:0, delay:1},
{target:ent, time:1.5, alpha:1}
]);
}
ent.addEventListener(MouseEvent.CLICK, motion);
function motion (e:MouseEvent):void
{
removeChildAt(0);
bar = null;
ent = null;
addChild(l);
}
this is the loader swf that loads the external swf. The swf being loaded is just a couple of movie clips tweening in.
-
I'm not sure I've ever seen this behavior before...the only thing in there that looks strange to me is the motion function - specifically that you're calling it with a mouseclick? Try removing that addChild and putting this into "done":
addChild(e.target.content);
-
cool thanx that worked.
The reason I had the motion function was for a "enter" button that tweens in and on click it loads the swf. Now it just skips right to the loaded swf after load, I can live with that cause at least it's working now.
Can you tell me how you would have done it if you don't mind, I'm still learning and if there is a better way then I will use that way.
Thank you for the reply
-
To load and then wait for the enter button, you could move things around like this:
PHP Code:
function done(e:Event):void{
ent.addEventListener(MouseEvent.CLICK, motion);
}
function motion (e:MouseEvent):void {
removeChildAt(0);
bar = null;
ent = null;
addChild(l);
TweenMax.multiSequence([{target:bar, time:1, alpha:0, delay:1}, {target:ent, time:1.5, alpha:1}]);
}
If you want to wait to start loading, you would move the loader code into a function and call that with your enter button. Otherwise everything looks good.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|