AS3: using button script functions
- Started
- Last post
- 10 Responses
- rounce0
Event handlers really shouldn't be doing any real execution logic, only redirecting calls to the appropriate functions. Mine was pretty dirty and should've been split into about 2 or 3 more.
- Aa770
you are running the 'reduce' function as if it was triggered by an event.
Instead, you want to pass a reference to the image_array[i] value inside the parenthesis instead...so line 27 should be more like this:
function reduce(reference:Object):void {
- PonyBoy0
use the same function - just pass a boolean to it verifying if the button was clicked and add an 'if()' statement to the function that is triggered only if that boolean is true
- rounce0
As you can tell from my previous post, I'm fucking retarded.
- rounce0
http://pastebin.com/87QTD2BA - I saw scope issues in your future.
- NONEIS0
You should also avoid adding and removing listeners the way you are in reduce as much as humanly possible...
- CyBrainX0
Sorry, forgot to post the link to the code. http://pastebin.com/4eZXDCYn
- I love that BrainFuck is a code formatting option on this site.CyBrainX
- CyBrainX0
Memory has returned. You can pass null as an event.
reduce(null);
to call the function
function reduce(e:Event):void {
}
but I'll have to do work some boolean jiggery-pokery in the function to replace the e.target references.