1 Reply Latest reply on Nov 2, 2010 10:11 AM by Flex harUI

    Can't determine event target


      I have a Canvas whose id is workarea. workarea has a UIComponent child named scene. scene will contain lots of Sprites.


      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="main();">





      import mx.core.UIComponent;


      private var scene:UIComponent;


      private function main():void {


          scene = new UIComponent;



          var square:Sprite = new Sprite();



          var rectangle:Sprite = new Sprite();



          square.graphics.beginFill(0xFFFCC4, 1);

          square.graphics.drawRect(50, 10, 64, 64);



          rectangle.graphics.beginFill(0x6B0933, 1);

          rectangle.graphics.drawRect(80, 100, 64, 128);



          scene.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

          scene.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);




      private function onMouseDown(e:MouseEvent):void {


          if (e.target != scene) {


          } else {

              trace("I didn't click over the scene!"); // this line is never executed





      private function onMouseUp(e:MouseEvent):void {








      <mx:Canvas id="workarea" backgroundColor="#E0CC70" width="494" height="372" x="108.5" y="94">





      When I click over a Sprite I want to be able to drag it. But when I click on the scene I want to do something else. My problem is that the line between the else brackets is never executed and I have no clue why.



      Here's the source (298 Kb): http://www.2shared.com/file/Zn1QaN6V/Sample.html