Skip navigation
Currently Being Moderated

HELP would be awesome!!

Aug 10, 2011 8:20 AM

Hi guys !!

 

I am working o a jargon buster for a college project.

 

I have written up an (External) XML document like this:

 

<Items>

      <Query>Rip</Query>

       <answer>to copy files from a disc onto a computer</answer>

 

</Items>

 

Basically the user inputs their query into a editable text field and then flash searches the xml for the query and returns an

answer into a readable text field below.

 

My problem is how do I get flash to do that??

 

Thanks in advanced.

 
Replies
  • Currently Being Moderated
    Aug 22, 2011 8:55 AM   in reply to Gaff2156

    Hi

     

    First and most difficult is to be able to Search on whatever the User types in - this is not the most secure or easily searchable method.

     

    I'd suggest; to make life easier on yourslf - limit the Search criteria by using a drop-down list populated with your <query>Rip</query>

    The User is then limited only to the selection in the list  - and the result can be instantly displayed in a dynamic textfield.

     

     

    Hope it helps

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 22, 2011 1:46 PM   in reply to Gaff2156

    Hi

     

    The drop-down list would be DYNAMIC - automatically populated by your XML.

     


    Google 'comboBox dataProvider'

     

    Hope it Helps

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 22, 2011 3:06 PM   in reply to Gaff2156

    OK Try this

     

    Drag a ComboBox from the Components Panel onto the Stage and give it a Instance name of combo in the Properties Panel.

    Create a Dynamic TextField on the Stage with an Instance name of answer in the Properties Panel.

     

    Copy and Paste this into the Actions Panel.

     

    import flash.net.URLLoader;
    import flash.net.URLRequest;

     

    var xml:XML;
    var urlRequest:URLRequest = new URLRequest("jargonBuster.xml");
    var urlLoader:URLLoader = new URLLoader(urlRequest);
    urlLoader.load(urlRequest);

     

    urlLoader.addEventListener(Event.COMPLETE, xmlDataLoaded,false,0,true);

     

    function xmlDataLoaded(e:Event)
    {
    xml = new XML(e.target.data);

    for each(var qry:XML in xml.items.Query)
    {
         combo.addItem({label: qry});
    }
    answer.text = xml.items[0].answer;
    combo.addEventListener(Event.CHANGE, comboChanged, false, 0, true);
    }

     

    function comboChanged(e:Event)
    {
        answer.text = xml.items[e.target.selectedIndex].answer;
    }

     

    jargonBuster.xml looks like this:-

     

    <?xml version="1.0"?>
    <jargonBuster>
      <items>
        <Query>HDD</Query>
        <answer>Hard Disk Drive</answer>
      </items>
      <items>
        <Query>USB</Query>
        <answer>Universal Serial Bus</answer>
      </items>
      <items>
        <Query>Rip</Query>
        <answer>to copy files from a disc onto a computer</answer>
      </items>  
    </jargonBuster>

     

    Now when you select and item in the list the answer appears in the textfield.

     

    Hope it helps.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 23, 2011 6:50 AM   in reply to Gaff2156

    Glad it helped:-

     

    But now your asking for a Predictive Text System - I think you would have to implement a Dictionary based lookup system.

    I'm not familiar with this so not very helpful there.

     

    However: you could extend the drop-down list method -

     

    Add a Category Attribute to your jargonBuster.xml this would then be your fisrt choice drop-down.

     

    Such as: Email

                   Hardware

                   Internet

                   Software

     

    <item cat="Email">

    <query>Spam</query>

    <answer>Unsolicited Email</answer>

    </item>

    <item cat="Hardware">

    <query>HDD</query>

    <answer>Hard Disk Drive</answer>

    <item cat="Email">

    <query>Junk Mail</query>

    <answer>Like Spam - but more annoying</answer>

    </item>

     

    Then in a second drop-down list you can have all the queries related to the choice in the first list.

     

    I am not trying to dissuade you from the way you want to do it - its just most systems use this type of drill-down method.

     

    Hope it helps

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points