February 2nd, 2010
‘Learning Actionscript 3.0‘ by Rich Shupe and Zevan Rosser bills itself as ‘A Begginer’s Guide’ to Actionscript 3 for non-traditional programmers. With this in mind, I picked it up a couple of years ago when committing to making the transition from AS2 to AS3.
The book is made up of several sections, each one containing a number of chapters dedicated to exploring the basics of a particular aspect of AS3. The topics covered are wide ranging, from language and syntax to sound and video, external assets, and even touching on OOP – a welcome addition that I wasn’t expecting in such a begginer’s book. Read the rest of this entry »
Tags: AS3, beginner, book, OOP, review
Posted in Reviews | No Comments »
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 »