In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2009-6-11

Simple tweener example for a friend
Get Adobe Flash player
by onedayitwillmake 11 Jun 2009
/**
 * Copyright onedayitwillmake ( http://wonderfl.net/user/onedayitwillmake )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/vv9U
 */

// Simple tweener example for a friend
package
{
    import flash.display.Sprite;
    import caurina.transitions.Tweener;
    
    public class Example extends Sprite
    {
        private var _circle     :Sprite; 
        
        public function Example()
        {
            stage.frameRate = 120;
            
            var i        :Number = 0;
            
            while(i < 40)    
            {
              var circleInstance :MyCircle = new MyCircle();
              
              if(Math.random() * 10 < 5)
              {
                  circleInstance.x = -100;
              }
              else
              {
                  circleInstance.x = 500;   
              }
              
              
              
              /// do the y
              
              if(Math.random() * 10 < 5)
              {
                  circleInstance.y = -100;    
              }
              else
              {
                 circleInstance.y = 500;
              }
                 
                
              circleInstance.spin();                 
              addChild(circleInstance);
              
              var finalX    :Number = 220;
              var finalY    :Number = Math.random() * 400;
              
              
              
              
              
            
              Tweener.addTween(circleInstance,
              {
                  
                  x: finalX, 
                  y: finalY, 
                  time: Math.random() * 5, 
                  delay: Math.random() * 4, 
                  transition: "easeInOutBack"}
                  )
              
              
              i++; 
            }
            
            
           
        }
    }
}

import flash.display.Sprite;
import flash.events.Event;

internal class MyCircle extends Sprite
{
    
    private var spinSpeed        :Number = Math.random() * 7
    ;
    public function MyCircle()
    {
        
        // RR GG BB
        this.graphics.beginFill(Math.random() * 255 * 255 * 255);
        this.graphics.drawRect(0, 0, Math.random() * 100, Math.random() * 100);
        this.graphics.endFill();
        
        addEventListener(Event.ENTER_FRAME, spinMe);
    }
    
    public function spin():void
    {
        this.rotationY = Math.random() * 360;
    }
    
    public function spinMe(e:Event):void
    {
        rotationY = rotationY + spinSpeed;
    }
}