ActionScript3.0とおやつの会 100423 宿題 【ActionScript3.0とおやつの会 100423 宿題】 kwkd kwkd forked:1favorite:0lines:53license : MIT License modified : 2010-04-26 23:35:57 Embed Tweet /* 【ActionScript3.0とおやつの会 100423 宿題】 kwkd */ package { import flash.display.Sprite; // マウスイベントを追加(btnのとこ) import flash.events.MouseEvent; // イベント(_moon) import flash.events.Event; // テキストフィールドを生成(tfんとこ) import flash.text.TextField; public class Main extends Sprite { private var _maru:Sprite; private var _moon:Sprite; public function Main() { this.graphics.lineStyle(4,0xFF0000,0.5); // graphics.lineStyle(太さ,0xカラーコード,アルファ) this.graphics.moveTo(100,100); // graphics.moveTo(スタート地点x座標,スタート地点y座標) this.graphics.lineTo(400,100); this.graphics.lineTo(100,200); this.graphics.lineTo(100,100); _maru = new Sprite(); _maru.graphics.beginFill(0xFF0000); // 塗り指定 _maru.graphics.drawCircle(200,200,50); // drawCircle(スタート地点x座標,スタート地点y座標,直径) _maru.graphics.endFill(); _maru.x = 50; _maru.x = 150; addChild(_maru); // テキストフィールドを生成(4行目の設定と連動) var tf:TextField = new TextField(); tf.text = 'hoge'; tf.textColor = 0xFFFFFF; tf.x = 190; tf.y = 190; _maru.addChild(tf); // tfは親(_maru)の座標(L20,21)に依存 //addChild(tf); // ボタン生成(3行目の設定と連動) var btn:Sprite = new Sprite(); btn.graphics.beginFill(0x0000FF); btn.graphics.drawCircle(50,50,30); btn.graphics.endFill(); btn.buttonMode = true; // マウスオーバー時にカーソルが変わる(この一行がなければデフォのまま) btn.addEventListener(MouseEvent.CLICK,onClick); addChild(btn); // 月っぽいなにか _moon = new Sprite(); _moon.graphics.beginFill(0xFFFF00); _moon.graphics.drawCircle(100,100,30); _moon.graphics.endFill(); _moon.x = 200; _moon.y = 200; this.addChild(_moon); this.addEventListener(Event.ENTER_FRAME,onEnter); trace("trace"); } private function onClick(event:MouseEvent):void{ trace("クリックされたよ。"); _maru.x +=1; } private function onEnter(event:Event):void{ _moon.rotation += 1; } } } Code Fullscreen Preview Fullscreen rotation trace buttonMode textColor addEventListener addChild TextField text Event.ENTER_FRAME Event Sprite sort new page view favorite forked pv108 forked from: ActionScript3.0とお.. kwkd forked:0 favorite:0lines:53 (diff:3)