The following examples show how you can parse URL encoded strings using ActionScript 2.0 and ActionScript 3.0.
Full code after the jump.
The following example shows how you can use the LoadVars class and the decode() method to parse a URL encoded string:
// ActionScript 2.0 var loadVars:LoadVars = new LoadVars(); loadVars.decode("firstName=Tom&lastName=Jones"); lbl.text = loadVars.lastName + "," + loadVars.firstName; |
In ActionScript 3.0, you can use one of two methods. The first method passes the string to be decoded to the URLVariables class constructor:
// ActionScript 3.0 var urlVariables:URLVariables = new URLVariables("firstName=Tom&lastName=Jones"); lbl.text = urlVariables.lastName + "," + urlVariables.firstName; |
The second method is similar to the ActionScript 2.0 approach and uses the decode() method to parse the URL encoded string:
// ActionScript 3.0 var urlVariables:URLVariables = new URLVariables(); urlVariables.decode("firstName=Tom&lastName=Jones"); lbl.text = urlVariables.lastName + "," + urlVariables.firstName; |
3 Responses to Decoding URL encoded strings in a Flash application using the URLVariables class in ActionScript 3.0
Leave a Reply Cancel reply
Recent Posts
- Getting started with the TLFTextField class in ActionScript 3.0 and Flash CS5
- Adding tick marks to a Slider control in Flash using ActionScript 3.0
- Creating a vertical Slider control in Flash using ActionScript 3.0
- Creating a custom context menu item in Flash using ActionScript 3.0
- Rotating a Sprite object around its x-axis in Flash using ActionScript 3.0 and Flash Player 10
- Detecting when the user changes the color in a ColorPicker control in Flash using ActionScript 3.0
- Getting the currently selected color as a hexadecimal value on a ColorPicker control in Flash using ActionScript 3.0
- Toggling the text field on the ColorPicker control in Flash using ActionScript 3.0
- Creating a vertical Slider control in Flash using ActionScript 3.0
- Setting the number of columns on a ColorPicker control in Flash using ActionScript 3.0
Categories
- Bitmap (1)
- Components (72)
- Button (19)
- CheckBox (2)
- ColorPicker (6)
- ComboBox (1)
- DataGrid (8)
- FLVPlayback (7)
- Label (9)
- ProgressBar (2)
- Slider (3)
- TextArea (1)
- TextInput (7)
- UILoader (7)
- ContextMenu (1)
- Embed (4)
- ExternalInterface (2)
- Flex (7)
- Font (2)
- General (5)
- Graphics (2)
- JSFL (14)
- Loader (3)
- LoadVars (3)
- Microphone (1)
- migration (12)
- MovieClip (1)
- MovieClipLoader (1)
- Sound (2)
- TextField (1)
- TLFTextField (1)
- TransitionManager (1)
- Tween (1)
- Uncategorized (1)
- URLLoader (4)
- URLVariables (1)
- Video (1)
- XML (2)
Advertising
"No public Twitter messages." — pdehaan


Just a little correction
Very helpful….I was wondering how do you deal with name value pairs in URLVariable. Lets say I have an array of name value pairs.
Thanks
var urlVariables:URLVariables = new URLVariables(infoTxt.data);
must be
var urlVariables:URLVariables = new URLVariables(evt.target.data);