Often when refactoring code I'll extract ActionScript code out of an MXML file into an ActionScript based superclass to get a cleaner separation between logic and the view. In doing so I sometimes forget to update MXML variable declrations, leading to the confusing error:
Could not resolve <mx:states> to a component implementation.
- <?xml version="1.0" encoding="utf-8"?>
- <example:CustomCanvas xmlns:example="com.example.*" xmlns:mx="http://www.adobe.com/2006/mxml">
- <mx:states>
- <mx:State name="default"/>
- <mx:State name="custom"/>
- </mx:states>
- </example:CustomCanvas>
confused about it being a property versus a child component. The simple fix is to just change the namespace on the
property to match the root component's namespace like this:
- <?xml version="1.0" encoding="utf-8"?>
- <example:CustomCanvas xmlns:example="com.example.*" xmlns:mx="http://www.adobe.com/2006/mxml">
- <example:states>
- <mx:State name="default"/>
- <mx:State name="custom"/>
- </example:states>
- </example:CustomCanvas>