TextConverter method call

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

TextConverter method call

Serkan Taş
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Alex Harui-2

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ş <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Monday, November 25, 2019 at 12:55 PM
To: "[hidden email]" <[hidden email]>
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Serkan Taş
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Monday, November 25, 2019 at 12:55 PM
To: [hidden email] [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Alex Harui-2

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ş <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Tuesday, November 26, 2019 at 9:13 AM
To: "[hidden email]" <[hidden email]>
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Monday, November 25, 2019 at 12:55 PM
To: [hidden email] [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Serkan Taş
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 9:13 AM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Monday, November 25, 2019 at 12:55 PM
To: [hidden email] [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Alex Harui-2

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ş <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Tuesday, November 26, 2019 at 11:44 AM
To: "[hidden email]" <[hidden email]>
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 9:13 AM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Monday, November 25, 2019 at 12:55 PM
To: [hidden email] [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Alex Harui-2

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 <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Tuesday, November 26, 2019 at 2:22 PM
To: "[hidden email]" <[hidden email]>
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ş <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Tuesday, November 26, 2019 at 11:44 AM
To: "[hidden email]" <[hidden email]>
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 9:13 AM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Monday, November 25, 2019 at 12:55 PM
To: [hidden email] [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Serkan Taş
Alex, I have implemented in other way, here it is : ====> https://drive.google.com/open?id=1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B

But I have another exception in other thread , can you check it ?

subject : "org.apache.royale.textLayout.conversion.FormatDescriptor is not a constructor"

27.11.2019 01:34 tarihinde Alex Harui yazdı:

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 [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 2:22 PM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 11:44 AM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 9:13 AM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Monday, November 25, 2019 at 12:55 PM
To: [hidden email] [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Alex Harui-2

That link took me to the FormatDescriptor class.

 

The FormatDescriptor exception is a side-effect of having naked static initialization code.  We want to defer static initialization until it is really needed so that the load order of classes doesn’t matter as much (or at all).

 

My current opinion (again without spending too much time thinking about it) is to convert the var into a get function.  Most other methods in TextConverter access _descriptor and thus would initialize it just-in-time as it is needed.  Something like:

 

        Static private var __descriptors:Array;

 

        static public function get _descriptors():Array

        {

              If (!__descriptors) {

                _descriptors = [];
                addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter, TextLayoutExporter, TEXT_LAYOUT_FORMAT,__descriptors);
                addFormat(TEXT_FIELD_HTML_FORMAT, TextFieldHtmlImporter,  TextFieldHtmlExporter, null,__descriptors);
                addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter, PlainTextExporter, "air:text", __descriptors);

            }
      }

 

And add an optional last param to addFormat to specify the array to add to, so it doesn’t access the getter during initialization.

 

HTH,

-Alex

 

From: Serkan Taş <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Tuesday, November 26, 2019 at 8:14 PM
To: "[hidden email]" <[hidden email]>
Subject: Re: TextConverter method call

 

Alex, I have implemented in other way, here it is : ====> https://drive.google.com/open?id=1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B

But I have another exception in other thread , can you check it ?

subject : "org.apache.royale.textLayout.conversion.FormatDescriptor is not a constructor"

27.11.2019 01:34 tarihinde Alex Harui yazdı:

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 [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 2:22 PM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 11:44 AM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Tuesday, November 26, 2019 at 9:13 AM
To: [hidden email] [hidden email]
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ş [hidden email]
Reply-To: [hidden email] [hidden email]
Date: Monday, November 25, 2019 at 12:55 PM
To: [hidden email] [hidden email]
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 | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Serkan Taş
Hi Alex,

Sorry for inconvenience. I was just sent it before leaving home in the  
morning. I am going to send you the real code and check your sample  
later today.

But I did not understand the what should I do for FormatDescriptor.

Is there a workaround ?


Alıntı Alex Harui <[hidden email]>:

> That link took me to the FormatDescriptor class.
>
> The FormatDescriptor exception is a side-effect of having naked  
> static initialization code.  We want to defer static initialization  
> until it is really needed so that the load order of classes doesn’t  
> matter as much (or at all).
>
> My current opinion (again without spending too much time thinking  
> about it) is to convert the var into a get function.  Most other  
> methods in TextConverter access _descriptor and thus would  
> initialize it just-in-time as it is needed.  Something like:
>
>         Static private var __descriptors:Array;
>
>         static public function get _descriptors():Array
>         {
>               If (!__descriptors) {
>                 _descriptors = [];
>                 addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
> TextLayoutExporter, TEXT_LAYOUT_FORMAT,__descriptors);
>                 addFormat(TEXT_FIELD_HTML_FORMAT,  
> TextFieldHtmlImporter,  TextFieldHtmlExporter, null,__descriptors);
>                 addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
> PlainTextExporter, "air:text", __descriptors);
>             }
>       }
>
> And add an optional last param to addFormat to specify the array to  
> add to, so it doesn’t access the getter during initialization.
>
> HTH,
> -Alex
>
> From: Serkan Taş <[hidden email]>
> Reply-To: "[hidden email]" <[hidden email]>
> Date: Tuesday, November 26, 2019 at 8:14 PM
> To: "[hidden email]" <[hidden email]>
> Subject: Re: TextConverter method call
>
> Alex, I have implemented in other way, here it is : ====>  
> https://drive.google.com/open?id=1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&data=02%7C01%7Caharui%40adobe.com%7Cf1bcbef8545341e8ec6e08d772f049d8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104248674874151&sdata=Aw7jIEhZttahHiV5zlDJjKC7X0Rkz10E0W2l0QiZKT0%3D&reserved=0>
>
> But I have another exception in other thread , can you check it ?
>
> subject : "org.apache.royale.textLayout.conversion.FormatDescriptor  
> is not a constructor"
> 27.11.2019 01:34 tarihinde Alex Harui yazdı:
> 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 <[hidden email]><mailto:[hidden email]>
> Reply-To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> Date: Tuesday, November 26, 2019 at 2:22 PM
> To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> 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ş  
> <[hidden email]><mailto:[hidden email]>
> Reply-To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> Date: Tuesday, November 26, 2019 at 11:44 AM
> To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> 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ş  
> <[hidden email]><mailto:[hidden email]>
> Reply-To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> Date: Tuesday, November 26, 2019 at 9:13 AM
> To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> 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ş  
> <[hidden email]><mailto:[hidden email]>
> Reply-To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> Date: Monday, November 25, 2019 at 12:55 PM
> To: "[hidden email]"<mailto:[hidden email]>  
> <[hidden email]><mailto:[hidden email]>
> 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


--
Serkan Taş
Mobil : +90 532 250 07 71
Likya Bilgi Teknolojileri
ve İletişim Hiz. Ltd. Şti.
www.likyateknoloji.com

--------------------------------------
Bu elektronik posta ve onunla iletilen bütün dosyalar gizlidir. Sadece  
yukarıda isimleri belirtilen kişiler arasında özel haberleşme amacını  
taşımaktadır. Size yanlışlıkla ulaşmışsa bu elektonik postanın  
içeriğini açıklamanız, kopyalamanız, yönlendirmeniz ve kullanmanız  
kesinlikle yasaktır. Lütfen mesajı geri gönderiniz ve sisteminizden  
siliniz. Likya Bilgi Teknolojileri ve İletişim Hiz. Ltd. Şti. bu  
mesajın içeriği ile ilgili olarak hiç bir hukuksal sorumluluğu kabul  
etmez.

This electronic mail and any files transmitted with it are intended  
for the private use of  the persons named above. If you received this  
message in error, forwarding, copying or use of any of the information  
is strictly prohibited. Please immediately notify the sender and  
delete it from your system. Likya Bilgi Teknolojileri ve İletişim Hiz.  
Ltd. Şti. does not accept legal responsibility for the contents of  
this message.
--------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Alex Harui-2
By deferring the initialization of _descriptors until it is actually needed, the code allows FormatDescriptor to get loaded.  If the initialization code that needs FormatDescriptor runs too soon, then FormatDescriptor won't have been loaded yet.

At least, that's the theory,
-Alex

On 11/26/19, 9:50 PM, "[hidden email]" <[hidden email]> wrote:

    Hi Alex,
   
    Sorry for inconvenience. I was just sent it before leaving home in the  
    morning. I am going to send you the real code and check your sample  
    later today.
   
    But I did not understand the what should I do for FormatDescriptor.
   
    Is there a workaround ?
   
   
    Alıntı Alex Harui <[hidden email]>:
   
    > That link took me to the FormatDescriptor class.
    >
    > The FormatDescriptor exception is a side-effect of having naked  
    > static initialization code.  We want to defer static initialization  
    > until it is really needed so that the load order of classes doesn’t  
    > matter as much (or at all).
    >
    > My current opinion (again without spending too much time thinking  
    > about it) is to convert the var into a get function.  Most other  
    > methods in TextConverter access _descriptor and thus would  
    > initialize it just-in-time as it is needed.  Something like:
    >
    >         Static private var __descriptors:Array;
    >
    >         static public function get _descriptors():Array
    >         {
    >               If (!__descriptors) {
    >                 _descriptors = [];
    >                 addFormat(TEXT_LAYOUT_FORMAT, TextLayoutImporter,  
    > TextLayoutExporter, TEXT_LAYOUT_FORMAT,__descriptors);
    >                 addFormat(TEXT_FIELD_HTML_FORMAT,  
    > TextFieldHtmlImporter,  TextFieldHtmlExporter, null,__descriptors);
    >                 addFormat(PLAIN_TEXT_FORMAT, PlainTextImporter,  
    > PlainTextExporter, "air:text", __descriptors);
    >             }
    >       }
    >
    > And add an optional last param to addFormat to specify the array to  
    > add to, so it doesn’t access the getter during initialization.
    >
    > HTH,
    > -Alex
    >
    > From: Serkan Taş <[hidden email]>
    > Reply-To: "[hidden email]" <[hidden email]>
    > Date: Tuesday, November 26, 2019 at 8:14 PM
    > To: "[hidden email]" <[hidden email]>
    > Subject: Re: TextConverter method call
    >
    > Alex, I have implemented in other way, here it is : ====>  
    > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&amp;data=02%7C01%7Caharui%40adobe.com%7C738fc536d2744ce2c68d08d772fdbbc8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104306472419414&amp;sdata=WI3lFGqAmrxWpR6M3kf6L%2FIIZZkIRoJAmNDX2zNcCvs%3D&amp;reserved=0<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oPLnVz7jyWJe7Z_V25o773hQYlrRaD6B&amp;data=02%7C01%7Caharui%40adobe.com%7C738fc536d2744ce2c68d08d772fdbbc8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104306472419414&amp;sdata=WI3lFGqAmrxWpR6M3kf6L%2FIIZZkIRoJAmNDX2zNcCvs%3D&amp;reserved=0>
    >
    > But I have another exception in other thread , can you check it ?
    >
    > subject : "org.apache.royale.textLayout.conversion.FormatDescriptor  
    > is not a constructor"
    > 27.11.2019 01:34 tarihinde Alex Harui yazdı:
    > 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 <[hidden email]><mailto:[hidden email]>
    > Reply-To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > Date: Tuesday, November 26, 2019 at 2:22 PM
    > To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > 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ş  
    > <[hidden email]><mailto:[hidden email]>
    > Reply-To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > Date: Tuesday, November 26, 2019 at 11:44 AM
    > To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > 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ş  
    > <[hidden email]><mailto:[hidden email]>
    > Reply-To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > Date: Tuesday, November 26, 2019 at 9:13 AM
    > To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > 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ş  
    > <[hidden email]><mailto:[hidden email]>
    > Reply-To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > Date: Monday, November 25, 2019 at 12:55 PM
    > To: "[hidden email]"<mailto:[hidden email]>  
    > <[hidden email]><mailto:[hidden email]>
    > 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
   
   
    --
    Serkan Taş
    Mobil : +90 532 250 07 71
    Likya Bilgi Teknolojileri
    ve İletişim Hiz. Ltd. Şti.
    https://nam04.safelinks.protection.outlook.com/?url=www.likyateknoloji.com&amp;data=02%7C01%7Caharui%40adobe.com%7C738fc536d2744ce2c68d08d772fdbbc8%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637104306472419414&amp;sdata=eSy9IgwkT8Cw8o4%2B045B8dnxpw2qrVNQoSuCTj7UmoE%3D&amp;reserved=0
   
    --------------------------------------
    Bu elektronik posta ve onunla iletilen bütün dosyalar gizlidir. Sadece  
    yukarıda isimleri belirtilen kişiler arasında özel haberleşme amacını  
    taşımaktadır. Size yanlışlıkla ulaşmışsa bu elektonik postanın  
    içeriğini açıklamanız, kopyalamanız, yönlendirmeniz ve kullanmanız  
    kesinlikle yasaktır. Lütfen mesajı geri gönderiniz ve sisteminizden  
    siliniz. Likya Bilgi Teknolojileri ve İletişim Hiz. Ltd. Şti. bu  
    mesajın içeriği ile ilgili olarak hiç bir hukuksal sorumluluğu kabul  
    etmez.
   
    This electronic mail and any files transmitted with it are intended  
    for the private use of  the persons named above. If you received this  
    message in error, forwarding, copying or use of any of the information  
    is strictly prohibited. Please immediately notify the sender and  
    delete it from your system. Likya Bilgi Teknolojileri ve İletişim Hiz.  
    Ltd. Şti. does not accept legal responsibility for the contents of  
    this message.
    --------------------------------------
   
   

Reply | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Serkan Taş
Hi Alex,

TextConverter :
https://drive.google.com/open?id=1_6-rBQqTISbeoLvS2-yV8bSFkvS_ApxZ

It is working without any excepiton, but still can not show the text in
TextArea.

Going to try to find-out why...

Thank,
Serkan

27.11.2019 08:57 tarihinde Alex Harui yazdı:

> By deferring the initialization of _descriptors until it is actually needed, the code allows FormatDescriptor to get loaded.  If the initialization code that needs FormatDescriptor runs too soon, then FormatDescriptor won't have been loaded yet.
>
> At least, that's the theory,
> -Alex
>
> On 11/26/19, 9:50 PM, "[hidden email]" <[hidden email]> wrote:
>
>      Hi Alex,
>      
>      Sorry for inconvenience. I was just sent it before leaving home in the
>      morning. I am going to send you the real code and check your sample
>      later today.
>      
>      But I did not understand the what should I do for FormatDescriptor.
>      
>      Is there a workaround ?
>      

Reply | Threaded
Open this post in threaded view
|

Re: TextConverter method call

Serkan Taş

Alıntı Serkan Taş <[hidden email]>:

> Hi Alex,
>
> TextConverter :  
> https://drive.google.com/open?id=1_6-rBQqTISbeoLvS2-yV8bSFkvS_ApxZ
>
> It is working without any excepiton, but still can not show the text  
> in TextArea.
>
> Going to try to find-out why...
>
> Thank,
> Serkan
>
> 27.11.2019 08:57 tarihinde Alex Harui yazdı:
>> By deferring the initialization of _descriptors until it is  
>> actually needed, the code allows FormatDescriptor to get loaded.  
>> If the initialization code that needs FormatDescriptor runs too  
>> soon, then FormatDescriptor won't have been loaded yet.
>>
>> At least, that's the theory,
>> -Alex
>>
>> On 11/26/19, 9:50 PM, "[hidden email]"  
>> <[hidden email]> wrote:
>>
>>     Hi Alex,
>>          Sorry for inconvenience. I was just sent it before leaving  
>> home in the
>>     morning. I am going to send you the real code and check your sample
>>     later today.
>>          But I did not understand the what should I do for FormatDescriptor.
>>          Is there a workaround ?
>>


--
Serkan Taş
Mobil : +90 532 250 07 71
Likya Bilgi Teknolojileri
ve İletişim Hiz. Ltd. Şti.
www.likyateknoloji.com

--------------------------------------
Bu elektronik posta ve onunla iletilen bütün dosyalar gizlidir. Sadece  
yukarıda isimleri belirtilen kişiler arasında özel haberleşme amacını  
taşımaktadır. Size yanlışlıkla ulaşmışsa bu elektonik postanın  
içeriğini açıklamanız, kopyalamanız, yönlendirmeniz ve kullanmanız  
kesinlikle yasaktır. Lütfen mesajı geri gönderiniz ve sisteminizden  
siliniz. Likya Bilgi Teknolojileri ve İletişim Hiz. Ltd. Şti. bu  
mesajın içeriği ile ilgili olarak hiç bir hukuksal sorumluluğu kabul  
etmez.

This electronic mail and any files transmitted with it are intended  
for the private use of  the persons named above. If you received this  
message in error, forwarding, copying or use of any of the information  
is strictly prohibited. Please immediately notify the sender and  
delete it from your system. Likya Bilgi Teknolojileri ve İletişim Hiz.  
Ltd. Şti. does not accept legal responsibility for the contents of  
this message.
--------------------------------------