Solved

Detecting type of control on stage

Posted on 2009-07-08
4
186 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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 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.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now