13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Mouse input<br />

Drag-and-drop in AIR<br />

In Adobe AIR, you can <strong>en</strong>able drag-and-drop support to allow users to drag data into and out of your application. For<br />

more details, see “Drag and drop in AIR” on page 607.<br />

Customizing the mouse cursor<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The mouse cursor (mouse pointer) can be hidd<strong>en</strong> or swapped for any display object on the Stage. To hide the mouse<br />

cursor, call the Mouse.hide() method. Customize the cursor by calling Mouse.hide(), list<strong>en</strong>ing to the Stage for the<br />

MouseEv<strong>en</strong>t.MOUSE_MOVE ev<strong>en</strong>t, and setting the coordinates of a display object (your custom cursor) to the stageX<br />

and stageY properties of the ev<strong>en</strong>t. The following example illustrates a basic execution of this task:<br />

var cursor:Sprite = new Sprite();<br />

cursor.graphics.beginFill(0x000000);<br />

cursor.graphics.drawCircle(0,0,20);<br />

cursor.graphics.<strong>en</strong>dFill();<br />

addChild(cursor);<br />

stage.addEv<strong>en</strong>tList<strong>en</strong>er(MouseEv<strong>en</strong>t.MOUSE_MOVE,redrawCursor);<br />

Mouse.hide();<br />

function redrawCursor(ev<strong>en</strong>t:MouseEv<strong>en</strong>t):void<br />

{<br />

cursor.x = ev<strong>en</strong>t.stageX;<br />

cursor.y = ev<strong>en</strong>t.stageY;<br />

}<br />

Mouse input example: WordSearch<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

This example demonstrates user interaction by handling mouse ev<strong>en</strong>ts. Users build as many words as possible from a<br />

random grid of letters, spelling by moving horizontally or vertically in the grid, but never using the same letter<br />

twice.This example demonstrates the following features of ActionScript 3.0:<br />

Building a grid of compon<strong>en</strong>ts dynamically<br />

Responding to mouse ev<strong>en</strong>ts<br />

Maintaining a score based on user interaction<br />

To get the application files for this sample, see www.adobe.com/go/learn_programmingAS3samples_flash. The<br />

WordSearch application files can be found in the folder Samples/WordSearch. The application consists of the<br />

following files:<br />

Last updated 6/6/2012<br />

576

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!