Webcam Motion Detection using AS3.
Some time back Guy Watson wrote an article in the developer center called Webcam Motion Detection: Using the BitmapData API in Flash 8. He later made a better version of it and included that source in the zip file. I went through that code and completely rewrote it in ActionScript 3. Here is the demo. This one of course requires a webcam and flash 9 player to play around. Once I clean up the...
Read MoreDesigning a Search Field .
Utilizing the available application space effectively is one of the important things we need to consider when designing an user interface. Olden search interfaces had two parts text input field and a search button. Then the “search”/”find”/”go” text is replaced with a lens icon. Now a days this lens icon is embedded inside the input text itself. If you want...
Read MoreEnhancing the Blog Reader Example.
In the Live docs you might have read about Retrieve and Display Data. Here I’ve enhanced the same MXML by the following The LinkButton hidden until the datagrid change event is fired. Enabled the Data Tips for ‘Posts’ column to show tool tips text on roll over. Made it a scalable layout by using constraint-based layout. Here is the MXML code, I’ve highlighted the changes...
Read MoreSending Arrays with offset Index.
Last time we saw the problem with sending ActionScipt 3 Associative Array. Now we let us see where associative arrays can help. Lets Make an Array with offset index in PHP: $arr =array(5=>5); in ActionScript: var arr:Array= []; arr[5]=5; Sending these arrays either way they go with the missing indices filled with null, so the PHP array comes to flash as arr=[null, null,...
Read MoreUnderstanding AMF0 and AS3 Array.
You might have already read about Array oddity in AMFPHP/Flex 2. AS3 Associative Arrays, when sent through AMF0 they include ‘length’ propery. But numeric index based Arrays are fine. I’ve created the following AMFPHP Service to showcase this issue. It is a simple service with a remote method that converts any given object to string and returns...
Read MoreHow to load data from a remote URL?
I found that the DataLoadingTest class given in Adobe Labs ActionScript 3 Resources site was buggy and did not work. I’ve corrected the file myself and made it work. Here is the working code ActionScript3 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162package { import...
Read MorePorting XMLHighlighter class to ActionScript 3.
XMLHighlighter generates color highlighted pretty printed HTML code for the given XML document, I have ported it from ActionScript 2 to ActionScript 3. Here is what I learned during the process XML object in ActionScript 3 is different (It is ECMAScript for XML (E4X)). For backward compatibility we have XMLDocument class which is equalent to XML in Actionscript 3. In ActionScript 3 we need to...
Read MoreEasy way to Randomize an Array.
Here is the sample code to shuffle the contents of an array 123456789// Here is a simple function for randomizing the array function randomsort(a, b) { return Math.random()>.5 ? -1 : 1; } //usage example var arr = [1, 2, 3, 4, 5]; arr.sort(randomsort); trace(arr); //traces 4,3,1,5,2 ...
Read MoreGenerating Unique Random Number for Flash Lite 1 and 1.1.
Generating Unique random number for Flash Lite 1.1 is tricky because of the Flash 4 style syntax. I’ve made a sample application which shows how this can be achieved. Here is the SWF showcasing this You can download the FLA from...
Read MoreXML Shortcuts V2 released
Here you can download the second version of XMLShortcuts component which helps to access XMLNodes easily. Refer to Online Help document below for more info <a href=”/HelpPanel/?target=XMLShortcuts” target=”_blank”>XMLShortcuts Online...
Read MoreNew Version of ActionScript() function for improved AS Tracing.
I’ve completely re-written my ActionScript function. For those who are hearing about it for the first time ActionScript(Object, ‘name_of_the_variable’) – gets complete reusable actionscript string of the Object including circular references. Now it takes care of special characters in properties and also shows null values properly Now the actionscript produced is more...
Read MoreAn Idea to document your components.
This could be an easy way to document your component. We need track the properties and methods of a component by looping through the instance. Say for example the following example can generate the color syntax xml for any component instance, we need to delete unwanted entries manually that’s all. 123456789101112<span style="color:...
Read MoreReal toString() method.
This code snippet helps to get the real insight of an object instead of returning ‘[object object]‘ while tracing. Now I’ve completely rewritten it to take care of circular references, escaping quotes in Strings, and function references. Also I’ve created a “ActionScript” function to get the complete picture of the object. We can use the produced ...
Read MoreEnter, Backspace and Delete Keys fail when using Listeners for Textbox
‘ve noticed it many times. When we use listeners for Textbox or while using onChanged event some times it fails to render backspace, delete and enter keys unless we have a selection. Removing the Listener reverts back to normal. Did anybody had the same problem and found a solution? If yes then please post it in the comments.
Read MoreMX: MovieClip-swapClip.
When we need to replace a movie clip on stage with another with a Linkage ID the following code will be useful. 1234567891011121314<span style="color: #993300;">MovieClip</span>.<span style="color: #000087;">prototype</span>.swapClip = <span style="color: #993300;">function</span>(idName) { ...
Read MoreFlash Remoting Using AMF in PHP!
There is an interesting thread in Flash-DB which is discussing the various possibilities of passing data to flash from PHP. The attractive part in that to me is using AMF(Action Message Format – binary format for sending Flash Objects) with PHP. Musicman has come out with this PHP class which can construct the AMF data. Alessandro(sephiroth) has put a sample application using this...
Read MoreString.changeCase(Title || Sentence || Toggle).
ActionScript Standard Library project is really picking up. For those who are hearing it for the first time, the ActionScript Standard Library is a collection of ActionScript classes and libraries that aims to create and provide a standard library of functionality to ActionScript. ASL is an Open Source initiative by Mike Chambers, the community manager of macromedia. Currently 33 developers...
Read More

