开发者

Access WindowedApplication from package class

I'm developi开发者_JAVA百科ng an AIR application, where i need to access WindowedApplication's function from the package class.

This is the Main application (Partial code)

<mx:WindowedApplication  xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="initApplication()">
<mx:Script>
    <![CDATA[

 import mx.events.CloseEvent;
 import messages.MessageWindow
public function undock():void {

        stage.nativeWindow.visible = true;
        stage.nativeWindow.orderToFront();

        //Clearing the bitmaps array also clears the applcation icon from the systray

        NativeApplication.nativeApplication .icon.bitmaps = [];
    }

  ]]>
</mx:Script>
</mx:WindowedApplication>

Package: (Partial code)


package messages
{
  public class MessageWindow extends NativeWindow
  {

    public function MessageWindow():void
    {

     stage.addEventListener(MouseEvent.MOUSE_DOWN,onClick);

    }
    private function onClick(event:MouseEvent):void
    {
        ****** Need to call the undock method from here. *****

    }
  }

}

Is it possible to call this way or suggest any other solution

Thanks in advance Senling.


Even if I don't recommend this for the sake of your code design, you can access your method like this: Application.application.undock() (if your undock() method is public in the WindowedApplication )


Cant see why it shouldnt work. Go ahead and give it a try, and if any errors come up, post it here.

What you can maybe try is to add parentApplication in front of stage in the MessageWindow method, like this..

parentApplication.stage.addEventListener(MouseEvent.MOUSE_DOWN,onClick);

and then call the undock() method from the onClick() method

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜