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

TEST

Get Adobe Flash player
by Snow 05 Mar 2011
    Embed
/**
 * Copyright Snow ( http://wonderfl.net/user/Snow )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/9WHy
 */

package 
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    
    
    /**
     * ...
     * @author Snow
     * ボールに触れると速度が変化
     */
    public class Main extends Sprite 
    {
        public var tama2:Ball;
        public var randomR:Number = (Math.random() * 30) + 20;    
        public var vx:Number = (Math.random() * 14) + 1;
        public var vy:Number = (Math.random() * 14) + 1;
        public var xover:Boolean = false;        
        public var yover:Boolean = false;        
        
        public function Main():void 
        {
            var randomC:uint = Math.random() * 0xffffff;        
            tama2 = new Ball(randomR, randomC);
            tama2.x = 150;
            tama2.y = 150;
            addChild(tama2);
            
            addEventListener(Event.ENTER_FRAME, reflect);
            addEventListener(MouseEvent.ROLL_OVER, change);        
        }
        
        public function reflect(e:Event):void
        {
             if (tama2.x >= stage.stageWidth - randomR)
             {
                 xover = true;
             }else if (tama2.x <= randomR){
                 xover = false;
             }
             
             if (tama2.y >= stage.stageHeight - randomR)
             {
                 yover = true;
             } else if (tama2.y <= randomR) {
                 yover = false;
             }
             
             if (xover == false) {
                 if (yover == false) {
                     tama2.x += vx;
                     tama2.y += vy;
                 } else if (yover == true) {
                     tama2.x += vx;
                     tama2.y -= vy;
                 }
             }else if (xover == true) {
                 if (yover == false) {
                     tama2.x -= vx;
                     tama2.y += vy;
                 }else if (yover == true) {
                     tama2.x -= vx;
                     tama2.y -= vy;
                 }
             }
        }
        
        public function change(e:Event):void
        {
            vx = (Math.random() * 14) + 1;
            vy = (Math.random() * 14) + 1;
        }
    }
    
}

import flash.display.*;

class Ball extends Sprite            
    {
        public function Ball(R:Number, C:uint):void
        {
            graphics.beginFill(C);
            graphics.drawCircle(0, 0, R);
            graphics.endFill();
        }
        
    }