Not sure that attach is the correct name for this.
What I am trying to do is set variables associated with objects and then access those variables from a class file. But I am getting an “undefined” error.
The highlited code below shows where I am trying to group 2 radio buttons.
function handleParameters(file:Object):void
{
/***** Set up the drop-down menu. ************************/
var mcAttribute1:mcAttributes = new mcAttributes();
mcAttribute1.name="mcAttribute1";
mcAttribute1.x=mcAttribute1.y=16;
mcAttribute1.comboAttribute.prompt="Choose";
mcAttribute1.comboAttribute.addItem({label:" ", data:.1});
mcAttribute1.comboAttribute.addItem({label:"0", data:0});
mcAttribute1.comboAttribute.addItem({label:"1", data:1});
mcAttribute1.comboAttribute.addItem({label:"2", data:2});
mcAttribute1.comboAttribute.addItem({label:"3", data:3});
mcAttribute1.comboAttribute.addItem({label:"4", data:4});
mcAttribute1.comboAttribute.selectedIndex = 0;
mcAttribute1.btnSubmitFile.addEventListener(MouseEvent.CLICK, handleSubmitFile);
[COLOR=darkred]var radBackTrack:RadioButtonGroup = new RadioButtonGroup("rbgBack");[/COLOR]
[COLOR=darkred]mcAttribute1.btnBackTrackTrue.group = radBackTrack;[/COLOR]
[COLOR=darkred]mcAttribute1.btnBackTrackFalse.group = radBackTrack;[/COLOR]
this.addChild(mcAttribute1);
/***** Set the focus to the text field. ************************************************************/
stage.focus = mcAttribute1.txtAttFileName;
mcAttribute1.txtAttFileName.setSelection(mcAttribute1.txtAttFileName.text.length,mcAttribute1.txtAttFileName.text.length);
//mcAttribute1.txtAttMainText.restrict = "a-fA-F0-9";
function handleSubmitFile(evt:Event):void
{
handleCheckDuplicate(mcAttribute1.txtAttFileName.text);
var numberChoices:uint = mcAttribute1.comboAttribute.selectedItem.data;
if (mcAttribute1.txtAttFileName.text != "" && mcAttribute1.comboAttribute.selectedIndex != 0 && duplicateFlag != true)
{
txtErrors.text = "";
var fileHeight:int = file.height;
file.txtFileName.text = file.name = mcAttribute1.txtAttFileName.text;
fileInventory.push(file.name);
var mcFileTarget1:mcFileTarget = new mcFileTarget();
mcFileTarget1.x= file.width/2;
mcFileTarget1.y = -2;
mcFileTarget1.addEventListener(MouseEvent.MOUSE_UP, drawFinish);
file.addChild(mcFileTarget1);
for(var i:uint = 0; i<numberChoices; i++)
{
var mcChoiceTarget2:mcChoiceTarget = new mcChoiceTarget();
mcChoiceTarget2.x= (file.width/numberChoices * i) + (5) + (3 * i) ;
mcChoiceTarget2.y = fileHeight;
mcChoiceTarget2.label = "choice"+(i+1);
mcChoiceTarget2.addEventListener(MouseEvent.MOUSE_DOWN, drawStart);
file.addChild(mcChoiceTarget2);
}
file.tracking = new mapTarget(file);
removeChild(getChildByName("mcAttribute1"));
}
}
}
Here is my class file where I try to access the radio buttons. But I guess they are not there.
package classes
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.utils.Dictionary;
import fl.controls.RadioButtonGroup;
public class mapTarget extends MovieClip
{
public var choiceMap:Dictionary = new Dictionary();
public var fileRef:Object;
public var backTrack:Boolean;
public function mapTarget(file:Object)
{
fileRef=file;
}
public function captureData(fileChosen:Object, choiceMapRef:Object):void
{
choiceMap[choiceMapRef]=[choiceMapRef.label,fileChosen.name];
for (var prop:* in choiceMap)
{
trace(choiceMap[prop]);
}
trace("");
}
public function mapDataToXML():void
{
for (var prop:* in choiceMap)
{
[COLOR=darkred]trace(fileRef.radBackTrack.selection.label);[/COLOR]
[COLOR=darkred] if (fileRef.mcAttribute1.radBackTrack.selection.label == "True")[/COLOR]
[COLOR=darkred] {[/COLOR]
[COLOR=darkred] trace("It's True!");[/COLOR]
[COLOR=darkred] }[/COLOR]
[COLOR=darkred] else if (fileRef.mcAttribute1.radBackTrack.selection.label == "False")[/COLOR]
[COLOR=darkred] {[/COLOR]
[COLOR=darkred] trace("It must be false!");[/COLOR]
[COLOR=darkred] }[/COLOR]
}
trace("");
}
}
}