@LucaTomaino11 Welp back in the day I used Dreamweaver, I used PHPed before, and Notepad++, but now I (try to) use sublime for everything. (Today)

@gritfish I have it set to HTML, tried disabling stuff. I type a > and it brings up auto complete which messes with me pressing enter :I (Today)

@___discovery @NoelFB @_andrio Hm, my issue is that it brings up the autocomplete window after I type a > which goes crazy if I hit enter. (Today)

I must be doing wrong but good god sublime text is terrible for editing html. It keeps doing autocomplete after a ">" which is a disaster. (Today)

@MANvsGAME I don't do calls at all. Something about that seems sketchy or scammy to me too. (Today)

@SleepyTearyEyed @SteveSwink @djcoreynolan @Livelyivy @stopmotioner Yeah Tim actually said he's good, so go with @stopmotioner ;D (Today)

@SleepyTearyEyed Hey I think @timwinsky is in the market for a pass. (Today)

@TheCasanovaGirl what is this magical place where someone is walkin around with an otter! (Today)

@TheCasanovaGirl t.co/L5tfC9WzFz (Yesterday)

@TheCasanovaGirl AAUAUGHAIghdsiash430th048hahdhfadfhioahsf (Yesterday)

@RobaatoX <3 <3 you reminded me that I need to finish this game ASAP! (Yesterday)

@JesusCripe I am making a bunch of stuff but all of which isn't really ready for release yet ;_; Hopefully something this year though! (3 days ago)

.@Livelyivy and her team worked their BUTTS OFF on Gravity Ghost t.co/ybroOoadqw get it so they can afford butt reattachment surgery (3 days ago)

RT @Livelyivy: GRAVITY GHOST IS LAUNCHED I LOVE YOU ALL! t.co/69UeajfNCF (3 days ago)

@arcv2 it's hopefully a tool that can be used on any Google sheet. I'll release it after I polish it a tiny bit more. (4 days ago)

@Silvanis_s I'm not sure, I'm using the google docs json feeds and I think those freak out over empty cells right now. Will test later! (4 days ago)

@Silvanis_s you mean like an empty cell in the sheet? (4 days ago)

Spent the weekend making a thing that takes somethin like this: t.co/KpA4JFMBcp and turns it into this: t.co/5yRHuaLSqZ :D (4 days ago)

@KnechtsLevel @mguniverse I'll make it out tonight, probably around 6ish. (4 days ago)

@mguniverse maaaybe I don't know for sure (4 days ago)

follow
search

2013 - 2 - 5 / 7:16 am / tools

Asset Class Generator for Actionscript 3

Asset Class Generator for Actionscript 3

The Reason
As I set forth to try and jam out the rest of this metroidvania game before GDC 2013, I've been trying to think of ways to make content generation as fast as possible. One of the big hurdles that I run into with AS3 when making a lot of content is constantly having to embed assets into the code. FlashDevelop makes this incredibly easy though. Right click a file, click generate embed, and there you go. However this still takes a lot of time when I'm talking about a game that is going to have nearly a hundred level files and who knows how many image assets, and I'm constantly switching assets around.

After a quick consultation with Twitter I got a crash course on Python and spent a couple hours making assetGenerator.py.

Download!
Download assetGenerator.py 1.0, along with an example project right here. You can also just view the code. All the files in the example project are blank files just to use as an example, and keep the download size tiny. Here's an example of the code it spits out. If you want to know more, then read the rest of the post!

How it Works
First if you don't have Python installed on your computer then you'll need to grab it and install it from here.

Place assetGenerator.py in the base folder of your AS3 project. Open up the file and change the ASSET_FOLDER to point toward the folder with all of your stuff in it. Image files, sound files, levels, etc.

Change your OUTPUT_FILE to whatever you want the resulting AS3 class to be. I usually just have this be an "Assets.as" class in one of my main folders inside src.

Set up your EXTENSIONS, PREFIXES, and EXCLUDES. By default the script will hunt down any files with the extensions png, mp3, oel, and ttf. It will then take those files and spit out embeds from them, and the name of each embed class is determined by the corresponding entry in PREFIXES. So for example, "batman.png" will come out as "IMG_BATMAN:Class" in the .as file.

When using EXCLUDES you should specify the name of any folder you don't want the script to parse. For me this usually means any folder that I store psd files in, or any folder that I store GraphicsGale files in. I usually have a lot of scrap and sketch png files in those folders and I don't want those in the project.

After all that, you're ready to just double click assetGenerator.py and run it! Be careful though, as this script doesn't really care if it stomps over a file. The file should be ready to execute in the example in the download if you want to just check out how it works before running it on your own stuff.

It's Not Perfect
I'm sure there are a bunch of issues that will come up with this, and if any do pop up then just let me know. If you want to modify this script in any way please feel free to do so!

One thing to note is that this script follows my current coding style. I prefer to have all of my embedded assets in one big static class so I can easily reference them as "Assets.IMG_PLAYER" or "Assets.IMG_POOP" or whatever. If this isn't your style, then this script isn't going to do much for you without some pretty heavy modifications.

Also I am not responsible if this script blows up your computer or whatever. I hope it comes in handy for some people!

5 Comments
Avatar

2013 - 2 - 5 9:05 AM

NemoStein

I've made one too, in PHP, but I took another route, however.
Instead of having one Assets.as3 with all embeds inside I generate one class per asset.
This class extends the base type of the asset (Bitmap for images, Sound for audio, XML for XMLs, Font for fonts and BiteArray for all the rest, including text files).
The [Embed] tag occurs in class level, so the class itself became the asset.

This means tree things:
1st - If I forget some unused asset in the assets folder it won't be compiled with the app.
2nd - FlashDevelop will highlight the asset as a class (default to blue) instead of some simple identifier (default to black), so it's easy to see it.
3rd - As the asset is a class, not a property of type Class, the auto completion of FD is MUCH better, since if you write "new MyAsset()" and press ctrl+shift+1 it will be completed to "var myAsset:MyAsset = new MyAsset();" instead of "var myAsset:Class = new MyAsset();"

My biggest issue is that my tool was made in PHP, so I need a server to run, so I'll port it into AIR someday.
If you want to, I can send you my current code. ;D

Avatar

2013 - 2 - 5 9:39 AM

Kyle

Huh, that sounds pretty interesting. Like I said, this script just goes with my style which is just having a giant class full of static variables. Feel free to post a link or send me a link or whatever, I'd love to take a look.

Avatar

2013 - 2 - 5 10:39 AM

NemoStein

Well, here it goes:
https://dl.dropbox.com/u/25066924/Static/Wild/AS3.AssetsParser.zip

There is .php file that processes any folder you pass through the http var "path" (e.g.: http://localhost/assetParser/index.php?path=C:\workspace\project\assets\)

There is a template.as file too, that guides the file generation.

All files will be created in the same folder that the asset lies, the package of the generated class relies on the folder structure inside the asset folder and the asset name is always prefixes with "Asset"

Avatar

2013 - 3 - 14 6:32 AM

NemoStein

Kyle,

Someone at FlashDevelop forum made this incredible plugin that just killed my PHP tool as it is far easier to use.
If you use FlashDevelop too, check it out.

http://www.flashdevelop.org/community/viewtopic.php?f=4&t=10567

Avatar

2013 - 5 - 11 1:08 AM

Kyle

Wow awesome! Didn't even notice a new comment until now, haha. I should hook up an email alert when a comment is posted... ;p

Avatar

Post your comment!

POST COMMENT

about

About

Hi there, my name is Kyle, and I'm a kid disguised as a grown up. I'm making video games and living the indie game developer life in Tempe, Arizona. Here you will find my thoughts, games, websites, doodles, and other stuff like that. I worked on Snapshot, Offspring Fling, and a whole bunch of other games. I also created and maintain Otter, a 2d game making framework. If you want to get a hold of me use the form on the bottom of the page, leave a comment, or just tweet at me. I try to post three times a week. Thanks for stoppin' by! You're the coolest.

facebook

videos

Do you want to make a Let's Play of one of my games, or a just a video featuring footage of my games? You have my full permission to do so! Even if you are monetizing your videos, you still have my full permission to use any footage from any of my games. Go for it!

contact

Your message has been sent! Thanks :)
SEND MESSAGE