|
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jun 2006
Posts: 873
|
Passing class instance to button code created by that class...
Having some troubles with this. I have posted this on the actionscript forum as well and bumped it but it just sinks like a stone unanswered. Maybe you good folk would be willing/able to help?
I will try to make this simple even though it confuses me. I have a class, ship. Inside there I am making some buttons and assigning them onRelease code. I want to pass the instance of the class object that made them to the buttons. So each button created would know which ship object created them. In my case, the buttons are cards in the hand, and the onrelease code calls a discard action. The cards have to go back to the discard pile, and the discard pile is a string in the ship objects (I have made each ship the physical manifestation of the player. All player data is held in their playing piece). I solved the problem by passing the value off to a _root level variable for temporary storage, which works fine for this solution, but it would NOT work if there were multiple ship objects generating cards that existed at the same time. To help, here is some pseudocode to show you what I am talking about. This is how I did it, is there a better way to pass the SHIPS 'this' value, and not the 'this' value of the button. PHP Code:
Is there a way to do this? Any variables inside that onRelease function definition are local to the onRelease function and won't evaluate until it is activated it seems. I have tried all sorts of convolutions of _root[this], eval(this), and this[this] and 'this' always comes out to be the button instance. Can this be done? |
|
|
|
|
|
#2 |
|
Truimagz.com
Join Date: Sep 2006
Location: St. Louis
Posts: 1,305
|
Not sure I understand 100% but what I think your trying to do is this.
PHP Code:
__________________
http://www.truimagz.com Last edited by everfornever; 08-31-2007 at 11:52 AM. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jun 2006
Posts: 873
|
Ah, that is way too easy!
myButton.mc = mc //OUTSIDE THE FUNCTION!!! GAH! DUH! Thank you! |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|