интерактивный объект? - PullRequest
0 голосов
/ 31 марта 2011

- это простой способ создания объектов, с которыми вы можете взаимодействовать с помощью мыши в ActionScript. Что-то вроде нескольких строк кода?

1 Ответ

1 голос
/ 07 апреля 2011
var sprite:Sprite = new Sprite(); // create a new sprite.
sprite.graphics.beginFill(0); // set fill color to black
sprite.graphics.drawRect(0,0,100,100); // draw a square
addChild(sprite); // add the sprite to the display list making it appear on screen.
sprite.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); // add responders for mouse interaction.
sprite.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);

function onMouseDown(event:MouseEvent):void {
   // When the mouse button is released over the object, this code executes.
   Sprite(event.target).startDrag(); // make the object follow the mouse.
}

function onMouseUp(event:MouseEvent):void {
   // When the mouse button is pressed over the object, this code executes.
   Sprite(event.target).stopDrag(); // make the object stop following the mouse.
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...