Notes
Notes: General AS3 Tips
This is the final bit migrated from the Labs Wiki. This is just a short list of quick and easy tips to keep in mind when programming AS3.
- Do not use Objects, if you know which properties will be finally involved. Write a class for it; AS3 seems to register a memory space for them and will have faster access.
- Keep variable names as short as possible. While this doesn’t help a lot, it does help a little.
- Items of 0 alpha are still draw on the stage. Use visible = false to save CPU cycles
Notes: Math Optimizations
This is some more stuff migrated from the Labs Wiki. Below is just some aggregated tips and tricks I’ve found on other blogs or websites.
Extract Colors
Not really an optimization per se, but just how to extract color values.
//24bit var color:uint = 0x336699; var r:uint = color >> 16; var g:uint = color >> 8 & 0xFF; var b:uint = color & 0xFF; //32bit var color:uint = 0xff336699; var a:uint = color >>> 24; var r:uint = color >>> 16 & 0xFF; var g:uint = color >>> 8 & 0xFF; var b:uint = color & 0xFF;
Notes: Flash 9 Gotchas/Bugs
This is also migrated over from labs. This was a list of bugs and gotchas I’ve run into over during my time as a Flash developer. I’m sure the best play to look would be Adobe’s Bug tracker but it doesn’t hurt to have a concise list of things to watch out for.
Bugs/ Gotches
-
Bug
wmode="opaque"or"transparent"disablesKeyDownactions (not true in 9,0,60,0 beta) and disablesMouseWheelactions
Notes: Cross-Domain Policy
Below is the structure of the cross-domain policy and all the allowed values. The majority of the content was aggregated from Adobe’s page on cross-domain policies.
A cross-domain policy file is an XML document that allows a web client to handle data across multiple domains. You will usually need one if the SWF is playing on Domain A and the files are located on Domain B. Policy files grant read access to data as well as permit a client to include custom headers in cross-domain requests. A policy file is also used when using Sockets during socket-based connections.
The most common location for a policy file on a server is in the root directory of a domain with the filename crossdomain.xml (e.g. http://example.com/crossdomain.xml)—the default location that clients check when a policy file is required. Policy files saved this way are known as master policy files. The following is an example of a typical, permissive URL (i.e. non-socket) master policy file:
Example
<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <site-control permitted-cross-domain-policies="master-only"/> <allow-access-from domain="*"/> <allow-http-request-headers-from domain="*" headers="SOAPAction"/> </cross-domain-policy>
Notes: Loop/Statement Labels
Below are some notes from Christian Cantrell’s blog that I just wanted to aggregate onto my site for my own personal reference. I am not claiming this as my own content, but I’ve been meaning to add this to my notes and Christian did a great job explaining it.
Labels are a relatively unknown feature in AS3. Basically what it does is give an ID to a specific loop or statement. So when you call break or continue, you can specify WHICH loop to break or continue.
› Continue reading