Results 1 to 1 of 1

Thread: [RESOLVED] Flash Action Script 3 - XML button label

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Flash Action Script 3 - XML button label

    Hi,

    This code shows you how to create a button to change its label via xml.

    1.You need to create a new movie clip! The name is up to you.
    2. Draw the button shape.
    3. Add a new layer called "Text".
    4. Add a dynamic textbox called "btText" to the "Text" layer.
    5. Go back to the main stage add a new layer called "Actions" and add the following code:

    Code:
    var link: URLRequest = new URLRequest("menuDef.xml");
    var loader:URLLoader = new URLLoader(link);
    var i:int
    var myXML:XML = new XML();
    //call the loaders load function to load the specified URL
    
    loader.load(link);
    
    
    loader.addEventListener(Event.COMPLETE,dataLoaded);
    //Button code
    function dataLoaded (event: Event){
    	myXML = new XML(loader.data);
    	for (i = 0; i < 6; i++){
    		var j:int = i+ 1; 
    		/**0 is the line in the  
    		xml the labels start from. (i) starts counting from the 0 line until the end
            specified above.**/
    	
    		this["btnEnter"].btText.text = myXML.child(0).child(0);
    	}
    	
    }
    6. Create an xml file called "menuDef.xml" and add the following text to it:

    <?xml version="1.0"?>
    <menu>
    <menuLabels>
    <label>Home</label>
    </menuLabels>
    </menu>
    7. Go back to flash and add another layer called "content".

    8. Drag the newly created movie clip onto the "content" layer (stage) and put "btnEnter" as the instants name.

    9. Run the project.

    Nightwalker
    Last edited by Nightwalker83; Jun 27th, 2009 at 11:24 PM. Reason: Adding more
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Tags for this Thread

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