Solved

Creating an XML string

Posted on 2003-12-11
3
179 Views
Last Modified: 2010-04-03
In a recent project I have been working on, I have an input box that I have prevented users from entering in unapropriate words by using an array and a "for" loop.
This is what my code looks like.

badWords = ["milk", "juice", "cordial", "wine", "beer"];
mybutton.onRelease = function ()
{
     if (this._parent.txtBox.length > 0) {
          for (i in badWords) {
               if (txtBox.indexOf(badWords[i])>-1) {
          status = "No Swearing";
               return;
               }
          }
     }
}

How can I achieve this same idea, however using values from an external xml file?

Cheers

-OBCT
0
Comment
Question by:OBCT
  • 2
3 Comments
 
LVL 9

Author Comment

by:OBCT
ID: 9926492
Sorry the title was meant to be "Creating an XML array"
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 9926699
OBCT, there's another thread asking a similar thing, though he wants to use attributes, and I couldn't get that to work properly.

In a normal xml setup. ie.

<xml>
<item1>milk</item1>
<item2>juice</item2>  
<item3>cordial</item3>
<item3>wine</item3>
</xml>

you can do this.

myXML = new XML();
myXML.load("xmlFileName.xml");
myXML.ignoreWhite = true;
myXML.onLoad = processXML;
function processXML() {
      wordArray = new Array();
      for (var n = 0; n<myXML.firstChild.childNodes.length; n++) {
            wordArray[n] = myXML.childNodes[0].childNodes[n].childNodes[0];
            trace(wordArray[n] add " array items");
      }
}

so you're creating an array in flash from an xml file.
0
 
LVL 9

Author Comment

by:OBCT
ID: 9926750
Thank you, blue. You are a genius :D
Cheers for that

-OBCT
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now