Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:16:18+00:00 2026-05-27T16:16:18+00:00

I have a inputTextField, and in my inputTextField in my GamePage class i want

  • 0

I have a inputTextField, and in my inputTextField in my GamePage class i want to be able to take the text that you should be able to write in the inputTextField, and replace the text from the inputTextField with my nodes in my xml-fil. In my Xml class above I want to have that code that converts the text from the inputTextField, ex. If i write “monkey” in my inputTextField, I want to replace {ANIMAL} node in my xml-fil with monkey.

package 
{

    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.xml.XMLDocument;
    import flash.xml.XMLNode;

    public class Xml extends Sprite 
    {

        private var xmlText:TextField;
        private var xml:XML;
        private var textBox:TextField;

        public function Xml() 
        {

            var xmlString:URLRequest = new URLRequest("tales.xml");
            var xmlLoader:URLLoader = new URLLoader(xmlString);

            xmlLoader.addEventListener("complete", init);

            function init(event:Event):void 
            {

                var xml:XML = XML(xmlLoader.data);
                var xmlText:TextField = new TextField();

                addChild(xmlText);

                xmlText.width = 500; xmlText.height = 500; xmlText.x = 5; xmlText.y = 100;
                xmlText.text = xml.tale; XML.ignoreWhitespace = true;

                var format:TextFormat = new TextFormat();
                format.color = 0x990000;
                format.size = 18;

                xmlText.setTextFormat(format); 
            }
        }
    } 
}

This is my xml-fil (Google Translated from Swedish):

There was once a {ANIMAL} who came from {CITY}. {ANIMAL} lived in a small little red julhus, just like Santa does. {CITY} also had her Santa Claus, and his name {NAME}. {ANIMAL} and {NAME} was in fact best friends for ages ago, and they lived in the same little red house.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:16:18+00:00Added an answer on May 27, 2026 at 4:16 pm

    If you want to replace the text by the change of an InputField you should listen to the Event.CHANGE of the InputFields. Within this listener you can redirect to a method which will do the replacement. After loading the XML you should also call this method so the initial values are stripped out.

    I didn’t see the InputFields in your code example so here’s a quick example of how you could set it up.

    private var animalInputField:TextField;
    private var cityInputField:TextField;
    private var nameInputField:TextField;
    private var xmlText:TextField;  
    
    public function Xml() 
    {
    
        var xmlString:URLRequest = new URLRequest("tales.xml");
        var xmlLoader:URLLoader = new URLLoader(xmlString);
    
        xmlLoader.addEventListener(Event.COMPLETE, init);
    
        function init(event:Event):void 
        {
    
            xml = XML(xmlLoader.data);
            xmlText = new TextField();
    
            addChild(xmlText);
    
            xmlText.width = 500; xmlText.height = 500; xmlText.x = 5; xmlText.y = 100;
            xmlText.text = xml.tale; 
            XML.ignoreWhitespace = true;
    
            var format:TextFormat = new TextFormat();
            format.color = 0x990000;
            format.size = 18;
    
            xmlText.setTextFormat(format); 
    
            // create inputfields
            animalInputField = createInputField();
            cityInputField = createInputField();
            nameInputField = createInputField();
    
            cityInputField.x = 100;
            nameInputField.x = 200;
    
            updateTale();
        }
    }
    
    private function createInputField() : TextField
    {
        var inputField:TextField = TextField(addChild(new TextField()));
        inputField.type = TextFieldType.INPUT;
        inputField.text = '...';
    
        inputField.addEventListener(Event.CHANGE, onInputChanged);
    
        return inputField;
    }
    
    private function onInputChanged(e:Event):void
    {
        updateTale();
    }
    
    private function updateTale() : void
    {
    
        var tale:String = xml.tale;
    
        tale = tale.replace(/{ANIMAL}/g, animalInputField.text);
        tale = tale.replace(/{CITY}/g, cityInputField.text);
        tale = tale.replace(/{NAME}/g, nameInputField.text);
    
        xmlText.text = tale;
    }
    

    Within the updateTale() method I’m using a regular expression where I use the ‘g’ (global) flag to make Flash search to any instance instead of only the first occurrence.

    Please note that in your example you have a private var xmlText and xml but never use them because within your init(event:Event) listener you create two local vars called xmlText and xml aswell.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a photography site that I want to prevent image copying from. How can
Have one Doubt In MVC Architecture we can able to pass data from Controller
in my form I have input text and then dataView: private class RegistrationForm extends
$('.xys').live('blur', function() { }); Say that I have a input textfield with class xyz
Have a query that should hopefully be nice and simple to answer. I have
I have an input textfield in my html file: <p>From Date: <input type=text id=datepicker></p>
I want to ask a objective C question. I have a string retrieve from
Have an app that can use tts to read text messages. It can also
have written this little class, which generates a UUID every time an object of
have a nice day. I got problem when trying to create an image from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.