?
Solved

Linking .xml using a comboBox  as3

Posted on 2009-04-27
3
Medium Priority
?
859 Views
Last Modified: 2013-11-11
Hi, I am trying to link the data of an item in the comboBox to load a xml file of the playlist I would like to show. I am able to get the comboBox to load the first xml I select, but I cannot get it to load the new file when I select it. I feel Im not completely understanding a concept or something, any help would be awesome.  Thanks.
0
Comment
Question by:P-j-S
  • 2
3 Comments
 

Author Comment

by:P-j-S
ID: 24243335

playlist_cb.addItem({label: "playlist1", data:"playlist1.xml"});
playlist_cb.addItem({label: "playlist2", data:"playlist2.xml"});
playlist_cb.addItem({label: "playlist3", data:"playlist3.xml"});
addChild(playlist_cb);
 
playlist_cb.addEventListener(Event.CHANGE, itemChangeTrace);
function itemChangeTrace(event:Event):void {
	trace("Selected  " + event.target.selectedItem.label);
	trace("Selected  " + event.target.selectedItem.data);
}
 
playlist_cb.addEventListener(Event.CHANGE, changePlist);
 
playlist_cb.addEventListener(Event.CHANGE, changePlist);
function changePlist(event:Event):void {
	var xmlURLLoader:URLLoader = new URLLoader();
	var loadedPlist=new URLRequest(event.target.selectedItem.data);
	var xmlURLRequest:URLRequest=loadedPlist;//relative location of .xml file. In this case, it must reside where the .swf is
	xmlURLLoader.load(xmlURLRequest);
	xmlURLLoader.addEventListener(Event.COMPLETE , dataLoaded );
	trace("playlist = "+event.target.selectedItem.data);
 
	function dataLoaded(event:Event):void {
		var theXMLData:XML=new XML(xmlURLLoader.data);
		var a:Number=theXMLData.video_path.length();
 
		//...while loop populates list... 
	}
}

Open in new window

0
 
LVL 22

Accepted Solution

by:
rascalpants earned 2000 total points
ID: 24254647
the structure should be more like this...

var xmlURLLoader:URLLoader = new URLLoader();
var loadedPlist:URLRequest = new URLRequest(event.target.selectedItem.data);
xmlURLLoader.addEventListener(Event.COMPLETE , dataLoaded );

xmlURLLoader.load(xmlURLRequest);

then put dataLoaded outside of the changePlist() function...

and it will look like this...


      function dataLoaded(event:Event):void {
            var theXMLData:XML= event.target.data;
            var a:Number = theXMLData.video_path.length();
 
            //...while loop populates list...
      }


hope I am clear...  if not... let me know...


rp / ZA

0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24254661
whoops....  

change this line...   xmlURLLoader.load(xmlURLRequest);


to this...   xmlURLLoader.load( loadedPlist );


rp / ZA
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to record live broadcast.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question