I have looked through the examples, and that’s what is confusing me. 

 

All of the examples show exactly what you have written:

 

myFunction(event:MouseEvent)

{

Alert.show(“hello world”);

}

 

 

myLabel.addEventListener(MouseEvent.CLICK, myFunction);

 

 

When I try to do this:

 

myFunction(event:MouseEvent, myString:String)

{

//do something here

Alert.show(myString);

}

 

myLabel.addEventListener(MouseEvent.CLICK, myFunction(MouseEvent.CLICK, 
“hello”);

 

I get the following error:

1067: Implicit coercion of a value of type String to an unrelated type 
flash.events:MouseEvent.

 

The problem I’m having is finding the correct syntax to use when passing the 
string to myFunction.

 

Can you point me to the part of the manuals that would help me with that?

 

Thanks,

 

Bob

 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Haykel 
BEN JEMIA
Sent: Thursday, September 25, 2008 9:56 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] help w/ setting click events on dynamically created 
linkbuttons

 

Use addEventListener() for registering an event handler: 
myLabel.addEventListener(MouseEvent.CLICK, myFunction);

You should take time to read about event handling in Flex/AS3 as it's a basic 
and very important concept!

 

 

On Thu, Sep 25, 2008 at 4:33 PM, Ramsey, Robert L <[EMAIL PROTECTED]> wrote:

Hi,

 

I am working on a scheduling application and need some help working with 
dynamically created clickable objects.  I've been using linkbuttons, but 
anything that is clickable will work.

 

I have an array that may contain 0-N items, where N can be any number.  If N>0, 
I need to create clickable linkbuttons that call a function.   What I'm doing 
is something like this:

 

                  for each (var conflict:String in conflictArray)

                  {

                        var myLabel:LinkButton = new LinkButton;

                        myLabel.label = conflict;

                        myLabel.y = myy;

                        

                        myy += 20;

                        
Application.application.conflictsPanel.addChild(myLabel);

                        

                  }

 

What I need to do is have each linkbutton call a function when it is clicked 
and pass two variables to that function.  What I'd like to be able to do is 
something like this:

 

myLabel.onClick(myFunction(label, label.length);

 

Is there an easy way to do this or a different clickable control I should be 
using?

 

Thanks,

 

Bob




-- 
Haykel Ben Jemia

Allmas
Web & RIA Development
http://www.allmas-tn.com



 

<<image001.jpg>>

<<image002.jpg>>

Reply via email to