Welcome, Guest
  • Author Topic: Bindable variable not updating with viewstack / swiz  (Read 1011 times)

    mike6679

    • Server what's that
    • *
    • Posts: 2
      • View Profile
    I'm using the Swiz framework and I'm trying to update my viewstack's selectedIndex with a bindable property. It gets to my event handler which updates the bindable variable but the Main app file's viewstack never realizes it. What could be the issue?



    ================================
    MAIN APP FILE
    ===============================
    <mx:Script>
        <![CDATA[
            import reg.model.ApplicationViewModel;
            import beyaz.reg.swiz.SwizBeans;
            import org.swizframework.Swiz;

            [Autowire(bean="applicationViewModel")]
            [Bindable]
            public var applicationViewModel:ApplicationViewModel;

            private function preInitialize():void {
                Swiz.loadBeans( [ SwizBeans ] );
            }

        ]]>
    </mx:Script>


           <mx:ViewStack id="theViewstack"  selectedIndex="    {applicationViewModel.mainViewIndex}" width="100%" height="100%">
        <prescreen:Prescreen id="prescreenView"/>
        <login:Login id="loginView"/>
        <profile:Profile id="profileView"/>

    </mx:ViewStack>

    ===================

    ApplicationViewModel
    =====================


    package com.beyaz.reg.model
    {
       
       public class ApplicationViewModel
       {
          public var PRESCREEN_VIEW:int = 0;
          public var LOGIN_VIEW:int = 1;
            public var PRSNL_INFO_VIEW:int = 2;
          
          
          [Bindable]
          public  var message:String = "";
          
          [Bindable]
          public  var mainViewIndex:int ;
       }
    }



    ===========================
    Controller

    ==========================

    package com.reg.controller
    {
    import com.reg.model.ApplicationViewModel;

    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.events.DynamicEvent;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.core.Application;

    import org.swizframework.Swiz;
    import org.swizframework.controller.AbstractController;

    public class PrescreenController// extends AbstractController
    {
        public static const START_REGISTRATION:String = "startReg";

        [Autowire(bean="applicationViewModel")]
        [Bindable]
        public var applicationViewModel:ApplicationViewModel;


        [Mediate(event="startReg")]
        public function startReg():void
               {

                  //CODE GETS TO HERE!
                  applicationViewModel.mainViewIndex = 1;

        }


    }




    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    I didn't work with Swiz framework, but I realize that you use START_REGISTRATION, that sounds to me like some initialization called from inside the framework, and probably the fail is related to the initialization cycle. Did you try to test using a simple button or someting like that, because probably this is not related to binding but framework initialization

    Jorge

    mike6679

    • Server what's that
    • *
    • Posts: 2
      • View Profile
    Jorge,

    I believe its because I do not have the latest version of Swiz.

    thanks

    -Mike