Photoshop Tutorials, Flash Tutorials, 3Ds Studio Max Tutorials, Web Design Tutorials


Software Tutorials

Featured Free Templates
View All Templates!
Preview  |  Download
Name: metamorph_flame
Downloads:
Preview  |  Download
Name: metamorph_skyandclouds
Downloads:
View All Templates!
Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!
Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!
:: Free Website Templates
Preview  |  Download Preview  |  Download Preview  |  Download
Name: metamorph_sunset Name: metamorph_flower Name: metamorph_waterfall
Downloads: Downloads: Downloads:

Do You Like Our Website? Share With Others!
GoogleGoogle slashdotYahooMyWebDiggTechnoratiDelicious
Page: 12345678910111213141516171819202122232425

Welcome To WebDesignTutorials.net Flash Tutorials Area - Flash and XML


------------------------------------------------
Download Flash File
Learn how to create a flash phonebook using the power of xml with flash.

Step First open up a new flash document. We are going to create the form elements and then get into loading the xml. (Please refer to the picture to see how everything was arranged.) First of all you will need to make three layers. Name them actions, text, textBoxes. In the first frame of the actions layer add a stop(); action. Next we will create the form.

Picture 1
Step To create all of the form elements you will need four dynamic textboxes and two buttons (be sure to select dynamic and not static or input for the textboxes). Once you have made the textboxes and lined them up accordingly give them variable names of name_txt, email_txt, web_txt, and entryNum_txt. Next you should put some sort of static label for the name, email, and website textboxes to show what those fields will be displaying. We will deal with the last textbox in a second. Once that is done you need to make the buttons to navigate through the contact list. I simply made a triangle graphic, converted it to a button and then duplicated it for the back button. I also placed my entryNum_txt textbox between these two buttons. Now the hard part is over and we get to have some fun.

Step The first thing you are going to need is the xml file to load into your flash movie. Right click this link and click "save target as". Be sure to save it to the same directory that your flash movie will be saved in. If you are having trouble understanding the xml file, please check out akash's tutorial on xml basics, but don't worry, all you need is that file and flash will do all of the work for you.

Step Finally we get to the fun part. We are going to be using flash's built in XML object to load the xml file and display the appropriate data. Add the following code into the actions layer above the stop(); action.
var contacts = new XML();
contacts.ignoreWhite = true;
var entry = 0;
var total = 0;
var current = 0;
First we are declaring a variable called contacts to handle all of the xml. The second line tells flash to ignore any and all extra whitespaces that may be in the xml file. If you are having trouble loading data from xml right, not having this line could be the reason. The last thing we are doing is declaring 3 variables called entry, total, and current which will be used when we are loading the data.

Step Now we need to load the data and write the function that will handle loading and parsing the loaded data. Add the following code right under what you just wrote and before the stop(); action.

contacts.load("contacts.xml");
contacts.onLoad = function(success) {
if (success) {
name_txt = this.firstChild.childNodes[_root.entry].attributes.name;
email_txt = this.firstChild.childNodes[_root.entry].attributes.email;
web_txt = this.firstChild.childNodes[_root.entry].attributes.website;
_root.total = this.firstChild.childNodes.length;
_root.current = _root.entry + 1;
entryNum_txt = _root.current+" of "+ _root.total;
}
};

There is kind of alot going on here, but we'll get through it. The first thing we are doing here is loading our xml file. contacts is a variable being used to store the xml data loaded. The next line starts the function which will handle all the parsing and loading of data into our form elements. success is the name of our xml file being loaded via contacts.load and the top if statement just verifies that the file is actually loaded.
The line name_txt = this.firstChild.childNodes[_root.entry].attributes.name; tells flash to look into the xml file just loaded (this) then move down to the first node or xml element (.firstChild) and then move down to the appropriate entry (.childNodes[_root.entry]) and finally to grab the appropriate data (attributes.name). Our xml file contains a main element of contacts and under that we have a list of entries. childNodes[0] is the first node, childNodes[1] is the second node and so on.
The next thing we are doing is telling flash how many total entries there are so we can see how many we have to browse through. Then we tell flash which entry we are currently looking at. We add one to _root.entry because 0 is the first element in the node array, but we want it to show that we are looking at entry 1, not entry 0. Then we output which entry we are looking at out of how many.

Step Finally, we will add the code to the buttons so that we can browse through our new phone book. copy the following code on the button that will move you ahead in the phonebook.
on(press) {
	if(_root.entry + 1 == _root.total) {
		_root.entry = 0;
	} else {
		_root.entry += 1;
	}
	_root.contacts.load("contacts.xml");
}
Here we are checking to see if the current entry is the last one in our xml file. If so we cycle back to the beginning. Otherwise we just move ahead one and view the next entry. Now add the following code to the button that will move back in the phone book.
on(press) {
if(_root.entry == 0) {
	_root.entry = _root.total - 1;
} else {
	_root.entry -= 1;
}
_root.contacts.load("contacts.xml");
}
In this code we are doing the same thing as above, but now we are checking to see if we are at the first entry. If so we go the last entry, otherwise we just move backwards one and view that entry.

Step Well, that's it. We are done. Hopefully this tutorial showed you some of what flash can do with xml and has let you think of ways to incorporate it in your projects. XML is a very powerful language and flash's support of it makes a great combination. I encourage you to browse the flash help files to find out more about the xml class. If you have any questions be sure to drop me an email.

Advertisements
Graphic Software, Flash Templates, Free Stock Photos, Web Templates, Web Design, Corporate Web Design, Royalty Free stock Photo, Affordable Website Design, Submit site, Add Url, Stock Photos, Survey Software, Anti Virus Software, E mail software, Computer Software

Premium Partners
  Free Website Templates - Flash templates, Affordable Website Design, Website Templates, Website Redesign, Custom Website Design, Web Design Tutorials, Flash Tutorials, Promotion Tutorials - that is what we do. Metamorphosis Design Studio offers quality, free and low cost web site templates for your business and personal life, we also offer affordable web design and site re-design.
  Vertex Website Tempales - It saves tones of time and money to use pre-made web designs to build your web site. You need a web site but you don't want to pay thousands dollars to professional web design companies? Our web templates is just for you! They are designed to be easilly edited by your favorite html editor, like MS FrontPage
  Photoshop Tutorials - Learn how to build stunning web pages using Adobe Photoshop, Macromedia Flash MX and 3D Studio Max software. The step-by-step approach makes it so easy, that even beginners can produce great web pages. Get started with these tutorials covering everything from page layout to content tips.
Free website templates and paid web templates are great tools to make your websites look perfect! You will save time and money with our flash templates and free website templates Our visitors are satisfied with the quality of our free and paid website templates! Please visit our free website templates and paid website templates sections. We offer free web templates, free web layouts, free web page templates and other stuff for free download. All templates come with the html and external css file so you may easily edit HTML with your favorite HTML editor. Feel free to download our free web templates for your personal websites.

Terms of use depend upon the website template vendor.
Home  |  Submit Tutorial  |  Top Sites  |  Free Templates  |  Website Templates  |  Privacy Policy  |  Contact Us
All Right Reserved by WebDesignTutorials.net