Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect component type?

Status
Not open for further replies.

frozenpeas

Technical User
Sep 13, 2001
893
CA
Hi,

Is it possible (FMX2004) to detect if an element is a checkbox?

I would like to handle the checkbox values differently than other components.

Thanks.

frozenpeas
--
Micfo.com Affiliate Program
 
just have an event handler that only check boxes will use

something like


myCheckboxListener = new Object();
myCheckboxListener.click = function(evt) {
trace (evt.target.label);
};
checkbox1.addEventListener("click", myCheckboxListener);
checkbox2.addEventListener("click", myCheckboxListener);

thats 2 check boxes and the code will detect the label of the selected box so you then take whatever action you need


not sure this is what you want though...i may have misunderstood the question
 
Thanks, Bill. The only trouble with that method is that the form changes a lot. So I was hoping that there is Actionscript that can detect checkboxes (within a loop) rather than tying something onto a hard-coded instance name.

frozenpeas
--
Micfo.com Affiliate Program
 
the checkbox itself is acually a movieclip and certainly using typeof you wouldnt be able to do more than detect all movieclips

again you are back to instance names
eg if all checkbox instance names start with check then you could use typeof


for (i in _root) {
if (typeof (_root) == "movieclip" && i.substring(0, 5) == "check") {
trace(i);
}
}

that would give a list of all checkboxes and you can then check their state
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top