1 Replies - 3797 Views - Last Post: 14 February 2014 - 01:40 PM

#1 art_vandelay  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 14-February 14

AS3 /XML - Cannot dynamically access xml

Posted 14 February 2014 - 10:53 AM

Hello! I'm extremely new to AS3 and seem to be over my head here.

I'm trying to get the script to pull a different .xml file as dependant on what was selected from an array generated menu on a previous scene. Though I'd wanted this to be more flexible, I'm willing to just create an 'if' statement to choose the .xml - but I'm unable to trace the variable that will change depending on the menu item selected.

Here is what I'm working with currently. It's the flexible version (I still have hope). Like I said, I'm very new to this and if you need to see more to get a better picture let me know.

var item_list = new Array();
var i:Number;
var total:Number;

var find_xml:XML = new XML();

// This part is what pulls from the frame that this is placed on
// The as3 script on the frame --- "page_2.load_xml("enter xml file");"

function push_array(e:Event):void 
{
	find_xml = XML(e.target.data);
	total = find_xml.item.length();
	for( i = 0; i < total; i++ )
	{
		item_list.push( { content: find_xml.item[i].content.toString() } );
	}
}

function load_xml(xml_file:String):void
{
	var xml_loader:URLLoader = new URLLoader();
	xml_loader.load( new URLRequest( xml_file ) );
	xml_loader.addEventListener(Event.COMPLETE, push_array);
}

var xml_file:String = "PLACE XML's NAME HERE";



Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: AS3 /XML - Cannot dynamically access xml

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 469
  • View blog
  • Posts: 1,706
  • Joined: 15-January 14

Re: AS3 /XML - Cannot dynamically access xml

Posted 14 February 2014 - 01:40 PM

What is the code that runs when a menu item is selected?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1