Need Help?

For technical questions, feel free to ask on the Swiz mailing list.

Save as HTML or PDF

You can export this entire Wiki in HTML or PDF format.

Child pages
  • FAQ
Skip to end of metadata
Go to start of metadata

Is there a mailing list where I can get help from the Swiz community?

Absolutely, you can find the Swiz group at http://groups.google.com/group/swiz-framework.

If I am exporting a release build for a Swiz project, what compiler arguments do I need to retain the custom metadata?

Because the Swiz swc is built with arguments to instruct the compiler to retain the Swiz metadata, you shouldn't normally need to do this yourself. However, if the metadata isn't retained for some reason, you can add this to the compiler arguments for your project:

-keep-as3-metadata+=Inject,Autowire,EventHandler,Mediate,Dispatcher,PostConstruct,PreDestroy,ViewAdded,ViewRemoved,ViewNavigator

If I am building the Swiz framework from the source code, what compiler arguments do I need?
-keep-as3-metadata+=Inject,Autowire,EventHandler,Mediate,Dispatcher,PostConstruct,PreDestroy,ViewAdded,ViewRemoved,ViewNavigator
-namespace http://swiz.swizframework.org manifest.xml
-include-namespaces http://swiz.swizframework.org
-define+=CONFIG::flex4,true 
-define+=CONFIG::flex3,false


When compiling for the Flex 3.x SDK, use -define+=CONFIG::flex4,false -define+=CONFIG::flex3,true. Be sure you only compile the /src directory into the library. Trying to compile the other packages, such as /tests, will result in library compile errors.

You will also want to mark the metadata.xml and manifest.xml files as Assets in your Build Path panel.

Lastly, using the Ant build script will take care of all of these things for you, so that is the easiest way to build Swiz from source.

I try to access my injected property during creationComplete but the reference is still null?

Swiz injects dependencies when the view's addedToStage event is dispatched, which is after creationComplete. Inject to a setter function to have direct access to the injected reference, or move your logic into a method decorated with [PostConstruct].

What versions of Flex are supported for Swiz?

Swiz works with Flex SDK 2, 3, 4 and 4.5. Flash Builder 4.5 added code completion for Swiz metadata!

Does Swiz work with Adobe AIR?

Yes, there is in general no difference between Web or AIR development. An additional Desktop Extensions library is available to add desktop-specific features.

I have dispatched an event from a view but the [EventHandler] is not invoked?

Ensure that the event handler method is public, and that the bubbles property of the event is true.

How can I cause a Prototype bean to be destroyed when a view is destroyed?

Swiz can't know what else you may have done with the Prototype, so it is not automatically torn down. If you wish to tear down a Prototype bean when a view is removed, implement a [PreDestroy] method and dispatch a TEAR_DOWN_BEAN event for the Prototype bean.

Why aren't new PopUp or AIR windows processed by Swiz (especially if created from within a Module)?

Because PopUps and NativeWindows are not part of the standard display list, Swiz has no way to know which Swiz instance is the owner of the window. To deal with this, you can have the class that creates the window implement ISwizAware. Once you have the correct Swiz instance injected, you can call the registerWindow() method on that Swiz instance to associate that window with the specified instance of Swiz. The window can then be processed correctly.

Why aren't bubbling events dispatched from a PopUp handled by Swiz?

Swiz uses the display object where it was created as its "root event dispatcher", and it listens for events on that event dispatcher. However, PopUps are not added to this display list, they are added as direct children of the SystemManager object, since they must appear above everything else in the application. As a result, events dispatched from PopUps don't bubble up to the Swiz dispatcher. However, the solution to this is simple: just use [Dispatcher] to inject the Swiz dispatcher into your PopUp, and dispatch events through it. This way, Swiz can process them.

Where is my application logic starting point?

If your startup logic only involves one bean, let that bean (probably a "main controller") implement IInitializingBean, or decorate a method with [PostConstruct], and start with your application logic in that method. Swiz calls these methods on beans when the injection process is complete.

If your startup logic depends on events that must be handled by other beans, you need to be sure that all of your beans have been properly set up. In this case, you can use an event handler method such as [EventHandler( "mx.events.FlexEvent.APPLICATION_COMPLETE" )]. This will mediate the applicationComplete event, and only kick off processing once all of the beans have been set up.

How should I dispatch events from bean classes?

You should inject a dispatcher using the [Dispatcher] metadata, and dispatch application events through this dispatcher.

Why did my view not get injections processed?

Be sure that the viewPackages in the SwizConfig tag are set correctly.

I defined a WebService object in my Beans.mxml, but my web service calls don't seem to work. What's wrong?

The Flex WebService class actually has two implementations, one for MXML and one for AS3. If you define a WebService within a UIComponent, the Flex framework automatically triggers a load of the web service's WSDL in the UIComponent's creationComplete() handler. However, the AS3 version does not (it has no creationComplete() handler). Because the BeanProvider is not a UIComponent, this automatic loading of the WSDL is not done by the Flex framework. As a result, you must call loadWSDL() on your web service before you can use it, because you are actually using the WebService's AS3 implementation.

Why do I get an error when using Swiz in a Flash Builder project when I use Design View?

Researching this seems to indicate that it can happen with any .swc where the .swc was compiled using a version of the SDK other than the version used by the project. Since there are so many possible SDK versions, creating separate versions of Swiz for all of them is not possible. If you need to use Design View, and you're using an SDK other than the one the framework was compiled with, we recommend that you download the source code, set up the framework as a library project, and add the library project to your application project. This should resolve the Design View error.

  • No labels

6 Comments

  1. Anonymous

    Why aren't new PopUp or AIR windows processed by Swiz
    (especially if created from within a Module)?

    i  dont  create a class,just  create an  mxml view ,what  should  i do ?   could  you  show  me   an   example?

    1. Please ask on the mailing list. Also, when you post to the mailing list, you'll need to expand on your question, because I have no idea what you're actually asking.

  2. Anonymous

    hey guys,

    whats the difference to robot legs? why did you build your own framework?

    why not use robot legs?

    thanks!

    peter

    1. For general questions, you may want to post to the mailing list. But to answer your question on why it was created, Swiz existed for over a year before Robotlegs was started.

  3. Anonymous

    [I have dispatched an event from a view but theEventHandleris not invoked?|wiki/display/SWIZ/FAQ?showComments=true&showCommentArea=true#FAQ-Ihavedispatchedaneventfromaviewbutthe%7B%7B%5CEventHandler%5C%7D%7Disnotinvoked%3F]

    For the love of all that is holy, make sure the function beneath your [EventHandler] is public, not private.

    1. I've updated the FAQ to state this explicitly, even though it is already covered in the other sections.