Solved

Detecting type of control on stage

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Action Script coding 1 170
free flash maker 5 197
Crash with shockwave flash 8 228
Problem witih Adobe Flash Player with a W7 machine 21 51
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

705 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

15 Experts available now in Live!

Get 1:1 Help Now