Webcam Motion Detection using AS3 – Source Released.

I rewrote the webcam motion detection example in Actionscript3 using Flash 9 Alpha. You can see the demo here. As I promised earlier the FLA is ready for download here ๐Ÿ™‚

Read More

Removing Byte Order Mark (BOM) from the given string.

Since PHP does not recognize and ignore BOM in the loaded files, I wrote the following script to find and remove the BOM from the loaded string. function removeBOM($str=''){     if(<a href="http://www.php.net/strpos">strpos</a>($str, "ยป")==1)$str=<a...

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

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 function wordcount(txt) {         if (!isNaN(txt+" 0"))...

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. String.prototype.addProperty('isWhite', function () {         return !isNaN(this+'...

Read More

XML Shortcuts component released.

The XMLShortcuts component enables shortcut access to All XML nodes. Biggest advantage of using XML shortcuts is it can be easily added to existing projects with out any modification. Simply drag and drop the component from components window to the stage and then delete it from stage (let it stay in the library). Available Shortcuts: Property Description childNode Get the first child...

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

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

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

Updated my ActionScript() function

Arrays and Functions can have other properties attached to it. But my .toString() method and ActionScript() function does not account for it. Now I’ve rewritten the code to include those other properties as well. Also now it takes care of the properties with undefined values. Take a look at the new ActionScript() function here. [UPDATE] included the ActionScript 3 version as well ๐Ÿ™‚...

Read More

An 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. <span style="color: #993300;">var</span> d =...

Read More

Improved ActionScript() Tracing

The objective of my .toStrong code and ActionScript() function is to generate the actionscript from any object with which we should be able to recreate the object again. My String.toString Prototype does manage the /n and /r properly(thanks to Rob for pointing this to me through his comment). Now I’ve fixed it. Have a look at it here. [UPDATE] included the ActionScript 3 version as well...

Read More

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

MX: MovieClip-swapClip.

When we need to replace a movie clip on stage with another with a Linkage ID the following code will be useful. <span style="color: #993300;">MovieClip</span>.<span style="color: #000087;">prototype</span>.swapClip = <span style="color: #993300;">function</span>(idName) {        ...

Read More

Correction to Object.toAS() version 2!

Ampre’s code has a bug in handling Array of strings (refer to my previous post). Since he is just enclosing the result of original Array.toString() with square backets it returns [a,b,10] when it is supposed to return [‘a’, ‘b’ ,10]. Just replacing his version of Array.prototype.toString with the following code fixes it. [UPDATE] included the ActionScript 3...

Read More

Better Object-toAS() Code

As you all already know my Object.toAS() code does fail with circular references. Ampre has replied with the following code in prototype, which is sleeker and also can addresses the circular reference issue to some extent. Here is that code [UPDATE] included the ActionScript 3 version as well ๐Ÿ™‚ It became lot more simpler with the regular expressions ActionScript 3.0 ...

Read More

XMLNode.transformTags() Source Code Released!

Wish you all very happy and prosperous New Year 2003! ๐Ÿ™‚ Here is my tiny gift for the new year, transformTags basically allows you to add, remove, and modify tags in any valid XML. You can take a look and download the source code from here! For more usage examples take a look at my previous posts. I will also try to put more examples.

Read More

Stripping HTML Tags using XML

There is a thread going on in flashcoders mailing list about how to stripp the HTML tags in the string. Here is my version to do the same using XML. It can be used to remove specific tags from the given string. Even though we can use flash textField for this purpose (setting the .htmlText property and getting .text property) the following method gives more options and flexibility. [UPDATE]...

Read More

Creating Unique Random Response

Whether we are developing a game or e-learning application we need to create random response which is unique and not repeating. Say for example if you are developing a Quiz application where you have 10 questions, you want to pick the question randomly, but the same question should not be repeated. Here is a custom class which we can use to produce such random values. I will write more about it...

Read More

String.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

Rendering HTML in FlashMX

Rendering of HTML text in browsers and flash text box is different in the fact that; spaces, tabs and line brakes are ignored in browsers but are rendered in flash text box. I faced this problem in my reference panel application and wrote the following script as a solution. [UPDATE] included the ActionScript 3 version as well ๐Ÿ™‚ It became lot more simpler with the regular...

Read More

Object.copyProperties(toObj, PropertyStr, exclude?)

When you need to copy only certain properties of one object to another object, this code will be useful. I’ve also given an example on how to use it. take a look at it here

Read More

Object to ActionScript Utility

Many times we need this! We create objects and arrays and modify them through code to get them as we want. Finally the object is ready but every time it is created using the same complex procedure when the SWF runs. This affects the performance to some extent. Also sometimes we need to see what’s in that object at that movement for debugging (including remote debugging) So I’ve...

Read More

Cloning objects

In ActionScript we cannot pass objects by value. It always passes objects by reference. If you need to create a perfect copy of an object you can make use of the following code. I have modified Flash Guru’s clone with support for Array Objects [UPDATE] included the ActionScript 3 version as well ๐Ÿ™‚ It became lot more simpler with the regular expressions ActionScript...

Read More