« 2006 Spam Statistics | Main | Three Cups of Tea »

Could not resolve * to a component implementation.

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.

In this case my MXML class extends another custom class and looks like:

<?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>

The issue is that the "mx" namespace doesn't match the root component's namespace so the MXML compiler gets 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>

Tags: as3 error flex2

Comments

Thanks very much for posting this. It really helped me resolve the issue quickly. No thanks to the adobe docs!
hi, thanks this was very helpful. regards, san
Thanks for the tip ;)
Good post, I ran into this while extending framework components.

-Shailesh

very helpful. thanks!
Good catch!
thanks!
Thank you. I was working on an application and came to this. Was about to toss the keyboard through the window when I came across this post!
Thanks!
Thanks very much! I've been caught in this problem for an hour.
Thank you. i meet same issue and now resloved. :)
Thank you very much, very, very helpful !
Great post Daniel. Save me lot of time.
Thanks a lot for ur post.. Gr8 job mate.. Please mail us any critical issues.
thank you very much for this, saved me valuable time.
Thanks for your post. Saved me a BUNCH of time!
Something makes me uneasy about using standard mx components under a custom namespace. But it solved my problem, and for that I'm grateful.
Thanks a lot! Once you know what's happening it makes a lot of sense, but that compiler error sure had me scratching my head for a while.
This is a key thing to know, thanks. It would be nice if Adobe docs were more helpful on this and other confusing issues. Most of their errors are abismal.
thanks. :D
THANKS!
Thank you very much for posting this. Solved my problem lickety split.
i had a similar problem but the its because there are 2 files with the same name: myform.mxml and myform.as (which is referenced by myform.xml). in the preview tab it shows the component but when there is this error when running it. solution: rename myform.as to be myformscript.as or something different with the mxml file.

Good post!

It's kind of obvious when you think about it -- the give away is the lower case on which means it is referring to an attribute of an object rather than the name of a class, so "obviously", the attribute has to be referenced out of the same namespace as its object.

Thanks again

Your the best !
cheers...
I've been coding in Flex for about 2 years, but this one still stumped me. I suppose it makes sense though. Thanks for posting this; you saved me a lot of time!
thanks for you help
Thanks. You helped me out!
Thanks.
thanks a lot it solve my problem
Very Nice
thanks
Fantastic. Thanks a Lot :)
Error: Could not resolve to a component implementation. what i want to do? for solve to above problem
thanks for you help ...Very much appreciated.