What’s in your Utils?

The Utils class is a collection of simple methods that carry out small tasks such as data converting and mathematical calculations. They are very general (and usually static) methods and therefore reusable in multiple projects. Actionscript has an inbuilt utils package (flash.utils).  What’s in your own Utils? Or are you using some other Utils package?

My Utils class includes i.a.:

getAsset – gets a class even from externally loaded SWF-files

convertClassToObject – converts a class into an object by collecting all properties that are readable and writable. Appends also new values if assigned and returns data types of all properties. This method uses the flash.utils.describeType method to convert classes to XML objects. Read my praise to this method!

cloneBitmap – clones a bitmap

HEXtoARGB & ARBGtoHEX – these methods converts an ARGB value to  HEX values and vice versa

hasFont – checks if a font exists

textFormatFromCSS – creates a textFormat object from a style of a StyleSheet

isValidURL – validates an URL

stripTags – removes tags from the string specified by the str parameter

getURL – mimics the old getURL method and opens the url to the given window

rotatePoint – rotates a point by the specified angle

combineObjects – combines parameters of two objects. Returns a new object or adds parameters of the secondary object to the primary

Download my Utils.as and see over many other methods!

Kommentoi