Image class not available in flex 4.1
I am facing a problem in flex 4.1 sdk. (thou I was using flex 4.5 sdk, but for some reasons I have to use 4.1, 开发者_如何学JAVAI can explain that too, but its relevant to the problem I am facing now)
My code was working fine in 4.5, with no errors. But when I compile the same code with 4.1, I get "Type was not found or was not a compile-time constant: Image." error.
So, it turns out that 4.1 does not has Image class.
How can I solve this issue. plz let me know
Best regards Zeeshan
You can also use BitmapImage. See http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/primitives/BitmapImage.html#source .
It is incorrect to say that the Flex 4.1 SDK does not have an Image class.
It is more accurate to say that the Flex 4.1 SDK does not have a Image class implemented using the Spark architecture.
An easy solution is to switch to using the MX Image class, which has been available since Flex 3, according to the docs.
I think the key thing you said there was that it was working fine in 4.5 but not 4.1. I'm guess you probably don't want to go back in and change all your Image components into BitmapImage components (I don't blame you).
This means that your 4.5 project included both the MX and Spark component sets but your 4.1 project does not, and only has Spark.
This means that you'll need to set up the namespaces and build settings for the project. If you're using the latest FlashBuilder, you can right click on the project in the package explorer, go to properties, then "Flex Build Path" - then in the library path tab, you can select your component set - you want "MX + Spark" option.
More details can be found on using / mixing component sets here :
http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb524b8220812e5611f28f-7fe1.html#WSe4e4b720da9dedb524b8220812e5611f28f-7fe0
Your namespaces should look something similar to this :
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
Then suddendly you're code works again - magic, like magnets!
精彩评论