A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Fade In/Fade Out external swfs on button click

  1. #1
    Member
    Join Date
    Apr 2008
    Posts
    63

    Fade In/Fade Out external swfs on button click

    I know this is a simple fix but I am new to learning AS 3.0 and was wondering if someone could help me.

    I have 2 buttons on the stage whose each MouseEvent load a different external swf when clicked. In an attempt to get the current swf to fade out and new swf to fade in on button click, I vainly added a Tween to the function but to no avail.

    As it is now, when the movie starts, the button 1 swf fades in, however, when button 2 is clicked, the new swf is loaded but the old swf does not fade.

    Any help? Thanks guys.

    Code:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    
    var image:Loader = new Loader();
    addChild(image);
    image.x = 0;
    image.y = 95;
    
    button1_mc.addEventListener(MouseEvent.CLICK, onButton1Click);
    button2_mc.addEventListener(MouseEvent.CLICK, onButton2Click);
    
    function onButton1Click(event:MouseEvent = null):void {
    	inContent("rectangle.swf");
    }
    
    function onButton2Click(event:MouseEvent):void {
    	inContent("square.swf");
    }
    
    function inContent(swfUrl:String):void {
    	var myTweenAlphaIn:Tween = new Tween(image, "alpha", Strong.easeOut, 0, 1, 10, true);
    	var url:URLRequest = new URLRequest ("swfs/" + swfUrl);
    	image.load(url);
    }
    
    onButton1Click();

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    23
    I worry that I'm going to start sounding like an evangelist since this is the second time today I make pretty much the same reccomendation but have a look at tweenlite. If you can use external classes it'll change your life you can then just make your event handler function tween and set the tween to execute the next function ... worth looking into ...

    http://blog.greensock.com/tweenlite/

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