In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Geolocation with IP address test

Get Adobe Flash player
by Fake 05 Nov 2010
package {
    import flash.events.SecurityErrorEvent;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.display.Sprite;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextField;
    import flash.events.IOErrorEvent;

    public class FlashTest extends Sprite {
        private var debugout:TextField;

        public function FlashTest() {
            // write as3 code here..
            debugout = new TextField();
            debugout.x = 50;
            debugout.y = 50;
            debugout.autoSize = TextFieldAutoSize.LEFT;
            debugout.background = true;
            debugout.border = true;
            debugout.backgroundColor = 0x000000;
            debugout.textColor = 0x0000FF;
            parent.addChild(debugout);
            
            var urlloader:URLLoader = new URLLoader();
            var req:URLRequest = new URLRequest("http://www.onflex.org/geo/xml/");
            urlloader.addEventListener(Event.COMPLETE, function (e:Event):void {
                var xml:XML = new XML(e.target.data);
                debugout.text = xml.toString();
            })
            urlloader.addEventListener(IOErrorEvent.IO_ERROR, function (e:Event):void {
                debugout.text = "ioerror";
            });
            urlloader.addEventListener(Event.OPEN, function (e:Event):void {
                debugout.text = e.toString();
            });
            urlloader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function (e:SecurityErrorEvent):void {
                debugout.text = e.toString();
            });
            try {
                urlloader.load(req);
            } catch (e:Error) {
                debugout.text = e.toString();
            }
        }
    }
}