Hello,
I have been working on a tool for use in our office which creates XML. At this point I am working on an error message that pops up if the user enters incorrect data in one of the textfields. I have a button nested inside of a MC. The MC contains my error message (as well as the button). The button will move the MC off stage. I am having a problem referencing the parent MC (at least I believe that is the problem) from that nested button.
Here is the code for the entire project. I am sure some of you will find a few other mistakes, I am still fairly new to AS. The function where I believe the error is, is at the bottom and I included some of the other things I tried. Nothing works yet. But any help would be greatly appreciated.
import fl.controls.RadioButtonGroup;
import flash.display.*;
load_file.addEventListener(MouseEvent.MOUSE_UP, do_load_file);//load file button click
function do_load_file(e:Event):void
{
var file_txtFld:TextField = doc_name;
//trace (file_txtFld.text);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
loader.load(new URLRequest(file_txtFld.text));
function loadXML(e:Event):void
{
var xml = new XML(e.target.data);
var url:URLRequest = new URLRequest("File loaded")
//trace(xml);
//load_file.removeEventListener();
}
function onIOError(e:IOErrorEvent):void //In case the file fails to load. Usually incorrect URL from user.
{
trace("Error loading file. " + e.text);
}
}
submit1.addEventListener(MouseEvent.MOUSE_UP, set_tags);
clear1.addEventListener(MouseEvent.MOUSE_UP, clearFields);
function set_tags(e:Event):void
{
this.err_msg.x_out.addEventListener(MouseEvent.MOUSE_UP, replace_msg);
var qname:TextField = q_name; //Set all of the text field variables.
var qnumber:TextField = q_number;
var qu:TextField = q;
var shuff:String = "";
var rad_grp:RadioButtonGroup = new RadioButtonGroup("rbg");
var ans_1a:TextField = ans_1;
var fdback_1a:TextField = fdback_1;
var ans_2a:TextField = ans_2;
var fdback_2a:TextField = fdback_2;
var ans_3a:TextField = ans_3;
var fdback_3a:TextField = fdback_3;
var ans_4a:TextField = ans_4;
var fdback_4a:TextField = fdback_4;
var cor_fdbacka:TextField = cor_fdback;
var pcor_fdbacka:TextField = pcor_fdback;
var incor_fdbacka:TextField = incor_fdback;
var quest:XML; //variable to store XML code output.
yes_btn.label = "Yes"; //Labels for the two radio buttons
no_btn.label = "No";
yes_btn.group = rad_grp;
no_btn.group = rad_grp;
if(rad_grp.selection.label == "Yes") //Test to see which button is checked.
{
shuff = "true";
}
else
{
shuff = "false";
}
if(!isNaN(Number(qnumber.text)) && qnumber.text.length == 3) //Check Question Number for 001 to 999.
{
var qnumbera:int = new int(qnumber.text);
if(qnumbera != 000)
{
nodesWithVariables();
}
else
{
this.err_msg.x =600;
this.err_msg.y =350;
}
}
else
{
this.err_msg.x =600;
this.err_msg.y =350;
}
function nodesWithVariables():void //Writes the XML code using variables from the text boxes.
{
quest = <question type="multichoice" number={qnumber.text}>
<name>
<text>{qname.text}</text>
</name>
<questiontext>
<text>{qu.text}</text>
</questiontext>
<single>true</single>
<shuffleanswers>{shuff}</shuffleanswers>
<correctfeedback>
<text>{cor_fdbacka.text}</text>
</correctfeedback>
<partiallycorrectfeedback>
<text>{pcor_fdbacka.text}</text>
</partiallycorrectfeedback>
<incorrectfeedback>
<text>{incor_fdbacka.text}</text>
</incorrectfeedback>
<answer fraction="100">
<text>{ans_1a.text}</text>
<feedback>
<text>{fdback_1a.text}</text>
</feedback>
</answer>
<answer fraction="0">
<text>{ans_2a.text}</text>
<feedback>
<text>{fdback_2a.text}</text>
</feedback>
</answer>
<answer fraction="0">
<text>{ans_3a.text}</text>
<feedback>
<text>{fdback_3a.text}</text>
</feedback>
</answer>
<answer fraction="0">
<text>{ans_4a.text}</text>
<feedback>
<text>{fdback_4a.text}</text>
</feedback>
</answer>
</question>;
trace(quest);
q_name.text = ""; //This clears the text boxes.
q.text = "";
ans_1.text = "";
fdback_1.text = "";
ans_2.text = "";
fdback_2.text = "";
ans_3.text = "";
fdback_3.text = "";
ans_4.text = "";
fdback_4.text = "";
cor_fdback.text = "";
pcor_fdback.text = "";
incor_fdback.text = "";
stage.focus = q_number; //This places the cursor in the "Question Number" text box.
}
function replace_msg(e:Event):void //Move the err_msg movieclip off stage.
{
this(parent).x =-300;
this(parent).y =300;
/*this(parent).err_msg.x =-300;
this(parent).err_msg.y =300;*/
/*MovieClip(parent).err_msg.x =-300;
MovieClip(parent).err_msg.y =300;*/
}
}