Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

need help in some basic syntax and symantec rule of AS eg var abc:*?

Participant ,
Mar 08, 2013 Mar 08, 2013

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;

TOPICS
ActionScript
576
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 08, 2013 Mar 08, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 08, 2013 Mar 08, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines