ViewNavigator is null when I set up Swiz through Actionscript class

80 views
Skip to first unread message

Tr0m

unread,
Oct 23, 2012, 4:35:47 PM10/23/12
to swiz-fr...@googlegroups.com
Hey there,

In a Air Mobile application developped in Flex and following this post: https://groups.google.com/forum/?fromgroups=#!topic/swiz-framework/FZbS9NIZoAc
I finally was able to have access to the viewNavigator through an injected singleton within a command.

public class ViewReference
{
      [ViewNavigator]
       public var viewNavigator:ViewNavigator;
}

public class PushViewCommand implements IEventAwareCommand
{
[Inject(source="viewReference.viewNavigator")]
public var viewNavigator:ViewNavigator;
}


A few refactoring later, I would like to configure Swiz through an actionscript class instead of MXML, like the wolling:

<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
                                xmlns:swiz="http://swiz.swizframework.org"
                                firstView="views.WelcomeView">
<fx:Declarations>
        <config:SomeSwizConfig context="{this}"/>
 </fx:Declarations>
</s:ViewNavigatorApplication> 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

public class SomeSwizConfig
    {
        public function set context(value:IEventDispatcher):void
        {
            var swizConfig:SwizConfig = new SwizConfig();
            swizConfig.setUpEventType = FlexEvent.PREINITIALIZE;
            swizConfig.viewPackages = ["views.*"];
            swizConfig.eventPackages = ["event.*"];

            var beans:Array = [];
            beans.push(new ViewReference());

            var beanProvider:BeanProvider = new BeanProvider(beans);

            var swiz:Swiz = new Swiz(value, swizConfig, null, [beanProvider]);
            swiz.init();
        }
    }


Unfortunately, the viewNavigator in the ViewReference class seems always null whatsoever.
Any suggestion on how to get access again to the ViewNavigator through commands?

Thanks
Thomas

Brian Kotek

unread,
Oct 23, 2012, 5:38:21 PM10/23/12
to swiz-fr...@googlegroups.com
I'm not at a computer, but pretty sure BeanProvider takes an array of Bean instances. 
--
You received this message because you are subscribed to the Google Groups "Swiz Framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swiz-framework/-/lHawjSpmV74J.
To post to this group, send email to swiz-fr...@googlegroups.com.
To unsubscribe from this group, send email to swiz-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swiz-framework?hl=en.
Reply all
Reply to author
Forward
0 new messages