0 Replies - 3243 Views - Last Post: 09 November 2012 - 07:20 AM

#1 hathead1990  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 25-November 11

Loading images from XML using actionscript 3.0

Posted 09 November 2012 - 07:20 AM

Hi all I am struggling to load images into flash using an XML file. (my code below). I have managed to load other information such as title and description using dynamic text boxes. However I want to load an image for that particular title and description! (images are in a folder)
Any help will be much appreciated thanks in advance :)/>

I have tried to find many tutorials on how to do this but I cannot find much.


stop() ; 

exitBTN.addEventListener(MouseEvent.CLICK,clickFunctionExit);
function clickFunctionExit(evt:MouseEvent):void {
gotoAndPlay(1,"Title"); }

//imports
import flash.display.Loader;
import flash.net.URLRequest;

//set up variables for XML below / XML located in data folder  
var myXMLURL:URLRequest = new URLRequest("data/pubs.xml");
var myLoader:URLLoader = new URLLoader();
var myXML:XML;
var currentVenue:int = 0; //set variable to 0 
 
myLoader.addEventListener(Event.COMPLETE, loaded);
 
function loaded(e:Event)
{
    myXML = new XML (e.target.data);
}
 
myLoader.load(myXMLURL); //load XML file from URL
 
function nextVenue(e:Event)
{
    if (currentVenue < myXML.venue.length())
    {
        currentVenue +=1; //cycle through venues when next_btn is clicked +1
    }    
    myTextBoxTitle.text = myXML.venue.name[currentVenue -1]
	
	myTextBoxDes.text = myXML.venue.description[currentVenue -1]
	
	myTextBoxAddress.text = myXML.venue.address[currentVenue -1]
	
}
 
function prevVenue(e:Event)
{    
    if (currentVenue >1)
    {
        currentVenue -=1; //cycle back through venue when prev_btn is clicked -1
    }    
    myTextBoxTitle.text = myXML.venue.name[currentVenue -1]	//Output to title textbox
	
	myTextBoxDes.text = myXML.venue.description[currentVenue -1] //Output to description textbox
	
	myTextBoxAddress.text = myXML.venue.address[currentVenue -1] //Output to address textbox
	
}

 
nextBTN.addEventListener(MouseEvent.MOUSE_DOWN, nextVenue);
backBTN.addEventListener(MouseEvent.MOUSE_DOWN, prevVenue);




Is This A Good Question/Topic? 0
  • +

Page 1 of 1