A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: start tween class halfway other tweens

  1. #1
    Senior Member
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    326

    start tween class halfway other tweens

    I've used some tweens to get the following effect. It rotates two images by fading them into eachother. Above that is the 'schuiver' clip which has an alpha of 10% which goes left to right and back. Take a look at below script. It used three tweens. One to move the image left to right, one the (at the same time) shrink the image to a smaller width and the fade tween which switches both images. This last fade I would like to start when the 'schuiver' clip (a transparant rectangle which moves accross the stage) is about halfway. I've tried using:
    code:
    xScroll.onMotionChanged = function() {
    if (xScroll.time>=2) {
    var xFade:Tween = new Tween(MyImageContainer1, "_alpha", Regular.easeOut, 100, 0, 2, true);
    delete this.onMotionChanged;
    }


    But this works just the first time. When the 'schuiver' clip goes from right to left again the onMotionChanged already has been deleted. Without that delete if would continiously start the fade tween after 2 seconds.

    Here's the script I'm using now. I immediately starts the fade tween along with the _x and _width tween, but I would like to start that one when everything is halfway. Any ideas?

    code:
    //basic transition settings
    import mx.transitions.*;
    import mx.transitions.easing.*;
    //
    //import clips
    var loader:MovieClipLoader = new MovieClipLoader();
    this.createEmptyMovieClip("MyImageContainer1", schuiver.getDepth()-1);
    this.createEmptyMovieClip("MyImageContainer2", schuiver.getDepth()-2);
    loader.loadClip("image1.jpg", MyImageContainer1);
    loader.loadClip("image2.jpg", MyImageContainer2);
    //
    //tweens
    var xScroll:Tween = new Tween(schuiver, "_x", Regular.easeOut, 0, 259.5, 4, true);
    var xWidth:Tween = new Tween(schuiver, "_width", Regular.easeOut, 259.5, 129.5, 4, true);
    var xFade:Tween = new Tween(MyImageContainer1, "_alpha", Regular.easeOut, 100, 0, 2, true);
    xScroll.onMotionFinished = function() {
    xScroll.yoyo();
    xWidth.yoyo();
    xFade.yoyo();
    };


    Illustration | Animation | Web Banners | Graphic Design
    Ducklord Studio

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Untested but should work:
    PHP Code:
    //basic transition settings
    import mx.transitions.*;
    import mx.transitions.easing.*;

    //import clips
    var loader:MovieClipLoader = new MovieClipLoader();
    this.createEmptyMovieClip("MyImageContainer1"schuiver.getDepth()-1);
    this.createEmptyMovieClip("MyImageContainer2"schuiver.getDepth()-2);
    loader.loadClip("image1.jpg"MyImageContainer1);
    loader.loadClip("image2.jpg"MyImageContainer2);

    //tweens
    var xScroll:Tween = new Tween(schuiver"_x"Regular.easeOut0259.54true);
    var 
    xWidth:Tween = new Tween(schuiver"_width"Regular.easeOut259.5129.54true);
    var 
    xFade:Tween = new Tween(MyImageContainer1"_alpha"Regular.easeOut10002true);

    // Stop the fade tween from starting
    xFade.stop();

    xScroll.onMotionChanged = function() {
        if(
    this.time == 2) {// == 50% or 1/2 of 4 seconds
            
    xFade.start();// Start the fade tween
        
    }
    }

    xScroll.onMotionFinished = function() {
        
    xScroll.yoyo();
        
    xWidth.yoyo();
        
    xFade.yoyo();
    }; 

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