<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jozef Chúťka&#039;s blog &#187; FlexIFrame</title>
	<atom:link href="http://blog.yoz.sk/tag/flexiframe/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yoz.sk</link>
	<description>My life, my work</description>
	<lastBuildDate>Fri, 27 Aug 2010 12:43:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>TextInput wmode opaque/tranpsarent workaround</title>
		<link>http://blog.yoz.sk/2010/02/textinput-wmode-opaque-transparent-workaround/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=textinput-wmode-opaque-transparent-workaround</link>
		<comments>http://blog.yoz.sk/2010/02/textinput-wmode-opaque-transparent-workaround/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 10:27:56 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[allowscriptaccess]]></category>
		<category><![CDATA[FlexIFrame]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[opaque]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[transparent]]></category>
		<category><![CDATA[wmode]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1004</guid>
		<description><![CDATA[Many of you have come accross the horrendous bug that happens with text input in flash when the swf is embedded with wmode=transparent/opaque. It has been much discussed (Firefox Bugzilla entry for this bug, Adobe Forum discussion, etc.), but it seems that in all the years that this bug has existed nothing much has been [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/fakeTextInput-200x100.png" alt="" title="fakeTextInput" width="200" height="100" class="alignleft size-medium wp-image-1015" /></p>
<p>Many of you have come accross the horrendous bug that happens with text input in flash when the swf is embedded with wmode=transparent/opaque. It has been much discussed (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=347185">Firefox Bugzilla entry for this bug</a>, <a href="http://bugs.adobe.com/jira/browse/FP-479">Adobe Forum discussion</a>, etc.), but it seems that in all the years that this bug has existed nothing much has been done. A <a href="http://www.google.cz/search?hl=cs&#038;rlz=1C1GGLS_csCZ334CZ334&#038;q=wmode+transparent+text+input+workaround&#038;btnG=Hledat&#038;lr=&#038;aq=f&#038;oq=">lot of workarounds have been published</a>, many of them based on custom key mapping etc&#8230; My workaround uses html element &lt;input type=&#8221;text&#8221;&gt; that is placed right over flex &lt;mx:TextInput&gt;. Html element is styled transparent (no design) so user will not notice.</p>
<p><span id="more-1004"></span></p>
<p>Following application uses wmode &#8220;opaque&#8221;, try inserting characters (čšň) into first text input (mx:TextInput) and than into second (uses html &lt;input type=&#8221;text&#8221;&gt; over flash)</p>
<p><iframe width="100%" height="300" src="http://blog.yoz.sk/examples/fakeTextInput/"></iframe></p>
<p>Main application</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    applicationComplete=&quot;init()&quot; viewSourceURL=&quot;srcview/index.html&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import mx.managers.PopUpManager;
    private function init():void
    {
        var window:FakeInputsWindow = new FakeInputsWindow();
        PopUpManager.addPopUp(window, this);
        PopUpManager.centerPopUp(window);
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;/mx:Application&gt;</pre>
<p>FakeInputsWindow</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:TitleWindow
    xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    xmlns:html=&quot;sk.yoz.html.*&quot;
    layout=&quot;vertical&quot; width=&quot;400&quot; height=&quot;250&quot;
    creationComplete=&quot;init()&quot;
    move=&quot;moveHandler()&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    [Bindable]
    private var text2:String = &quot;&quot;;

    private function init():void
    {
        ExternalInterface.addCallback(&quot;fakeTextInputChange&quot;, fakeTextChange);
    }

    private function moveHandler():void
    {
        fakeTextInput.positionChanged = true;
        fakeTextInput.invalidateProperties();
    }

    private function fakeTextChange(value:String):void
    {
        text2 = value;
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Text text='&amp;lt;mx:TextInput ....'/&gt;
&lt;mx:TextInput id=&quot;text1&quot; width=&quot;300&quot; height=&quot;20&quot;/&gt;
&lt;mx:Label text=&quot;{text1.text}&quot; /&gt;
&lt;mx:Spacer height=&quot;10&quot; /&gt;
&lt;mx:Text text='&amp;lt;input type=&quot;text&quot; ....'/&gt;
&lt;mx:Canvas width=&quot;300&quot; height=&quot;20&quot;&gt;
    &lt;mx:TextInput width=&quot;300&quot; height=&quot;20&quot;/&gt;
    &lt;html:IFrame width=&quot;100%&quot; height=&quot;100%&quot; id=&quot;fakeTextInput&quot;
        autoResize=&quot;true&quot;/&gt;
&lt;/mx:Canvas&gt;
&lt;mx:Label text=&quot;{text2}&quot; /&gt;
&lt;/mx:TitleWindow&gt;</pre>
<p>lines:</p>
<ul>
<li>15: javascript-to-flash callback definition fakeTextInputChange (from javascript) sends value into actionscript fakeTextChange()</li>
<li>18: fakeTextInput is IFrame class, that controls position and size of html input, lets correct position on TitleWindow move&#8230;</li>
<li>35-39: I placed IFrame over TextInput. IFrame is in fact transparent html input, so what user see is just flex TextInput graphics</li>
</ul>
<p>Html template file</p>
<pre class="brush: xml;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
&lt;head&gt;
    &lt;title&gt;FakeTextInput&lt;/title&gt;
    ...
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/swfobject.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/flexiframe.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    &lt;!--
        var flashvars = {}

        var params = {
            allowscriptaccess: &quot;always&quot;,
            wmode: &quot;opaque&quot;
        };
        var attributes = {
            id: &quot;flash&quot;
        };
        swfobject.embedSWF(&quot;Tests.swf&quot;, &quot;alternative&quot;, &quot;100%&quot;, &quot;100%&quot;, &quot;10.0.0&quot;,
            &quot;flash/expressInstall.swf&quot;, flashvars, params, attributes);

        function fakeTextInputChange()
        {
            var input = document.getElementById('fakeTextInput');
            var flash = document.getElementById('flash');
            flash.fakeTextInputChange(input.value);
        }
    //--&gt;
    &lt;/script&gt; 

    &lt;style type='text/css'&gt;
    &lt;!--
        body {margin:0px;overflow:hidden;}
        html, body, object, embed {width:100%;height:100%;outline:none;}
        #fakeTextInput {
            position:absolute;
            border:none;
            outline:none;
            padding:0;
            margin:0;
            background:transparent url(&quot;images/spacer.gif&quot;);
            vertical-align:middle;
        }
    --&gt;
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id=&quot;alternative&quot;&gt;
        &lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;
            &lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;
        &lt;/a&gt;
    &lt;/div&gt;
    &lt;input type=&quot;text&quot; id=&quot;fakeTextInput&quot; onkeyup=&quot;fakeTextInputChange()&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Notice lines:</p>
<ul>
<li>07: import <a href="http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/">flexiframe.js</a> used for positioning html input on correct place</li>
<li>13: allowscriptaccess must be enabled</li>
<li>14: wmode opaque/transparent is what the source of all evil</li>
<li>22: javascript-to-flash communication</li>
<li>35-42: remove all html input text design and makes it transparent</li>
<li>53: input text definition, you may want to define your own handlers (submit, paste, focus&#8230;)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/textinput-wmode-opaque-transparent-workaround/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Elegant Facebook Login For Desktop Application</title>
		<link>http://blog.yoz.sk/2010/01/elegant-facebook-login-for-desktop-application/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=elegant-facebook-login-for-desktop-application</link>
		<comments>http://blog.yoz.sk/2010/01/elegant-facebook-login-for-desktop-application/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 11:24:29 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[DesktopSession]]></category>
		<category><![CDATA[facebook api]]></category>
		<category><![CDATA[FacebookLogger]]></category>
		<category><![CDATA[FacebookPopup]]></category>
		<category><![CDATA[FlexIFrame]]></category>
		<category><![CDATA[IFrame]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=915</guid>
		<description><![CDATA[Default facebook login page is usualy opened in new browser window or popup window, so user lose focus from your page. This application opens facebook login page within your flash application, so user will not lose your page. In fact little iframe trick is used. This post connects my 3 previous posts: Flex IFrame – [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/elegantFacebookLogin.jpg" alt="" title="elegantFacebookLogin" width="200" height="124" class="alignleft size-full wp-image-920" /></p>
<p>Default facebook login page is usualy opened in new browser window or popup window, so user lose focus from your page. This application opens facebook login page within your flash application, so user will not lose your page. In fact little iframe trick is used.</p>
<p>This post connects my 3 previous posts: <a href="http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/">Flex IFrame – Web browser in flash</a>, <a href="http://blog.yoz.sk/2009/12/facebooklogger/">FacebookLogger</a> and <a href="http://blog.yoz.sk/2010/01/facebook-extended-permissions-with-authorization-by-overriding-class-in-swc/">Facebook Extended Permissions With Authorization by Overriding Class in swc</a> in order to create elegant solution for facebook connect with your desktop application (means outside facebook iframe or fbml). I recomend to read all previous mentioned posts before trying to run this app.</p>
<p><span id="more-915"></span></p>
<p>Final application (view source enabled)</p>
<p><iframe src="http://blog.yoz.sk/examples/elegantFacebookLogin/" style="border:none;" width="100%" height="600"></iframe></p>
<p>FB class. Read more about <a href="http://blog.yoz.sk/2009/12/facebooklogger/">FacebookLogger</a> class here.</p>
<pre class="brush: as3;">package
{
    import flash.net.URLRequest;
    import flash.net.URLVariables;

    import mx.core.Application;

    import sk.yoz.events.FacebookLoggerEvent;
    import sk.yoz.net.FacebookLogger;

    public class FB extends FacebookLogger
    {
        private static const SINGLETON_LOCK:Object = {};
        private static const _instence:FB = new FB(SINGLETON_LOCK);

        protected var API_KEY:String = &quot;bc55511efba53af7a3529ea9e7d1989b&quot;;
        protected var APP_SECRET:String = &quot;727616ab7a9acb969e7cec3c7de04d79&quot;;

        private var initCallback:Function;

        public function FB(lock:Object)
        {
            super();

            if(lock != SINGLETON_LOCK)
                throw new Error(&quot;Use FB.instance!&quot;);

            addEventListener(FacebookLoggerEvent.CONNECTED, loggerConnectedHandler)
        }

        public static function get instance():FB
        {
            return _instence;
        }

        public function init2(application:Application):void
        {
            if(public::connected)
                return;
            init(API_KEY, APP_SECRET, application.loaderInfo);
        }

        public function initWithCallback(application:Application, callback:Function):void
        {
            initCallback = callback;
            init2(application);
        }

        private function loggerConnectedHandler(event:FacebookLoggerEvent):void
        {
            if(initCallback != null)
                initCallback();
            initCallback = null;
            // now we are connected, your code may go here
        }

        public function openPopup(login_url:String, auth_token:String):void
        {
            var request:URLRequest = new URLRequest(login_url);
            var variables:URLVariables = new URLVariables();

            variables.req_perms = 'publish_stream';
            variables.api_key = facebook.api_key;
            variables.v = facebook.api_version;
            variables.auth_token = auth_token;
            variables.fbconnect = &quot;true&quot;;
            variables.connect_display = &quot;popup&quot;;

            request.data = variables;

            FacebookPopup.open(request);
        }
    }
}</pre>
<p>DesktopSession class. Read more about <a href="http://blog.yoz.sk/2010/01/facebook-extended-permissions-with-authorization-by-overriding-class-in-swc/">Overriding Class in swc</a>.</p>
<pre class="brush: as3;">... some code ...

protected function onLogin(p_event:FacebookEvent):void {
	p_event.target.removeEventListener(FacebookEvent.COMPLETE, onLogin);

	if (p_event.success) {
		_auth_token = (p_event.data as StringResultData).value;

		FB.instance.openPopup(login_url, _auth_token);

		_waiting_for_login = true;
		dispatchEvent(new FacebookEvent(FacebookEvent.WAITING_FOR_LOGIN));
	} else {
		onConnectionError(p_event.error);
	}
}

... some code ...</pre>
<p>FacebookPopup class. Read more about <a href="http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/">Flex IFrame</a>.</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:TitleWindow xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;vertical&quot;
    width=&quot;510&quot; height=&quot;465&quot; xmlns:html=&quot;sk.yoz.html.*&quot; move=&quot;moveHandler()&quot;
    title=&quot;Facebook login&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import mx.core.Application;
    import mx.managers.PopUpManager;

    [Bindable]
    protected var url:String;

    [Bindable]
    protected var fb:FB = FB.instance;

    protected function moveHandler():void
    {
        iframe.positionChanged = true;
        iframe.invalidateProperties();
    }

    public function set request(value:URLRequest):void
    {
        var url:String = value.url;
        url += &quot;?&quot;;
        for(var param:String in value.data)
            url += &quot;&amp;&quot; + param + &quot;=&quot; + value.data[param];
        this.url = url;
    }

    public static function open(request:URLRequest):void
    {
        var window:FacebookPopup = new FacebookPopup();
        window.request = request;
        window.visible = true;
        PopUpManager.addPopUp(window, Application(Application.application));
        PopUpManager.centerPopUp(window);
    }

    protected function validateLogin():void
    {
        fb.validate();
        close();
    }

    protected function close():void
    {
        visible = false;
        PopUpManager.removePopUp(this);
    }

    protected function refresh():void
    {
        iframe.url = url;
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;html:IFrame width=&quot;100%&quot; height=&quot;100%&quot; id=&quot;iframe&quot; autoResize=&quot;true&quot;
    url=&quot;{url}&quot; visible=&quot;{visible}&quot;/&gt;
&lt;mx:HBox width=&quot;100%&quot;&gt;
    &lt;mx:Text text=&quot;Clik Ok after you login to Facebook.&quot; /&gt;
    &lt;mx:Spacer width=&quot;100%&quot; /&gt;
    &lt;mx:Label text=&quot;refresh&quot; click=&quot;refresh()&quot; textDecoration=&quot;underline&quot;
        buttonMode=&quot;true&quot;/&gt;
&lt;/mx:HBox&gt;
&lt;mx:HBox width=&quot;100%&quot; horizontalAlign=&quot;center&quot; &gt;
    &lt;mx:Button label=&quot;Ok&quot; click=&quot;validateLogin()&quot;/&gt;
    &lt;mx:Button label=&quot;Cancel&quot; click=&quot;close()&quot;/&gt;
&lt;/mx:HBox&gt;
&lt;/mx:TitleWindow&gt;</pre>
<p>Application (do not forget to add facebook flex .swc, version 3.4 used in example)</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import FB;

    [Bindable]
    private var fb:FB = FB.instance;
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Button label=&quot;Facebook connect&quot; click=&quot;fb.init2(this)&quot;/&gt;
&lt;mx:Text text=&quot;{fb.connected ? 'connected' : 'not connected'}&quot; /&gt;
&lt;/mx:Application&gt;</pre>
<p>Application html template. <a href="http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/">More about flexiframe.js here</a>.</p>
<pre class="brush: xml;">... some code ...
&lt;script type=&quot;text/javascript&quot; src=&quot;flexiframe.js&quot;&gt;&lt;/script&gt;
... some code ...</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/01/elegant-facebook-login-for-desktop-application/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Flex IFrame &#8211; Web browser in flash (update)</title>
		<link>http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=flex-iframe-web-browser-in-flash</link>
		<comments>http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 10:45:21 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[FlexIFrame]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[IFrame]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=139</guid>
		<description><![CDATA[You can not have a web browser inside your web flash applications right? Well, you can! This solution uses html iframe to generate fake build in browser. So the behaviour of the browser in flash is the same as the one you are previewing this flash in (it is the same one). The best part [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.yoz.sk/wp-content/uploads/Clipboard02.png"><img src="http://blog.yoz.sk/wp-content/uploads/Clipboard02-200x196.png" alt="Clipboard02" title="Clipboard02" width="200" height="196" class="alignleft size-medium wp-image-370" /></a></p>
<p>You can not have a web browser inside your web flash applications right? Well, you can! This solution uses html iframe to generate fake build in browser. So the behaviour of the browser in flash is the same as the one you are previewing this flash in (it is the same one). The best part of it is, you can manipulate with the position and size of this browser directly from flash. <a href="http://classes.yoz.sk/sk/yoz/html/IFrame.as">sk.yoz.html.IFrame</a> solution was inspired by <a href="http://www.netthreads.co.uk/">Alistair Rutherford, www.netthreads.co.uk</a>.</p>
<ul style="float: left;">
<li><a href="http://classes.yoz.sk/sk/yoz/html/IFrame.as">sk.yoz.html.IFrame</a></li>
<li>FlexIFrame.js</li>
<li>Application</li>
<li>Application html</li>
</ul>
<p><span id="more-139"></span></p>
<p style="clear:both;">Flex Iframe application</p>
<p><iframe src="http://blog.yoz.sk/examples/flexIframe/" width="100%" height="350" style="border:none;"></iframe></p>
<p>Core of this thing is <a href="http://classes.yoz.sk/sk/yoz/html/IFrame.as">sk.yoz.html.IFrame</a> class. It extends Canvas that is used to inherit properties and methods for positioning and sizing. There is one in order to make it work &#8211; every IFrame element must have id!</p>
<pre class="brush: as3;">package sk.yoz.html
{
    import flash.events.Event;
    import flash.external.ExternalInterface;
    import flash.geom.Point;

    import mx.containers.Canvas;

    public class IFrame extends Canvas
    {
        public var methodResize:String = &quot;FlexIFrame.resize&quot;;
        public var methodMove:String = &quot;FlexIFrame.move&quot;;
        public var methodNavigate:String = &quot;FlexIFrame.navigate&quot;;
        public var methodVisibility:String = &quot;FlexIFrame.visibility&quot;;

        public var positionChanged:Boolean = false;
        public var sizeChanged:Boolean = false;

        private var _autoResize:Boolean = false;
        private var _url:String = '';

        public function IFrame()
        {
            super();
            addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler)
        }

        override public function set id(value:String):void
        {
            super.id = value;
        }

        protected function addedToStageHandler(event:Event):void
        {
            positionChanged = true;
            sizeChanged = true;
            invalidateProperties();
        }

        public function set autoResize(value:Boolean):void
        {
            _autoResize = value;
            if(value)
                addEventListener(Event.RESIZE, autoResizeHandler);
            else
                removeEventListener(Event.RESIZE, autoResizeHandler);
        }

        public function get autoResize():Boolean
        {
            return _autoResize;
        }

        protected function autoResizeHandler(event:Event):void
        {
            positionChanged = true;
            sizeChanged = true;
            invalidateProperties();
        }

        override protected function commitProperties():void
        {
            super.commitProperties();

            if(positionChanged)
            {
                var point:Point = localToGlobal(new Point(0, 0));
                callJS(methodMove, point.x, point.y);
                positionChanged = false;
            }

            if(sizeChanged)
            {
                callJS(methodResize, width, height);
                sizeChanged = false;
            }
        }

        public function set url(value:String):void
        {
            _url = value;
            callJS(methodNavigate, value)
        }

        public function get url():String
        {
            return _url;
        }

        protected function callJS(method:String, ... values):void
        {
            if(!id)
                throw new Error(&quot;IFrame id is not defined&quot;);
            var args:Array = [method, id];
            try
            {
                ExternalInterface.call.apply(ExternalInterface, args.concat(values));
            }
            catch(error:Error)
            {
                trace(error.message);
            }
        }

        override public function set visible(value:Boolean):void
        {
            super.visible = value;
            callJS(methodVisibility, value);
        }

        override public function set width(value:Number):void
        {
            super.width = value;
            callJS(methodResize, value, height);
        }

        override public function set height(value:Number):void
        {
            super.height = value;
            callJS(methodResize, width, value);
        }

        override public function set x(value:Number):void
        {
            super.x = value;
            var point:Point = localToGlobal(new Point(0, 0));
            callJS(methodMove, point.x, point.y);
        }

        override public function set y(value:Number):void
        {
            super.y = value;
            var point:Point = localToGlobal(new Point(0, 0));
            callJS(methodMove, point.x, point.y);
        }
    }
}</pre>
<p> FlexIFrame.js is JavaScript file. It uses your flex IFrame id from to create (html iframe) or use html element (any element) with the same id (id in flash = id in html). So you can use your prefabricated html elements (banners etc).</p>
<pre class="brush: jscript;">var FlexIFrame = {
    get: function(id)
    {
        var iframe = document.getElementById(id);
        if(!iframe)
            return FlexIFrame.create(id);
        return iframe;
    },

    create: function(id)
    {
        var iframe = document.createElement('iframe');
        iframe.id = id;
        iframe.frameborder = 0;
        iframe.style.position = &quot;absolute&quot;;
        iframe.style.zIndex = 1;
        iframe.style.border = &quot;none&quot;;
        document.body.insertBefore(iframe, document.body.firstChild);
        return iframe;
    },

    resize: function(id, width, height)
    {
        var iframe = FlexIFrame.get(id);
        iframe.style.width = width + &quot;px&quot;;
        iframe.style.height = height + &quot;px&quot;;
    },

    move: function(id, x, y)
    {
        var iframe = FlexIFrame.get(id);
        iframe.style.left = x + &quot;px&quot;;
        iframe.style.top = y + &quot;px&quot;;
    },

    navigate: function(id, url)
    {
        var iframe = FlexIFrame.get(id);
        iframe.src = url;
    },

    visibility: function(id, visible)
    {
        var iframe = FlexIFrame.get(id);
        iframe.style.display = visible ? &quot;block&quot; : &quot;none&quot;;
    }
}</pre>
<p>This is simple applicationion presenting draggable TitleWindow with &#8220;web browser&#8221; inside:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;vertical&quot; applicationComplete=&quot;init()&quot; xmlns:html=&quot;sk.yoz.html.*&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    private function init():void
    {
        go();
    }

    private function go():void
    {
        iframe.url = iframeURL.text;
    }

    private function mouseDownHandler():void
    {
        container.startDrag();
        container.addEventListener(Event.ENTER_FRAME, enterFrameDrag);
    }

    private function mouseUpHandler():void
    {
        container.stopDrag();
    }

    private function enterFrameDrag(event:Event):void
    {
        iframe.positionChanged = true;
        iframe.invalidateProperties();
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:TitleWindow id=&quot;container&quot; layout=&quot;vertical&quot; width=&quot;300&quot; height=&quot;300&quot;
    mouseDown=&quot;mouseDownHandler()&quot; mouseUp=&quot;mouseUpHandler()&quot; &gt;
    &lt;mx:HBox width=&quot;100%&quot;&gt;
        &lt;mx:TextInput id=&quot;iframeURL&quot; text=&quot;http://blog.yoz.sk&quot; width=&quot;100%&quot;
            enter=&quot;go()&quot;/&gt;
        &lt;mx:Button label=&quot;Go&quot; click=&quot;go()&quot;/&gt;
    &lt;/mx:HBox&gt;
    &lt;html:IFrame width=&quot;100%&quot; height=&quot;100%&quot; id=&quot;iframe&quot; autoResize=&quot;true&quot;/&gt;
&lt;/mx:TitleWindow&gt;
&lt;/mx:Application&gt;</pre>
<p>Finally do not forget to add flexiframe.js into your .html file:</p>
<pre class="brush: xml;">&lt;html&gt;
    &lt;head&gt;
        &lt;script type=&quot;text/javascript&quot; src=&quot;js/flexiframe.js&quot;&gt;&lt;/script&gt;
        ...</pre>
<p>Update (Feb 8, 2010): flexiframe.js resize() method uses style property for width and height (instead of original html element width, height)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
