How to load data from a remote URL?
Posted by Luracast on Jul 4, 2006 in Blog, Examples, Flash 9 | 0 comments
I found that the DataLoadingTest class given in Adobe Labs ActionScript 3 Resources site was buggy and did not work. I’ve corrected the file myself and made it work. Here is the working code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | package { import flash.net.URLLoader; import flash.net.URLRequest; import flash.events.Event; public class DataLoadingTest { private var urlString : String = "http://weblogs.macromedia.com/mxna/"; private var dataLoader : URLLoader; public function DataLoadingTest () { dataLoader = new URLLoader (); dataLoader.addEventListener ("complete", onDataLoad); dataLoader.addEventListener ("securityError", onSecurityError); dataLoader.load (new URLRequest (urlString)); } private function onDataLoad (event : Event) : void { trace ("Raw Data : " + event.target.data); } private function onSecurityError (event : Event) : void { trace ("Security Error : " + event); } } } /* //Usage:- //place the following code in the first frame var dlt:DataLoadingTest=new DataLoadingTest(); */ package { import flash.net.URLLoader; import flash.net.URLRequest; import flash.events.Event; public class DataLoadingTest { private var urlString : String = "http://weblogs.macromedia.com/mxna/"; private var dataLoader : URLLoader; public function DataLoadingTest () { dataLoader = new URLLoader (); dataLoader.addEventListener ("complete", onDataLoad); dataLoader.addEventListener ("securityError", onSecurityError); dataLoader.load (new URLRequest (urlString)); } private function onDataLoad (event : Event) : void { trace ("Raw Data : " + event.target.data); } private function onSecurityError (event : Event) : void { trace ("Security Error : " + event); } } } /* //Usage:- //place the following code in the first frame var dlt:DataLoadingTest=new DataLoadingTest(); */ |
You can download the file from here.
Archives
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Sep | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
About Me
Multi-platform (desktop, mobile, devices etc) and web application development consultant focusing on flash platform
Tags
AcionScript
ActionScript
ActionScript1
ActionScript3
ActionScript Utility
Application
Applications
Arul Blog
AS1
AS3
Bug Fixing
Code
Code developer
Code PHP
Content
Content Development
Developer
Development Tools
Development Utility
Flash
Flash-DB
Flash 5
Flash Coders
Flash Communication Server
Flash Developer
Flash Development
Flash Framework
Flash JavaScript API
Flash MX
Flash News
Flex
Framework
JSFL
Macromedia Flash
PHP
PHP Developer
RSS
RSS XML Feed
Simplified Flash Framework
SWF
Technical News
Tips
Web Applications
Web Development
XML
Recent Posts
Recent Comments
- Tahir Alvi on Webcam Motion Detection using AS3.
- Luracast on Restler
- RV on Restler
- RV on Restler
- RV on Restler


