You might want to consider using the ActionStep framework which deals
with the MVC model.
You could also look at past discussions on "delegate" in this forum.
(google it)
Everyone has to deal with this.
Ron
Jason Boyd wrote:
OK this is making me nuts. It seems to be an impossible scope problem,
to do something that ought to be very very possible, and in fact
common. The basic problem: I want to have initialization code in a
Main class that hooks up GUI controls to methods in this class (acting
as a controller class essentially). For various reasons, I do not want
to use components; the GUI elements are either Buttons or MovieClips.
Again, this ought to be possible, right?
So here's the problem case:
class Main {
var myButton:Button; // placed on stage in authoring time
function init() {
myButton.onRelease = function() {
doSomething();
}
}
function doSomething() {
trace("something");
}
}
This does not work, nor is there any way I can wrap my head around
getting it to work, as the anonymous function assigned to the button
event handler has "this" scoped as the button itself, so
"doSomething()" refers to a non-existent function
myButton.doSomething(). Simply assigning the member function to the
button event handler directly doesn't help, as this function is then
unable to call other member functions for the same reason. E.g.:
function init() {
myButton.onRelease = doSomething();
}
function doSomething() {
// this will be called now, but "this" still refers to the button,
not objects of this class
}
There has *got* to be some way around this issue. Right?
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com