States in components inheriting from a custom class

A standard recommendation is to separate view from controlling code. A good way to achieve this in Flex is to have a mxml class that contains nothing but view and to move all the controlling code to a superclass.


<p:LoginScreenClass xmlns:mx="" xmlns:p="*" />

import mx.containers.VBox;
public class LoginPanelClass extends VBox {}

It works smoothly once you remember that in '', unctions called from the mxml file needs to be declared as protected and ui elems of the mxml file that the as class refers to need to be declared as public.

Expect for one thing, states.

if you add <mx:states> in a component that inherits from a custom class that itself inherits from a Flex container, the compiler tells you that states is not allowed in that context.

A solution is given on Justin Moses' blog. "Use the same xml namespace as your base component to load up the property, even though it is inherited."

Rather than

<mx:states />


<p:states />

Powered by Drupal, an open source content management system