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 2011-9-23

[SWF(backgroundColor=0, width=465, height=465)]
Get Adobe Flash player
by tepe 23 Sep 2011
    Embed
/**
 * Copyright tepe ( http://wonderfl.net/user/tepe )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4MjT
 */

// forked from tepe's flash on 2011-3-19
package {
    import flash.events.*;
    import flash.display.*;
    import flash.text.*;
    //[SWF(backgroundColor=0, width=465, height=465)]
    public class FlashTest extends Sprite {
        private var node1:node = new node();
        private var text1:TextField = new TextField();
        public function FlashTest() {
            
            //パラボラ曲線の描画
            
            var s2:Shape = new Shape();
            var st:int = 100; 
            var a:Number =-0.001;
            s2.graphics.lineStyle(1,0x00ff00);
            s2.graphics.moveTo(st,a*(st*st));
            s2.graphics.lineTo(0,0.25/a);
            s2.graphics.moveTo(-st,a*(st*st));
            s2.graphics.lineTo(0,0.25/a);
            s2.graphics.beginFill(0x00ff00);
            s2.graphics.drawCircle(0,0.25/a,5);
            s2.graphics.endFill();
            //s2.graphics.beginFill(0xff0000);
            s2.graphics.lineStyle(1,0xff0000);
            s2.graphics.moveTo(-st,a*(st*st));
            
            for(var i:int = -st;i<st;i++){
                //放物線:y = ax^2
                s2.graphics.lineTo(i,a*(i*i));
                s2.graphics.moveTo(i,a*(i*i));
            }
            s2.graphics.lineTo(st,a*(st*st));
            
            node1.map.addChild(s2);
            addChild(node1);
            addChild(text1);
            
            
            addEventListener(Event.ENTER_FRAME,function():void{
                text1.text = String(node1.scaleSize);
            });


                
        }
    }
}
    import flash.geom.Point;
    import caurina.transitions.Tweener;
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    import flash.ui.*;
    import flash.utils.*;

class node extends Sprite{
        
        private var scale:Number = 1;
        
        public var wheel:int;//ホイール回転量
        private var zoom:Number = 1.0;//拡大率
        public var map:Sprite;//フィールド
        
        private var mapFocusX:Number=0;
        private var mapFocusY:Number=0;
        private var scrFocusX:int=0; 
        private var scrFocusY:int=0; 
        private var mX:int=0; 
        private var mY:int=0; 
        
        private var scalingPanel:Sprite;
        private var base:Sprite;
              
        private var mapscale:int=0;
        
        private var dragPanel:Shape = new Shape();
        
        
        
        //コンストラクタ 
        public function node():void{
            
            //カーソル位置描画
            //scalingPanel ズーム中心
            scalingPanel = new Sprite();//ズーム中心 
            scalingPanel.graphics.lineStyle(1,0x00ff00,0.3);
            scalingPanel.graphics.moveTo(-100,0);
            scalingPanel.graphics.lineTo(100,0);
            scalingPanel.graphics.moveTo(0,-100);
            scalingPanel.graphics.lineTo(0,100);
            addChild(scalingPanel);
            
            
            //マップ基準座標
            base = new Sprite();
            
            base.graphics.lineStyle(1,0xff0000,0.3);
            base.graphics.moveTo(-100,0);
            base.graphics.lineTo(100,0);
            base.graphics.moveTo(0,-100);
            base.graphics.lineTo(0,100);
            
            scalingPanel.addChild(base);
            
            //マップ上への配置
            map = new Sprite();
            scroolOn();
 
            base.addChildAt(map,0); 
            map.addChild(dragPanel);
            
            aaaa();
        }
        
        public function get scaleSize():int{
            return mapscale;
        }
        
        
        //画面移動操作の受付 ON・OFF切り替え
        public function scroolOn():void{
            map.addEventListener(MouseEvent.MOUSE_DOWN,down1);
            map.addEventListener(MouseEvent.MOUSE_UP,up1);

            this.addEventListener(MouseEvent.MOUSE_WHEEL,on_wheel);//ホイール操作 
            this.addEventListener(Event.ENTER_FRAME, onFrame);//メインループ
        }
        public function scroolOff():void{
            map.removeEventListener(MouseEvent.MOUSE_DOWN,down1);
            map.removeEventListener(MouseEvent.MOUSE_UP,up1);

            this.removeEventListener(MouseEvent.MOUSE_WHEEL,on_wheel);//ホイール操作 
            this.removeEventListener(Event.ENTER_FRAME, onFrame);//メインループ
        }

  
        //マップドラッグ
        private function down1(event:MouseEvent):void{
            wheel=0;
           event.currentTarget.startDrag();
           addEventListener(MouseEvent.MOUSE_MOVE,onMove);
           event.stopPropagation();//イベントの伝播を止める
        }
        private function up1(event:MouseEvent):void{
            event.currentTarget.stopDrag();
            removeEventListener(MouseEvent.MOUSE_MOVE,onMove);
           // event.stopPropagation();//イベントの伝播を止める
        }
        
        private function onMove(e:MouseEvent):void{
            aaaa();
        }
    
        //ホイール操作
        private function on_wheel(event:MouseEvent):void{
            wheel += event.delta;        
        }
  
        //メインループ
        private function onFrame(e:Event):void {
            on_zoom(1+(0.005*wheel));
            if(stage.displayState == StageDisplayState.FULL_SCREEN){
                if(stage.mouseY < 10)map.y -= (stage.mouseY-10)/zoom;
                else if(this.root.loaderInfo.height-10 < stage.mouseY){
                    map.y -= (10+stage.mouseY-this.root.loaderInfo.height)/zoom;                    
                }
                if(stage.mouseX < 10)map.x -= (stage.mouseX-10)/zoom/10;
                else if(this.root.loaderInfo.width-10 < stage.mouseX){
                    map.x -= (10+stage.mouseX-this.root.loaderInfo.width)/zoom/10;                    
                }
            }
        }
        
        
        //マップスクロール基準点の更新
        private function aaaa(z:Number = 1):void{

            if(1<=z){//ズームイン
                mX = mouseX; mY = mouseY;//カーソル位置
                //ズーム中心
                scalingPanel.x = mouseX; scalingPanel.y = mouseY; 
                //マップ位置
                base.x -= (mX-scrFocusX)/zoom; base.y -= (mY-scrFocusY)/zoom;
                //フォーカス位置
                scrFocusX = mX; scrFocusY = mY;
            }
            else{//ズームアウト
                mX = this.root.loaderInfo.width/2; mY = this.root.loaderInfo.height/2;//カーソル位置
                //ズーム中心
                scalingPanel.x =this.root.loaderInfo.width/2; scalingPanel.y = this.root.loaderInfo.height/2; 
                //マップ位置
                base.x -= (mX-scrFocusX)/zoom; base.y -= (mY-scrFocusY)/zoom;
                //フォーカス位置
                scrFocusX = mX; scrFocusY = mY;
            }

            //フィールドドラッグ用
            dragPanel.graphics.clear();
            dragPanel.graphics.beginFill(0xff0000,0.0);
            dragPanel.graphics.drawCircle(-(map.x+map.parent.x)/map.scaleX,-(map.y+map.parent.y)/map.scaleY,600/map.scaleX);
            dragPanel.graphics.endFill();
        }

        
        
        private function on_zoom(z:Number=0):void{
            if(z==0)return;
            aaaa(z);//基準点更新
            zoom *= z;    
                
            if(2 < zoom){

                map.scaleX *= 2;
                map.scaleY *= 2;
                zoom /= 2;
                map.x += map.x+base.x;
                map.y += map.y+base.y;
                    
                mapscale--;
                
            }
            else if(zoom < 1.0){
             
                map.x -= (map.x+base.x)/2;
                map.y -= (map.y+base.y)/2;
                zoom *= 2;
                map.scaleX /= 2;
                map.scaleY /= 2;
                    
                mapscale++;
                    
            }    
            scalingPanel.scaleX = zoom;
            scalingPanel.scaleY = zoom;        
          
        }
        
    }