Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check boxes

Status
Not open for further replies.

copeZero

Programmer
Aug 31, 2007
46
CA
Hi I was wondering if it was possible to create check box dynamically? I have an xml that i will be iterating thru and for each node i would like to create a text box on the main stage. How would i go about this? Thanks for the insight!
 
Thanks oldnewbie, after reading that article i attempted (today) to produce something. Was wondering if you oldnewbie eyes can take a look at it, thanks:

This is the xml i'm toying with:
Code:
<Risk>
        <Lables>
            <Risks name="BMI" change="10" modname=""></Risks>
        </Lables>
        <Lables>
            <Risks name="Physical Activity" change="15" modname="Increase you daily activities"></Risks>
        </Lables>
        <Lables>
            <Risks name="Whole Grain Intake" change="10" modname="Increase whole grain intake"></Risks>
        </Lables>
        <Lables>
            <Risks name="Lacking Healthy Fats" change="5" modname="Eat more health fats"></Risks>
        </Lables>
</Risk>

I'm will be trying (below) to make and display check boxes of the inline attribute "modname"

Code:
_global.a1=1;
// above prevents the script from firing again since 
//the movie has two frames without a stop on either

function processXMLRiskData(success)
{

if (success && a1<2){
a1=1+1;

// Create a variable to store a reference to each checkbox as it is created.
var cchItem:mx.controls.CheckBox;

// how many checkboxes
numBoxes = this.firstChild.childNodes.length;

		for (i=0; i<numBoxes; i++) {
		// creating an array of items to populate checkboxes
		var aLabels:Array = this.firstChild.childNodes[i].childNodes[0].attributes.modname;
		
		  // Create a checkbox.
		  cchItem = this.createObject("CheckBox", "cch" + aLabels[i], this.getNextHighestDepth());
		
		  
//trace(cchItem);  //--> get undefined 4 times
		  
		  // Assign the checkbox a label.
		  cchItem.label = aLabels[i];
		
		  // Move the checkbox so they are not each overlapping.
		  cchItem.move(100, 20 * i + 100);
		
		};

		// Loop through each of the checkbox to add an event listener.
		for(var i:Number = 0; i < aCheckBoxes.length; i++) {
		  // Add an event listener.
		  aCheckBoxes[i].addEventListener("click", oListener);
		};
	
	}
}
 
forgot to mention that am using:
import mx.controls.CheckBox;

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top