A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: external loaded swf plays while loading

  1. #1
    Member
    Join Date
    Nov 2007
    Posts
    58

    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.PROGRESSloop);
    l.contentLoaderInfo.addEventListener(Event.COMPLETEdone);
    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:bartime:1alpha:0delay:1},
                                {
    target:enttime:1.5alpha:1}
                            ]);
    }

    ent.addEventListener(MouseEvent.CLICKmotion);

    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.

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    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);

  3. #3
    Member
    Join Date
    Nov 2007
    Posts
    58
    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

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    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.CLICKmotion);
    }

    function 
    motion (e:MouseEvent):void {
        
    removeChildAt(0); 
        
    bar null
        
    ent null
        
    addChild(l); 
        
    TweenMax.multiSequence([{target:bartime:1alpha:0delay:1}, {target:enttime:1.5alpha: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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center