You have to put it in your assets folder and add an assets node in your project.xml to have it copied, then it’ll have the url “assets/castle.swf”. <assets path="Assets/" include="*.swf" />
Though since it’s an asset you may prefer to use the Asset class to get it back.
Are you trying to load the bytes, or are you trying to use the SWF contents to display something? Unless you are targeting the Flash target, you will not be able to execute code from a SWF file, but for other targets, you can use the SWF library to provide some runtime support for the content.
Check out the “SimpleSWFLayout” or “NyanCat” samples for an example of using SWF content cross-platform
Hi all,
I am new here and I am trying to switch from AS3 to HaXe OpenFl.
I am trying to instantiate a movieclip from an swf, like nyanCat sample does, but I receive the error “Assets.hx:309: [Assets] There is no asset library named “library”” when doing
var elephant = Assets.getBitmapData ("library:TargetChoice1");
addChild (new Bitmap(elephant ));
The SWF is in assets folder, its name is library.swf, what am I missing?
Oh, and is it possible to use movieclips containing FLVs?
Make sure you use <haxelib name="swf" /> in your project XML, and either call it “library.swf” or use the id attribute when including it (like <library path="my.swf" id="library" />)
Does this help?
FLV is a proprietary format, when targeting Flash Player, you should be able to do this (unless you use the “swflite” type) but when targeting other platforms, I’m not sure how we would handle FLV (even with work) because of licensing problems
(taken from NyanCat sample project.xml)
I am receiving
Assets.hx:475: [Assets] There is no String asset with an ID of "libraries/library.json"
Assets.hx:800: [Assets] There is no asset library named "library"
I am confused, but I am totally new to OpenFl, I think it is normal
EDIT:
I forgot <haxelib name="swf" />
I added it and now it works, but using
path “Assets/...” and property preload="true" are necessary -
I thought that folder Assets was used by default, but it looks it is not (at least for swf libs).
Oh, I tried to compile NyanCat targeting HTML5, and I can’t see the animation but just the first static frame, why?
EDIT:
Trying to instantiate a BMP from my library works ok… if targeting Flash, but with HTML5 the bmp does not show up at all. Same story for the MovieClip.
I have done another test, this time using SWC: both SWF and SWC can be added to libray with the FlashDevelop command “Add to library”, but it looks like it is doing anything. I tried to load it adding
Assets.hx:475: [Assets] There is no String asset with an ID of "libraries/library.json"
Assets.hx:800: [Assets] There is no asset library named "library"
Yep, so first step, the link to the SWF haxelib is totally needed.
The “preload” attribute means you can use your SWF stuff right away, rather than calling Assets.loadLibrary ("library", onLoaded); first, which is handy
SWC is not currently supported, but an SWC is actually a ZIP – inside is an XML file and an SWF file, so as a workaround (for now) you can just publish and use the SWF from Flash, or you can extract a SWF out of a SWC manually if you need to
I read a few old articles and posts saying it was supported time ago… has it been removed?
Yes, I know SWCs are zip, ok, I can stay with SWF, but what kind of contents are supported when targeting HTML5? Static images or animations too? NyanCat MovieClip is displayed as a static image, FLVs are not supported, so what can I use SWFs for?
MovieClip animation has not been added to SWFLite yet (but could be brought from type “swf” to “swflite” if someone wants to help). The biggest use-case for SWFs right now is for pulling in layout content, like the menu screen, game interface, etc.
I would look at using a spritesheet/tilesheet solution if you have to get a lot of animation, right now
Do you mean to generate spritesheets, or to use them at runtime? There’s a spritesheet library on haxelib, there are tilelayer and other libraries and there might be support baked into game frameworks, such as HaxeFlixel or HaxePunk (and others)
To use them at runtime: to generate them I can export animation from CS6 or later, or TexturePacker etc…
About the frameworks, how is the situation with HaXeFlixel, HaXePunk, HaXeStarling etc? Is there an updated list of the available framework portings with their current state?
HaxeFlixel then HaxePunk are probably the most mature (and most-used) OpenFL based game frameworks. There is also Stencyl (targeting a different audience). There are other frameworks that are not used as often that may well work really well. I don’t know if there is a full stable port of Starling, but I would like to see that long-term – it’s a bit redundant (OpenFL is the Flash API over hardware renderered APIs) but helps with porting code. Only recently did we add Stage3D compatibility into OpenFL, which will continue to improve over time. It’s being used well by Away3D so far
Hi all
I have recently started playing around with swf.
I am not good with Adobe flash.
so yeah I dared… I made a small thing in haxe using FlashDevelop, targetted flash
and tadam I got my own .swf
in NyanCat example, you used Assets.getMovieClip("library:NyanCatAnimation");
I saw in FlashDevelop that the swf file is represented like this:
so I concluded NyanCatAnimation in “library:NyanCatAnimation” is the unique class of library.swf
And I thought cool I’ll do the same with the swf I made earlier from openfl.
I browsed throught my swf and this is what I saw:
and now I am completly lost.
I tried my luck with some of the classes I found among the list:
“Main”, “ApplicationMain” but was giving an error saying there’s no asset with an ID of MySwf:Main or MySwf:ApplicationMain.
“boot_35a0” it didn’t give an error but nothing was showing.
So now my question is, we can’t use swf made with openfl for an openfl project, can we?
If you’re on the Flash target, you can use a Loader to load another SWF. However, the SWF library is designed primarily for using assets packed into a SWF, so it does not carry any of the code over. This means that the class name you reference must be a MovieClip, SimpleButton, etc