package {
    import com.hurlant.jsobject.JSObject;
    
    import flash.display.Sprite;

    public class DOM extends Sprite
    {
        public function DOM()
        {
            // try using the dom..
            
            with (JSObject.getWindow()) {
                trace("width=" + top.window.self.innerWidth);
                //window.innerWidth = 500;
                //trace("width="+window.innerWidth);
                //trace("answer= "+window.prompt("2+2=","4"));
                trace("window = "+window);
                body = document.getElementsByTagName("body")[0];
                trace("body = "+body);
                body.style.backgroundColor="green";
                tags = document.getElementsByTagName("script");
                trace(tags.length+" script tags:");
                for (var tag:* in tags) {
                    trace("tag: "+tag+" value:"+tags[tag]);
                }
                // ok. try something more involved
                e = document.getElementById("test");
                b = document.createElement("button");
                b.innerHTML = "Click me!";
                b.onclick = function(e:*):void {
                     alert("clicked on "+this+" at "+e.clientX+","+e.clientY); 
                };
                document.body.insertBefore(b,e);
            }
        }
    }
}