January 25th, 2010
(This is part 4 of a series of posts on ways to pass arguments to a function through event listeners. For part one, see here, for part two, see here, and for part three, see here.)
Today sees the last chapter of our quest to pass information to a function through a listener. For this final method we’re going to be looking at creating our own custom events, andĀ how they can be used to store and retrieve information.
Read the rest of this entry »
Tags: Actionscript, AS3, constant, custom, event listeners, events, Flash, listeners, OOP, static
Posted in Actionscript Tips | No Comments »
January 22nd, 2010
(This is part 3 of a series of posts on ways to pass arguments to a function through event listeners. For part one, see here, for part two, see here, and for part four, see here.)
For today’s method of passing values to a function through a listener, we’re going to bend the rules a little. The result will be a set of slightly different listeners, but each will eventually call our desired function. At the expense of bending the rules, we’re going to end up with what is probably the best solution short of creating custom events, albeit quite a long-winded one.
Read the rest of this entry »
Tags: Actionscript, AS3, event listeners, events, Flash, functions, listeners
Posted in Actionscript Tips | No Comments »
January 20th, 2010
(This is part 2 of a series of posts on ways to pass arguments to a function through event listeners. For part one, see here, for part three, , and for part four, .)
So you’ve decided anonymous functions aren’t for you. Congratulations, you’ve decided correctly! But that doesn’t help you on your way to really dynamic listeners. What other options are available to you? Read the rest of this entry »
Tags: Actionscript, AS3, event listeners, events, Flash, listeners, variables
Posted in Actionscript Tips | No Comments »
January 18th, 2010
(This is part 1 of a series of posts on ways to pass arguments to a function through event listeners. For part two, see here, for part three, , and for part four, .)
One of the things I often wonder about actionscript 3 is the best way to pass arguments to a function through an event listener. Typically when you add an event listener, you simply specify a type of event, and the name of the function to call when the event is dispatched. (You may also specify the optional parameters useCapture, priority, and useWeakReference, but seeing as how that’s not relevant to the subject at hand, we’ll be focusing on just the first two):
myButton.addEventListener(MouseEvent.CLICK, outputText);
When ‘myButton’ was clicked, this would then call the function ‘outputText’, which would take just one parameter – the event that triggered it:
function outputText(evt:MouseEvent):void {
trace("Hello World!");
}
But what if you wanted to have multiple buttons that all triggered one function, each passing a different parameter? This functionality isn’t supported as standard, so a little improvising is required. This series of posts aims to discuss all your options, from custom events (the good), to external variables (the bad), and anonymous functions (the ugly). Read the rest of this entry »
Tags: Actionscript, anonymous, AS3, event listeners, events, Flash, functions, listeners
Posted in Actionscript Tips | No Comments »
January 10th, 2010
Connecting a Wii remote to my PC for use in flash is something that I’ve been meaning to do forĀ a while – however, when I built my PC the one thing I forgot was bluetooth. Over the holidays, I remedied this situation by picking up this USB bluetooth dongle, and was happy to find that setting up WiiFlash Server couldn’t be easier. The dongle I linked to comes with BlueSoleil bluetooth software, which does just fine for connecting to a controller.
I found this handy guide linked to on the WiiFlash homepage and was up and running in no time. I had one problem in that the way that I connected to the remote was different to the one documented at the link, so I just wanted to go over the slight differences here, in case anyone else is having trouble.
Read the rest of this entry »
Tags: bluesoleil, bluetooth, controller, Flash, guide, remote, step by step, tutorial, wii, wiiflash
Posted in Interface | No Comments »