Shootorials #0, #1, and #2 with Free Tools - mtasc and swfmill page 2

84 posts

Flag Post

Thanks! This was really helpful.

One quick note on the depth issue. It’s not really a bug at all. Presumably, Adobe’s flash treats the depth as a signed integer; thus, if your ship has a depth of 1, then the background can have a depth of -5.

swfmill treats the depth as an unsigned integer (ranging from 0 to 65535). In fact, if you set the ship depth to 1 and the background depth to 0, it works perfectly. However, if you later want to add any other objects, they will necessarily go above the ship and the background. Really, any number between 0 and 65535 is fine, as long as you keep them enough toward the center of the range so that you have flexibility to add things further in the foreground or further in the background.

 
Flag Post

One more note—by fixing the registration point issue, our ship actually starts partially off the screen. We can fix this by adding these two lines into the onLoad() function in Ship.as:

_x = 39.5; _y = 18.5;

This will account for the fact that the ship graphic is now centered at (0,0) and start the ship fully on the screen.

 
Flag Post

When you set the depth to 0 in Flash IDE → the real depth in the SWF is 0
When you set the depth to -100 in Flash IDE → the real depth in the SWF is -100

When you set the depth to 0 in swfmill → the real depth in the SWF is -65534
When you set the depth to -100 in swfmill → ??? Maybe it breaks, I don’t know.

swfmill could easily turn the “0” you provide to an actual unsigned int 0. And it should. The only reason I discovered this problem was that in some early versions of the code, I created the background in ActionScript (using depth 0) and placed the ship in swfmill (using depth 1). The ship ended up UNDERNEATH the background. How could that possibly not be called a bug? ;p

Also, I’m hoping the next shootorials deal with putting the ship in the middle of the screen. In all the shootorials so far (#0, #1, #2, and my next guide which I’ve already written which hopefully pre-empts #3 and #4) I haven’t needed to make changes to the .as files as specified by the flash Shootorials.

 
Flag Post

I’m having some real trouble getting swfmill to compile. Any tips? I’m running ArchLinux on i686. The configure script works, but when I type ‘make’ it ends up with errors like:
swft_css.cpp:197: error: ‘strcmp’ was not declared in this scope

and so on…

 
Flag Post

jimay333: That’s a specific issue with GCC 4.3’s increased strictness. You should be able to solve it by inserting “#include <cstring>” under the other includes in src/SWF.sh, src/SWFReader.h, and src/swft/swft.h

If you get any other problems, check here. In particular, many of the ‘not declared in this scope’ issues should be fixed by inserting the includes for the entries in the table in the section “Header dependency cleanup” in the three files I mentioned.

If you get really stuck, try compiling the current svn trunk. I did that a couple of days ago with gcc-4.3.2 and it works perfectly well.

 
Flag Post

explodingferret: I have no prior flash experience whatsoever, and I only have the command line tools so no graphical debugger to test more thoroughly, so my comments are just based on other programming knowledge and the results I get when I run the compiled flash. That said…

As far as positioning the ship initially, if you center the graphic itself about the registration point (by placing the ship.png at offset x=-39.5 and y=-18.5), then you should be able to position the re-centered ship instance at the top left corner by simply placing the particular instance at offset x=39.5 and y=18.5. That is, change the place tag for the ship instance in the xml file to:

<place />

Similarly, we could start the ship centered by setting x=300 and y=150, since our flash is 600×300 and the graphic is already centered. Thus, the .as files can be preserved. Any problems this might create?

As for the depth values in swfmill, swfmill is smart enough to convert values outside the accepted range into something acceptable, so trying to set depth=-100 won’t break it. For the following depth values, this is what you get:

ship depth=1, background depth=0: ship is on top
ship depth=0, background depth=-1: background is on top.
ship depth=0, background depth=-100: background still on top.
ship depth=-1, background depth=-2: ship is on top (so numbers less than 0 wrap around)
ship depth=65535, background depth=65534: ship is on top
ship depth=65535, background depth=0: ship is on top
ship depth=65536, background depth=65535: background is on top (so valid range is 0-65535, with 0 being minimum and 65535 being maximum)

I’m not sure why swfmill depth=0 converts to real depth=-65534. Any clue what swfmill depth=65535 really is in the SWF? It’s possible they convert the depths to a real depth value between -65534 and 1 to use the full range, but that’s a pretty bizarre choice.

 
Flag Post

Whoops, my place tag didn’t come out. Should have been:
place id=“Ship” name=“ship” depth=“65535” x=“39.5” y=“18.5”

 
Flag Post

Aghannor: 65535 becomes 1 in the SWF. Looking at your other tests, it looks like -1 becomes the maximum bound of a uint.

The reason I haven’t set the ship to be centred or in the top left corner or anywhere special in the XML is because, if you look at the finished AS2 Ship.as, the centring code is in there. So, at some point hopefully the Shootorials will also put that code in Ship.as. :)

 
Flag Post

Got it then—swfmill sets the actual depth as -65534 + depth. If you try ship depth = 65535 and background = -2, the ship is still on top. Background = -1 places the ship and background on the same layer, because the background is overwritten by the ship. So the values going into swfmill are within an unsigned int range, and for whatever reason are shifted to be within the range -65534 to 1 in the SWF.

 
Flag Post

explodingferret: worked like a charm thanks. I knew it had something to do with the includes, but I had checked those files and found ‘#include <string>’ so I didn’t think that was the problem.

Thanks again.

 
Flag Post

I also recommend checking out Project Sprout that makes acquiring the compilation tools and bootstrapping a new project a simpler affair, as well as providing a robust testing framework for your game.

 
Flag Post

Any ideas on good free tools that can handle AS3? I have spent a large part of the last 12 hours trying to find a relatively simple solution without much luck. The Flex SDK uses its own special MXML, which is really not worth the effort to learn, seeing as it’s useless anywhere. You can use swfmill with an AS3 compiler (like mxmlc), but it doesn’t seem to actually work. I guess you have to use some other method to make the objects placed in the xml accessible to the .as script.

I found a decent tutorial for creating AS3-based flash exclusively from .as files (no .xml or .mxml necessary), but the Flex SDK compiler seems to be incapable of compiling multiple .as files into a single .swf output, and I’m not about to make an entire application in a single giant .as file. Thoughts? I’m getting pretty fed up spending hours trying to get a working compiler/linker just so I can reproduce Shootorial 1 using AS3.

 
Flag Post

Hopefully if your main class refers to other classes in the same directory, they’ll be loaded. I haven’t tried flex sdk so I don’t know for sure, but you may also need import lines for your other class files just inside the package scope of your main file.

EDIT: bah, I’ll download it and try it. Two eyes are better than one. :)

 
Flag Post

Well, you can set an include path in the compiler options, so it’s possible that if I set the game path in there that it will automatically compile any other .as files with classes that are used by the target .as script.

The issue I had before was that the mxmlc compiler throws an error if I try to feed it multiple .as files, so even if I were to import my other class files within the .as that I’m compiling, I’d still need to compile all those other .as files separately and link them or they won’t be found when I try to run the SWF (I think… didn’t actually try it, but it seems common sense). But if the include path in the compiler set-up functions as above, that should address that issue.

I deleted the flex sdk in a fit of rage, so I’ll have to try that later :p

 
Flag Post

Eurgh, flex sdk doesn’t work with gcj java, and I’m not installing a new java on someone else’s laptop. I’ll have to wait until my laptop is fixed.

 
Flag Post

We have used a bunch of online flash animation and game creation tutorials in our high school animation class. The shootorials are by far the best laid out and easiest to follow. Keep up the great work!!

 
Flag Post

does it work with python?

 
Flag Post

Please explain? As far as I know none of swfmill, mtasc, flash, or any of the other programs mentioned have anything to do with python at all. Or anything specifically not to do with it…

 
Flag Post

I dont get it is this free? And I would like to create a game like but dont know what some of that stuff is like “msctc” and all that i am not sure can someone explain for me please.
Thanks Maloney.

 
Flag Post

www.python.org

I’m new to it and I’m not completely sure how it works but I can’t seem to get swfmill or mtasc to work (not sure how to set environment variables) so I ofund it and I’m trying to find something to work.

 
Flag Post

pyroplushy: I’m still confused about what you mean. I’m aware that Python is a programming language, but it’s a totally different one from actionscript and doesn’t have anything to do with mtasc or swfmill or flash or anything. You may as well have asked me:

does it work with BBC Micro BASIC?

It won’t work with Python because you don’t compile python into SWF. You compile ActionScript into SWF. mtasc and swfmill are just ways to take that ActionScript you wrote (in a text editor) and some extra XML stuff you also write in a text editor (still not python) and turn them into SWF.

Maloney123: mtasc (Note: not “msctc”) and swfmill are programs. You get them off the internet for free, and install them, and then use them in this guide. Look at the hyperlinks in the first post to find them.

 
Flag Post

Ok thanks :D

 
Flag Post

Aghannor: Try FlashDevelop for AS3. I’m using the version 3 beta, and it’s letting me fight my way through the tutorials. It uses the Flex SDK to do the actual compilation, but it’s mostly transparent. For some odd reason, Flex enforces one class per .as file, and embedding assets into the project is a bit of a headache, but otherwise, it works. I’ve finished up through Shootorial #3 using it, though it’s been tricky at times.

 
Flag Post

Hey explodingferret! Question my swfmill.exe doesn’t want to create Shoot.swf. When I run Build.bat, here’s some of the gobbligook:

..\mtasc-1.14\mtasc.exe *.as -version 8 -wimp -swf Classes.swf -header 1:1:30
Ship.as:6: characters 0-8 : parse error Unexpected function

..\swfmill-0.2.12-win32\swfmill.exe simple Shoot.xml Shoot.swf
runtime error: element apply-templates
swft:document() : failed to read file ‘Classes.swf’
runtime error: element apply-templates

ERROR: transformation failed

Any ideas for a newb like myself? thanks.

 
Flag Post

ikeusa: Swfmill’s only failing because mtasc failed to create Classes.swf. It looks like you’ve got a problem in Ship.as around line 6 or so. Make sure that you didn’t leave out a semi-colon or forget a right parenthesis, right brace, or closing quotation mark. It’s hard to tell exactly, but something like that is often the culprit when the compiler has trouble parsing your code.