放大跟隨的圓形

by plus.log
♥0 | Line 41 | Modified 2011-07-05 01:16:04 | MIT License
play

ActionScript3 source code

/**
 * Copyright plus.log ( http://wonderfl.net/user/plus.log )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/8SsE
 */

/* http://wonderfl.net/user/plus.log/codes */
/*
-- 20110626 --
囧 Q. Can I ignore this Warning message ? (it just displayed in wonderfl builder) 囧
Warning: var 'scaleSize' will be scoped to the default namespace: Sample: internal.  
It will not be visible outside of this package.
        var scaleSize:Number;

囧 Q. What dose that mean..? 囧
http://help.adobe.com/zh_TW/FlashPlatform/reference/actionscript/3/compilerWarnings.html
%s will be scoped to the default namespace: %s internal. It will not be visible outside of this package. 
%s 範圍將為預設的名稱空間:%s 內部。在此套件外將不會看到它。     
    不宣告名稱空間是一種屬於個人偏好的程式撰寫風格。如果您希望在忘記對定義宣告名稱空間或存取指定字時出現提示提醒您,請啟用此警告。
    若沒有,位於此檔案外的程式碼便看不到定義。如果要讓位於此檔案外的程式碼看得到定義,請使用存取指定字 public 或名稱空間宣告來宣告它。
    如果要讓定義屬於這個檔案,並避免出現這個警告,請將定義宣告為 private。

-- 20110627 --
anyway I try to add "public" to the Properties、Constructor and Methods ,
then the Warning message isn't displayed anymore..
*/

package {
    import flash.display.*;
    import flash.text.*;
    import flash.utils.Timer;
    import flash.events.TimerEvent;

    public class Sample extends MovieClip {
        public var scaleSize:Number;
        public var timer:Timer;
        public var child:Sprite;

        public function Sample() {
            scaleSize = 0;
            doDrawCircle();
            timer = new Timer(30);
            timer.addEventListener(TimerEvent.TIMER, loop);
            timer.start();

        }
        public function doDrawCircle():void {
            var circleSize:uint = 30;
            child = new Sprite();
            child.graphics.beginFill(0x99CC66);
            child.graphics.drawCircle(0 ,0 ,circleSize);
            child.graphics.endFill();
            var label:TextField = new TextField();
            label.text = "I'm\nCircle";
            label.autoSize = TextFieldAutoSize.CENTER;
            label.x = -circleSize/2;
            label.y = -circleSize/2;
            child.addChild(label);
            this.addChild(child);
        }
       public function loop(e:TimerEvent):void {
            scaleSize += 0.05;
            if (scaleSize > 15) {
                scaleSize = 0;
            }
            child.x = this.mouseX;
            child.y = this.mouseY;
            child.scaleX = child.scaleY = scaleSize;

        }
    }
}