Skip navigation
Gavino_22
Currently Being Moderated

Wierd error when porting code from HTML to Desktop Application - Drag and Drop MouseDown Function

Jun 22, 2013 3:44 AM

Tags: #error #flash #4.5 #actionscript #!flash_builder #drag_and_drop #air_application #mousedownhandler

Hi,

 

Im quite new to Flex, and actionscript3 in general so apologies if some of my explanations are unclear or lacking in some common sense.

 

Basically Ive written a small, working drag and drop test application which works perfectly under the HTML (i.e. non 'desktop AIR') version of Flex Project. When testing I have no errors and all code works as expected.

However, when I port the code across to a new desktop application (Which is necessary for the build I am doing), I get a persistent error over the "mouseDownHandler()" event:

 

Error 1023 - Incompatable override

Error 1024 - Overriding a function that is not marked for override

 

 

I have traweled the web and the only thing Ive got is that something present in the Desktop Application / AIR environment has a function named 'mouseDownHandler' and thus I could be referencing a duplicate function.

All I need to do is use the mousedownhandler for a simple drag and drop interaction so any ideas, or solution or even a cheap workaround would be massively appreciated!

 

 

Affected code here:

 

 

 

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                                     xmlns:s="library://ns.adobe.com/flex/spark"

                                     xmlns:mx="library://ns.adobe.com/flex/mx">

      

       <fx:Script>

              <![CDATA[

                    

                     import mx.controls.Alert;

                     import mx.core.IUIComponent;

                     import mx.core.DragSource;

                     import mx.events.DragEvent;

                     import mx.managers.DragManager;

                    

                    

//user clicks the src, so allow drag


// ERROR here:                    

       private function mouseDownHandler(e:MouseEvent):void {

              DragManager.doDrag(e.currentTarget as IUIComponent, null, e);

                     }

      

                  

 

              ]]>

       </fx:Script>

      

       <fx:Declarations>

       </fx:Declarations>

 

       // just something random here for the sake of debugging

      // Ive omitted the rest of the drag drop stuff to narrow things down

       <s:CheckBox x="273" y="293" label="CheckBox"/>

      

      

</s:WindowedApplication>

 

As I said this code works perfectly compile as a web application but NOT as a desktop Air Application?

Thanks very much in advance,

Gav

 
Replies
  • Currently Being Moderated
    Jun 22, 2013 7:05 AM   in reply to Gavino_22

    When you switched from web to desktop, you had to change probably from Application to WindowedApplication.  When you did that, you inherited methods on WindowedApplication one of which is called mouseDownHandler which collided with your mouseDownHandler.

     

    You can rename yours, or override the one in WindowedApplication, but if you override, I would recommend calling super.mouseDownHandler(event) somewhere in your override.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2013 10:18 PM   in reply to Gavino_22

    Error loading initial content usually means the SWF never got built because of build errors.  However, I don't see anything obviously wrong with the code snippet.

     

    If you get an error, it is  best to post the exact text of the error including the stack trace.  There is often very useful information in that stack trace.

     

    I would guess that DragManager threw the error because null got passed into doDrag because you moused over something that wasn't an IUIComponent.

     

    Flex is a framework layer on top of Flash/AIR and if you start mixing Flex widgets with low-level Flash/AIR widgets you have to know what you're doing.

     

    -Alex

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points