A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: Noob tweening Question

  1. #21
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    To make it go slower, change the amount of time it takes to do the tween. Change 1 to 7, for instance. I must have somehow mis-calculated the final coordinate somehow. Try just adding fudge factors to stage.stageHeight until you fine-tune it.

    To get Jesus to be in front of the starfield, either add him to the display after the starfield (you can re-add him even if he's already on), or add the starfield to a container which is behind him to begin with.

  2. #22
    Member
    Join Date
    Aug 2008
    Posts
    40
    The starfield is an externally read .as file.

  3. #23
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Doesn't matter. You're adding it to the displayList with the line
    Code:
    addChild(field);
    Simply re-add jesus after that so he's on top:
    Code:
    addChild(field);
    addChild(jesus);
    Or add the field to a container placed on the display in the IDE, which is behind him
    Code:
    fieldHolder.addChild(field);

  4. #24
    Member
    Join Date
    Aug 2008
    Posts
    40
    Code:
    addChild(field);
    addChild(jesus);
    
    import com.greensock.*; 
    import com.greensock.easing.*;
    
    
    
    TweenLite.to(earth, 7, {x:stage.stageWidth/2, y:stage.stageHeight+(earth.height), overwrite:0});
    TweenLite.to(earth, 10, {scaleX:2, scaleY:2, overwrite:0});
    TweenLite.to(bg, 1, {x:stage.stageWidth/2, y:stage.stageHeight/2, overwrite:0});
    TweenLite.to(bg, 10, {scaleX:2, scaleY:2, overwrite:0});
    Works perfect to keep Jesus above the stars.

    But I still can't figure out your explaination of moving the earth further below stage.

  5. #25
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Just add more offset to the y coordinate of the tween.
    Code:
    TweenLite.to(earth, 7, {x:stage.stageWidth/2, y:stage.stageHeight+100, overwrite:0});
    And if that isn't far enough:
    Code:
    TweenLite.to(earth, 7, {x:stage.stageWidth/2, y:stage.stageHeight+200, overwrite:0});
    etc.

  6. #26
    Member
    Join Date
    Aug 2008
    Posts
    40
    Thank YOU!

    Everything is perfect, now I just need to make Jesus and the logo fade in after the earth and background tweens have finished.

    Going to give it a shot on my own, will post broken code if any.

  7. #27
    Member
    Join Date
    Aug 2008
    Posts
    40
    Okay, I have no Idea how to have the logo and the picture of Jesus fade in when the earth and background tweens stop..

  8. #28
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Read up on the TweenLite documentation. You can pass a function to be called when the tween completes.

    So, set Jesus and the Logo (pretty good band name) to alpha=0 originally, then write a function to apply a tween to them to fade them in. Call that function as the onComplete from your scaling tween.

    Code:
    //...
    jesus.alpha = 0;
    logo.alpha = 0;
    addChild(jesus);
    
    
    TweenLite.to(earth, 10, {scaleX:2, scaleY:2, overwrite:0, onComplete:fadeInJesus});
    
    function fadeInJesus():void{ //I don't know if this should take parameters or not.
      TweenLite.to(jesus, 5, {alpha:1});
      TweenLite.to(logo, 5, {alpha:1});
    }

  9. #29
    Member
    Join Date
    Aug 2008
    Posts
    40
    That just does not seem to work..

    I think I am happy with the results:

    http://ssdev.hlrse.net/orion/

    But maybe perhaps when you download the files, CS3 (CS4 runs like crap on my awesome PC), you could take a look at why that code won't work.

    Thanks bro, you're a great teacher.

Tags for this Thread

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