Switch Statements - Switching on a Input Textbox
Hello,
I have 3 input text boxes and I want to display a different part of an XML file to display (in a different textbox) depending on what input textbox has been selected.
I have achieved this by using 3 separate functions and it works fine but I want to use a switch statement within one function to achieve the same result. So the user will click on a textbox which calls the function and switches depending on the textbox to load the text from an XML file.
I am reletively new to AS3 and Flash in general so I don't know if using a switch statment in this way is even possible to do.
Code looks like this:
var req:URLRequest = new URLRequest("Manual.xml");
var loader:URLLoader = new URLLoader();
var manual:XML;
euProduct1_txt.addEventListener(MouseEvent.CLICK, loadText);
euProduct2_txt.addEventListener(MouseEvent.CLICK, loadText);
euProduct3_txt.addEventListener(MouseEvent.CLICK, loadText);
function loadText(evt:MouseEvent):void
{
switch(MouseEvent.CLICK)
{
case euProduct1_txt:
manual = new XML(loader.data);
external_txt.text = manual.sales_area[0].info;
manualTitle_txt.text = manual.sales_area[0].name;
break;
case euProduct2_txt etc etc....
}
}
loader.addEventListener(Event.COMPLETE, loadText);
loader.load(req);
The parts I'm struggling with are what goes in the switch condition and each case statement.
Thanks