The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

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