<?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; URLRequest</title>
	<atom:link href="http://blog.yoz.sk/tag/urlrequest/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yoz.sk</link>
	<description>My life, my work</description>
	<lastBuildDate>Thu, 09 Sep 2010 14:00:43 +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>URLRequestBuffer &#8211; Buffer Your URLRequests</title>
		<link>http://blog.yoz.sk/2010/06/urlrequestbuffer-buffer-your-requests/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=urlrequestbuffer-buffer-your-requests</link>
		<comments>http://blog.yoz.sk/2010/06/urlrequestbuffer-buffer-your-requests/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 14:09:50 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[delay]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[priority]]></category>
		<category><![CDATA[timeout]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[URLRequest]]></category>
		<category><![CDATA[URLRequestBuffer]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1698</guid>
		<description><![CDATA[Let&#8217;s suppose your app makes a lot of http requests at once, and you need a good administration for that. Based on used browser your app is running on, you are only allowed to limited request count &#8211; mostly its 2 requests per domain, the remaining ones are sitting in browser buffer waiting to finish [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/buffer.jpg" alt="" title="buffer" width="200" height="100" class="alignleft size-full wp-image-1711" /></p>
<p>Let&#8217;s suppose your app makes a lot of http requests at once, and you need a good administration for that. Based on used browser your app is running on, you are only allowed to limited request count &#8211; mostly its 2 requests per domain, the remaining ones are sitting in browser buffer waiting to finish those actual. URLRequestBuffer is handy class that lets you manage URLRequest-s. E.g. you are creating image gallery and request hundreds of images in gallery at a time, now when user navigates throug the images you need to make some request more prioritized before others, some to be canceled, some may timeout etc. Here comes URLRequestBuffer in scene.</p>
<p><span id="more-1698"></span></p>
<p>Pushing requests into the buffer automaticaly sorts requests by priority and tries to load next request based on priority/delay logic. After request is complete (timeouted, or error) it loads next and so on. Usage is very simple once you get familiar with 3 classes it consist of (<a href="http://classes.yoz.sk/sk/yoz/net/URLRequestBuffer.as">URLRequestBuffer</a>, <a href="http://classes.yoz.sk/sk/yoz/net/URLRequestBufferItem.as">URLRequestBufferItem</a> and <a href="http://classes.yoz.sk/sk/yoz/events/URLRequestBufferEvent.as">URLRequestBufferEvent</a>)</p>
<pre class="brush: as3;">// define buffer and max simultaneous (active) requests
var buffer:URLRequestBuffer = new URLRequestBuffer(2);

// loader - URLLoader or Loader instance
// request - URLRequest instance
// priority - uint, higher priority requests loads first
// delay - request is called after X milliseconds after pushing
// pushing requests into buffer returns URLRequestBufferItem, next suitable requests called
var bufferItem:URLRequestBufferItem = buffer.push(loader, request, priority, delay);
var bufferId:uint = bufferItem.id;

// URLRequestBufferItem by bufferId
buffer.getWaitingById(bufferId)
buffer.getActiveById(bufferId)

// stop and trash request (buffered or active)
buffer.removeWaitingById(bufferId);
buffer.removeActiveById(bufferId);

// enumerating waiting item list
for(var i:uint = 0; i &lt; buffer.countWaiting; i++)
    bufferItem = buffer.getWaitingItem(i);

// enumerating active item list
for(var i:uint = 0; i &lt; buffer.countActive; i++)
    bufferItem = buffer.getActiveItem(i);

// buffer event handling
buffer.addEventListener(URLRequestBufferEvent.WAITING_REQUEST_ADDED, onBufferChange);
buffer.addEventListener(URLRequestBufferEvent.WAITING_REQUEST_REMOVED, onBufferChange);
buffer.addEventListener(URLRequestBufferEvent.ACTIVE_REQUEST_ADDED, onBufferChange);
buffer.addEventListener(URLRequestBufferEvent.ACTIVE_REQUEST_REMOVED, onBufferChange);
buffer.addEventListener(URLRequestBufferEvent.REQUEST_TIMEOUT, onBufferChange);

private function onBufferChange(event:URLRequestBufferEvent):void
{
    var bufferItem:URLRequestBufferItem = event.item;

    // some stats
    trace(buffer.countWaiting, buffer.countActive)
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/06/urlrequestbuffer-buffer-your-requests/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to communicate between loader and child</title>
		<link>http://blog.yoz.sk/2010/04/how-to-communicate-between-loader-and-child/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-communicate-between-loader-and-child</link>
		<comments>http://blog.yoz.sk/2010/04/how-to-communicate-between-loader-and-child/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 12:55:24 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Child]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[Parent]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1367</guid>
		<description><![CDATA[This post is about communication between loader (Parent.as) flash object (.swf) and loaded (Child.as) flash object. While flash is event based, I find it correct to use events to communicate, although different methods exist (direct function call etc.) Here is our Parent.as class (goes Parent.swf). It loads Child.as on init and listens for events on [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/loaderCommunication-200x78.png" alt="" title="loaderCommunication" width="200" height="78" class="alignleft size-medium wp-image-1371" /></p>
<p>This post is about communication between loader (Parent.as) flash object (.swf) and loaded (Child.as) flash object. While flash is event based, I find it correct to use events to communicate, although different methods exist (direct function call etc.)</p>
<p><span id="more-1367"></span></p>
<p style="clear:both;">Here is our Parent.as class (goes Parent.swf). It loads Child.as on init and listens for events on it Child. It contains green circle pseudo button:</p>
<pre class="brush: as3;">package
{
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;

    public class Parent extends Sprite
    {
        private var loader:Loader = new Loader();

        public function Parent()
        {
            var request:URLRequest = new URLRequest(&quot;Child.swf&quot;);

            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
            loader.load(request);
            addChild(loader);

            addEventListener(&quot;hallo&quot;, hallo);

            var btn:Sprite = new Sprite();
            btn.graphics.beginFill(0x00ff00);
            btn.graphics.drawCircle(0, 50, 50);
            btn.graphics.endFill();
            btn.addEventListener(MouseEvent.CLICK, click);
            addChild(btn);
        }

        private function complete(event:Event):void
        {
            trace(&quot;Parent::complete()&quot;);
        }

        private function hallo(event:Event):void
        {
            trace(&quot;Parent::hallo()&quot;);
        }

        private function click(event:MouseEvent):void
        {
            trace(&quot;Parent::click()&quot;);
            loader.content.dispatchEvent(new Event(&quot;welcome&quot;));
        }
    }
}</pre>
<p>Child.as (published as Child.swf) dispatches event when added to stage and listens for other events from Parent loader. Contains black button:</p>
<pre class="brush: as3;">package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;

    public class Child extends Sprite
    {
        public function Child()
        {
            super();

            var btn:Sprite = new Sprite();
            btn.graphics.beginFill(0);
            btn.graphics.drawCircle(50, 50, 50);
            btn.graphics.endFill();
            btn.addEventListener(MouseEvent.CLICK, click);
            addChild(btn);

            addEventListener(Event.ADDED_TO_STAGE, added);
            addEventListener(&quot;welcome&quot;, welcome);
        }

        private function click(event:MouseEvent):void
        {
            trace(&quot;Child::click()&quot;);
            dispatchEvent(new Event(&quot;hallo&quot;, true));
        }

        private function added(event:Event):void
        {
            trace(&quot;Child::added()&quot;);
            dispatchEvent(new Event(&quot;hallo&quot;, true));
        }

        private function welcome(event:Event):void
        {
            trace(&quot;Child::welcome()&quot;);
        }
    }
}</pre>
<p>Make sure you create Child.swf before you load it in Parent.swf. After you run Parent.swf, following is traced:</p>
<pre class="brush: plain;">Child::added()
Parent::hallo()
Parent::complete()</pre>
<p>after clicking button in Parent.swf you see:</p>
<pre class="brush: plain;">Parent::click()
Child::welcome()</pre>
<p>and click on button in Child.swf:</p>
<pre class="brush: plain;">Child::click()
Parent::hallo()</pre>
<p>The communication is event based, it is as easy as call dispatchEvent() with bubbling from Child or loader.content.dispatchEvent() from Parent:</p>
<p><img src="http://blog.yoz.sk/wp-content/uploads/loaderCommunication.png" alt="" title="loaderCommunication" width="300" height="118" class="size-full wp-image-1371" /></p>
<p>In fact, loader.content is instance of Child.as root, so If you define listener directly on loader.content, you do not need to make dispatchEvent()-s bubbling.</p>
<p>To make it work online, make sure both .swf files are with the same securty sandbox and from same domain (or acceptable Security.allowDomain() set to make the other file access script).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/04/how-to-communicate-between-loader-and-child/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>URLShorten Class (update)</title>
		<link>http://blog.yoz.sk/2010/02/urlshorten-class/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=urlshorten-class</link>
		<comments>http://blog.yoz.sk/2010/02/urlshorten-class/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 10:52:18 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[shorten]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[URLLoaderDynamic]]></category>
		<category><![CDATA[URLRequest]]></category>
		<category><![CDATA[URLShorten]]></category>
		<category><![CDATA[URLShortenEvent]]></category>
		<category><![CDATA[URLVariables]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=989</guid>
		<description><![CDATA[URL shortening is a technique where a provider makes a web page available under a very short URL in addition to the original address. There are hundreds of provider out there, but only a few of them provides public api and crossdomain.xml. I put toghether some of those that work and URLShorten class was created [...]]]></description>
			<content:encoded><![CDATA[<p>URL shortening is a technique where a provider makes a web page available under a very short URL in addition to the original address. There are hundreds of provider out there, but only a few of them provides public api and crossdomain.xml. I put toghether some of those that work and URLShorten class was created <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  feel free to use it and enjoy </p>
<p>Update: <a href="http://jdem.cz">jdem.cz</a>, <a href="http://tinyurl.com">tinyurl.com</a>, <a href="http://bit.ly">bit.ly</a>, <a href="http://tr.im">tr.im</a>, <a href="http://is.gd">is.gd</a> providers implemented.</p>
<p><span id="more-989"></span></p>
<p>Application (view source enabled), please use your own api key for bit.ly</p>
<p><iframe width="100%" height="200" src="http://blog.yoz.sk/examples/URLShorten/"></iframe></p>
<p>I have just discovered tr.im has not crossdomain.xml, please do not us it while it throws errors. I have just asked them and few more providers to create crossdomain files, will see&#8230;</p>
<p>There are two methods you can handle resuls:</p>
<pre class="brush: as3;">// 1. use callback function
URLShorten.jdemcz(long_url.text, jdemczResult);

// ...callback function gets one parameter = short url
private function jdemczResult(url:String):void
{
    jdemcz = url;
}

// 2. addEventDispatcher to have bigger control
var dispatcher:EventDispatcher = URLShorten.tinyurlcom(long_url.text);
dispatcher.addEventListener(URLShortenEvent.COMPLETE, tinyurlcomComplete);

// ...dispatched event.url = short url
private function tinyurlcomComplete(event:URLShortenEvent):void
{
    tinyurl = event.url;
}</pre>
<p><a href="http://classes.yoz.sk/sk/yoz/net/URLShorten.as">URLShorten class</a></p>
<pre class="brush: as3;">package sk.yoz.net
{
    import com.adobe.serialization.json.JSON;

    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.net.URLVariables;

    import sk.yoz.events.URLShortenEvent;

    public class URLShorten extends Object
    {
        public function URLShorten()
        {
            super();
        }

        private static function prepare(request:URLRequest,
            variables:URLVariables, callback:Function,
            completeHandler:Function=null):URLLoaderDynamic
        {
            var loader:URLLoaderDynamic = new URLLoaderDynamic();
            var handler:Function = completeHandler || complete;

            request.data = variables;
            loader.callback = callback;
            loader.load(request);
            loader.addEventListener(Event.COMPLETE, handler);
            return loader;
        }

        private static function complete(event:Event):void
        {
            var loader:URLLoaderDynamic = URLLoaderDynamic(event.target);
            var url:String = String(loader.data);

            loader.removeEventListener(Event.COMPLETE, complete);
            dispatch(url, loader)
        }

        private static function dispatch(url:String, loader:URLLoaderDynamic)
            :void
        {
            var callback:Function = loader.callback;
            var type:String = URLShortenEvent.COMPLETE;

            if(callback != null)
                callback(url);
            loader.dispatchEvent(new URLShortenEvent(type, false, false, url));
        }

        public static function jdemcz(longUrl:String, callback:Function=null)
            :URLLoaderDynamic
        {
            var apiUrl:String = &quot;http://www.jdem.cz/get&quot;;
            var request:URLRequest = new URLRequest(apiUrl);
            var variables:URLVariables = new URLVariables();

            variables.url = longUrl;
            return prepare(request, variables, callback);
        }

        public static function tinyurlcom(longUrl:String,
            callback:Function=null):URLLoaderDynamic
        {
            var apiUrl:String = &quot;http://tinyurl.com/api-create.php&quot;;
            var request:URLRequest = new URLRequest(apiUrl);
            var variables:URLVariables = new URLVariables();

            variables.url = longUrl;
            return prepare(request, variables, callback);
        }

        public static function bitly(longUrl:String, login:String,
            apiKey:String, version:String=&quot;2.0.1&quot;, callback:Function=null)
            :URLLoaderDynamic
        {
            var apiUrl:String = &quot;http://api.bit.ly/shorten&quot;;
            var request:URLRequest = new URLRequest(apiUrl);
            var variables:URLVariables = new URLVariables();

            variables.version = version;
            variables.longUrl = longUrl;
            variables.login = login;
            variables.apiKey = apiKey;
            return prepare(request, variables, callback, bitlyComplete);
        }

        private static function bitlyComplete(event:Event):void
        {
            var loader:URLLoaderDynamic = URLLoaderDynamic(event.target);
            var result:String = String(loader.data);
            var data:Object = JSON.decode(result);
            var url:String;

            loader.removeEventListener(Event.COMPLETE, bitlyComplete);
            for each(var resultItem:Object in data.results)
                url = resultItem.shortUrl;
            dispatch(url, loader);
        }

        public static function trim(longUrl:String,
            callback:Function=null):URLLoaderDynamic
        {
            var apiUrl:String = &quot;http://api.tr.im/v1/trim_simple&quot;;
            var request:URLRequest = new URLRequest(apiUrl);
            var variables:URLVariables = new URLVariables();

            variables.url = longUrl;
            return prepare(request, variables, callback);
        }

        public static function isgd(longUrl:String,
            callback:Function=null):URLLoaderDynamic
        {
            var apiUrl:String = &quot;http://is.gd/api.php&quot;;
            var request:URLRequest = new URLRequest(apiUrl);
            var variables:URLVariables = new URLVariables();

            variables.longurl = longUrl;
            return prepare(request, variables, callback);
        }
    }
}</pre>
<p>we need loader to hold callback function reference, <a href="http://classes.yoz.sk/sk/yoz/net/URLLoaderDynamic.as">URLLoaderDynamic class</a> pretty much fits this needs</p>
<pre class="brush: as3;">package sk.yoz.net
{
    import flash.net.URLRequest;
    import flash.net.URLLoader;

    import sk.yoz.net.URLLoaderDynamic;

    public dynamic class URLLoaderDynamic extends URLLoader
    {
        public function URLLoaderDynamic(request:URLRequest=null)
        {
            super(request);
        }

    }
}</pre>
<p>custom <a href="http://classes.yoz.sk/sk/yoz/events/URLShortenEvent.as">URLShortenEvent class</a> is dispatched after url is returned</p>
<pre class="brush: as3;">package sk.yoz.events
{
    import flash.events.Event;

    public class URLShortenEvent extends Event
    {
        public static const COMPLETE:String = &quot;URLShortenEventCOMPLETE&quot;;

        private var _url:String;

        public function URLShortenEvent(type:String, bubbles:Boolean=false,
            cancelable:Boolean=false, url:String=&quot;&quot;)
        {
            super(type, bubbles, cancelable);
            _url = url;
        }

        public function get url():String
        {
            return _url;
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/urlshorten-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Extended Permissions With Authorization by Overriding Class in swc</title>
		<link>http://blog.yoz.sk/2010/01/facebook-extended-permissions-with-authorization-by-overriding-class-in-swc/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=facebook-extended-permissions-with-authorization-by-overriding-class-in-swc</link>
		<comments>http://blog.yoz.sk/2010/01/facebook-extended-permissions-with-authorization-by-overriding-class-in-swc/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 12:27:10 +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[swc]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=901</guid>
		<description><![CDATA[It may be not popular, but it is possible to substitute / override whole class from .swc file. Lets say you are using some public api, in our case Facebook actionscript api. I admire work of developer team, but I would like to have some things different. My facebook application requires publish_stream extended permission right [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/extendedPermissionWithLoginSmall.jpg" alt="" title="extendedPermissionWithLoginSmall" width="200" height="100" class="alignleft size-full wp-image-911" /></p>
<p>It may be not popular, but it is possible to substitute / override whole class from .swc file. Lets say you are using some public api, in our case <a href="http://code.google.com/p/facebook-actionscript-api/">Facebook actionscript api</a>. I admire work of developer team, but I would like to have some things different. My facebook application requires <a href="http://wiki.developers.facebook.com/index.php/Extended_permissions">publish_stream</a> extended permission right after user login (authorize) my application. Even if official facebook api documentation says it is possible to ask for <a href="http://wiki.developers.facebook.com/index.php/Authorization_and_Authentication_for_Desktop_Applications">extended permission with login.php</a> call (req_perms parameter), our facebook actionscript api does not offer setting this parameter.</p>
<p><span id="more-901"></span></p>
<p>After few moments of research it was clear that login.php call makes <a href="http://code.google.com/p/facebook-actionscript-api/source/browse/trunk/source/actionscript/com/facebook/session/DesktopSession.as">DesktopSession class</a>, method onLogin()&#8230;</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;

		//now that we have an auth_token we need the user to login with it
		var request:URLRequest = new URLRequest();
		var loginParams:String = '?';

		if (_offline_access) {
				loginParams += 'ext_perm=offline_access&amp;';
		}

		request.url = login_url+loginParams+&quot;api_key=&quot;+api_key+&quot;&amp;v=&quot;+api_version+&quot;&amp;auth_token=&quot;+_auth_token;

		navigateToURL(request, &quot;_blank&quot;);

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

... some code ...</pre>
<p>Now lets do the dirty work. If it were possible, I would extend DesktopSession class and override just onLogin function, but api creates and uses DesktopSession inside its whole logic, so there is no way to succeed. However, it is possible to override whole class. First, in your flex project (with facebook swc in library path), create directory structure com/facebook/session/ (the same as DesktopSession package defines), than copy <a href="http://code.google.com/p/facebook-actionscript-api/source/browse/trunk/source/actionscript/com/facebook/session/DesktopSession.as">DesktopSession.as</a> file inside. Well, thats it <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  &#8230; From now, when you publish your application, compilator uses your DesktopSession instead of the one in .swc.</p>
<p>To make the new class working for my needs, onLogin function needs to be changed into something like this:</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;

		//now that we have an auth_token we need the user to login with it
		var request:URLRequest = new URLRequest(login_url);
		var variables:URLVariables = new URLVariables();

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

		request.data = variables;
		navigateToURL(request, &quot;_blank&quot;);

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

... some code ...</pre>
<p>By asking extended permissions with login.php, facebook opens more step authorization dialog where each permissions is separated into own step and user can allow or dont allow each.</p>
<p><img src="http://blog.yoz.sk/wp-content/uploads/extendedPermissionWithLogin.jpg" alt="" title="extendedPermissionWithLogin" width="658" height="713" class="alignnone size-full wp-image-908" /></p>
<p><strong>Important:</strong></p>
<ul>
<li>Even if you send req_perms=publish_stream with login.php, facebook only accepts it when your app is live (not from your desktop testing) &#8230; Functionality already bugged in facebook bugzilla</li>
<li>Even if it is possible to override class this way, consider using it. Next time there may be newer version of .swc with some changes in your overriden class!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/01/facebook-extended-permissions-with-authorization-by-overriding-class-in-swc/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Flex Error #1034: Type Coercion Failed: Cannot Convert *** to mx.core.IFlexDisplayObject</title>
		<link>http://blog.yoz.sk/2009/10/flex-error-1034-type-coercion-failed-cannot-convert-to-mx-core-iflexdisplayobject/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=flex-error-1034-type-coercion-failed-cannot-convert-to-mx-core-iflexdisplayobject</link>
		<comments>http://blog.yoz.sk/2009/10/flex-error-1034-type-coercion-failed-cannot-convert-to-mx-core-iflexdisplayobject/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 16:10:11 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[ApplicationDomain]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Error]]></category>
		<category><![CDATA[IFlexDisplayObject]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[LoaderContext]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=501</guid>
		<description><![CDATA[When you keep getting: Flex Error #1034: Type Coercion Failed: Cannot Convert *** to mx.core.IFlexDisplayObject &#8230; after using getDefinition() method, in my case: // url = &#34;../some.swf&#34; var request:URLRequest = new URLRequest(url); var context:LoaderContext = new LoaderContext(); context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, assetsComplete); loader.load(request, context); ... // assetsComplete() var applicationDomain:ApplicationDomain = [...]]]></description>
			<content:encoded><![CDATA[<p>When you keep getting:</p>
<pre>Flex Error #1034: Type Coercion Failed: Cannot Convert *** to mx.core.IFlexDisplayObject</pre>
<p>&#8230; after using getDefinition() method, in my case:</p>
<pre class="brush: as3;">
// url = &quot;../some.swf&quot;
var request:URLRequest = new URLRequest(url);
var context:LoaderContext = new LoaderContext();
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, assetsComplete);
loader.load(request, context);
...
// assetsComplete()
var applicationDomain:ApplicationDomain = assetsLoader.contentLoaderInfo.applicationDomain;
var assetsClass:Class = applicationDomain.getDefinition(&quot;Assets&quot;) as Class;
...
</pre>
<p>The problem is, in fact, the security not coercion! Try move your .swf (the one that is beeing loaded) into the same directory where master .swf file is located.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/flex-error-1034-type-coercion-failed-cannot-convert-to-mx-core-iflexdisplayobject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bitmap, BitmapData, ByteArray&#8230;</title>
		<link>http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=bitmap-bitmapdata-bytearray</link>
		<comments>http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 12:26:40 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[converting]]></category>
		<category><![CDATA[DisplayObject]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Loader]]></category>
		<category><![CDATA[LoaderInfo]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=135</guid>
		<description><![CDATA[Lets see how to convert between Bitmap, BitmapData and ByteArray in few examples: DisplayObject to BitmapData BitmapData to Bitmap BitmapData to ByteArray URL (image) to ByteArray (asynchronous) URL (image) to BitmapData (asynchronous) ByteArray to BitmapData (asynchronous) DisplayObject to BitmapData. FYI DisplayObject is any visible object in flash (Sprite, MovieClip, Bitmap, UIComponent, Video etc&#8230;): import flash.display.BitmapData; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.yoz.sk/wp-content/uploads/bitmap_converting.png"><img src="http://blog.yoz.sk/wp-content/uploads/bitmap_converting-200x119.png" alt="bitmap_converting" title="bitmap_converting" width="200" height="119" class="alignleft size-medium wp-image-452" /></a></p>
<p>Lets see how to convert between Bitmap, BitmapData and ByteArray in few examples:</p>
<ul style="float:left;">
<li>DisplayObject to BitmapData</li>
<li>BitmapData to Bitmap</li>
<li>BitmapData to ByteArray</li>
<li>URL (image) to ByteArray (asynchronous)</li>
<li>URL (image) to BitmapData  (asynchronous) </li>
<li>ByteArray to BitmapData  (asynchronous) </li>
</ul>
<div style="clear:both;"></div>
<p><span id="more-135"></span></p>
<p>DisplayObject to BitmapData. FYI <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html">DisplayObject is any visible object in flash</a> (Sprite, MovieClip, Bitmap, UIComponent, Video etc&#8230;):</p>
<pre class="brush: as3;">import flash.display.BitmapData;
var bitmapData:BitmapData = new BitmapData(button.width, button.height, false, 0xFFFFFF);
bitmapData.draw(button);
// result: bitmapData</pre>
<p>BitmapData to Bitmap:</p>
<pre class="brush: as3;">import flash.display.Bitmap;
var bitmap:Bitmap = new Bitmap(bitmapData);
// result: bitmap</pre>
<p>BitmapData to ByteArray. Requires jpeg / png or any other encoder. <a href="http://blog.yoz.sk/2009/10/actionscript-3-encoding-jpeg/">Read more about JPEG encoding here</a>:</p>
<pre class="brush: as3;">import mx.graphics.codec.JPEGEncoder;
import flash.utils.ByteArray;
var encoder:JPEGEncoder = new JPEGEncoder(90);
var byteArray:ByteArray = encoder.encode(bitmapData));
// result: byteArray</pre>
<p>URL (image) to ByteArray. Asynchronous operation:</p>
<pre class="brush: as3;">import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import flash.utils.ByteArray;

var loader:Loader = new Loader();
loader.load(new URLRequest(&quot;banner1.jpg&quot;));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);

private function loaderComplete(event:Event):void
{
    var loaderInfo:LoaderInfo = LoaderInfo(event.target);
    var byteArray:ByteArray = loaderInfo.bytes;
    // result: byteArray
}</pre>
<p>URL (image) to BitmapData. Asynchronous operation:</p>
<pre class="brush: as3;">import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.BitmapData;

var loader:Loader = new Loader();
loader.load(new URLRequest(&quot;banner1.jpg&quot;));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);

private function loaderComplete(event:Event):void
{
    var loaderInfo:LoaderInfo = LoaderInfo(event.target);
    var bitmapData:BitmapData = new BitmapData(loaderInfo.width, loaderInfo.height, false, 0xFFFFFF);
    bitmapData.draw(loaderInfo.loader);
    // result: bitmapData
}</pre>
<p>ByteArray to BitmapData. Asynchronous operation:</p>
<pre class="brush: as3;">import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.display.BitmapData;

var loader:Loader = new Loader();
loader.loadBytes(byteArray);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);

private function loaderComplete(event:Event):void
{
    var loaderInfo:LoaderInfo = LoaderInfo(event.target);
    var bitmapData:BitmapData = new BitmapData(loaderInfo.width, loaderInfo.height, false, 0xFFFFFF);
    bitmapData.draw(loaderInfo.loader);
    // result: bitmapData
}</pre>
<p><a href="http://www.bytearray.org/?p=1089">Synchronous JPEG ByteArray to BitmapData can be found here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
