Flash development for C programmers

Well, for C programmers using (Ubuntu) GNU/Linux… similar instructions may apply for Windows development.

Install the ActionScript2 compiler (mtasc):

sudo aptitude install mtasc

Write an ActionScript2 program (in a file called “main.as”):

class App
{
	static function main(mc)
	{	
		_root.createTextField("tf",0,0,0,320, 240);
 
		_root.onMouseMove = function()
		{
			_root.tf.text = "X: " + _root._xmouse + "\nY: " + _root._ymouse;
		}
	} 
}

Create a makefile:

CC = mtasc
CFLAGS = -main -header 320:240:20:666666
DEBUG = -v
DEPS = main.as
 
default: example
 
example:
	$(CC) $(CFLAGS) -swf example.swf $(DEPS)
 
clean:
	rm -f example.swf

Run make:

make

(Hmmm, it was probably a little gratuitous making that command explicit here…)

Embed flash applet in a webpage using the following html embed snippet:

<object width="320" height="240">
<param name="movie" value="example.swf">
<embed src="example.swf" width="320" height="240">
</embed>
</object>

Final product (mouse-over for action… well… “not inaction”):

Next steps: swfmill and Inkscape… maybe haxe.

Leave a Reply

Your email address will not be published. Required fields are marked *