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 More

Designing 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 More

Free SWF to XAML Converter.

This should interest any one who wants to get into WPF (Windows Presentation Foundation). What interests me is Michael Swanson’s interview in which he explains SWF file format internals.

Read More

Enhancing 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 More

Sending 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 More

Understanding 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 More

How 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 More

Porting 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 More

Solution for using relative paths in swfs to load data.

Only starting from Flash 9 and Actionscript 3 we can reliably use relative path to load data. Let me explain the problem. say for example we have an swf file named ‘Slide.swf’ in a folder ‘Slide001′ folder which loads ‘data.xml’ using the following statement my_xml=new XML(); my_xml.onLoad=function(success){ //process the xml...

Read More

Using XMLShortcuts Example.

XML Shortcuts helps to access the XMLNodes with ease. You may read my previous post which compares the XMLShortcuts with XPath from XFactor Studio, XML to Object Prototype, and XMLNode easy access by tatsuo kato Here is a example file, that shows how you can use XMLShortcuts in your MTASC projects. ...

Read More

Counting number of words in a String.

Here is a simple code to get the word count. To ease up the process, I do not count the words that are not separated by space For Example “Mr.Arul” will still be counted as one word. but it makes sure whitespace is not counted as words Here is the code 1234567891011121314151617181920function wordcount(txt) {         if...

Read More

String.isWhite and String.getWordCount().

This is the same word count function that I showed in the previous post presented in the good old way of adding more properties and methods through the prototype. String object is extened to have isWhite read only property and getWordCount method. 12345678910111213141516171819202122232425262728293031323334String.prototype.addProperty('isWhite', function ()...

Read More

Easy 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 More

Generating 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 More

XML 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 More

XML and V2 Tree Example 5 – Limit by Depth.

Lets explore how we can hide nodes beyond the predefined depth from rendering in tree. Before hiding the text nodes, the tree looks like this (as per Example 1) with this XML Start with a blank FLA, add a tree component to stage, name it “tree”, add a text area component name it “textArea” Write the following in the first frame ...

Read More

XML and V2 Tree Example 4 – Hiding Text Nodes.

Lets explore how we can hide text nodes from rendering in tree. Before hiding the text nodes, the tree looks like this (as per Example 1) with this XML Start with a blank FLA, add a tree component to stage, name it “tree”, add a text area component name it “textArea” Write the following in the first frame ...

Read More

ColorSyntax Extractor now generates XML for Flash based Syntax Highlighter .

I’ve modified my Color Syntax Extractor to include XML for Igor’s Flash Syntax Highlighter, which is a flash based synctax highlighter for actionscript. You can download the tool from here!...

Read More

New RIA Interface for my blog.

Quick Blog Viewer v3 is a Flash based RIA for my blog. Now you can keep track of the posts easily, find out what is new since your last visit, flag your favorite posts. It’s interface should explain how. Check it out at blog/quickview Don’t forget to right click on the grid after selecting something

Read More

XML and V2 Tree Example 2: Open/Close All.

Lets enhance the last example by adding two buttons to open and close all tree nodes Add the following code to the first frame 1234567891011function openOrCloseAll (x, open:Boolean) {         if (tree.getIsBranch (x)) {                 tree.setIsOpen (x, open, false,...

Read More

Actionscript Syntax Highlighting with SE|PY Editor v.1.0.5.4.

SE|PY has become my favorite actionscript editor these days. It’s default color highlighting scheme is very different from Flash IDE. So I’ve modified it to syntax highlight similar to my actionscript highlighting service 2 and exported the settings using File > Import/Export > Export Settings for your convenience. You may download SEPY_ColorStyle.tar.gz and import it into SEPY...

Read More

PriorityQueue Class

Brandan Hall wrote the PriorityQueue (pQueue) class in “Object Oriented Programming with ActionScript” published by New Riders. I’ve converted that class to ActionScript 2 which you may download from here.

Read More

Actionscript for XML pretty printing and color highlighting . XMLHighlighter class

XMLHighlighter class Availability Flash Player 6 (copy the XMLHighlighter class actionscript file to the same folder as the FLA or to the class path). Description Use the methods and properties of the XMLHighlighter class to generate the html code to generate color highlighted pretty printed XML Method summary for the XMLHighlighter...

Read More

XML pretty printing and color highlighting .

We used to build many Flash Applications which exports data as XML. How about pretty printing it with colors? Before writing my own code I searched to find any existing code and found this code written by Evgeniy Potapenko in prototype. It does the basic pretty printing part, but it had few problems in handling the text nodes. It adds tabs before text nodes and unlike the native .toString()...

Read More

Converting Date Strings back to Date.

We all know that trace(new Date()) traces the date as a string that looks like “Mon Jul 12 13:20:09 GMT+0800 2004″ How to convert this String back to Date? There is no built in method, so I’ve written this function to do that. Usage: #include “getDateFromString.as” //sample date in Pacific Daylight Time var str = “Sun Aug 11 17:00:00 GMT-0700...

Read More

Breeze Presentation on "Taking Sketches into full-blown Flash Animations".

Yesterday we really enjoyed the presentation by Chris Georgenes, one of our Team Macromedia Volunteers. He talks about the minute details of animation. Take a look at his great presentation here. If you like to see the resulting animation of his presentation, take a look at his website. Enjoy ...

Read More

Pixel Perfect Drawing Tools for Flash MX04.

So far, whenever in need of pixel accurate graphics in flash, I follow the following steps 1. Enable the snap to pixel option (if not enabled already) 2. Zoom in to see the pixel grid 3. Select Rectangle Tool 4. Select ‘No Color’ for Stroke 5. Draw Pixel Rectangles with the help of snap to pixel The good news is, now we have a better and efficient way to do the same, thanks to Patrick...

Read More

Solution for skipping files from getting cached by Server and Browser

Cache is a place to store something more or less temporarily. Web pages we’ve visited are stored in our browser’s cache directory on our hard disk. Likewise, ISPs and Web Servers cache web pages which speeds up access times for users, as the page is being read from the cache memory and not downloaded from the actual web site It can become a problem when we are loading external...

Read More

New 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 More

Yet another way to generate reference documents

Philter has developed a parser to parse the flash doc style comments in your actionscript. Using his parser you can generate gModeler XML. You already know that gModeler can generate reference XML. Combining this two tools we are getting complete solution for free. On behalf of all the users let me thank Philter and Grant Skinner for all their...

Read More