SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: XML Navigation

  1. #1
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML Navigation

    Hi,

    I have the following flash file,

    a symbol called navelements, which includes several dynamic text boxes, and image holder and a couple of buttons. I then use the following actionscript to loop through an XML document producing another instance of navelements, populated with different information.

    However I'm having trouble accessing or applying actions to the buttons.

    I can't work out how to apply actiosn to the "readmore" and "launch project" buttons.

    any help would be appreciated. I've attached my FLA and XML file.

    This is the code I'm using to import the XML data.

    Code:
    importXML = new XML();
    importXML.ignoreWhite = true;
    _global.count = 0;
    importXML.onLoad = function(success) 
    	{
    	if (success) 
    		{
    		var depth = 0;
    		var nextX = 10.5;
    		var root = this.firstChild; // The root node
    		var attr = root.attributes;
    		for (var i = root.firstChild; i != null; i = i.nextSibling) 
    			{
    			tempMC = attachMovie ("navelements", "navelements" + count, depth ++, {_x : (nextX) , _x : (10.5)} );
    			nextX += tempMC._width + 20;
    			tempMC.title_text.text = i.attributes.title;
    			tempMC.blurb.text = i.attributes.blurb;
    			tempMC.thumbloader.loadMovie(i.attributes.image);
    			_global.count ++;
    			}
    			
    		} 
    	}
    importXML.load("webthumbs.xml");
    Attached Files Attached Files

  2. #2
    SitePoint Addict
    Join Date
    Jul 2005
    Location
    USA
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One way to do it:

    Code:
    importXML = new XML();
    importXML.ignoreWhite = true;
    _global.count = 0;
    importXML.onLoad = function(success) 
    	{
    	if (success) 
    		{
    		var depth = 0;
    		var nextX = 10.5;
    		var root = this.firstChild; // The root node
    		var attr = root.attributes;
    		for (var i = root.firstChild; i != null; i = i.nextSibling) 
    			{
    			tempMC = attachMovie ("navelements", "navelements" + count, depth ++, {_x : (nextX) , _x : (10.5)} );
    			nextX += tempMC._width + 20;
    			tempMC.title_text.text = i.attributes.title;
    			tempMC.blurb.text = i.attributes.blurb;
    			tempMC.thumbloader.loadMovie(i.attributes.image);
    			
    			// use your depth var to give an id to each button so
    			// it knows which item to track
    			tempMC.readmore.linkId = depth
    			tempMC.readmore.onRelease = function():Void
    			{
    				// put your action here
    				trace("readmore function for button " + this.linkId);
    			}
    			// do the same for the "launch project" button
    			
    			_global.count ++;
    			}
    			
    		} 
    	}
    importXML.load("webthumbs.xml");


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •