How to make the bitmap generate the SWF file
The bitmap resource, It's usually make the bitmap generate the SWF file ,and use Loader class to load into the application. I search some answers from google, find two ways to generate SWF File, one. use mxmlc tool. and another, use jsfl. I know we can embed the bitmap or swf file into As code. and use mxmlc command like this: the as file is Vip.as , and the code :
package
{
public class Vip
{
[Embed(source="vip.gif"]
public static var vip:Class;
}
}
and now, I use mxmlc Vip.as ... It's has Vip.swf file, upload the Vip.swf file to Server. Then, In flashBuilder, create a new ActionScript project, the application code is :
public class LoadUI extends Sprite
{
public function LoadUI()
{
init();
}
private function init():void {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader.load( new URLRequest('http://localhost/swfResouce/Vip.swf'));
}
private function completeHandler(e:Event):void {
var loaderInfo:LoaderInfo = e.currentTarget as Loa开发者_开发百科derInfo;
}
and debug the application, Error is:
VerifyError: Error #1014: Class Not Found mx.core::BitmapAsset.
I don't know how to use mxmlc generate swf file . And no error when debug the code.
Another way is that use JSFL to generate SWF in flash cs5, But I don't know how to use this. Ah, very pain.
I am guessing you want to display an embedded image (gif).
Here is how its done:
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
public class Main extends Sprite
{
[Embed(source="vip.gif")]
private var embeddedVip : Class;
public function Main()
{
var vip : Bitmap = new embeddedVip();
addChild(vip);
}
}
}
Why don't you just load the images directly (from Loader) and wrap them in a Sprite? A GIF doesn't exactly need a timeline. :)
To avoid
VerifyError: Error #1014
try to compile with static linking:
mxmlc -static-link-runtime-shared-libraries=true -debug=true Main.swf --Main.as
[EDIT]
mxmlc -static-link-runtime-shared-libraries=true -debug=true Main.as
精彩评论