PDA

View Full Version : Problems with events in flex


madrid
08-06-2009, 06:34 PM
Hi there. I'm a AS2 and Flash CS3 guy. I started to learn AS3 and transfer to Flex 3. But I got a problem w/ Events in AS3. I'm adding a canvas component to the stage. On that canvas, I added 3 different events: mouse down, mouse move, and mouse up. When mouse move is fired, there is no way for me to get mouse up event fired, and viceversa, when mouse up is fired, there is no way to get the mouse move event fired. Is there any one to help this newbie with this particular problem? Any help will be very appreciated.

Code:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:canvas id="myCanvas" x="50" y="50" width="500" height="500" click="event_1();" mouseMove="event_2();" mouseUp="event_3();">
</mx:Canvas>

<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.events.*;
public function event_1():void
{ Alert.show("First event fired"); }
public function event_2():void
{ Alert.show("Second event fired"); }
public function event_3():void
{ Alert.show("third event fired); }
</mx:Script>
</mx:Application>

Sekhar
08-08-2009, 04:38 PM
It's to do with Alert. E.g., when the mouse first moves, you get an alert; but after you clear the alert, the next event is going to be of another mouse move (because you're trying to do the next thing and you move the mouse a bit). And so on.

To see the different events getting triggered, use trace() instead.