Initializing GraniteDS Tide framework

145 views Asked by At

I'm trying to work with GDS Tide framework. My basic code is this one :

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               preinitialize="Tide.getInstance().initApplication()">

<fx:Script>
    <![CDATA[
        import controllers.TestController;

        import events.TestEvent;

        import models.TestModel;
        import models.interfaces.ITestModel;

        import mx.events.FlexEvent;

        import org.granite.tide.Tide;


        [Bindable][Inject]
        public var testModel:ITestModel;

        Tide.getInstance().addComponents([TestController, TestModel]);


    ]]>
</fx:Script>


<s:layout>
    <s:VerticalLayout />
</s:layout>

<s:Label text="{testModel.ab}" />
<s:Button click="dispatchEvent(new TestEvent());" label="test !" />

I can compile and run my code but when I'm launching my application, I see blank windows, my button or my label don't appear. No errors are fired.

When I change my code to this one :

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               preinitialize="Tide.getInstance().initApplication()" creationComplete="application1_creationCompleteHandler(event)">

<fx:Script>
    <![CDATA[
        import controllers.TestController;

        import events.TestEvent;

        import models.TestModel;
        import models.interfaces.ITestModel;

        import mx.events.FlexEvent;

        import org.granite.tide.Tide;


        [Bindable][Inject]
        public var testModel:ITestModel;


        protected function application1_creationCompleteHandler(event:FlexEvent):void
        {
            Tide.getInstance().addComponents([TestController, TestModel]);
        }

    ]]>
</fx:Script>


<s:layout>
    <s:VerticalLayout />
</s:layout>

<s:Label text="{testModel.ab}" />
<s:Button click="dispatchEvent(new TestEvent());" label="test !" />

it works I see label and button but my label isn't initialized properly because my controller and model are added on mx.events.FlexEvent.CREATION_COMPLETE event.

What am I doing wrong please with the first (and recommanded) method ?

0

There are 0 answers