Updating a Swiz 0.6.4 application to Swiz 1.0 will require the following changes:
Update configuration and creation of Swiz
Prior to 1.0, there was only one instance of Swiz. 1.0 now allows for multiple versions of Swiz, primarily to support modules and separate AIR windows. As a result, the creation of Swiz within the application will need to be modified.
In a 0.6.4 application, Swiz was created like this:
<script src="http://gist.github.com/370722.js?file=swiz_064_main.mxml"></script>
In Swiz 1.0, this would look like:
<script src="http://gist.github.com/370722.js?file=swiz_10_main.mxml"></script>
You might also note that several of the properties on Swiz have changed:
- the
strict
property has been renamedvalidateEventTypes
, and now defaults totrue
so in most cases it can be removed mediateBubbledEvents
has been removed since Swiz 1.0 mediates bubbled events automatically- the
beanLoaders
property has been renamed tobeanProviders
, and has been moved to theSwiz
class - the
eventPackages
andviewPackages
now accept package paths in both the formatmyapp.events
andmyapp.events.*
- the
injectionEvent
property has been renamedsetUpEventType
, and now defaults toEvent.ADDED_TO_STAGE
instead ofEvent.PREINITIALIZE
Full details on configuration and the default values for 1.0 can be found in the Configuration section.
The BeanLoader
class has been deprecated in favor of BeanProvider
. BeanLoader
will still work in 1.0, but it is recommended that you update your code to BeanProvider
. In addition, a central dispatcher property was available within BeanLoader
in 0.6.4. This property has been removed in 1.0. If a bean or prototype bean requires a dispatcher from Swiz, this is now accomplished using the [Dispatcher]
metadata tag:
<script src="http://gist.github.com/370670.js?file=Use_Dispatcher_Metadata.as"></script>
Changes within Swiz beans
- the
[Autowire]
metadata tag has been deprecated in favor of[Inject]
.[Autowire]
will still function in 1.0 but it is recommended that you update your code to use[Inject]
.