Hi - I am relatively new to Classes and OOP, and have come across a
strange problem... I have a function in a class that creates dynamic
buttons (xml driven). But when I try to actually use the buttons (ala
'onPress = function()') to fire up a different function within the
class, it just won't work. it's like I'm outside the class now, and
back to the main timeline.
Before you suggest me to use the Delegate class, I've already done
that. It works, but the problem is that I have an unspecified amount
of buttons (could be 10, could be 400) -- and each needs to pass a
parameter, or variable to keep score. The Delegate class wouldn't let
me pass any other variables other than which object is passing the
onPress function, and which function to refer it to...
so I'm at a loss. if someone has a solution I would greatly
appreciate it.
here's an abbreviated version on my function, see the bottom for both
methods I tried.
.I.
function createAnswers(theTarget:MovieClip,
myAnswerFont:String,
myAnswerSize:Number
):Void{
for (n=0; n<answerNum; n++){
theTarget.createEmptyMovieClip("myButton"+n,
theTarget.getNextHighestDepth()+n);
theTarget["myButton"+n].createTextField("myText",1,0,0,300,50);
theTarget["myButton"+n].myText.text =
this.myTarget.answerText[n];
/*
//THIS FUNCTION WON'T RESPOND
theTarget["myButton"+n].onPress = function(){
clickMe();
}
*/
//DELEGATE CLASS WON'T PASS PARAMETERS FOR CUSTOMIZATION
theTarget["myButton"+n].onRelease =
Delegate.create(this, onPress);
}
}
_______________________________________________
[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