<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4685391077804343177</id><updated>2012-01-20T03:35:24.644-08:00</updated><title type='text'>Subi Flex/Flash- ActionScripter</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://subashflash.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4685391077804343177/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://subashflash.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Subash Selvaraj</name><uri>http://www.blogger.com/profile/14442698842880857797</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4685391077804343177.post-2543318356475965207</id><published>2010-08-20T10:30:00.000-07:00</published><updated>2010-08-20T11:13:01.573-07:00</updated><title type='text'>Rotate around center Flex/AS3</title><content type='html'>&lt;span style="font-family:georgia;"&gt;I have been searching for rotating any display object based on its center&lt;/span&gt; and ended up with the stuffs using MatrixTransformer.&lt;br /&gt;&lt;br /&gt;Though it may helpful to use those stuffs, it didnt work for me. finally i did a work around it and created a method which uses the getRect() of AS3 and works well without the MatrixTransformer stuff. I have posted that function here and it will be helpful for some one.&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;        *  Rotates the object based on its center&lt;br /&gt;        *  Parameters: @obj =&gt; the object to rotate&lt;br /&gt;        *              @ rotation =&gt; angle to rotate&lt;br /&gt;        * */&lt;br /&gt;       &lt;span style="font-style:italic;"&gt;public function&lt;/span&gt; &lt;span style="font-weight:bold;"&gt;RotateAroundCenter&lt;/span&gt;&lt;span style="font-style:italic;"&gt;(obj:Object, rotation:Number):void&lt;/span&gt;&lt;br /&gt;      &lt;span style="font-style:italic;"&gt; {&lt;br /&gt;         &lt;br /&gt;           var bound:Rectangle = new Rectangle();&lt;br /&gt;           // get the bounded rectangle of objects&lt;br /&gt;           bound = obj.getRect(this);      &lt;br /&gt;         &lt;br /&gt;           // calculate mid poits   &lt;br /&gt;           var midx1:Number = bound.x + bound.width/2;&lt;br /&gt;           var midy1:Number = bound.y + bound.height/2;&lt;br /&gt;         &lt;br /&gt;           // assign the rotation&lt;br /&gt;           obj.rotation = this._rotation;&lt;br /&gt;         &lt;br /&gt;           // assign the previous mid point as (x,y)&lt;br /&gt;           obj.x = midx1;&lt;br /&gt;           obj.y = midy1;       &lt;br /&gt;         &lt;br /&gt;           // get the new bounded rectangle of objects  &lt;br /&gt;           bound = obj.getRect(this);   &lt;br /&gt;         &lt;br /&gt;           // calculate new mid poits   &lt;br /&gt;           var midx2:Number = bound.x + bound.width/2;&lt;br /&gt;           var midy2:Number = bound.y + bound.height/2; &lt;br /&gt;         &lt;br /&gt;           // calculate differnece between the current mid and (x,y) and subtract  //it to position the object in the previous bound.&lt;br /&gt;           var diff:Number  = midx2 - obj.x;&lt;br /&gt;           obj.x -= diff;&lt;br /&gt;           diff  = midy2 - obj.y;&lt;br /&gt;           obj.y -= diff;&lt;br /&gt;       }&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//////////////////&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Usage:&lt;br /&gt;&lt;br /&gt;you can use the above function as described below,&lt;br /&gt;&lt;br /&gt;var img:Canvas =  new Canvas()&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;RotateAroundCenter&lt;/span&gt;(img, rotation);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;cheers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4685391077804343177-2543318356475965207?l=subashflash.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://subashflash.blogspot.com/feeds/2543318356475965207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://subashflash.blogspot.com/2010/08/rotation-of-object-based-on-center.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4685391077804343177/posts/default/2543318356475965207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4685391077804343177/posts/default/2543318356475965207'/><link rel='alternate' type='text/html' href='http://subashflash.blogspot.com/2010/08/rotation-of-object-based-on-center.html' title='Rotate around center Flex/AS3'/><author><name>Subash Selvaraj</name><uri>http://www.blogger.com/profile/14442698842880857797</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
