Ming and version numbers

May 3, 2006

Ming has an obscure and not very well-documented function Ming_useSWFVersion() which can come in handy. In Ming 0.4.0, it defaults to Flash 5 SWF. This means if you want to add Flash 6+ functionality to your created SWF (e.g. you want to incorporate an onRollOver event function on an SWFSprite) from externally, it will not react. However, you can use the above function to set the version, e.g. (in Python, as always):

import ming

However, this creates what surely must be a bug. If you try adding code to a SWFSprite that uses the keyword this then the Ming ActionScript compiler throws an error, saying it does not recognise it. For me, this code does not work:

my_mc.add(SWFAction("this.onRelease = function() { trace('foo'); };"))

Luckily, I think you can miss out the this without too much worry, as Flash’s scoping usually picks up local variables first. If you really need it, you can always use eval to do:

  "t = eval('this'); t.onRelease = function() { trace('foo'); };"

and this compiles satisfactorily.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: