Good to be able to move forward without making so much changes in the original code Greg,

Thanks,
Serkan

2.11.2019 00:32 tarihinde Greg Dove yazdı:

Yeah, I have also seen things like that, although not specifically with ResourceManager, I recall seeing it with instances of custom classes. To keep things as close as possible to the original code, the way I have addressed this in the past it is to convert the static const into a static getter, with the instance constructed the first time the getter is accessed.
private static var _ERROR:String
public static function get ERROR():String { if (_ERROR) return _ERROR; _ERROR = ResourceManager.getInstance().getString('messages', 'error'); return _ERROR }

you could probably opt out of the local private storage variable and simply return the value from ResourceManager, but that might change if locale changes happen (which I don't know if we support yet, I did not check that).

On Sat, Nov 2, 2019 at 10:21 AM Alex Harui <aha...@adobe.com <mailto:aha...@adobe.com>> wrote:

    It may not work to define static constants from ResourceManager.

    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: *Friday, November 1, 2019 at 1:47 PM
    *To: *"users@royale.apache.org <mailto:users@royale.apache.org>"
    <users@royale.apache.org <mailto:users@royale.apache.org>>
    *Subject: *WARNING

    Hi,

    Need and advice, I am getting a compiler warning that appears as
    an exception in web console :

    WARNING:
    
D:/dev/royale-emulation-works/github/royale-testing/src/main/mtest/bin/js-debug/main/mtest/FindBug.js:141:
    WARNING - mx.resources.ResourceManager.getInstance defined before
    its owner. mx.resources.ResourceManager is defined at
    
D:/dev/royale-emulation-works/github/royale-testing/src/main/mtest/bin/js-debug/mx/resources/ResourceManager.js:19
    main.mtest.FindBug.ERROR =
    mx.resources.ResourceManager.getInstance().getString('messages',
    'error');
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


    And the exception :

    FindBug.js:141 Uncaught TypeError: Cannot read property
    'ResourceManager' of undefined
        at FindBug.js:141
    (anonymous) @ FindBug.js:141
    SystemManager.js:231 Uncaught TypeError: Cannot read property
    'mixins' of undefined
        at
    FindBug_mx_managers_SystemManager.mx.managers.SystemManager.start
    (SystemManager.js:231)
        at index.html:366

    The source piece :

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
    
<https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fns.adobe.com%2Fmxml%2F2009&data=02%7C01%7Caharui%40adobe.com%7C19e026478f6c4b7237cf08d75f0ca489%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637082380221864549&sdata=%2B%2BuxytHojeYDlAVSDLry850kQE1aCNeMEhZG%2BZdq5mg%3D&reserved=0>
                   xmlns:s="library://ns.apache.org/royale/spark
    <http://ns.apache.org/royale/spark>"
                   xmlns:mx="library://ns.apache.org/royale/mx
    <http://ns.apache.org/royale/mx>"
                   paddingBottom="0" paddingTop="0" paddingLeft="0"
    paddingRight="0"
                   height="100%" width="100%"
                   creationComplete="onCreationComplete()"
                   xmlns:comps="com.likya.pinara.comps.*"
                   >

        <fx:Metadata>
            [ResourceBundle("messages")]
        </fx:Metadata>

        <fx:Script>
            <![CDATA[
                import mx.resources.ResourceManager;

                public static const ERROR:String =
    ResourceManager.getInstance().getString('messages', 'error');

                public function onCreationComplete():void {

                }

                protected function
    button_clickHandler(event:MouseEvent):void {
                }

            ]]>
        </fx:Script>

        <fx:Declarations>
        </fx:Declarations>

        <s:layout>
            <s:VerticalLayout gap="10" paddingRight="10"
    paddingLeft="10" paddingTop="10" paddingBottom="20" />
        </s:layout>

        <s:Button id="button" width="200" label="Show/Hide"
    click="button_clickHandler(event)"/>

        <mx:Panel title="Form Container Example"
                  paddingBottom="10" paddingTop="10" paddingLeft="10"
    paddingRight="10"
                  height="100%" width="100%">

            <mx:Text width="100%"
                     text="Moving from one form field to another
    triggers the validator."/>

            <mx:Form width="100%" height="100%" >
                <mx:FormHeading label="Enter values into the form."/>

                <mx:FormItem label="First name" >
                    <mx:TextInput id="fname" width="200"/>
                </mx:FormItem>

                <mx:FormItem
    label="{resourceManager.getString('messages', 'userName')}">
                    <mx:TextInput id="username" width="200"/>
                </mx:FormItem>
            </mx:Form>

        </mx:Panel>

    </s:Application>

    Thanks,
    Serkan


Reply via email to