Show modal isn't defined in TestDialog, as it's defined in Dialog. So the 
message is correct. In java static properties and methods aren't inherited 
either. (I think)

Chris



Von meinem Samsung Galaxy Smartphone gesendet.


-------- Ursprüngliche Nachricht --------
Von: Carlos Rovira <carlosrov...@apache.org>
Datum: 19.01.17 02:27 (GMT+01:00)
An: dev@flex.apache.org
Betreff: [FlexJS] Singletons are working ok?

Hi,

I found a problem with my Dialog implementation. It's creating a dialog
each time I show it, so I try to make it a Singleton, but I can't get it
working as expected:

The singleton is (remove comments and not related methods to remove
verbosity):

*public class Dialog extends ContainerBase implements IPopUp*
* {*
* public function Dialog()*
* {*
* if(_instance)*
* {*
* throw new Error("Dialog should not be instantiated.");*
* }*

* _instance = this;*
* }*

* static private var _instance:Dialog;*

* COMPILE::JS*
* static private var dialog:HTMLDialogElement;*

* static public function addDialog():Dialog*
* {*
* if(!_instance)*
* {*
* _instance = new Dialog();*

* if(Application.topLevelApplication != null)*
* {*
* Application.topLevelApplication.addElement(_instance);*
* }*
* }*

* return _instance;*
* }*

* static public function showModal():Dialog { *
*                        if(!_instance) { *
*                              addDialog();*
*                       }*

*                      COMPILE::JS *
*                      {*
*                             dialog.showModal();*
*                       }*

*                       return _instance;*
*                }*
*       }*
*}*


Then I have a MXML file called TestDialog.mxml that has some custom content.

I call with a button click like this:

*var t:TestDialog = TestDialog.showModal();*

This reports and error when compile MDLExample:

*Error: Call to a possibly undefined method showModal through a reference
with static type TestDialog.*
*                var t:TestDialog = TestDialog.showModal();*
                                              ^

But as I said TestDialog is an mxml declared as:

*<mdl:Dialog xmlns:fx="http://ns.adobe.com/mxml/2009
<http://ns.adobe.com/mxml/2009>"*
*            xmlns:js="library://ns.apache.org/flexjs/basic
<http://ns.apache.org/flexjs/basic>"*
*            xmlns:mdl="library://ns.apache.org/flexjs/mdl
<http://ns.apache.org/flexjs/mdl>"*
*            xmlns="http://www.w3.org/1999/xhtml
<http://www.w3.org/1999/xhtml>">*

*....*

So should has showModal static method

So this seems to me a bug in FlexJS

Thanks


--
Carlos Rovira
http://about.me/carlosrovira

Reply via email to