3 Replies Latest reply on Jun 22, 2013 10:18 PM by Flex harUI

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

    Gavino_22

      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

        • 1. Re: Wierd error when porting code from HTML to Desktop Application - Drag and Drop MouseDown Function
          Flex harUI Adobe Employee

          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.

          • 2. Re: Wierd error when porting code from HTML to Desktop Application - Drag and Drop MouseDown Function
            Gavino_22 Level 1

            Thank you that has been a big help, I know im not just barking up (several) wrong trees.

             

            Im making some progress now, the rename having stopped the error..... Ive tried renaming the function call but strangely I get a runtime only error relating to a null object reference on the line of code featuring the 'dragManager':

             

            private function mouseDownHandler2(e:MouseEvent):void {

                   // Alert.show("mouseevent: " + e);

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

                                 }

             

             

             

             

            Alternatively I have now tried the 'override' but I get a "error while loading initial content" failure message when using this code below (Which I imagine is very wrong!?):

             

            override protected function mouseDownHandler(e:MouseEvent):void {

                        super.mouseDownHandler(e);

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

                                 }

             

             

            Im probably being too vague with both these methods so let me know if you need more info or error details etc.

             

            I think for what I need, which is very basic drag and drop from image control to label control, either method will work for me.

            Thanks for any help,

            Gav

            • 3. Re: Wierd error when porting code from HTML to Desktop Application - Drag and Drop MouseDown Function
              Flex harUI Adobe Employee

              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