Nevermind, that won’t work in this case.  I think you still need to initialize 
_descriptors with a static initializer.  I think I would use an internal 
version of addFormat for doing that.  Or maybe manually code _descriptors as a 
get/set.

HTH,
-Alex

From: Alex Harui <aha...@adobe.com>
Reply-To: "users@royale.apache.org" <users@royale.apache.org>
Date: Tuesday, November 26, 2019 at 2:22 PM
To: "users@royale.apache.org" <users@royale.apache.org>
Subject: Re: TextConverter method call

Yes, probably a good idea, in which I case I would just use a dummy initializer

        /** @private */
        static public function setFormatsToDefault():Boolean    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, 
"air:text");
            return true;
        }
        static public var _descriptors:Array;
        static private var formatsSet:Boolean = setFormatsToDefault()



From: Serkan Taş <serkan....@likyateknoloji.com>
Reply-To: "users@royale.apache.org" <users@royale.apache.org>
Date: Tuesday, November 26, 2019 at 11:44 AM
To: "users@royale.apache.org" <users@royale.apache.org>
Subject: Re: TextConverter method call

Do I have to keep addFormat and addFormatAt compatible for external usage, 
because they are public may be called from other classes ?
26.11.2019 21:15 tarihinde Alex Harui yazdı:
It “should” but we are not fully supporting “naked code” (code not in methods) 
right now.  I’ve never liked the pattern and I’m not sure all minifiers know 
how to handle it, so the easiest answer for now is to rewrite the pattern.

One way to rewrite is to have setFormatDefaults return an array and initialize 
_descriptors.  Something like:

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():Array    // No PMD
        {
            var arr:Array = [];
            addFormat(arr, TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(arr, TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
            addFormat(arr,PLAIN_TEXT_FORMAT, PlainTextImporter, 
PlainTextExporter, "air:text");
            return arr;
        }
        static public var _descriptors:Array = setFormatsToDefault()

You’ll have to change addFormat to accept the array to modify.

HTH,
-Alex

From: Serkan Taş 
<serkan....@likyateknoloji.com><mailto:serkan....@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<mailto:users@royale.apache.org> 
<users@royale.apache.org><mailto:users@royale.apache.org>
Date: Tuesday, November 26, 2019 at 9:13 AM
To: "users@royale.apache.org"<mailto:users@royale.apache.org> 
<users@royale.apache.org><mailto:users@royale.apache.org>
Subject: Re: TextConverter method call

Unfortunately there is not a getter for the property, but the call for 
setFormatsToDefault is in the class body.

        public static const TEXT_LAYOUT_FORMAT:String = "textLayoutFormat";

        // Descriptors - ordered list of all FormatDescriptors
        /** @private */
        static public var _descriptors:Array = [];

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, 
"air:text");
        }


Shouldn't it be called while the class is initialized ?

Thanks,
Serkan
26.11.2019 08:06 tarihinde Alex Harui yazdı:
Without looking at more of the code, I’m guessing there is a “descriptors” 
property that returns the “_descriptors” array.  If that’s the case, then I 
would add a check to the descriptors getter to check if _descriptors has been 
initialized and if not, call setFormatsToDefault.

-Alex

From: Serkan Taş 
<serkan....@likyateknoloji.com><mailto:serkan....@likyateknoloji.com>
Reply-To: "users@royale.apache.org"<mailto:users@royale.apache.org> 
<users@royale.apache.org><mailto:users@royale.apache.org>
Date: Monday, November 25, 2019 at 12:55 PM
To: "users@royale.apache.org"<mailto:users@royale.apache.org> 
<users@royale.apache.org><mailto:users@royale.apache.org>
Subject: TextConverter method call

Hi,

TextConverter has a method named setFormatsToDefault() and called while the 
application is loaded  - I guess automatically because I could not find any 
reference - in Flex, but never called in Royale.

Source piece Royale  :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static public function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, 
"air:text");
        }


Flex :

        // register standard importers and exporters
        setFormatsToDefault();

        /** @private */
        static tlf_internal function setFormatsToDefault():void    // No PMD
        {
            _descriptors = [];
            addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, 
TextLayoutExporter, TEXT_LAYOUT_FORMAT);
            addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  
TextFieldHtmlExporter, null);
            addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, 
"air:text");
        }

How should be the mechanism for the flow in Royale ?

Thanks,
Serkan











Reply via email to