Solved

Detecting type of control on stage

Posted on 2009-07-08
4
188 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:moshem
  • 2
4 Comments
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 24801680
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

0
 
LVL 2

Expert Comment

by:Iklu
ID: 24801694
I don't know if AS2 can.  Have you thought of using actionscript 3?
0
 
LVL 1

Author Comment

by:moshem
ID: 24801928
I dont think this can work in AS2

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

thanks
0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 500 total points
ID: 24801978
Oh gee  ... my mistake ... Flex2 didn't use ActionScript 2 ... sorry. Then my approach will not work.

Using the following code you should be able to get the class-object of your instance. Hope it works in ActionScript 2:
var myClass:Class = Object(myObj).constructor;

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AWAY 3d Using BitMapCubeTexture 1 406
Action Script commands 4 315
Adobe Media Server Or Encoder Broken Affer Static IP Change 4 169
System Center Configuration Manager 2012R2 7 86
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question