Posts Tagged ‘ conversion ’

Convert int to String

The AS3 Util Function is posted on the below link
Utility to convert number or integer to String. The util function is useful in many applications.
https://gist.github.com/703108

Debug Flash Player Capabilities

The below code debugs the capabilities of system, might be useful for debugging.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”horizontal”
initialize=”init()”>
<mx:Script>
<![CDATA[
import flash.system.Capabilities;
import mx.utils.ObjectUtil;
private function init() : void
{
var _capObj:Array = new Array();
capability.dataProvider = objectToArray(Capabilities);
}
private function objectToArray(cap:Class) : Array
{
var capObj:Object = ObjectUtil.getClassInfo(cap);
var _capArr:Array = new Array();
for each (var _capPropObj:Object in capObj.properties)
{
if (_capPropObj.localName != “prototype”)
{
var capProp:Object = new Object();
capProp.Capability = _capPropObj.localName;
capProp.Value =Capabilities[capProp.Capability]
_capArr.push(capProp);
}
}
return _capArr;
}
]]>
</mx:Script>
<mx:DataGrid id=”capability” width=”100%” height=”100%” />
</mx:Application>

Data Filter

Check the demo for data filtering xml output with LOGICAL AND, updating the Datagrid dynamically.
The source is available over here. It uses data filter component developed by Jack Herrington.

Steps to be followed for AS3 migration

1. Declare types for all variables, parameters, and return values.
2. Declarations with no access specifier now default to package internal, not public.
3. Classes are sealed by default, meaning properties cannot be added dynamically at runtime.
4. Use package declarations to put a class definition into a package.
5. Import classes, even if references to the class are fully qualified.
6. Always mark method overrides. Declare return types in your functions.
7. Delegates are now built into the language, making event dispatching easier.
8. De referencing a null or undefined reference will throw an exception.
9. For debugging use the -verbose-stacktraces and -debug options.
10. Explicitly declare properties to be bindable.
11. Flash Player API has been reorganized into packages.
12. Use the new Timer class instead of setInterval/setTimeout.
13. Be sure to subclass events.
14. Visual elements must extend DisplayObject, and define them like any other class.
15. E4X (ECMAScript for XML) is used for manipulating XML.use toXMLString() method when using E4X.
16. for…in loop will not enumerate properties and methods declared by a class.