0

I am using the example code in flash. I want a single variable and not the whole text. I have a dynamic textfield called OUTPUT on the stage.

var fl_TextLoader:URLLoader = new URLLoader();
var fl_TextURLRequest:URLRequest = new URLRequest("http://www.testing.com/Christmas.txt");

fl_TextLoader.addEventListener(Event.COMPLETE, fl_CompleteHandler);

function fl_CompleteHandler(event:Event):void
{
    var textData:String = new String(fl_TextLoader.data);
    OUTPUT.text = textData;
}

fl_TextLoader.load(fl_TextURLRequest);

The Christmas text file contents:

Var1=Jesus&Var2=Mary&Var3=Christmas

The OUTPUT comes out with the whole string. How do I get the url parameter values separately?

Like OUTPUT.text = textData.Var1; (<--- But this does not work.)

1 Answer 1

1

The .data property is just a string, the raw data returned by the HTTP call, so you will have to parse the variable-value pairs, either using simple .split() on the strings or using the URLVariables object, that can do the parsing for you:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html#decode()

Sign up to request clarification or add additional context in comments.

1 Comment

This guy is right, do this: var vars:URLVariables = new URLVariables(fl_TextLoader.data); trace(vars.Var2); //Traces "Mary"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.