I have a FlexLib Project with a embed class:
package
{
public class EmbedAssets
{
[Embed( source="image.png" )]
public static var IMAGE:Class;
}
}
At the same project, I have a class that use this embedded image:
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
public class Visual extends Sprite
{
public function Visual()
{
super();
var aa:DisplayObject = new EmbedAssets.IMAGE() as DisplayObject;
开发者_如何转开发 addChild( aa );
}
}
}
And I have another Actionscript Project that use this FlexLib Project and add the Visual class on stage:
package
{
import flash.display.Sprite;
public class AsTest extends Sprite
{
public function AsTest()
{
addChild( new Visual());
}
}
}
The image don't show up, just.
I had debug the application and found the bitmapData of aa was NULL. But if I implement out of Lib Project, this work!
In properties of projects ai tried a lot configurations on Flex Library Build Path -> Classes / Assets. But none work correctly.
EDIT: Idemax Green (question author) discovered that it works ok with prev SDK's but not with Flex SDK Hero - Beta - 4.5.0.17689, he logged it as a bug: https://bugs.adobe.com/jira/browse/SDK-29135
If the FlexLib project is merged with your application code, then i'm pretty sure it will not see the image at that location at runtime, as the location will be different e.g. the library will be in the libs folder of the main app. Check where the FlexLib swc is located in you bin-debug folder, and maybe modify the path in EmbedAssets to reflect this.
You should add the library project's assets directory to the application project's source path.
If you are using FlashBuilder, you should edit the flex application's .project file, and extend the linkedResources
tag as follows:
<linkedResources>
[...]
<link>
<name>[source path] assets</name>
<type>2</type>
<locationURI>YOUR_WORKSPACE/YourFlexLib/src/assets</locationURI>
</link>
</linkedResources>
精彩评论