Re: [Flashcoders] onPress events from within a Class
> > "One way is to create a MyButton clip in the library and attach a class > to it." > +1 > > "Instead of Delegate, use the Proxy class from Person13.com. It will make > you happy." > -1 ;-) ___ Flashcoders@chattyfig.figleaf.com 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
RE: [Flashcoders] onPress events from within a Class
"One way is to create a MyButton clip in the library and attach a class to it." - Ricky | Good Angel "Instead of Delegate, use the Proxy class from Person13.com. It will make you happy." - Adam | Bad Angel ___ Flashcoders@chattyfig.figleaf.com 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
Re: [Flashcoders] onPress events from within a Class
Instead of Delegate, use the Proxy class from Person13.com. It will make you happy. http://www.person13.com/articles/proxy/Proxy.htm On 7/8/07, Ricky Bacon <[EMAIL PROTECTED]> wrote: Itai Asseo wrote: > > 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... > ___ Flashcoders@chattyfig.figleaf.com 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
Re: [Flashcoders] onPress events from within a Class
Itai Asseo wrote: 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. One way is to create a MyButton clip in the library and attach a class to it. Something like: import mx.utils.Delegate; class MyButton extends MovieClip { public var answer:String; public function dispatchEvent() {}; public function addEventListener() {}; public function removeEventListener() {}; function MyButton() { super(); mx.events.EventDispatcher.initialize(this); onRelease = Delegate.create(this, release); } private function release():Void { dispatchEvent({target: this, type: "release", answer: answer}); } } Then when you create the buttons: //this is what the onRelease calls function myButtonRelease(o:Object):Void { trace(o.answer); } //loop stuff var myButton = theTarget.attachMovie("MyButton", "myButton" + n, theTarget.getNextHighestDepth()+n); myButton.answer = "foo"; myButton.addEventListener("release", Delegate.create(this, myButtonRelease)); -Ricky ___ Flashcoders@chattyfig.figleaf.com 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