‘with’ Statement Performance
Whilst reading a post from the Learning ActionScript 3.0 blog I noticed a tip which dealt with use of the ‘with’ statement. This reminded me of a post which I published on the old version of this site.
The ‘with’ statement can be used in your code to help make the code easier to read. Examples of how useful it can be can be found in the documentation.
I’ve never actually used the ‘with’ statement in any of my personal projects however after reading an article which mentioned it I decided to see whether or not there was a speed increase to be gained from using the ‘with’ statement. I created a small test which attempts to determine this which you can try out below.
How to use the test is self explanatory. When you start a test, 500 MovieClips are created. On every frame, the position, dimensions, alpha and rotation of each MovieClip is altered to a random value. You can view how long it takes for each frame to render in the dPanel by pressing the grave accent key (the ‘dPanel’ is a class I have created for debug purposes - I will make it available in the near future).
I presumed that the ‘with’ statement would be faster because there are less reference calls but you can see for yourself that the ‘with’ statement is actually a little slower.
Flash Alert Dialog Class
I actually built an Alert class a long time ago and have used it very frequently for my own personal use. I recently received some impetus to update it after finding out that one person actually copied my class and then passed it off as their own on the flashgods forum (It’s now been taken down).
And so I’ve now updated my Flash Alert Dialog class, a class which enables you to display a modal dialog message box with AS3 very much like the built in Alert for Flex. Here is an example showing how the Alert can be used:
Using the Alert class is very easy. After importing the class you simply need to ‘initialise’ the class with a call to the function Alert.init() passing as a parameter a reference to the stage like so:
import com.dVyper.utils.Alert; Alert.init(stage); |
Once this function has been called you can call Alert.show() to display a modal prompt at any time and from any class file.
What this means, is that you can use the Alert class extensively throughout your project, and instead of having to comment out all of the lines which have a call to Alert.show() (which is what you have to do if you use for example the trace() command), you simply have to comment out the call to Alert.init(). All calls to Alert.show() are ignored if Alert.init() is not called.
Here is more information on how you can use the Alert class:
Click here to continue reading
Fatal Breakout on Flashgamelicense
I’ve submitted Fatal Breakout to Flashgamelicense. Hopefully I’ll be able to get some constructive feedback on the game while I put together some music and get some graphics for the game.
You can view it either on flashgamelicense or here.
Hello World!
Welcome to the new and improved Fatal Exception Studios! Now housed in a different hoster and with a blog powered by Wordpress 2.7!
After a careless mistake by myself, all of the database data containing previous blog posts and comments (and spam) have been lost. Nooo! All of the explanations of my experiments and classes, gone! But all was not lost; thanks to the ultimateness that is Google, all of the important posts were still alive in the Google cache! I was able to get all of the text I needed from the relevent posts with no problems!
Instead of trying to repost them all I have instead created an ‘Articles’ section of the website which will house all of the past and future experiments and classes that I have created. I’ll be posting to that section as time progresses. The first one which deals with graphics rendering has already been made available.
Hopefully my new design will be visually appealing - I hope you enjoy the site!