Flash

All posts tagged Flash

FDT supports special variables in the mxmlc compiler arguments when building a project, that allow you access to certain useful information.  Typically when you create a new project through FDT, you will get these two lines in the compiler arguments:

You can already see two variables being used here: {playerVersion} and {flexSDK}.  These variables are parsed before the arguments are sent to the mxmlc compiler, and would end up looking something like this:

Very useful!  So what variables are available then?  Unfortunately there does not seem to be any documentation about compiler argument variables, so I do not have a definitive list, but I do know of four:

  • {playerVersion} – The player version you selected when choosing the SDK for your flash project
  • {flexSDK} – The path to the selected flex SDK
  • {project} – The full path to the folder the project is located in
  • {locale} – The chosen locale (for example en_US)

I have not actually managed to get the {locale} variable to work, but I have seen it referenced in forums and in FDT bug reports, so I presume it at least works for some people.  There are a couple of variables that I would love to see added to that list that could be really useful, including the project name, swf filename and the name of the current build configuration.

Do you know of any other compiler argument variables that are available in FDT?  Please leave a comment if you do, and I will add them to the list.

Not everyone realizes it, but you can actually customize the context menu that appears when you right click a flash application in ActionScript 3.  You can add new items and you can even remove some of the existing items.  But lets get one thing out of the way first:

Can I remove or hide the Flash context menu?

The answer is no, you cannot.  There is no way to hide the context menu, and although you can remove some items like the print option, there is no way to hide the “Settings…” or “About Adobe Flash Player” items.  But lets go over what you can do.

Continue Reading

I recently ran into a quirk with the getBounds() and getRect() methods of DisplayObject, where the returned x and y coordinates would be extremely high (and incorrect) values.  This occurs when the DisplayObject is empty, using the following code:

Executing the above code gives the following result:

What?!  Where are these crazy numbers coming from?  Since childObject was added as a child to parentObject without having its x or y coordinates modified, you would expect that x and y would be 0, but instead we get the unexpected result of 6710886.4!  It is worth noting that if you try to get the bounds of an empty object using itself as the argument to getBounds(), x and y return 0 as expected.  Now if we were to add anything that has a width and height to childObject, say a vector rectangle or a bitmap, the resulting x and y values are 0 as expected.

I am not totally sure what is going on here, but if you need to get the bounds of a child DisplayObject, you may want to add a check to make sure that childObject.numChildren is greater than 0 first.