Using SwizConfig with Flex 4
June 15th, 2009
No comments
I recently started my first Flex 4 project using the Swiz framework. After setting up my main application class to use SwizConfig and compiling I was greeted with this error.
“In initializer for ‘mxmlContentFactory’, type org.swizframework.SwizConfig is not assignable to target type Array or target element type mx.core.IVisualElement”
The solution: Flex 4 introduced a new method of grouping non-visual elements together <fx:Declarations>. In Flex 4 non-visual elements such as formatters, validators, effects etc. need to be grouped within a <fx:Declarations> section. So if you’re using Flex 4 (Gumbo) your SwizConfig would look something like this:
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:swiz="http://swiz.swizframework.org" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <fx:Declarations> <swiz:SwizConfig viewPackages="com.myapp.views" eventPackages="com.myapp.events" strict="true" beanLoaders="{[Beans]}" /> </fx:Declarations> </s:WindowedApplication>