A Flash Developer Resource Site

Results 1 to 20 of 40

Thread: [CS3] Help With my code!

Hybrid View

  1. #1
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Well here is what I would probably do. Tweens are weird in that they are in fact reusable, but I have not found a way to create them without passing the initial parameters, which in turn stars the tween. So basically what I normally end up doing with them is creating them and then immediately stopping them, or create them with a starting and ending value that is the same (I do this when I will be customizing the values later). So if I understand you correctly, you want that sequence of tween to loop. I did not actually test this, but you can give it a try and see how it works for you:

    var yellowTween:Tween = new Tween (circle_mc.yellow_mc, "alpha", None.easeInOut, 1 , 0 , 1 , true );
    yellowTween.stop();
    yellowTween.addEventListener(TweenEvent.MOTION_FIN ISH, startBlue);
    var blueTween:Tween = new Tween (circle_mc.blue_mc, "alpha", None.easeInOut, 1 , 0 , 1 , true );
    blueTween.stop();
    blueTween.addEventListener(TweenEvent.MOTION_FINIS H, startRed);
    var redTween:Tween = new Tween (circle_mc.red_mc, "alpha", None.easeInOut, 1 , 0 , 1 , true);
    redTween.stop()
    blueTween.addEventListener(TweenEvent.MOTION_FINIS H, startYellow);
    yellowTween.start();

    function startBlue(event:TweenEvent):void
    {
    blueTween.start();
    }
    function startRed(event:TweenEvent):void
    {
    redTween.start()
    }
    function startYellow(event:TweenEvent):void
    {
    yellowTween.start();
    }

    by doing it this way you are reusing the tween objects and only assigning the event listeners once instead of recreating them and assigning them each time the TweenEvent.MOTION_FINISH is triggered. Since each TweenEvent.MOTION_FINISH triggers the next tween to start, you basically just set the loop up and let it run.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  2. #2
    Member
    Join Date
    Aug 2008
    Posts
    39
    right heres the code so far

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


    var yellowTween:Tween = new Tween (circle_mc.yellow_mc, "alpha", None.easeInOut, 1 , 0 , 1 , true );
    yellowTween.stop();
    yellowTween.addEventListener(TweenEvent.MOTION_FIN ISH, startBlue);

    var blueTween:Tween = new Tween (circle_mc.blue_mc, "alpha", None.easeInOut, 1 , 0 , 1 , true );
    blueTween.stop();
    blueTween.addEventListener(TweenEvent.MOTION_FINIS H, startRed);

    var redTween:Tween = new Tween (circle_mc.red_mc, "alpha", None.easeInOut, 1 , 0 , 1 , true);
    redTween.stop()
    redTween.addEventListener(TweenEvent.MOTION_FINISH , startYellow);

    yellowTween.start();

    function startBlue(event:TweenEvent):void
    {
    blueTween.start();
    }
    function startRed(event:TweenEvent):void
    {
    redTween.start()
    }
    function startYellow(event:TweenEvent):void
    {
    yellowTween.start();
    }

    the first time it goes it loops over each other giving a sorta cross fade effect the second time is different

    id like each to fade in straight after each other, and how do i slow them down?

    my fla is attached if it helps to use my example
    and the swf to view it

    Thankyou very much for your help so far
    Attached Files Attached Files

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