Kuhtich / flexmonkey

Automatically exported from code.google.com/p/flexmonkey
0 stars 0 forks source link

Initialize theMonkey #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I wanna to propose the following patch.

It will allow me to add listeners to theMonkey. Like this:
FlexMonkey.theMonkey.addEventListener(FlexEvent.CREATION_COMPLETE, startUp);

I need that to run integration tests using flex-mojos.

Index: src/com/gorillalogic/aqadaptor/AQAdapter.as
===================================================================
--- src/com/gorillalogic/aqadaptor/AQAdapter.as (revision 78)
+++ src/com/gorillalogic/aqadaptor/AQAdapter.as (working copy)
@@ -254,7 +254,7 @@
            var byteArray:ByteArray = new FlexMonkeyEnv() as ByteArray;
            var env:String = new String(byteArray.readUTFBytes(byteArray.length));
            setTestingEnvironment(env);
-           PopUpManager.createPopUp(DisplayObject(Application.application),
FlexMonkey);            
+           PopUpManager.addPopUp(FlexMonkey.theMonkey,
DisplayObject(Application.application));            

         }
     }
Index: src/com/gorillalogic/flexmonkey/FlexMonkey.mxml
===================================================================
--- src/com/gorillalogic/flexmonkey/FlexMonkey.mxml (revision 78)
+++ src/com/gorillalogic/flexmonkey/FlexMonkey.mxml (working copy)
@@ -50,12 +50,12 @@
        /**
         * Currently running FlexMonkey instance
         */ 
-       public static var theMonkey:FlexMonkey;
+       public static const theMonkey:FlexMonkey = new FlexMonkey();

        private static var autoStart:Boolean = false;

        private function create():void {
-           theMonkey = this;
+//         theMonkey = this;
            if (autoStart) {
                // For some inexplicable reason, setting selectedIndex is having no
effect :(
                tabs.selectedIndex = 2;

Original issue reported on code.google.com by velo...@gmail.com on 17 Nov 2008 at 1:56

GoogleCodeExporter commented 8 years ago

theMonkey is a reference to the currently running FlexMonkey instance (ie, the
FlexMonkey window), so we can't just initialize theMonkey to an instance we 
create
statically.

Original comment by stuinbou...@gmail.com on 17 Nov 2008 at 11:10

GoogleCodeExporter commented 8 years ago
But this will keep a unique instance, like it is done now.

Instead of creating the instance using PopupManager.createPopUp(), I initialize 
the
static theMonkey (which now is a const, so is not changeable).

Well, this was the way I found to made possible to add event listeners to 
theMonkey

Original comment by velo...@gmail.com on 18 Nov 2008 at 12:14

GoogleCodeExporter commented 8 years ago
Done.

Original comment by stuinbou...@gmail.com on 18 Nov 2008 at 2:16