Link to home
Start Free TrialLog in
Avatar of moshem
moshem

asked on

Detecting type of control on stage

Hi,

I am trying to build an AS2 logic that first detects the type of control and then checks it according to it's type

if I test an input text control :

trace (tyepof (aa_txt));

I get "Input" which is great

if I do the same for a checkbox or combobox I get "movieclip" which is not unique and does not help me identify the type of control I am dealing with..

how can I tell which type is it in runtime ?

thanks
Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

I use the function flash.utils.getQualifiedClassName to get the fully qualified class name of an object. Maybe this helps you a little.

The code below uses getQualifiedClassName to find out if a class is an "Enum" (A class generated by the flex builder to represent a Java Enum in Flex ... I know It's not a real Enum)
// An Enum is defined by having a property that equals
// the class name with a prefix of "_". If such a property
// exists, this class is very propable an enum.
protected function isEnum(value:Object):Boolean
{
    var qualifiedClassName:String = getQualifiedClassName(value);
    var className:String = qualifiedClassName.substring(qualifiedClassName.lastIndexOf(":") + 1, qualifiedClassName.length);
    var propName:String = "_" + className;
    var hasProp:Boolean = value.hasOwnProperty(propName);
    return hasProp;
}

Open in new window

Avatar of Iklu
Iklu

I don't know if AS2 can.  Have you thought of using actionscript 3?
Avatar of moshem

ASKER

I dont think this can work in AS2

I can't work with AS3 in this project..

thanks
ASKER CERTIFIED SOLUTION
Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial