I'm having a issue using a var within a button.
I create the button and add the var to the to button:

addChild(answerButton);
answerButton.thisX = ii; // temp value that changes with each addchild

The Question is how do I get the buttons to trace (to start with) the value of the var contained within them?

So easy in as 2


Here is my code below:


PHP Code:
//matchingSetUp.as
package {
    
import flash.display.Sprite;
    
import flash.text.*;
    
import flash.events.MouseEvent;
    
import flash.display.MovieClip;

    public class 
matchingSetUp extends Sprite {
        private var 
choiceButton:choice;
        private var 
allAnswers:Array;
        private var 
answerButton:answer_box;
        private var 
tempString;//my movieclip name
        
private var myThis:MovieClip;//my movieclip
        
private var sortMethods:Array = [1,2,8];// 3 diverse types of sorts
        
var sortInt:int=0;
        private var 
_matchingObj:Object;
        public function 
matchingSetUp(_matchingObj) {
            
init(_matchingObj);
        }
        private function 
init(_matchingObj) {
            
// setting up drop zones
            
for (var i:int=0_matchingObj.problemCodes.lengthi++) {
                
choiceButton=new choice  ;
                
addChild(choiceButton);
                
choiceButton.x=_matchingObj.targetsX;
                
choiceButton.y=_matchingObj.targetsY[i];
                
choiceButton.name="mc" _matchingObj.problemCodes[i];
            }
            
//setting up Correct answer buttons
            //// putting all answer into 1 array
            
allAnswers _matchingObj.choiceBank;
            for (var 
k:int 0k_matchingObj.extraChoices.lengthk++) {
                
allAnswers.push(_matchingObj.extraChoices[k]);
            }
            
//// pseudo-randomizing the answers boxes based on sorts
            
sortInt = (Math.random() * 3);
            
allAnswers.sort(sortMethods[sortInt]);
            
//// adding the boxes to the stage
            
for (var ii:int=0ii allAnswers.lengthii++) {
                
answerButton=new answer_box  ;
                
addChild(answerButton);
                
answerButton.x=757;// this needs to be in the fla struct
                
if (ii == 0) {
                    
answerButton.y=108;// this needs to be in the fla struct
                
} else {
                    
tempString =allAnswers[ii-1];
                    
myThis=answerButton.parent.getChildByName(tempString)  as  MovieClip;
                    
answerButton.y=myThis.29;
                }
                
answerButton.name=allAnswers[ii];
                
answerButton.thisX ii;
                
trace(answerButton.thisX);                myThis=answerButton.parent.getChildByName(answerButton.name)  as  MovieClip;
                
myThis.my_name.text allAnswers[ii];
                
answerButton.addEventListener(MouseEvent.CLICK,myMouseDown2);


            }
        }

        private function 
myMouseDown2(event:MouseEvent):void {
            
trace(thisX); // how do I access the var here ??????????????????????????
        
}
    }