Asset library and pure Haxe preloader tool
After KukkerMan's idea we have started a Haxe/neko project aiming to be able to assemble flash9+ resource libraries. The tool will be easily compilable on both Linux and Windows (and supposedly Mac?) as it is written for the nekovm target with as minimal external library dependencies as possible.People will also be able to extend it via plugins to support importing their favourite formats into the library swf. So far we use it with success for importing png, jpg, alpha-masked jpeg images, binary data and mp3 sound into the asset library. As it turned out, the since far sought pure Haxe-based preloading is also possible via the tool. Read on for some insight!
(Edit: Don't forget to check out our latest article Preloading with Haxe and SamHaxe on the topic!)
KukkerMan does a nice work implementing the modular import system: The asset library is described with an xml file, something like swfmill's simple format. However, a separate configuration xml file describes which tags are handled by which import modules. For example, the image tag is currently handled by our default Image plugin, but you could easily change that in the configuration file. (By the way, KukkerMan had hard time trial-and-erroring how to use the poorly documented ImageMagick library, and is now considering to throw the whole code into trash and restart with a better library :)
About preloading with Haxe: I implemeted the Sound import module, currently with mp3 support and more to come. For that, the hxformat lib was extended with mp3 support (more to come of course). When testing the sound import, placing the DefineSound swf tag on the second frame of the asset lib made the flashplayer cry out loud. It had a SymbolClass exported. After experimenting, it turned out that flash requires (? correct me, I'm not an AVM2 insider) an AS3 class definition for resources with a SymbolClass.
But you can say: "Hey, I use an asset lib with Haxe and I don't write class definitions for my assets!" Well, that works because Haxe generates the class stubs for you if this is the case. "Ok, but then why did you get that error?" That happened because Haxe only generates these class stubs for resources on the first frame of the asset lib.
So basically if you can generate class stubs for those resources, you can put all your heavy assets on the first second frame, wait with Haxe code for the whole file to load (possibly displaying preloader gfx), and continue executing rest of the code once the whole file (or at least the required frames) are ready. How to generate class stubs?
- You can do that by hand, creating simple class definitions with a constructor calling super(), with Haxe. The stubs will be on frame 1, but they don't eat up much space.
- Or you can generate an AS3 code block along with the asset onto the frame it resides (frame 2 currently). I tried this and seems to work nice (not sure about generating a code block for frame1 would not collide with Haxe, I will have to research this later).
// ctx is the format.abc.Context
var cl = ctx.beginClass(_name, true);
cl.superclass = ctx.type("flash.media.Sound");
ctx.endSubClass();
ctx.finalize();
Here you may spot two differences from the standard lib. First, beginClass() has a second true parameter. With this I tell it to call the superclass constructor, resulting in the following code inside the method:
...
beginFunction([],null);
var cst = curFunction.f.type;
curFunction.f.maxStack=1;
if (callsuper) { // this block was added
op(OThis);
op(OConstructSuper(0));
}
op(ORetVoid);
endFunction();
...
Also, the endSubClass() method was added with the minor difference from endClass() that it registers the class name as inheriting from the proper superclass. This solution is not a general one, but is a good starting point for now.
As a bottom line, this tool would prove to be useful and is an interesting challenge, so I hope that we are able to have an initial release in some weeks time. In the meanwhile (or during the meanwhile, Brian? :) you can try to guess the name of the tool, you get three hints for this:
- Assets are not only important for flash developers, but also for whom?
- Let's hope that this friendly tool won't inform on you to the FBI ;)
- ???
Comments
Comment by Matus, on 09.07.16. 08:58
Cool news!!!
(btw isn’t there a typo? (first instead of second) you can put all your heavy assets on the first frame)
Comment by KukkerMan, on 09.07.22. 00:35
You’re absolutely right. It doesn’t make any sense to put heavy assets on the first frame and use a preloader anyway. :)
Typo corrected.
Comment by edA-qa mort-ora-y, () (URL) on 09.08.01. 18:34
Perhaps it might help you, the DHLIB has a Ruby script which reads a swfmill resource.xml file and produces the haXe definitions for all of the contained resources.
Comment by [ron], (URL) on 09.08.01. 23:51
Before we began writing this tool, we had a custom resource xml format, which we transformed into swfmill xml and haxe class definitions. Now the tool is able to generate proper as3 class definitions for resources into the asset lib itself. However what you suggest is a nice feature, and we may add support for it in an upcoming version (maybe not in 1.0, because KukkerMan is already bashing my head for incorporating too many stuff into the initial release – he doesn’t want the asset tool to be the second Duke Nukem Forever :)
Comment by edA-qa mort-ora-y, () (URL) on 09.08.02. 10:07
Alright, sounds reasonable. If you do need feel free to just take it from the DHLIB package on my site — it is just a simply Ruby script.
Let me know when you have a working first version and I can test it out — I have a project that needs it and have no interest installing the adobe tools.
Comment by [ron], () (URL) on 09.08.02. 13:09
We would like to based the tool with as few external dependencies as possible, so Ruby is no-go for now – but I’m sure that we will be able to manage writing out haxe class definitions ;)
Right now we are waiting for format.swf modifications to be reviewed and maybe merged, and adding the finishing touches in the meanwhile. I hope we can make a test release in one or two weeks.
Comment by Martin Quinson, (URL) on 09.08.12. 23:40
An Haxe asset handling solution is what I really need to get started with the toolset, so your work is more than welcomed.
However, I’m still unsure whether it will be a flash-only solution or whether it will be usable for the neko and cpp backends too. I was thinking of doing something similar to SuperPackMe in Haxe (transcoding the images to hexa strings at compilation time, embeeding the strings within the app and decoding them at run time).
What are your plans? Did I miss something obvious?
Comment by [KukkerMan], () on 09.08.13. 22:16
It’s a flash resource assembly tool so it’s output is an SWF file. It’s based on format.swf haXe library and runs on neko VM.
Comment by Martin Quinson, (URL) on 09.08.13. 22:31
I understood that your primary target was the flash backend of haxe, and that the tool itself was on the command line with neko. But I wanted to know whether your solution would be usable for the other backends too. Do you think it’ll be usable as is provided that ? Do you have any plans to increase the target backend? Any hints about how to do so if I find the time to help?
Comment by [KukkerMan], () on 09.08.15. 11:58
Ah I think I finally get it. :-) Well, we’re using neko mostly for file system access and loading neko primitives from .ndll files. It can easily be ported to cpp target for example. We’ll think about it.
Comment by [KukkerMan], () (URL) on 09.08.27. 19:45
SamHaXe (yes, that’s its name) is now available for testing. You can download it from here: http://mindless-labs.dyndns.org/trac/sam..
Comment by cheap moncler jackets, () (URL) on 11.08.13. 12:48
Obama announced last year, 3 million more troops to Afghanistan and will withdraw its troops next year, starting in July. But the troops, the Afghan security situation has not improved, more troops have little effect, many people leave the U.S. cheap moncler jacketsmilitary expressed doubts whether the schedule. Obama’s report released the same day a year since the U.S. government to make the surge the moncler outlet onlinemost comprehensive review of strategy. Obama stressed that the U.S. military is scheduled to begin in July 2011 handed over security responsibilities to the Afghan side.
Comment by belstaff outlet, () (URL) on 11.10.04. 03:47
At the network’s I wandered. By chance after your web site, read your post. Very fruitful,thank you for sharing. On the Internet, it is hard to find useful information. Thank you
Comment by burberry outlet, () (URL) on 11.10.04. 03:47
Its performance and its appearance are fascinated me, I was deeply attracted to it, it made me feel very fashionable. I believe that people who understand it will have the same feelings with me.
Comment by LV Bags, () (URL) on 11.10.08. 13:17
It is part of a flurry of activity over the weekend which will also see the French leader visit Berlin for talks with German Chancellor Angela Merkel.They will discuss how to help banks over-exposed to sovereign debt.The European Commission has urged member states to draft a bailout plan to restore confidence in banking.However, Germany and France, the eurozone’s dominant economic powers, have yet to agree on the way to proceed.On Friday, the international ratings agency Fitch downgraded the sovereign credit ratings of Italy and Spain, putting new pressure on two of the eurozone’s biggest economies.
Comment by Justin Bieber Shoes, () (URL) on 11.10.15. 08:45
Nice one! I did one of these myself.
Comment by nike air max 2011, (URL) on 11.10.19. 11:43
In regards to amazing jogging sneakers, the actual nike air max 2010 is probably the best obtainable. Your boot features significantly nicely and likewise it really is considered by way of really several to be just one using the substantially far better working athletic footwear round the sector. The actual mens air max 2009 is usually a wonderful running shoes. It really is very stylish, big, comfortable also to provides great effectiveness. This comfort and ease and ease total in the air max ninety current cannot always be discovered. Your boot matches and so properly, I have in no way worn a pair of footwear similar to this forward of at my existence.
Comment by coach outlet, () (URL) on 11.10.21. 06:57
coach outlet has a zippered closure and buckles for extra security. Shiny brass hardware, rounded leather handle, and an interior pocket. It also includes a limited edition Hawaii luggage tag and lock. With the great diversity of styles, patterns and sizes available nowadays, finding the right pieces to highlight your personality is quite important. Coach Outlet offers exactly what you want.
Comment by hermes birkin, () (URL) on 11.10.21. 11:52
Your bridesmaids will love the jewelry at the hermes birkin and they will look stunning wearing it at your wedding. You can have your bracelets made in any of the Swarovski colors. If you don’t see enough options, either call or tell us in the comments section at checkout how we can make yours perfect.This is a set of finely crafted hermes scarf.
Comment by coach outlet store online, () (URL) on 11.10.22. 03:39
If you have enough leisure time, you may go to the mall or go to the Coach franchised store to have a good look at varieties of coach outlet store online the diverse styles and rich colors of the purses with low cost will surely impress you a lot!
Comment by tods shoes, () (URL) on 11.10.26. 05:45
However, earnings might not be wasted. It must turn into utilized for (some) proper purposes. We youthful guys may possibly type the superb habit of not spending earnings utilizing the incorrect way.
Comment by TORY BURCH BOOTS, () (URL) on 11.10.27. 04:47
may possibly type the superb habit of not spending earnings utilizing the incorrect way.
Comment by coach purses, () (URL) on 11.10.29. 07:14
Coach is one of the most distinguished leather brand all over the world. You can find many wonderful cheap Coach Purses on our Coach Factory Stores
Comment by coach outlet store online, () (URL) on 11.10.29. 08:12
coach outlet store online has been voted by Hour Detroit magazine readers as the Best of Detroit in their 12th annual readers’poll. Coach Outlet Store is in part simply a response to consumer demand. Consumers accept the notion of the desirability of select consumer product brands and designer labels.
Comment by coach outlet, () (URL) on 11.10.29. 11:27
coach outlet has a zippered closure and buckles for extra security. Shiny brass hardware, rounded leather handle, and an interior pocket. It also includes a limited edition Hawaii luggage tag and lock. Here you can find the latest products in different kinds of coach outlet store online making best materials.They are leisure practical products in the new generations.
Comment by Louis Vuitton Outlet, () (URL) on 11.10.31. 03:35
Thanks for posting this useful information.
Comment by Gucci Outlet, (URL) on 11.10.31. 03:36
This blog is very necessary for us who are finding this topics for a long time.
Comment by tory burch flats sale, () (URL) on 11.11.04. 03:44
The article wrote very good-looking benefit, believe to be of great help to me later, finally thank the share
Comment by Moncler outlet, () (URL) on 11.11.04. 03:44
Start blogging by creating a new post. You can edit or delete me by clicking under the comments. You can also customize your sidebar by dragging in elements from the top bar.
Comment by Rosetta Stone, () (URL) on 11.11.04. 09:53
For example, the image tag is currently handled by our default Image plugin, but you could easily change that in Rosetta Stone the configuration file.
Comment by ghd hair outlet, () (URL) on 11.11.14. 06:59
Oh. Disappointing. Zou Jiming face inquiries by telling her. Thought it a gossip. ugg boots bailey button, Xiao Han is not in the chase Yin Xinhui?” With a word directly reached the revolutionary base areas. ghd outlet, but never seen her so comfortable smile. .
Comment by herve leger outlet, () (URL) on 11.11.14. 06:59
you talk about your views.”“ ugg boots bailey button, However he is not your standard three-point shot. Heart Hui Head said. 7 ghd outlet, She stared at him: ““The teacher did not have said herve leger.
Comment by ugg boots bailey button, () (URL) on 11.11.14. 07:00
Chemical examination paper out quite hard ugg boots bailey button, I’m also looking quite like it is the opposite. Yang Yu also saw two men for a while ghd outlet, he knew the girl before her at the same table
Comment by herve leger, () (URL) on 11.11.28. 07:23
Nice to be visiting your blog again Herve Leger, it has been months for me. Well this article that i’ve been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article Herve Leger Dresses. Thanks, great share.
Comment by louis vuitton outlet, () (URL) on 11.12.28. 07:45
We take burberry wallets outlet not for the purpose of expanding the war into Cambodia, but for the purpose of ending the war in Vietnam.zxj http://www.designerbagfactory.com/
Comment by Louis Vuitton Outlet, () (URL) on 11.12.31. 03:05
Thanks for a great time visiting your site. Today, http://www.louisvuittonprimeoutlet.com is a symbol of style and presence, especially for people.
Comment by Gucci Outlet, (URL) on 11.12.31. 03:10
Oh, I genuinely enjoyed it. My heart again boiling, http://www.gucciofficialoutlet.com was so wonderful and I like it! I hpe you can come to gucciofficialoutlet buy it.
Comment by uggs outlet, () (URL) on 12.01.02. 09:11
It’s good to see this information in your post, I was looking the same but there was not any proper resource, thanks now I have the link which I was looking for my research.
Comment by north face outlet, () (URL) on 12.01.03. 04:20
This is nice post , that display the signs for each state of the states , i hope to visit Texas so i can see the sign. http://www.nfmart.org
