First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com/services/

The combo Box:

We keep all of the available translation modes in a separate text file from which we load into Flash and populate the combo box with. First we need to create a text file with the necessary data. How this text file is formatted is the most important aspect of populating components with external data sources. So here's a look:

&mode0=en_fr&desc0=English to French&
&mode1=en_zh&desc1=English to Chinese&
&mode2=en_de&desc2=English to German&
&mode3=en_it&desc3=English to Italian&
&numModes=4&

Ok what the data contains is not as important as how it's formatted. In the download we have a text file with all of the modes contained in it. In this example we are just using 4 possible modes so it doesn't take up to much space. Notice how the numbers work, after each mode and desc variable their is an increasing incremental number, ie 0,1,2,3. The mode in this case is a string that for example looks like 'en_fr' indicating English to French, that is all that is really needed. We added the description (desc) variable as a way to visually display the short hand.

Next we have to load this text file (called Modes.txt in the download) - into the movie. The ActionScript for that will look like the following:

// Create a New LoadVars Object
myModes 		= new LoadVars();

// This Tells the Flash movie What function to invoke when the Load Vars Is complete. 
myModes.onLoad 	= addModes;

// Find the Text File - Load it - after which the function addModes is invoked.
myModes.load("Modes.txt");

We are using the LoadVars Object in this case to load the text file. This is useful because we can use the .onLoad function associated with the Load Vars object to wait for the data to load - and then invoke a function when it's done (addModes). That function will populate the combo box with the data from the Text file - and looks like this:

function addModes() {

	// Loops through the number of listings in the text file and sets them up as nodes.
	for (i=0; icomboBox.addItem(desc, Modes);
	}
}

The comments in the script above should cover about everything. Basically we loop through each record in the text file and add an item to the combo Box for each row in the text file. By creating a data provider for each we can assign as much data to each individual combo box item as needed. This function is found in the 'Functions' layer of the FLA that comes with the download. Some more examples and downloads for this type of thing can be found here: flash-db.com/Components/

So with the combo Box set up and all of the component styles and formats set - we have something that looks like:

So now it's onto the interesting stuff.

» Level Advanced

Added: 2002-08-19
Rating: 7 Votes: 10
(10 being the highest)
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content, applications, and content management systems. Specialty's include SQL, PHP, Perl, XML, web services, and Flash clients for web services.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.