“could not resolve <mx:…> to a component implementation”
If you have ever tried to add
mx.core.ToolTip (or certain other classes) as a mxml-tag to your Flex project then you might've run into the following compiler-error:
"Could not resolve <mx:ToolTip> to a component implementation."
So why does Flex (or rather MXMLC, the compiler) let you write
<mx:Canvas> and all those other Flex components, but not
<mx:ToolTip> -- it's a native Flex class and it's in the mx package just like all of the others, right?
Fact is, it's not the mx class-package that defines whether or not you can add a component by saying
<mx:...>, but rather the Flex component manifest file -- it describes which of the native Flex classes fall under the mx xml-namespace (or actually any namespace you want to use). I might write a post about manifest-files in Flex somewhere in the near future, but for now you'll have to read up in the docs if you want to know more.
It so happens that the
ToolTip class isn't included in the native Flex component manifest, and consequently the compiler won't be able to find it if you just write "<mx:ToolTip />". You can work around this by specifying a seperate xml-namespace for the
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:controls="mx.controls.*"> <controls:ToolTip /> </mx:Application>
Note that in the above example we can't change the value of the xmlns:mx attribute so that it would point to the
mx.controls class-package, because if we would then the compiler wouldn't recognize the
<mx:Application> tag anymore (since the
Application class isn't in the mx.controls package).
Also, for the naysayers who completely miss the point and start talking about why on earth you would want to instantiate a
ToolTip through mxml: To tell the truth I was wondering about this myself, but if you think about it, tooltips in Flex aren't restricted to just having whatever you put into
UIComponent.toolTip automatically pop up when you mouse-over. In fact you may want to create a custom mxml-component subclass of
ToolTip and manually add it to your application using the
ToolTipManager class during runtime.
That having been said,
ToolTip isn't the only Flex-class not included in the Flex component manifest, naturally what I wrote in this post also applies to any other class in the Flex framework that extends
UIComponent but isn't included in the manifest.