Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Detecting type of control on stage

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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 …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

856 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