AS3 Random Color


Creating a random color has a number of purposes, but mainly for me it creates pure randomness for either testing or beta development.
Here is a quick tip on how to generate a random color between black #000000 and white #FFFFFF.

Setting Width and Height in ActionScript Project

Something I’ve found little documentation on, is how to set the width and height in an ActionScript Project in Flash Builder. In an MXML project you have the tag with ‘width’ and ‘height’. You don’t have these options in your document class in an ActionScript Project.

In order to set the width and height, you need to add the [SWF] metadata just before the class definition. Within this you can add the width and height properties, along with several others.

[SWF (width="400", height="400")]

This is also how you would set the swf to be 100% for size if you like. Here is a list of all the properties.
(frameRate=”", height=”", heightPercent=”", pageTitle=”", scriptRecursionLimit=”", scriptTimeLimit=”", width=”", widthPercent=”")

AS3 Create an Array of Numbers From Min and Max

Here is a simple function in AS3 that returns an array of integers from a minimum and maximum. Let’s say you have an application that the user is required to input a range of numbers, with a minimum and maximum, and the application will take the entire range of those numbers and perform an operation on.

AS3 Random Number Between


Here’s another quick tip in AS3, how to get a random number between two numbers. This simple function takes two two numbers as parameters (a minimum number and a maximum number) and returns a random number between the two.

AS3 Custom Events Not Bubbling


Building custom events in your application is almost a must. I can’t remember the last time I build an application without some sort of custom events. When dispatching your custom events, sometimes you will want the event to only dispatch within the custom component, and sometimes it’s better to have the events bubble out to the main application and have the application then handle the event.

Powered by WordPress | Designed by: MMORPG Games | Thanks to Game Music, VPS Hosting and Shared Hosting