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

ライン作成 クリックVer

画面をクリックするとクリックした位置まで
ラインが伸びていきます。

練習版1~3を通してようやく自分の作りたかった動きを
表現することが出来ました~。
Get Adobe Flash player
by yuugurenote 15 Jan 2012
    Embed
/**
 * Copyright yuugurenote ( http://wonderfl.net/user/yuugurenote )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eXU8
 */

package {
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.geom.Point;
    [SWF(width=465,height=465,backgroundColor=0xFFFFFF,frameRate=60)]

    public class AS120115_01 extends Sprite {
        public var sw:Number=stage.stageWidth;
        public var sh:Number=stage.stageHeight;
        public var _mySprite:mySprite;
        public var _px1:Number;
        public var _py1:Number;
        public var _px2:Number;
        public var _py2:Number;
        public var myAr:Array= new Array();
        public var count:uint;

        public function AS120115_01() {

            stage.addEventListener(MouseEvent.MOUSE_DOWN,xDown);
        }
        public function xDown(e:MouseEvent):void {
            var px:Number = mouseX;
            var py:Number = mouseY;
            var myPoint = new Point();
            myAr.push(myPoint= new Point(px,py));
            count = myAr.length - 1;
            _mySprite=new mySprite(myAr[count-1].x,myAr[count-1].y,myAr[count].x,myAr[count].y);
            addChild(_mySprite);
        }
    }
}

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

class mySprite extends Sprite {
    public var _px1:Number;
    public var _py1:Number;
    public var _px2:Number;
    public var _py2:Number;
    public var myNum:Number=0;
    public var px:Number=465;
    //public var cNum:Number=Math.random()*0xFFFFFF;

    public function mySprite(px1:Number,py1:Number,px2:Number,py2:Number):void {
        _px1=px1;
        _py1=py1;
        _px2=px2;
        _py2=py2;
        addEventListener(Event.ENTER_FRAME,xEnter);
    }
    public function xEnter(e:Event):void {
        myNum+=0.02;
        if (myNum>1) {
            myNum=1;
        }
        this.graphics.clear();
        this.graphics.lineStyle(3,0x000000,1,false,"none");
        this.graphics.moveTo(_px1,_py1);
        this.graphics.lineTo((_px2 - _px1)*myNum+_px1,(_py2-_py1)*myNum+_py1);
        this.addEventListener(Event.ENTER_FRAME,xEnter);

        this.alpha-=0.001;
        if (this.alpha<0) {
            removeEventListener(Event.ENTER_FRAME, xEnter);
        }
    }
}