Monday, June 02, 2008

Happy June

Things are busy as usual and that means not posting. That's not to say I'm not doing anything and just to prove it...

I ran into a problem in a recent project where I had a series of buttons and I wanted to one to be active right off the bat. ie, like a gallery where the first image is the triggered from the first thumbnail.

There are two ways I found;

1. When your button isn't actually sending any information along with it you can change your callback function to accept a null parameter.

ex.
button.addEventListener(MouseEvent.CLICK, onClick);

private function onClick(mevt:MouseEvent=null):void
{
//do whatever here
}

now I can just call the onClick function like any regular ol' function

onClick();

However, if you want to actually click the button because you need to know something that button has;

//using the same code as above

button.dispatchEvent(new MouseEvent(MouseEvent.CLICK));

TADA!

Now tell me I haven't been doing anything.

Labels: , ,

0 Comments:

Post a Comment

<< Home