flash interactivity_global_event
Global Events
In ActionScript 1 and 2 movie clips were capable of listening to all mouse events, even if they were not clickable, or hidden. To listen to move movements on the stage we could write:
// definition of event management myClip.onMouseMove = function () { // output : 78 : 211 trace( _xmouse + " : " + _ymouse ); }
By defining an anonymous onMouseMove function we have an efficient means to listen to the mouse movements across the entire application. In ActionScript 3 the mouse behaviour was modified. If we listen to mouse events from an object which is not contained within the display list, the events are not captured because there’s no interaction between the mouse and the graphic object.
Conversely, if the object is visible, the event is only captured when the mouse is over the object. To better understand we’re going to place an instance of a button symbol on the main stage and call it myButton, and listen for the MouseEvent.MouseMove events:
// register the button for the MouseMove event myButton.addEventListener ( MouseEvent.MOUSE_MOVE, mouseMove ); function mouseMove ( pEvt:MouseEvent ):void { trace("This is only called when the mouse is over the button"); }
To put into practice the notion of global events, we’re going to develop a drawing application. Later on we’ll add new functionality like exporting to JPEG and PNG to allow us to save our drawings.
Mediabox Training Centre © 2000 - 2008 All rights reserved.
Adobe Authorized Training Centre. State convention under number 25 14 02167 14.
Mediabox : SARL au capital de 62.000€ - Activity number: 25 14 02167 14 - SIRET : 493 716 468 00027
MEDIABOX, 102 Avenue des Champs Elysées, 75008 PARIS - Tel. +33(0)2.31.91.96.89 - Fax. +33(0)2.72.68.56.42


