Copy link to clipboard
Copied
I want to know what this following lines in action script signify
1)var abc:*;
is this mean it can take any kind of value ?
2)var abc:Function;
Copy link to clipboard
Copied
The following code:
import flash.utils.describeType;
var abc:*;
abc = new Object();
describe(abc);
abc = new Function();
describe(abc);
abc = new MovieClip();
describe(abc);
function describe(_abc:*):void
{
var description:XML = describeType(_abc);
trace("Properties:\n------------------");
for each (var a:XML in description.accessor)
{
trace(a.@name+" : "+a.@type);
}
trace("\n\nMethods:\n------------------");
for each (var m:XML in description.method)
{
trace(m.@name+" : "+m.@returnType);
if (m.parameter != undefined)
{
trace(" arguments");
for each (var p:XML in m.parameter)
{
trace(" - "+p.@type);
}
}
}
}
produces this:
Properties:
------------------
Methods:
------------------
Properties:
------------------
length : int
prototype : *
Methods:
------------------
Properties:
------------------
accessibilityImplementation : flash.accessibility::AccessibilityImplementation
...
currentLabels : Array
Methods:
------------------
addChild : flash.display::DisplayObject
arguments
...
removeChild : flash.display::DisplayObject
arguments
- flash.display::DisplayObject
play : void
Copy link to clipboard
Copied
1) Asterisks in variable declaration means that it can be any datatype. Basically you instruct Flash to treat it as anything.
For example
var abc:*;
abc = 2; // assigned integer and all good
abc = new MovieClip() // again - all good
abc = "haha" // still takes it
2) Means that var abc is a Function. You promise to Flash that when you assign value - value will be Function only.
var abc:Function;
abc = new Function () // all good
abc = 2; // error because int is not Function
abc = new MovieClip() // error - MovieClip is not Function
abc = "haha" // error = "haha" is a string and not a Function
Any object in AS3 has a datatype.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now