Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 2 of 2

Thread: Fade Out External SWF on MouseEvent

  1. #1

    Fade Out External SWF before removeChild

    Hi there,

    I am so stuck on the simplest of transitions! I've just started using AS3 and and doing alright so far, but have been looking for days for a solution to this.... HELP ME PLEASE!!?

    I have a simple gallery with 3 buttons.

    Each button calls in a different SWF. The SWF fades into place, and when you click on a different button it is removed and a new one fades into the same position.

    All done with AS3 (below). What I just can't manage is how to fade the SWF out before the
    removeChild(gallery);
    
    kicks in.... please tell me how!!




    // Import classes for easier use
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;

    // Load Default Image Into gallery
    var Xpos:Number = 20;
    var Ypos:Number = 90;
    var swf:MovieClip;
    var gallery:Loader = new Loader();

    var defaultSWF:URLRequest = new URLRequest("swfs/img1.swf");

    gallery.load(defaultSWF);
    gallery.x = Xpos;
    gallery.y = Ypos;
    addChild(gallery);

    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(gallery);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    var myTweenIn:Tween = new Tween(gallery, "alpha", None.easeOut, 0, 1, 1, true);
    gallery.load(newSWFRequest);
    gallery.x = Xpos;
    gallery.y = Ypos;
    addChild(gallery);
    }
    // Btn listeners
    img1.addEventListener(MouseEvent.CLICK, btnClick);
    img2.addEventListener(MouseEvent.CLICK, btnClick);
    img3.addEventListener(MouseEvent.CLICK, btnClick);
    Last edited by stevensunsunsun; February 3rd, 2010 at 11:05 AM. Reason: Wrong subject heading

  2. #2

    Solved

    wow... thanks to kglad in Adobe's forums...

    var myTweenOut:Tween;
    var nextLoadS:String;

    function btnClick(event:MouseEvent):void {
    nextLoadS = event.target.name
    myTweenOut=new Tween(gallery,"alpha",None.easeOut,gallery.alpha,0,1,true);
    myTweenOut.addEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF);
    }

    function tweenOutCompleteF(e:TweenEvent){
    myTweenOut.removeEventListener(TweenEvent.MOTION_FINISH,tweenOutCompleteF);
    myTweenOut=null;
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + nextLoadS + ".swf");
    var myTweenIn:Tween = new Tween(gallery, "alpha", None.easeOut, gallery.alpha, 1, 1, true);
    gallery.load(newSWFRequest);
    gallery.x = Xpos;
    gallery.y = Ypos;
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012