A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: AS3 Tween Class stalls

  1. #1
    Senior Member
    Join Date
    Nov 2003
    Posts
    385

    AS3 Tween Class stalls

    using the tween class below - I am having trouble with it stalling before the reveal content runs. So my content sits there at like 5% opacity and does not finish loading. How do I fix this? Am I using a bad tween class?

    Much Thanks,
    -M

    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;

    function display(endX,frame):void {
    var mover:Tween = new Tween(line_mc, "x", Regular.easeOut, line_mc.x, endX, .5, true);
    content_mc.gotoAndStop(frame);
    var revealContent:Tween = new Tween(content_mc, "alpha", Regular.easeOut, 0,1,4,true);
    }

  2. #2
    Junior Member
    Join Date
    May 2009
    Posts
    20
    Sorry this doesn't really help your problem but i use tweenlite (http://blog.greensock.com/tweenliteas3/) which is a stripped down version of tweening and runs faster than as3 built in tween (so I have heard) ... if you used that I could help lol ... good luck finding answer

  3. #3

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    The Adobe Tween class is horrible - since you're using a local variable, it gets cleaned up after that function is run - but the Tween class is screwy and sometimes gets garbage collected along with the variable, abruptly killing your tween in the process.

    I highly recommend getting away from fl.transitions.Tween and grabbing any of the other third-party engines (TweenLite is great, Tweener is solid, gTween, Go, &c).

  5. #5
    Senior Member
    Join Date
    Nov 2003
    Posts
    385

    Example

    SStalder - here is a complete example of how I am using the function....

    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;

    function display(endX,frame):void {
    var mover:Tween = new Tween(line_mc, "x", Regular.easeOut, line_mc.x, endX, .5, true);
    content_mc.gotoAndStop(frame);
    var revealContent:Tween = new Tween(content_mc, "alpha", Regular.easeOut, 0,1,4,true);
    }

    display(btn_hom.x, "home");

    btn_hom.addEventListener(MouseEvent.CLICK, home);

    function home(event:MouseEvent):void {
    display(btn_hom.x,"home");

    }

    btn_abo.addEventListener(MouseEvent.CLICK, about);

    function about(event:MouseEvent):void {
    display(btn_abo.x,"about");

    }

    btn_ser.addEventListener(MouseEvent.CLICK, services);

    function services(event:MouseEvent):void {
    display(btn_ser.x,"services");

    }

    btn_tea.addEventListener(MouseEvent.CLICK, team);

    function team(event:MouseEvent):void {
    display(btn_tea.x,"team");

    }

    btn_car.addEventListener(MouseEvent.CLICK, careers);

    function careers(event:MouseEvent):void {
    display(btn_car.x,"careers");

    }

    btn_con.addEventListener(MouseEvent.CLICK, contact);

    function contact(event:MouseEvent):void {
    display(btn_con.x,"contact");

    }

  6. #6
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    I would suggest going with TweenLite as neznein9 mentioned above. It's much more stable than the native Tween class.

  7. #7
    Senior Member
    Join Date
    Nov 2003
    Posts
    385
    I will look at that - Thanks to all!
    -M

  8. #8
    Senior Member
    Join Date
    Nov 2003
    Posts
    385

    Tween Lite Help

    So I've got the Tween lite but I don't really understand how to translate my old tween to tween lite. For instance this is what I had:

    function display(endX,frame):void {
    var mover:Tween = new Tween(line_mc, "x", Regular.easeOut, line_mc.x, endX, .5, true);
    content_mc.gotoAndStop(frame);
    var revealContent:Tween = new Tween(content_mc, "alpha", Regular.easeOut, 0,1,4,true);
    }

    How do I rewrite the mover tween and revealContent tween in tween lite?

    -M

  9. #9
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    This should do it:

    PHP Code:
    function display(endX,frame):void {
        
    TweenLite.to(line_mc0.5, { xendXeaseRegular.easeOut });
        
    content_mc.gotoAndStop(frame);
        
    TweenLite.to(content_mc4, { alpha1easeRegular.easeOut });


  10. #10
    Senior Member
    Join Date
    Nov 2003
    Posts
    385
    OMG - Thank You. This is huge for me

  11. #11
    Senior Member
    Join Date
    Nov 2003
    Posts
    385

    blank white page

    hmmm - when I preview my move now I just get a blank white page.

  12. #12
    Senior Member
    Join Date
    Nov 2003
    Posts
    385

    nevermind

    it's working fine now - I just closed and re-opened the file.

    Thanks again!
    best,
    -M

  13. #13
    Senior Member
    Join Date
    Nov 2003
    Posts
    385
    One thing though the alpha tween is not working.

    This one:

    TweenLite.to(content_mc, 4, { alpha: 1, ease: Linear.easeOut });

  14. #14
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Is the alpha of content_mc not 0 before that tween starts? You could set the alpha before the tween runs I suppose.

  15. #15
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Try using autoAlpha: - it's the same param but it accounts for visibility when you go in and out of alpha=0

  16. #16
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    I think his issue is the actual alpha already being at 1 when the tween is starting. So he would need to put in some logic to set the alpha to 0 somewhere first (before the tween). Correct me if I am wrong bluedawg65.

    So it could be something like this:

    PHP Code:
    function display(endX,frame):void {
        
    TweenLite.to(line_mc0.5, { xendXeaseRegular.easeOut });
        
    content_mc.gotoAndStop(frame);
        
    content_mc.alpha 0;// Set to 0 then start the tween below
        
    TweenLite.to(content_mc4, { alpha1easeRegular.easeOut });


  17. #17
    Senior Member
    Join Date
    Nov 2003
    Posts
    385
    oh yes, I will try this...

  18. #18
    Senior Member
    Join Date
    Nov 2003
    Posts
    385
    Yes, With the alpha set to 0 beforee the tween starts - then it work s correctly.
    Thank You!

  19. #19
    Junior Member
    Join Date
    May 2009
    Posts
    20
    Isn't Tweenlite so much nicer

  20. #20
    Senior Member
    Join Date
    Nov 2003
    Posts
    385
    Now that I am beginning to see how it works... and just the fact that it does work is awesome! I couldn't deliver the other to the client as it kept stalling.

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