all groups > flash actionscript > october 2004 >
You're in the

flash actionscript

group:

Inspectable: Converting of type String to type Function


Inspectable: Converting of type String to type Function PEF
10/28/2004 12:06:05 PM
flash actionscript: Working with AS2 I come accross the problem of converting a type String to a
type Function. Can anyone tell me how to fix it?

[Inspectable (name="onClick", defaultValue="")]
public function set onClick (fOnClick : Function) : Void {

this.onRelease = function () {
dispatchEvent ({target : this, type : "onClick"});
}
addEventListener ("onClick", fOnClick);
// won't work when retrieving parameter from Inspectable. fOnClick is
//regarded as type String and not as type Function.
}

Works well when setting the handler function explicit:
my_comp.onClick = myFunction; // works well

Thanx
Peter


Re: Inspectable: Converting of type String to type Function PEF
10/29/2004 12:01:43 AM
With the help of Joey Lott i solved the problem - the addEventListener
wasn't initialized. Working with Inspectable means that You're in for a lot
of surprises.

Futhermore I modified the function, so that it can handle both functions and
strings as parameters.
/Peter

[quoted text, click to view]

AddThis Social Bookmark Button