Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Mouse-position/ActionScript/mouse-position.as
Normal file
37
Task/Mouse-position/ActionScript/mouse-position.as
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package {
|
||||
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFieldAutoSize;
|
||||
import flash.text.TextFormat;
|
||||
|
||||
public class MousePosition extends Sprite {
|
||||
|
||||
private var _textField:TextField = new TextField();
|
||||
|
||||
public function MousePosition() {
|
||||
if ( stage ) init();
|
||||
else addEventListener(Event.ADDED_TO_STAGE, init);
|
||||
}
|
||||
|
||||
private function init(e:Event = null):void {
|
||||
removeEventListener(Event.ADDED_TO_STAGE, init);
|
||||
|
||||
_textField.autoSize = TextFieldAutoSize.RIGHT;
|
||||
_textField.x = stage.stageWidth - 10;
|
||||
_textField.defaultTextFormat = new TextFormat(null, 15);
|
||||
_textField.text = "Mouse position: X = 0, Y = 0";
|
||||
_textField.y = stage.stageHeight - _textField.textHeight - 14;
|
||||
addChild(_textField);
|
||||
|
||||
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
|
||||
}
|
||||
|
||||
private function _onEnterFrame(e:Event):void {
|
||||
_textField.text = "Mouse position: X = " + stage.mouseX + ", Y = " + stage.mouseY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue