and you can also do...

function onSomeEvent(e:Event = null):void{
}

and then just call the function directly, without creating a new Event
instance. i.e.:

onSomeEvent();


On Tue, Jul 27, 2010 at 12:20 PM, Paul Andrews <p...@ipauland.com> wrote:

> On 27/07/2010 19:37, Henrik Andersson wrote:
>
>> Paul Andrews wrote:
>>
>>> If you try and call a function designed to be an event handler directly,
>>> you must create an event object instance to correspond with the event
>>> argument yourself when it is called.
>>>
>>>
>> You must at the very least give the parameter a value. A null reference
>> counts as a value. You can either make it optional or simply pass null each
>> time you are calling it yourself. If it is valid depends on what the
>> function does with it.
>>
>
> Well it will work, though I think it's not the best practice.
>
> If I have an event handler that does "taskX", and I want to do taskX
> directly without an event, I would code this as
>
> function onSomeEvent(e:Event):void {
> taskX();
> }
>
> and have a separate taskX() function to allow that to be called directly.
> Then there's no ambiguity over whether a function is an event handler or
> not. Generally speaking calling event handlers directly is to be avoided.
>
> Paul
>
>
>
>
>  _______________________________________________
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to