First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Joachim Schnier | Website: http://www.cancerinform.net/

The Actionscript: part 4

Completing our search

We have now scripts, which will do the final job to complete our search. In this example we execute the function findSubgroup_1 (subGroup), which searches for blond or black models who speak a foreign language. After looping through the haircolor childnodes we ask by an if statement if count04>=0. This makes sure we include all nodes. Counting nodes in flash starts with 0, which we have to include as well. Then we ask if there are any nodes with the attribute "foreign", since these are the ones we are looking for disregarding others. Finally we want to make sure that there are no undefined nodes.

If there was success and there were nodes then we want to know the names and descriptions, which are held by the var modelName and modelDescription. Since our description of the model can be in a textfile or in the XML file itself as the first child of a node, we have to distinguish that by another if statement. Finally we want to show a list of the matches, which is done by the function for the listbox chooseModel(modelName,modelDescription);, which is explained below. We write actionscript such as this one for all the search categories. You can see another example following this one.

//now we have to access all the childnodes, here for those which contain the attribute name "foreign"
function findSubgroup_1 (subGroup) {
    for (var count04=0; count04 <= subGroup.childNodes.length; count04++) {
        myModel04 = subGroup.childNodes[count04];
        //"count04" will count all childnodes starting from 0.
        //only the nodes with a positive match will be listed.	
        if(count04>=0 && myModel04.attributes.language == "foreign" && myModel04 != undefined){
            modelName = myModel04.attributes.name;//name attribute
            //the var modelDescription holds the nodeValue of the firstChild of each node
            //but when there is no nodeValue and therefore firstChild is undefined, then
            //this means we have an attribute "ID" and modelDescription will hold the
            //attribute ID, which is a text document.
            if (modelDescription == undefined){
            }//here we now execute the function for the listbox with the 
            //two arguments "modelName", which holds the name of the models
            //and "modelDescription", which holds a nodeValue or the ID attribute.

//this is essentially the same as in the previous chapter, except we will list
//all childnodes of a particular parent node.
function findSubgroup_2 (subGroup) {
    for (var count04=0; count04 <= subGroup.childNodes.length; count04++) {
        myModel04 = subGroup.childNodes[count04];
        if(count04>=0 && myModel04 != undefined){
            modelName = myModel04.attributes.name;

» Level Intermediate

Added: 2002-09-17
Rating: 8.83 Votes: 72
(10 being the highest)
» Author
The author is a basic scientist doing cancer research.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • 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: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
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: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.