如何让位图生成SWF文件
位图资源,通常是将位图生成SWF文件,并使用Loader类加载到应用程序中。 我从google上搜索了一些答案,找到了两种生成SWF文件的方法,一。使用 mxmlc 工具。另一种是使用 jsfl。 我知道我们可以将位图或 swf 文件嵌入到 As 代码中。并使用 mxmlc 命令,如下所示: as 文件是 Vip.as ,代码:
package
{
public class Vip
{
[Embed(source="vip.gif"]
public static var vip:Class;
}
}
现在,我使用 mxmlc Vip.as ... 它有Vip.swf文件,将Vip.swf文件上传到服务器。 然后,在flashBuilder中,创建一个新的ActionScript项目,应用程序代码为:
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 LoaderInfo;
}
并调试应用程序,错误为:
VerifyError: Error #1014: Class Not Found mx.core::BitmapAsset.
我不知道如何使用mxmlc生成swf文件。并且调试代码时没有错误。
另一种方法是使用JSFL在flash cs5中生成SWF,但我不知道如何使用这个。啊,好痛苦。
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 LoaderInfo;
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜你想显示嵌入的图像(gif)。
这是如何完成的:
I am guessing you want to display an embedded image (gif).
Here is how its done:
为什么不直接(从 Loader)加载图像并将它们包装在 Sprite 中? GIF 并不完全需要时间线。 :)
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
try to compile with static linking:
[EDIT]