[COLOR=#333333]Hi there experienced AS3 fanatics![/COLOR]
[COLOR=#333333]This AS3 beginner is struggling with the following and asks for your help (and what is there in it for you, you ask?! RESPECT from my side [/COLOR][COLOR=#333333] :[/COLOR]
[COLOR=#333333]I have an XML with 350 nodes (geographical areas).[/COLOR]
[COLOR=#333333]I have an text input field, where I want to fill in a number.[/COLOR]
[COLOR=#333333]I have an dynamic text field where I want to show the corresponding node from the XML. [/COLOR]
[COLOR=#333333]At this moment I can fill in number “1” and the correct geographical area comes up in the dynamic text field.[/COLOR]
[COLOR=#333333]Here is my problem:[/COLOR]
[COLOR=#333333]How can I call the other 349 nodes, without creating a new VAR and a FUNCTION for every single node?[/COLOR]
[COLOR=#333333]My code so far is as follows:[/COLOR]
[COLOR=#333333]import flash.ui.Keyboard;[/COLOR]
[COLOR=#333333]import flash.events.KeyboardEvent;[/COLOR]
[COLOR=#333333]var inputField:TextField = new TextField();[/COLOR]
[COLOR=#333333]addChild(inputField);[/COLOR]
[COLOR=#333333]inputField.border = true;[/COLOR]
[COLOR=#333333]inputField.width = 27;[/COLOR]
[COLOR=#333333]inputField.height = 20;[/COLOR]
[COLOR=#333333]inputField.x = 112;[/COLOR]
[COLOR=#333333]inputField.y = 10;[/COLOR]
[COLOR=#333333]inputField.type = “input”;[/COLOR]
[COLOR=#333333]inputField.maxChars = 3;[/COLOR]
[COLOR=#333333]inputField.restrict = “1234567890”;[/COLOR]
[COLOR=#333333]stage.focus = inputField;[/COLOR]
[COLOR=#333333]var outputField:TextField = new TextField();[/COLOR]
[COLOR=#333333]addChild(outputField);[/COLOR]
[COLOR=#333333]outputField.border = true;[/COLOR]
[COLOR=#333333]outputField.width = 230;[/COLOR]
[COLOR=#333333]outputField.height = 20;[/COLOR]
[COLOR=#333333]outputField.x = 10;[/COLOR]
[COLOR=#333333]outputField.y = 40;[/COLOR]
[COLOR=#333333]outputField.type = “dynamic”;[/COLOR]
[COLOR=#333333]var xmlLoader:URLLoader = new URLLoader();[/COLOR]
[COLOR=#333333]var xmlData:XML = new XML();[/COLOR]
[COLOR=#333333]xmlLoader.addEventListener(Event.COMPLETE, LoadXML);[/COLOR]
[COLOR=#333333]xmlLoader.load(new URLRequest(“prefix_list.xml”));[/COLOR]
[COLOR=#333333]function LoadXML(e:Event):void {[/COLOR]
[COLOR=#333333]xmlData = new XML(e.target.data);[/COLOR]
[COLOR=#333333]for (var i:int = 0; i<xmlData..length(); i++){[/COLOR]
[COLOR=#333333]trace("PREFIX " + (i+1) + ", COUNTRY " + xmlData.prefix_list.country);[/COLOR]
[COLOR=#333333]};[/COLOR]
[COLOR=#333333]}[/COLOR]
[COLOR=#333333]this.stage.addEventListener(KeyboardEvent.KEY_DOWN , keyDownHandler);[/COLOR]
[COLOR=#333333]function keyDownHandler(event : KeyboardEvent):void {[/COLOR]
[COLOR=#333333]if (event.keyCode == Keyboard.ENTER) {[/COLOR]
[COLOR=#333333]if (inputField.text == “1”) {[/COLOR]
[COLOR=#333333]outputField.text = xmlData.prefix_list.country[0];[/COLOR]
[COLOR=#333333]} else {[/COLOR]
[COLOR=#333333]outputField.text = xmlData.prefix_list.country[351];[/COLOR]
[COLOR=#333333]}[/COLOR]
[COLOR=#333333]}[/COLOR]
[COLOR=#333333]}[/COLOR]
[COLOR=#333333]Thanks so much for your time and effort in trying to help me![/COLOR]
[COLOR=#333333]Best regards,[/COLOR]
[COLOR=#333333]James.[/COLOR]