convert XML to a random string for text fields

Hello

I'm now trying tolearn XML as a way to solve a word game project and I can see why it was suggested as a good direction to go.

Currently, I sketched this little code just to see how it would work.

Each text box receives another word is the word game / the other is a hint.

I was hoping to get a new one appear each time I tested the movie but I can't seem to get it.

Any suggestions to get me going in the right direction?

Thank you

import flash.net.URLLoader;

import flash.events.Event;

var allWords:Array;

var thisWord:String;

var gameWordsXML:XML;

var xmlLoader:URLLoader = new URLLoader();

xmlLoader.addEventListener (Event.COMPLETE, xmlLoaded);

xmlLoader.load (new URLRequest ("words.xml"));

function xmlLoaded(event:Event):void

{

gameWordsXML = new XML (event.target.data);

/ * gameWordsXML:String = event.target.data;

allWords = gameWordsXML.split(","); * /

gameWordsXML [Math.floor (Math.random () * gameWordsXML.length ())];

for (var i: int; i < gameWordsXML.length (); i ++)

{

text_boxA.text = gameWordsXML.word [i]. @ val.

text_boxB.text = gameWordsXML.word [i]. @ allusion;

}

}

using


    
    
    
    
    
    

use

private function xmlLoaded(event:Event):void
{
    gameWordsXML = new XML(event.target.data);

    var words:XMLList = gameWordsXML.elements("word");
    var randomIndex:int = Math.random() * words.length();

    text_boxA.text = gameWordsXML.word[randomIndex].@ val;
    text_boxB.text = gameWordsXML.word[randomIndex].@ hint;
}

method length() of an XML object always returns 1

You must get the XMLList of the nodes that you are interested in and then call length() on it

Tags: Adobe Animate

Similar Questions

  • Is it Apex_Item function for "text field with AutoComplete?

    Hi all
    Is it Apex_Item function for "text field with AutoComplete? I can't find it in the website http://apex.oracle.com/i/doc/AEAPI/apex_item.htm

    Respect,
    Taylor.

    Hello

    I think that there is not. If there is, it is not documented.

    You can use the normal text field and Add AutoComplete using jQuery UI and jQuery autocomplete plugin.
    Those who are willing to Apex 4

    See for example this post how manually to add autocomplete text field
    Plugin of JQuery autocomplete

    Kind regards
    Jari

  • Convert resultlist container to a string for report

    Hi all

    Is there a way to convert a resultlist containing a string? I have a ResultList of a separate test that I need to add to the ModifyBatchReportHeader point of the string for my report in ASCII format.

    I tried adding "str (OtherTestResults)", but it adds just periods as if he doesn't know how to access the test data (name test, measure, etc.). Is there a a way to convert it containing a string the TestStand way automagically done at other times?

    Thank you

    Chris

    Hi Chris,

    Unless you said, I did not realize the batch mode.

    For my example, I used the ModifyBatchReportFooter. You can also use the header.

    You just have to play with the HTML tags.

    This example only works with HTML-reports!

    For the generation, it uses the sequence: PutResultsInReport reportgen_html.seq in the template folder - OR

    Hope this helps a little more

    Jürgen

  • using AS3 to create a quote at random in the text field

    Hello

    I think it would work, but unfortunately, I am not pulling the txt files in the field.

    It's definitley give me feedback at random.

    There are ten citations in a folder: Suzuki_quotes/quote1.txt etc.

    Should I not use a dynamic text field and create a text field by using var.

    Thank you

    Stop();

    var randomNumber:Number = Math.ceil (Math.random () * 10);

    var reqB:URLRequest = new URLRequest("Suzuki_quotes/quote1.txt");
    var loaderB:URLLoader = new URLLoader();

    function textLoadedB(event:Event):void {}
    quoteLdr.text = "Suzuki_quotes/quote" + NombrAl + ".txt";
    }

    loaderB.addEventListener (Event.COMPLETE, textLoadedB);
    loaderB.load (reqB);


    Btn1.addEventListener (MouseEvent.CLICK, goPage2);

    btn2.addEventListener (MouseEvent.CLICK, goPage1);


    function goPage1(evt:MouseEvent):void {}
    gotoAndStop ("page1");
    }

    function goPage2(evt:MouseEvent):void {}
    gotoAndStop ("page2");
    }

    If you have multiple txt files each with a quote, try:

    Stop();

    var randomNumber:Number = Math.ceil (Math.random () * 10);

    var reqB:URLRequest = new URLRequest("Suzuki_quotes/quote"+randomNumber+".txt");
    var loaderB:URLLoader = new URLLoader();

    function textLoadedB(event:Event):void {}
    quoteLdr.text = event.target.data;
    }

    loaderB.addEventListener (Event.COMPLETE, textLoadedB);
    loaderB.load (reqB);

    Btn1.addEventListener (MouseEvent.CLICK, goPage2);

    btn2.addEventListener (MouseEvent.CLICK, goPage1);

    function goPage1(evt:MouseEvent):void {}
    gotoAndStop ("page1");
    }

    function goPage2(evt:MouseEvent):void {}
    gotoAndStop ("page2");
    }

  • Why have I not the properties stocks, Format, validate and calculate for text fields in Acrobat DC?

    I'm looking into buying acrobat dc but note that when you make a form, text fields is more options above when property a right click. This removed the DC?

    No, he's still here.

    Try this: click Tools - prepare the form and then click on "More" to the right of the window, click "return to Acrobat Form.

  • How to remove labels for text fields?

    Hey everybody!

    I have trouble with the forms in Dreamweaver CM³.

    I insert a text field in a form, but the text field automatically comes with a label.

    How can I stop this?

    Click where you want the text box to appear while in Code view and choose Insert > form > text

    Who will placetag without the tag

  • How to create a group/list of the variables in the box for display in the text field, in the format in annex

    I need to identify a series of variables single-response checkbox and display links selected (as a group) in a text field in an annex (comma, space) format. Last week, you provided a small script for a similar requirement by using the list box (multiple response) variables. This time, I need to know how to identify the variables of the box officially and, presumably, use a similar script to display the results in a comma, space format.

    You've been a great help.

    Thank you

    Here's the script for this situation. It assumes there are ten boxes named cb1, cb1, cb2,... cb10.

    // Custom Calculate script for text field
    (function () {
    
        // Initialize the string
        var v, s = "";
    
        // Loop through the check boxes to build up a string
        for (var i = 1; i < 11; i++) {
    
            // Get the value of the current check box
            v = getField("cb" + i).value;
    
            if (v !== "Off") {
                if (s) s += ", ";  // Add a comma and a space if needed
                s += v;  // Add the selected value
            }
        }
    
        // Set this field value to the string
        event.value = s;
    
    })();
    

    You will have to change the name of the field and start/end numbers to match your form.

  • conversion of XML node to a string using Xquery transformation in OSB

    How to convert XML node to a string using a built in function by using Xquery transformation in OSB? In BPEL, we the Xpath function ora extension: getContentAsString() to do the same.

    Do you mean fn - bea:serialize()?

    http://download.Oracle.com/docs/CD/E13159_01/OSB/docs10gr3/Userguide/XQuery.html#wp1104692

  • Completely random behavior for script of division. Need help :)

    Hi people,

    I put a lot of hard work in a form for a client (with the much appreciated help of people on these cards) and I thought it was full but...

    The customer got my attention on a seemingly random behavior for 2 fields on the form.

    I have no knowledge of Javascript but, based on the research online, I came with a custom script. I've rechecked the script but can't understand why random behavior would occur.

    Here are the scripts for 2 fields:

    Basic loan

    ----------------------------------------------------------

    (function () {}

    Get the field values as numbers

    var numerator = + getField("Loan_Amount_3_L2").value;

    denominator = var + getField("Bank_Value").value;

    Do the math if the denominator does not evaluate to zero

    If (denominator! == 0) {}

    Event.Value = numerator / denominator.

    } else {}

    Event.Value = "";

    }

    })();

    Ready

    ----------------------------------------------------------

    (function () {}

    Get the field values as numbers

    var numerator = + getField("Total_Loan_2_L2").value;

    denominator = var + getField("Bank_Value").value;

    Do the math if the denominator does not evaluate to zero

    If (denominator! == 0) {}

    Event.Value = numerator / denominator.

    } else {}

    Event.Value = "";

    }

    })();

    ----------------------------------------------------------

    And here's screenshots of the completely random behavior:

    Below if we begin to enter numbers... and things look OK. $500,000 divided by $500,000 = 100 percent

    pic1.jpg

    Below, we add more numbers. Now, things are unhinged. Here, the result of 92% is incorrect. $400,000 divided $ 500,000 must be equal to 80%.

    pic2.jpg

    Then below the plot thickens again when we add more numbers. Here the basic loan value is correct at 80%, but the end of loan value is not correct. The ready value must be equal to 81% - not 80% ($ 405 000 divided by $500,000 = 81%)

    pic3.jpg

    As a side note, if I do a simplified field notation, the calculations seem to work. The reason why I do not have a simplified field notation, however, is that I get those annoying WARNING come up:

    Warning 1: "The value entered does not match the format [Base_Loan_to_Value_Ratio_LVR_L2]"

    Warning 2: "The value entered does not match the format [End_Loan_to_Value_Ratio_LVR_2]"

    (The fields mentioned in these warnings are the destination fields that produce the above incorrect percentage values).

    Could someone please identify what is happening here? Why is there such a seemingly random variation? And how can I solve this problem?

    Thank you

    Did you check the order of calculation of (different from the tab order) field to make sure it makes sense that the form?

  • How to pull information from a text field in my email subject line using a button to send email?

    I know how to create a button to e-mail with the static object, but I need to pull on the name field in the subject line.

    I use LiveCycle Designer ES2 v. 9.0 on a Windows computer.

    Example: Change request for < text field of the form >

    Not in the XML file, in the Click event of the button.

    You will find the scripteditor on the 'window '. "scripteditor.

    There you can change the event right next to 'show '.

  • Is it possible to create an Advisory Committee would be email address from a text field that connects to a button "submit"?

    I was told that I must submit this question to the forum script... I wonder if this is possible in Acrobat, because so far I was not able to do, but a customer wants that one:

    I have a 'Submit Request' button that includes the e-mail addresses of the intended recipients of a PDF form. But the customer also wants the person who fills out the form to be cc would be in the email that is sent to other recipients. Then the area where the person enters their email address on the form, is it possible to have somehow this email address appear in the cc a section of the email that is sent when the person reaches the 'submit request' at the bottom of the form?

    As far as I can see, the only way to get the form by e-mail to anyone is to the list of previously selected addresses in the section actions of the submit button. That's why I was not able to understand how to get an email address at random from a text field to also be cc would

    Hope this has meaning and any help is very appreciated.

    Thank you!

    So that the drive to send the complete PDF, the document must be enabled for the drive. This gives the document certain usage rights that allow the reader to do things that he cannot normally, including saving a form updated the. To do this:

    Acrobat 9: Advanced > extend features in Adobe Reader

    Acrobat 10: File > save as > Reader Extended PDF > activate additional features

  • Slider custom text field (Cap) does not appear

    All;

    I created a custom text field based on the standard text field, changes work fine (really just a custom height and width and a border).  The problem is the method of painting which seems to remove the cap of the field when it gets the focus.  To be clear the carret never shown at all.

    public class CustomText extends TextField //cutom text field width
    {
        //Custom Height and Width in Pixels
        final static int textwidth=125;
        final static int textheight=25;
    
         CustomText()
         {
         super(); // Call the default constructor    
    
         //Border for text fields
         XYEdges padding = new XYEdges(5, 5, 5, 5); //space between box and border
         Border theborder = BorderFactory.createSimpleBorder(padding, Border.STYLE_SOLID);
    
         //Assign the border to the object
         this.setBorder(theborder);
         }
    
         public void onFocus( int direction )
         {
            super.onFocus( direction ); //invoke parent procedure
            invalidate(); //mark for redraw
         }
    
         public void onUnfocus()
         {
        super.onUnfocus(); //invoke parent procedure
        invalidate(); //mark for redraw
         }
    
         //Override the layout with the custom Width and Height
         protected void layout(int width, int height)
         {
            super.layout(textwidth,textheight);
            setExtent(textwidth,textheight);
    
         }      
    
        //Override the display message such that no message is displayed when the field is full
        protected void displayFieldFullMessage()
        {
        }
    
        //Override the default paint method to call the super class constructor and then assign the border
        protected void paint(Graphics graphics)
        {
           // int prevColor = graphics.getColor(); //Save Previous Color
            graphics.setBackgroundColor(Color.LIGHTGRAY); // Set to Gray
            graphics.clear(); // Clear for redraw
            super.paint(graphics); //Force Redraw of Object
          //  graphics.setColor(prevColor); //restore for cursor paint
    
        }
    
    };
    

    In the paint in the first and last method lines that are commented out were a soloution that I tried after reading on this subject.  Something along the lines of the restoration of the default color, but unfortunately without success.   Any ideas would be more useful

    Thank you!

    Quick thoughts:

    (a) to remove the requirement to substitute paint by setting the background a Color.LIGHTGRAY using the base class

    (b) you put on the field by using this:

    Super.Layout (TextWidth, TextHeight);

    If you then do the following:

    setExtent (textwidth, textheight);

    you are likely to confuse the field.  If you still want to use the entire height and use the full width and then try to deal with it in the Style, that is, replace this:

    Super(); Call the default constructor

    with this

    Super(TextField.USE_ALL_HEIGHT |) TextField.USE_ALL_WIDTH); Call the default constructor

    (c) why you override onFocus and onUnfocus?  I would like to delete these if you do not have anything specific to these methods.

    Make these changes, and you'll have a more simple TextField.  See if these changes will solve the problem of the caret too.

  • I have created a form in Indesign. Is there a way to create the default text in a text field that displays the interactive pdf "insert text here" in the text field?

    I have created a form for the company, so that I work. It is a form that will be used in several offices and has buttons, drop downs and text fields. One of the text fields has a requirement that when the PDF file is opened, the text field has something written in there already, as an example (and one only) INSERT the TEXT HERE. I created the text field in Indesign and used the text tool to type in the area of the body-copy required. After that I have to export it as an interactive PDF, text in the text field disappeared.

    Drop-down lists give an option for a default choice, but I don't see a way to create default text in the Panel of buttons and forms for text fields. Is there a workaround or a hidden feature?

    Thank you!

    Set it in Acrobat.

  • Custom Custom Format AND Date text field label

    I have created a form where I wanted each form field to have a label so that the user knows what to connect, BUT when I arrived at this day it became clear that I can only do one or the other, enter a name or select a date format, because they are both under the same category selection and you can choose only one. I found a previous discussion and was able to use the following code to label all the text fields and he also mentioned that an additional coding would be required to customize the date:

    Custom format for text field script

    If (! event.value) {}

    Event.Value = "enter meeting requested Date."

    Event.Target.Display = display.noPrint;

    } else {}

    Event.Target.Display = display.visible;

    }

    Now my problem is that in order to label the tabled text, I had to do a custom format, so I am unable to choose a custom date format. Instead of getting the error message when the format is wrong there at - it a way to make sure that no mater what type of date is connected, it is automatically reformatted to (mmmm dd, yyyy)?

    I don't know am new to the form of coding features and indeed if there is another way to lock it I would appreciate the help.

    Yes, it is possible... Basically you would use something like this as the custom for the field validation script:

    Event.RC = true;

    If {(event.value)

    var d = util.scand ("mm/dd/yyyy", event.value);

    If (d == null) {}

    App.Alert ("Invalid value.");

    Event.RC = false;

    } else {}

    Event.Value = util.printd ("mmmm dd, yyyy", d);

    Event.Target.Display = display.visible;

    }

    } else {}

    Event.Value = "enter meeting requested Date."

    Event.Target.Display = display.noPrint;

    }

    I have not tested, but I think he should do the trick.

  • How can I make my text field accepts only alphabets?

    It would really help that anyone here help me with a text field where I can enter only alphabets, nothing else. I'm using Acrobat 9 Pro.

    Here is a function at the level of the document that can be called from the event of typing in a text field that will limit the entry of characters A - Z and a - z:

    // Document-level function
    function alphaOnlyKS() {
    
        // Get all that is currently in the field
        var val = AFMergeChange(event);
    
        // Reject entry if anything but digits
        event.rc = AFExactMatch(/[A-z]*/, val);
    }
    

    Call it like that since the event in the sequence of keys:

    // Custom Keystroke script for text field
    alphaOnlyKS();
    

    If you get stuck or you need a wider range of characters, post again.

Maybe you are looking for

  • Cannot install Windows 98 on Tecra 540CDT

    I have an old 540CDT TECRA who worked very well until recently. Due to some problems, I need to reinstall Windows 98 SE (I believe it's 98 is installed, but it could have just 98), the installation stops with a message that the modem drivers are not

  • What is the phone number for the support of safari

    What is the phone number for the support of Safari.  I got a notice that I was hacked.  Thank you

  • Compact rio

    Hello. I am a new user of Labview and I have a question for interfacing with FPGA. I have a 2 and a compactrio or 9237 which has a couple of pressure sensors connected to it. At the beginning I wanted to just make sure that my sensors work well so I

  • Computer stops abruptly after games for 5 minutes

    Ok This problem is more than a gambling problem, but it started as one. I installed Starcraft 2 around the time he was released and in the beginning it was only a problem that has affected this game here. What would happen, I log into the game and pl

  • Emails coming back frequently to ascending order, when I set in ascending order

    I love all my registration e-mail (box receipt, files, etc.) for inclusion in descending chronological order (ie most recent at the top). So I put ' sort by ' in 'View' therefore 'Descending order', in each entry. No problem. But, when I have not con