开发者

How to generate an SWF file from an actionscript file?

Hi I have an actionscript file which is displayi开发者_StackOverflow中文版ng a button. I want to remove the button from my display. So i need to make changes to the actionscript code and generate a new SWF file after doin the changes.

Can anyone kindly help me regarding how to generate an SWF file from an actionscript file.

Thanks In Advance.


I think you are asking what you use to compile as3 to a .swf file.

Is your source file a .fla or a .as file ? Keep in mind that a .swf is not a source file, it is the compiled file. So if you wanted to modify that on the fly, you could use the method suggested by anemgyenge above.

Otherwise, if "on the fly" is not your intention you'd need to decompile it - which doesn't really result in quality source as the decompiled symbols can be hard to work with.

Flash CS5 can compile to a .swf, and your main source file is a .fla and .as for code files.

Flex SDK can compile AS3 to a .swf, and you can use either Flex Builder or Flash Develop as an IDE for editing your as3 code.

FlashDevelop is free and you can get it here :

FlashDevelop Download Page

You need the Flex SDK to compile with FlashDevelop, so you'll need to get that here :

Flex SDK - you can use either 3 or 4

If you are looking to tinker with it, why not try out wonderfl.net. It is a little sloppy in terms of the layout of the site, but there is tons of code to learn from and you don't need to install anything!


If you still have the problem and need a quick solution, then instead of "changing the actionscript code and generate a new SWF", you can try to do a workaround.

Embed the swf file with the button in a new flash project: for this use the Embed metatag and embed the file as a ByteArray then load it to a Loader object.

[Embed(source="filename-of-swf-with-button", mimeType="application/octet-stream")]
var class1:Class;

var ldr:Loader = new Loader();
ldr.loadBytes(new class1());

After this you can reach the "swf's" content by ldr.content. There you go, if you know the name of the instance, make it invisible or remove it from the displaylist. If you don't know the name, then try to find it the hard way:

for(var i:int = 0; i < ldr.content.numChildren; i++)
{
     trace(ldr.content.getChildAt(i).name);
}

and after the search, pick the button instance.


Are you asking to generate on the fly (at runtime) or to compile the AS file to a SWF file? If you're just looking to compile an AS file to a SWF, you can create a new project in various ActionScript IDEs (Flash Builder, Flex, FlashDevelop [my favorite]), include the file in question as your Main application file, compile it, and if everything runs well... presto - you have a SWF!

Each IDEs have slightly different ways to set the said "*.as" file as the main application file. You must make sure it extends the Sprite or MovieClip class (or another base-class that does this already) so it has a point-of-entry to attach itself to the Stage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜