4 Replies Latest reply on Oct 21, 2008 12:48 PM by Handycam

    Mouse event listener error 1069

    Handycam Level 1
      I am using the attached code to try and use a event listener callback that can work for several similar objects.

      However, it fails with the error:

      ReferenceError: Error #1069: Property startDrag not found on mx.core.FlexLoader and there is no default value.
      at UltimateSewingRoom/startDragging()[/Users/Shared/WORK/CraftStylish/Ultimate Sewing Room/flex/src/UltimateSewingRoom.mxml:102]

        • 1. Re: Mouse event listener error 1069
          Peter Lorent Level 2
          The error shows you what is wrong: the target property of the event is a reference to - most likely - a SWFLoader instance. Try event.currentTarget
          • 2. Re: Mouse event listener error 1069
            Handycam Level 1
            Yes, thanks, that was it.

            Anyone have any ideas on how I can move the event listeners into a Class? I know how to add the other properties but have never added an event listener. Starting with, this, I supposed.

            package assets
            {
            import mx.controls.Image;
            public class ItemImage extends Image
            {
            public function ItemImage()
            {
            super();
            }
            public var filePath:String;
            }
            }

            How do I add the event listener for mouse down and mouse up here?
            • 3. Re: Mouse event listener error 1069
              Peter Lorent Level 2
              Then you want to register the listeners on the current object so you use addEventListener or this.addEventListener
              • 4. Re: Mouse event listener error 1069
                Handycam Level 1
                Thanks, Luigi. I think this is working fine:

                package assets
                {
                import flash.events.MouseEvent;

                import mx.controls.Image;

                public class ItemImage extends Image
                {
                public function ItemImage(fp:String)
                {
                super();
                filePath = fp;
                this.source = filePath;
                this.addEventListener(MouseEvent.MOUSE_DOWN, dragMe);
                this.addEventListener(MouseEvent.MOUSE_UP, dropMe);
                }
                public var filePath:String;

                private function dragMe(e:MouseEvent):void {
                this.startDrag();
                }

                private function dropMe(e:MouseEvent):void {
                this.stopDrag();
                }
                }
                }