Monday, February 28, 2011

HTML Loder in Flex Air Application

mxml code

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" viewSourceURL="srcview/index.html">
    <mx:Script>
        <![CDATA[
            import mx.events.ResizeEvent;
            import mx.controls.Alert;
       
       private var htm:HTMLLoader=new HTMLLoader();
       private var loc:String = "<html><head></head><body><iframe width='100%' height='100%' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=33 Wood Ave, Iselin, NJ 08246&z=12&output=embed'></iframe></body></html>";
       private var conti:Sprite=new Sprite();
       private var buttun:Boolean=true;
       
        public function aceesslink():void
        {
            htm.loadString(loc);
            conti.addChild(htm);
            uicomponent.addChild(conti);
            /* Alert.show("Hi EveryBody") */;
        }
         
        private function onResize(e:ResizeEvent):void
        {
                htm.width = uicomponent.width;
                htm.height = uicomponent.height;
        }
       
        public function activatebtn():void
        {
              buttun=false;
              if(buttun==false)
              {
                  cheing.selected=false;
                  mapaction.enabled=false;
              }
        }
       
        public function checkboxaction():void
        {
            if(cheing.selected)
            {
                mapaction.enabled=true;
            }
            else
            {
                mapaction.enabled=false;
            }
        }
       
        ]]>
    </mx:Script>
   
   
    <mx:Button x="323" y="535" label="Click ME" id="mapaction" width="146" height="49" click="aceesslink(),activatebtn();"/>
    <mx:Panel x="10" y="10" width="782" height="505" layout="absolute" id="includegoogle">
    <mx:UIComponent  id="uicomponent" width="100%" height="100%" resize="onResize(event)"/>
    </mx:Panel>
    <mx:CheckBox x="16" y="549" label="Map Refresh" id="cheing" selected="true" change="checkboxaction()"/>

</mx:WindowedApplication>

Output Image: