A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Could someone please help?

  1. #1
    Junior Member
    Join Date
    Dec 2004
    Location
    U.S.A.
    Posts
    6

    Could someone please help?

    Hi, first of all, I'll just go ahead let it be known that I didn't search for the topic before posting, but to be honest, I'm not really sure what to search for. Let me give some background info on what I'm doing first and then my question on how to achieve my goal.

    Okay, I'm in the process of creating a band website for my band. There is a section on the site for upcoming shows. I would like to set it up to where I wouldn't have to edit the .fla file every time I add new shows, so that's where XML comes in. Here's what I pictured happening. Please correct me if I'm wrong. If I could somehow dynamically create a movie clip complete with 4 text fields for the corresponding XML nodes and populate these text fields with the info from the XML file, I believe this might work.

    Now, how would I do that exactly? I already created a movie clip with text fields and populated it with the info from the XML file, but I need to have a different movie clip for each show listing with different text fields. Please help! Thanks a ton. Let me know if you need me to describe it better. Peace!

    Brehnan

  2. #2
    Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    88
    ok here you go- ive knocked up a quick example using a recursive parsing technique - it might be a bit more than you need but that will make it more scalable in the long term... here is the xml file...

    Code:
    <gigs>
    	<gig venue="Venue 1" dt="15/09/08 21:30" />
    	<gig venue="Venue 2" dt="16/09/08 21:30" />
    	<gig venue="Venue 3" dt="17/09/08 21:30" />
    	<gig venue="Venue 4" dt="18/09/08 21:30" />
    	<gig venue="Venue 5" dt="19/09/08 21:30" />
    </gigs>
    here is the actionscript:

    Code:
    this.X 		= 50;
    this.Y 		= 50;
    this.Yoff 	= 50;
    
    this.ParseElement = function(node)
    {	
         switch(node.nodeName) {
    		 
    		case "gig":
    			this.attachMovie("gig", "gig"+this.getNextHighestDepth(), this.getNextHighestDepth(), {_x: this.X, _y:this.Y, venue: node.attributes.venue, dt:  node.attributes.dt});
    			this.Y+= this.Yoff;
    		break;				 				
         }
    }
    
    
    this.ParseNode = function(node) {
        if(node) { 
    	  this.ParseElement(node);  
    	  this.ParseNode(node.firstChild);
    	}
    	if(node.nextSibling) {
    	  this.ParseNode(node.nextSibling);
    	}
    }
    
    this.getGigsOnLoad = function() {
    	this["parent"].ParseNode(this);
    
    }
    
    this.getGigs = function() {
    	delete this.getGigsTx;
    	delete this.getGigsRx;
    
    	
    	this.getGigsTx			= new XML("<?xml version\"1.0\" ?><getGigs />");
    	this.getGigsRx 			= new XML();
    	this.getGigsRx.onLoad 	             = this.getGigsOnLoad;
    	this.getGigsRx["parent"]                    = this;
    	this.getGigsTx.sendAndLoad("gigs.xml", this.getGigsRx);
    }
    
    this.getGigs();
    download the example and see if you can get it working - then hit me up with some questions....
    Attached Files Attached Files
    http://robotnic.co.uk/
    -----------------------------------------

  3. #3
    Junior Member
    Join Date
    Dec 2004
    Location
    U.S.A.
    Posts
    6
    Oh man, thank you so much. It works fantastically! I added a couple things but it's great. Perhaps you could help me with something else: http://board.flashkit.com/board/showthread.php?t=760033 Thanks again man! Peace.

    Brehnan
    Last edited by Brehnan; 02-29-2008 at 02:57 PM.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center