<?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>Amoeba Solution Kiosk &#187; Flash &amp; Action Script</title> <atom:link href="http://ask.amoeba.co.in/topics/flash-action-script/feed/" rel="self" type="application/rss+xml" /><link>http://ask.amoeba.co.in</link> <description>Providing solutions for PHP, MySQL, Flash, Flex, Action Script, Javascript, YUI, JQuery, CSS, XHTML problems.</description> <lastBuildDate>Fri, 30 Dec 2011 18:12:55 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <item><title>How to Protect your SWF (AS2 or AS3). Prevent SWF Decompile using SWF Protector</title><link>http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/</link> <comments>http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/#comments</comments> <pubDate>Wed, 01 Sep 2010 16:01:04 +0000</pubDate> <dc:creator>Aneeska</dc:creator> <category><![CDATA[Flash & Action Script]]></category> <category><![CDATA[Flex]]></category> <category><![CDATA[Programming Techniques]]></category> <category><![CDATA[action script]]></category> <category><![CDATA[as2]]></category> <category><![CDATA[as3]]></category> <category><![CDATA[dcomsoft]]></category> <category><![CDATA[decomipler]]></category> <category><![CDATA[decompile]]></category> <category><![CDATA[encryption]]></category> <category><![CDATA[obfuscate]]></category> <category><![CDATA[obfuscation]]></category> <category><![CDATA[php]]></category> <category><![CDATA[protection]]></category> <category><![CDATA[solution]]></category> <category><![CDATA[sothink]]></category> <category><![CDATA[swf]]></category> <category><![CDATA[swfprotector]]></category> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=150</guid> <description><![CDATA[Being a flash programmer, I have always had this concern. The way a flash application works differs from a php application. We don’t really need to worry about protecting the PHP code because the code is interpreted in the server and only the html codes are sent to the client browser. But a Flash engine basically lies in the user browser and the AS2 or AS3 codes are rendered in the user Browser. Though a Flash application is compiled in to a compact SWF file which is served to the user, this file contains all the codes we have written, thus making it easy for hackers or other developers to steal codes from our SWF application. And the Actionscript code is the most important part of any Flash/Flex application.]]></description> <content:encoded><![CDATA[<p>Being a flash programmer, I have always had this concern. The way a flash application works differs from a php application. We don’t really need to worry about protecting the PHP code because the code is interpreted in the server and only the html codes are sent to the client browser. But a Flash engine basically lies in the user browser and the AS2 or AS3 codes are rendered in the user Browser. Though a Flash application is compiled in to a compact SWF file which is served to the user, this file contains all the codes we have written, thus making it easy for hackers or other developers to steal codes from our SWF application. And the Actionscript code is the most important part of any Flash/Flex application.</p><p>I normally share codes I write with the developer community. But there are occasions when I don’t want others to see the source code of my application. This could be when I have concerns over the security of my application or when it is a proprietary application built for a customer.  But unfortunately stealing the source code of a Flash SWF application is very easy. With reverse engineering technologies gaining popularity day by day among the Flash development communities, protecting the Actionscript code is a big problem. There are plenty of SWF decompilers like Sothink available in the market making it easy for anyone to decompile an SWF file fetched from a browser and see the whole source code written for the application.</p><p>This is when we need to really think about code security and protecting our source codes from being stolen. There are some flash protector applications available and I tried SWF Protector from DComSoft. It works out really well. The application is available for Windows, Mac and Linux. Protecting an SWF application using the SWF Protector is really easy. Add your SWF files to the SWF Protector and click on the Protect All button. The SWF Protector uses different algorithms for AS2 and AS3 versions. For AS2, it uses “Mix Script” and “Mask Script” methods which basically mix up functions, arguments and variables names, so it becomes difficult for understanding after de-compilation. For AS3, the code can be “Protected” which modifies the scripts in such way that SWF files can play in Flash player, but cannot be decompiled, or “Obfuscated” which renames variable and other objects in the code making it impossible to compile the code further.</p><p>There is another method to protect your SWF code without using any application. That is by creating a loader SWF which will embed the actual SWF as a byteArray and it can be loaded using  Loader.loadBytes().</p><p>When someone tries to decomplile an SWF file which is protected using SWF Protector the code would look something like this.</p><pre class="brush: as3; title: ; notranslate">
do {
// unexpected jump
} while (true);
// swfAction0xAD hexdata 0x52,0x17,0x99,0x02,0x00,0x39,0x00,0x9A,0x01,0x00,0x00,0x99... // Unknown action
}
&quot;holder1&quot;.holder1.loadMovie();
// unexpected jump
/* Error1016 */
// unexpected jump
do {
(this);// not popped
if (true) {
// unexpected jump
} while (this);
(this);// not popped
// unexpected jump
}
}
}
Set(&quot;\x0B\x1A\x13\x16&quot;, true);
} while (true);
</pre><p>Now you say, would this be useful for someone? No, of course!</p><p>The SWF Protector is not free but comes with a small price tag. But it’s more than worth the money you pay and better than concerning over the security of your code. You can get more information or buy this tool from <a
href="http://www.dcomsoft.com/" target="_blank">http://www.dcomsoft.com</a></p><div
class="bottomcontainerBox" style=""><div
style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <iframe
src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fask.amoeba.co.in%2Fhow-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div><div
style="float:left; width:65px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <g:plusone size="medium" href="http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/"></g:plusone></div><div
style="float:left; width:100px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <a
href="http://twitter.com/share" class="twitter-share-button" data-url="http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/"  data-text="How to Protect your SWF (AS2 or AS3). Prevent SWF Decompile using SWF Protector" data-count="horizontal" data-via="aneesme">Tweet</a></div><div
style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/" data-counter="right"></script></div><div
style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/"></script></div></div><div
style="clear:both"></div><div
style="padding-bottom:4px;"></div>]]></content:encoded> <wfw:commentRss>http://ask.amoeba.co.in/how-to-protect-your-swf-as2-or-as3-prevent-swf-decompile-using-swf-protector/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Save Images from Flash &#8211; Actionscript 3, Filereference.save, JPGEncoder</title><link>http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/</link> <comments>http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/#comments</comments> <pubDate>Wed, 19 May 2010 10:41:04 +0000</pubDate> <dc:creator>Aneeska</dc:creator> <category><![CDATA[Flash & Action Script]]></category> <category><![CDATA[Flex]]></category> <category><![CDATA[action script]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[as3]]></category> <category><![CDATA[as3corelib]]></category> <category><![CDATA[bitmapdata]]></category> <category><![CDATA[bytearray]]></category> <category><![CDATA[cs3]]></category> <category><![CDATA[cs4]]></category> <category><![CDATA[filereference]]></category> <category><![CDATA[filereference.save]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[imageloader]]></category> <category><![CDATA[jpegencoder]]></category> <category><![CDATA[loader]]></category> <category><![CDATA[movieclip to image]]></category> <category><![CDATA[save image]]></category> <category><![CDATA[save image from flash]]></category> <category><![CDATA[save jpg]]></category> <category><![CDATA[urlrequest]]></category> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=112</guid> <description><![CDATA[Saving an image from a flash movie to user&#8217;s local machine hard-disk was a hectic task sometime back. To save Dynamic movie clips (which could be images or any bitmapData) on the stage as Images we had to send the whole pixel data to the server and process it to create an image, then download [...]]]></description> <content:encoded><![CDATA[<p>Saving an image from a flash movie to user&#8217;s local machine hard-disk was a hectic task sometime back. To save Dynamic movie clips (which could be images or any bitmapData) on the stage as Images we had to send the whole pixel data to the server and process it to create an image, then download it on to the user machine.</p><p>This task has now become very simple with ActionScript3, Flash Player 10 and as3CoreLibrary. We don&#8217;t need to send the BitmapData back to the server to process and create the image. A file can be saved direct from the flash to the user computer. This is possible of a cool new<strong> FileReference.save()</strong> feature added to Flash Player 10. hich allows the Flash Player to write to  the local file system as long  as the save request is requested by the  user. Upon  calling FileReference.save() the default file  system dialog will open and user can save the data from the flash movie to their local machine. No server processing needed!</p><p>Please note that <strong>FileReference.save() </strong>can be only invoked if the invoke call is associated with an <strong>OnClick</strong> event.</p><p>Additionally we are using JPEGEncoder which comes with the <strong>as3corelib</strong>. You can download this library here: <a
class="wpGallery" title="as3CoreLib" href="http://code.google.com/p/as3corelib/" target="_blank"><strong>http://code.google.com/p/as3corelib/ </strong></a><br
/> After downloading copy the source files (the <strong>com </strong>folder) on to your Class path or your application root directory. Apart from the <strong>JPEGEncoder</strong>, this library is packaged with a lot of other classes related to Hasing, Text, Date etc.</p><p>This is how we save an image from a flash movie to a local machine.</p><p><strong>1) Create a BitmapData object out of the MovieClip or the Loader.<br
/> 2) Encode the BitmapData using the JPEGEncoder and form a ByteArray.<br
/> 3) Use FileReference.save() to download the image on to the User machine.</strong></p><p>See an example:<br
/> Create a blank Flash movie and name it as &#8220;ImageSave.fla&#8221;. In the same folder create &#8220;ImageSave.as&#8221; file and copy the below code in to it. You need the &#8220;com&#8221; folder copied from the <strong>as3corelib </strong>to this folder. I have a button on the stage named &#8220;save_mc&#8221; which triggers the saveImage function.</p><pre class="brush: as3; title: ; notranslate">
package {
	import flash.display.MovieClip;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.utils.ByteArray;
	import flash.net.FileReference;
	import flash.net.FileFilter;
	import flash.events.*;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import com.adobe.images.JPGEncoder;
	public class ImageSave extends MovieClip {
		private var imgFile:URLRequest;
		private var img:MovieClip;
		private var imgLoader:Loader;
		private var file:FileReference;
		public function ImageSave() {
			imgFile = new URLRequest(&quot;coffee.jpg&quot;); //change it to your image path
			imgLoader = new Loader();
			imgLoader.load(imgFile);
			imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
			save_mc.addEventListener(MouseEvent.CLICK, saveImage);
		}
		private function onLoaded(evt:Event):void {
			imgLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
			imgLoader.cacheAsBitmap = true;
			addChild(imgLoader);
		}
		function saveImage(e:MouseEvent):void {
			var myBitmapData:BitmapData = new BitmapData(imgLoader.width, imgLoader.height);
			myBitmapData.draw(imgLoader);
			var jpgEncoder:JPGEncoder = new JPGEncoder(80);
			var imgByteData:ByteArray = jpgEncoder.encode(myBitmapData);
			file = new FileReference();
			file.browse(new Array(new FileFilter(&quot;Images (*.jpg, *.jpeg)&quot;, &quot;*.jpg;*.jpeg&quot;)));
			file.save(imgByteData, &quot;test.jpg&quot;);
		}
	}
}
</pre><p>For your convenience you can download a working copy of this sample here:<br
/> <a
class="dLink" href="http://ask.amoeba.co.in/wp-content/uploads/2010/05/ImageSave.zip">Download &#8216;SaveImagefromFlash&#8217; SourceCode &#8211; CS4 [ZIP]</a></p><p>This sample contains the as3CoreLib, so you don&#8217;t need to download it separate. The FLA source can be opened only in CS4. However you can still open the AS file and explore the code.</p><p>Please let me know if you have any questions.</p><div
class="bottomcontainerBox" style=""><div
style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <iframe
src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fask.amoeba.co.in%2Fsave-images-from-flash-actionsctipt-3-filereference-save-jpgencoder%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div><div
style="float:left; width:65px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <g:plusone size="medium" href="http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/"></g:plusone></div><div
style="float:left; width:100px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <a
href="http://twitter.com/share" class="twitter-share-button" data-url="http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/"  data-text="Save Images from Flash &#8211; Actionscript 3, Filereference.save, JPGEncoder" data-count="horizontal" data-via="aneesme">Tweet</a></div><div
style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/" data-counter="right"></script></div><div
style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/"></script></div></div><div
style="clear:both"></div><div
style="padding-bottom:4px;"></div>]]></content:encoded> <wfw:commentRss>http://ask.amoeba.co.in/save-images-from-flash-actionsctipt-3-filereference-save-jpgencoder/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Batch Uploader using Flash Action Script 2</title><link>http://ask.amoeba.co.in/flash-batch-uploader/</link> <comments>http://ask.amoeba.co.in/flash-batch-uploader/#comments</comments> <pubDate>Mon, 21 Dec 2009 17:38:30 +0000</pubDate> <dc:creator>Aneeska</dc:creator> <category><![CDATA[Flash & Action Script]]></category> <category><![CDATA[PHP/MySQL]]></category> <category><![CDATA[action script]]></category> <category><![CDATA[as2]]></category> <category><![CDATA[batch upload]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[image upload]]></category> <category><![CDATA[uploader]]></category> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=61</guid> <description><![CDATA[Here is the source code of a Batch Upload tool created in Flash. A brief description about the working of the application is provided. This flash tool can be integrated in any websites and uses PHP as the backend application to process the files sent to the server. The features of the application are, 1) Users can add multiple files from different folders in their computer. 2) Manage the list by adding/removing files in the list. Choose albums/folders to upload the files into. 4) Fixed the Flash process delay error, which causes the browser to throw an alert to abort a script that runs longer than usual. Read more to see the complete article and to download the source code.]]></description> <content:encoded><![CDATA[<p>Pretty long  time back, I developed a batch uploading tool in Flash for a large online photo  sharing website. The purpose of the tool was to allow the site users to upload  photos from their computer to their online account. This flash tool with the  complete source code is given free here.</p><p>Many of  the Batch process tools available cause errors while processing for a long time  and the browsers try to abort the script by showing a warning alert to the  user. I was successful in fixing this issue.</p><p>The  photos were organized in Albums. The users could create albums in their Photo  manage page. To give the users the ability to upload a bunch of photos together  as a batch process, the tool was introduced. User can launch this Batch  uploader tool from their account homepage and browse for Photos from their  folders. The features of this uploader include the ability to add files from  different folders to the list. The file list can be managed by removing selected  files or adding more files in to the list. When the user is ready with the list  of files, he/she can then choose an Album fro m the dropdown where these photos  will be stored.</p><p>The Batch  Uploader is developed using Action Script 2 and uses PHP as the backend to  process the file upload. The current user ID can be passed to the flash module  by defining a FlashVars variable as “userid” which will be passed to the PHP  function when albums are requested or when the upload is processed.</p><p>Here is  an example of passing a variable to flash from HTML using FlashVars.</p><p><pre class="brush: php; html-script: true; title: ; notranslate">
//Object Tag Example:
&lt;PARAM NAME=FlashVars VALUE=&quot;userid=10&quot;&gt;
//Embed Tag Example:
&lt;EMBED href=&quot;display.swf&quot; FlashVars=&quot;userid=10&quot;&gt;&lt;/EMBED&gt;
</pre></p><p>The  application initially request for the albums created by the user, by calling a  PHP script which returns a list of albums and their ids in XML format.</p><p>See the  code at line 86.</p><p><pre class="brush: php; html-script: true; title: ; notranslate">
var albumListURL = (_root.albumUrl)?_root.albumUrl:&quot;http://yourwebsite.com/albumList.php&quot;;
</pre></p><p>The  albumList.php should return the list of Albums in XML format as shown below.</p><p><pre class="brush: php; html-script: true; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;albums&gt;
	&lt;album&gt;&lt;id&gt;1&lt;/id&gt;&lt;name&gt;My Little Baby&lt;/name&gt;&lt;/album&gt;
	&lt;album&gt;&lt;id&gt;2&lt;/id&gt;&lt;name&gt;Wedding Photos&lt;/name&gt;&lt;/album&gt;
&lt;/albums&gt;
</pre></p><p>The tool also allows the user to create a new album right from the uploader interface. Open the &#8220;albumpop_mc&#8221; movieclip on the stage to see the album creation functionalities.</p><p>The batch  upload tool sends selected files one by one to the server. “uploadItem” (Line  number 172) is the function which sends the file to the server PHP script.  </p><p><pre class="brush: php; html-script: true; title: ; notranslate">
if (!itemRef.upload(&quot;http://yourwebsite.com/batchUploadProcess.php&amp;album=&quot;+albumHash+&quot;&amp;user=&quot;+_root.userId)) {
	errorList.push(&quot;Failed to upload : &quot;+item.name);
}
</pre></p><p>This code  sends one file at a time to a php script named “batchUploadProcess.php” which  receives the file at the server and add a record in the database. The ID of the  album the user has chosen from the list and the user Id the application is  given as a FlashVars variable are sent to the PHP script.</p><p>Below is  the script I used to process the file sent from Flash.</p><p><pre class="brush: php; html-script: true; title: ; notranslate">
switch($_FILES['Filedata']['error']) {
    case 1:
    case 2:
    case 3:
    case 6: die; break;
    case 4:
    case 0: break;
    default: die; break;
}
if ($_FILES['Filedata']['error'] == 0) {
    $fileInfo['photo'] = getimagesize($_FILES['Filedata']['tmp_name']);
    if ($fileInfo['photo'][2] != 2) die;
}
move_uploaded_file($_FILES['Filedata']['tmp_name'], &quot;./photos/originals/YourFileName.jpg&quot;);
//Add your other codes here
echo &quot;success&quot;;
</pre></p><p>Click the below link to download the source file in CS3 format.<a
class="dLink" href='http://ask.amoeba.co.in/wp-content/uploads/2009/12/batchUploadCS3.zip'>Free Batch Upload tool &#8211; Flash Action Script</a></p><p>If you  are an intermediate flash programmer, you can easily understand the code flow. Modify  and use the code wherever you want. I don’t really want to explain the complete  code here. But you can contact me if you have any questions.</p><div
class="bottomcontainerBox" style=""><div
style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <iframe
src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fask.amoeba.co.in%2Fflash-batch-uploader%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div><div
style="float:left; width:65px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <g:plusone size="medium" href="http://ask.amoeba.co.in/flash-batch-uploader/"></g:plusone></div><div
style="float:left; width:100px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"> <a
href="http://twitter.com/share" class="twitter-share-button" data-url="http://ask.amoeba.co.in/flash-batch-uploader/"  data-text="Batch Uploader using Flash Action Script 2" data-count="horizontal" data-via="aneesme">Tweet</a></div><div
style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://ask.amoeba.co.in/flash-batch-uploader/" data-counter="right"></script></div><div
style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://ask.amoeba.co.in/flash-batch-uploader/"></script></div></div><div
style="clear:both"></div><div
style="padding-bottom:4px;"></div>]]></content:encoded> <wfw:commentRss>http://ask.amoeba.co.in/flash-batch-uploader/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
