Arul's Blog On Multimedia, Flash MX, Director And Dreamweaver MX
Recent Entries | Guest Book | QuickView | XML-RSS feed | My Profile | Home
::: About this Blog :::
Welcome to Arul's Blog!
Weblog on Multimedia,
Macromedia Flash MX Flash MX
Macromedia Director Shockwave Studio 8.51 Director
Macromedia Dreamweaver MX Dreamweaver MX
View my profile And me :)
Here I'm going to share my views, opinions and code with you all.

::: Services :::

:. ActionScript Highlighting
:. AS Highlighter v2 new!


::: ActionScript :::
:. toString
:. skipCache
:. getWords
:. getDateFromString
:. colorUtils
:. XMLNode-transformTags
:. Object-copyProperties
:. Object-clone

::: ActionScript 2 :::
:. XMLHighlighter
:. PriorityQueue

::: Archives :::
[September 2002]
[October 2002]
[November 2002]
[December 2002]
[January 2003]
[February 2003]
[March 2003]
[April 2003]
[May 2003]
[June 2003]
[July 2003]
[September 2003]
[October 2003]
[December 2003]
[January 2004]
[February 2004]
[March 2004]
[April 2004]
[May 2004]
[June 2004]
[July 2004]
[December 2004]
[January 2005]
[February 2005]
[March 2005]
[May 2005]
[June 2005]
[July 2005]
[August 2005]
[June 2006]
[July 2006]
[November 2006]
[December 2006]
[January 2007]

::: Time Zone :::
All Times on this blog are
GMT + 5:30 Hours
(Indian Standard Time)

::: Flash Resources :::
:. Flash Components
:. Were-Here Forum
:. Digital Illusion
:. Flashmove Forum
:. Flash Goddess
:. Prototypes
:. Actionscript Toolbox
:. UltraShock
:. Chattyfig
:. Full as a Goog
:. Flog

::: Flashers :::
:. Mike Chambers
:. Greg Burch
:. Branden Hall
:. Samuel Wan
:. Stuart Schoneveld
:. Guy Watson
:. Robin Debreuil
:. Mario Klingemann
:. Moises
:. Aral Balkan
:. Peter Hall
:. Josh Dura
:. Alessandro
:. Brajeshwar
:. Nik Khilnani

::: Small Print :::

© Copyright 2002
R.Arul Kumaran

[Made with Blogger]


Monday, December 30, 2002

Examples.Flash MX: Easy way to highlight the links in flash dynamic text.

Yet another transformTags() example.
You all know that links in flash text won't highlight with blue color and underline as it does in browser. If you want to highlight all the links in your dynamic text box you may use the following object as the format object to transformTags to achieve the results as shown below.
#include "XMLNode-transformTags.as"
my_xml = new XML("<a href=\"http://www.shockwave-india.com/blog\">URL for my Blog</a>");
fObj = {};
fObj.a = function(node) {
        var aList = "";
        var attrib = node.attributes;
        for (i in attrib) {
                aList += " "+i.toLowerCase()+"=\""+attrib[i]+"\"";
        }
        var tag = {};
        tag.start = "<font color=\"#0000FF\"><u><a"+aList+">";
        tag.end = "</a></u></font>";
        return tag;
};
//change all 'a' tag to a combination of font,u,a tags to highlight
trace(my_xml.transformTags(fObj,true));
/*
traces
'<font color="#0000FF"><u><a href="http://www.shockwave-india.com/blog">URL for my Blog</a></u></font>'



*/

posted by Arul | link | ^top | next> | comments [1]
Friday, December 27, 2002

Demo.Flash MX: Creating X-HTML using Flash MX Text box.

Further extending my strippTags code I came up with transformTags code to modify the tags in an xml object which is very useful for many different purposes. One of which I'm demonstrating here.

basic syntax is
XMLNode.transformTags(formatObject, AllowTagsByDefault)
formatObject - generic Object which contains the info on how to modify the tags.
AllowTagsByDefault - boolean value which specifies whether to allow unspecified tags or not

This demo is using the code below to transform the tags generated by an input text box so that it can be rendered in any HTML 4.0 compatible browser. We can utilize the rich text editing capabilities of flash to create a forum/comment system which will produce HTML which is compatible to the browser by modifying the .htmlText which is basically a modified version of HTML 1.0

//create an object to specify the format
var fObj = {};
//remove all  tags
fObj.textformat=false;
//change all <b> tags to <strong>
fObj.b="strong";
/*
convert
<font face="_sans" SIZE="12" COLOR="#000000">
to
<span style="font-family:Arial, Helvetica, sans-serif;font-size:12pt;color:#000000;">
*/
//change <font> tags to <span> tags
fObj.font ={__replace__:"span"}
// change size attribute to style attribute
fObj.font.size={__replace__:"style"}
fObj.font.size.__value__ = function(size) {
        return ("font-size:"+size+"pt;");
};
// change color attribute to style attribute
fObj.font.color={__replace__:"style"}
fObj.font.color.__value__ = function(color) {
        return ("color:"+color+";");
};
// change face attribute to style attribute
fObj.font.face={__replace__:"style"}
fObj.font.face.__value__ = function(face) {
        switch (face) {
         case "_sans" :
                face = "Arial, Helvetica, sans-serif";
                break;
         case "_serif" :
                face = "Times New Roman, Times, serif";
                break;
         case "_typewriter" :
                face = "Courier New, Courier, mono";
                break;
        }
        return ("font-family:"+face+";");
};
//transformTags when Main text changes
main_txt.onChanged = function() {
        flash_txt.text = this.htmlText;
        //create a XML object
        my_xml = new XML(this.htmlText);
        //transform the tags in the XML with the format object which we created
        htm_txt.text = my_xml.transformTags(fObj, true);
};

To see transformTags in action type something and format the text in the input textbox below

I will optimize and release the XMLNode.transformTags() source soon! :)

posted by Arul | link |<prev. | ^top | next> | comments [8]
Tuesday, December 24, 2002

Extension.Flash MX: Improved version of Flash Remoting Helper component.

I've improved the component and now it has the following additional features / improvements.

New Features:
  • There is no limitation for the number of parameters.
  • Now you can optionally specify the name of the array to use as the parameters of the remote function (for dynamic values and also for using other data types than string and numbers).
  • You can specify result handler and status handler functions to process the return values of the remote function.
  • All the Status (error) Messages are traced when no status handler function is defined.
You can download the component from here.

posted by Arul | link |<prev. | ^top | next> | add comment
Friday, December 20, 2002

News.Flash MX: Using CF.query with ServerSide ActionScript in JRun.

Many of you already aware that CF.query method is available for ServerSide ActionScript only in Coldfusion to query a database. There is no such object available in JRun 4.0.

Tom Muck created an object for JRun 4 ServerSide ActionScript that adds a CF.query() method to SSAS. He has given example of how to make use of it in his Flash Remoting Random Thoughts. Take a look at it here.

posted by Arul | link |<prev. | ^top | next> | add comment
Tuesday, December 17, 2002

Extension.Flash MX: Remoting Helper Component.

Many Java, .NET and Coldfusion MX developers are now jumping into Flash Remoting. The problem they face when they are not much familiar with actionsript is in testing their server side remoting script. Every time they have to go to the flash developer for testing.

To solve this problem I've developed a component called RemotingHelper which allows you to define the GatewayUrl, name of the remoting Service to connect to, remote Function to call and Parameters to pass to that function using the Component Parameters. You can download the component from here

It has to be used along with the NetConnection Debugger (Menu : Window > NetConnection Debugger) that comes with Flash Remoting components.

Known limitations:

  • You can only pass Strings and Numbers to the remote function other object types are not supported
  • It can only take a maximum of 10 parameters

Usage:

  • Drag and drop RemotingHelper component from the components window and set the properties
  • Open the NetConnection Debugger from the Window menu.
  • Test the Movie and see the NetConnection Debugger window for the events.

posted by Arul | link |<prev. | ^top | next> | comments [3]
Friday, December 13, 2002

Code.Flash MX: 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.
XMLNode.prototype.strippTags = function(tagList,exclude){
	if(exclude != true)exclude = false;
	if(tagList == undefined)tagList = "";
	if(this.nodeType == 1){
		var c = this.childNodes;
		var str = "";
		for(var i=0; i<c.length; i++){
			if(c[i].nodeType == 1){
				var startTag = "";
				var endTag = "";
				var aList = "";
				if(exclude != (tagList.indexOf(c[i].nodeName.toLowerCase())!= -1)){
					for(a in c[i].attributes){
						aList += " " + a + "=\"" + c[i].attributes[a] + "\"";
					}
					startTag="<" + c[i].nodeName + aList + ">";
					endTag="</" + c[i].nodeName + ">";
				}
				str += startTag + c[i].strippTags(tagList,exclude) + endTag;
				}else{
					str += c[i].nodeValue;
				}
			}
			}else{
				 return this.nodeValue;
	}
	return str;
  };
  //Usage Examples:-
  var my_str="hi! my <font color=\"#00FF00\">name</font> is <b>arul</b>"
  var my_xml=newXML(my_str);
  trace(my_xml.strippTags());
  //traces 'hi! my name is arul'
  trace(my_xml.strippTags("b"));
  //traces 'hi! my name is <b>arul</b>'
  trace(my_xml.strippTags("b",true));
  //traces 'hi! my <font color="#00FF00">name</font> is arul'
  trace(my_xml.strippTags("font",true));
  //traces 'hi! my name is <b>arul</b>' 
This is the one which I'm using in my Reference Viewer Application ;)

posted by Arul | link |<prev. | ^top | next> | comments [5]
Friday, December 13, 2002

News.Flash MX: New Public Flash Player is released.

After a big round of beta testing public version is now released. Also it is the first Flash 6 Player for Linux with full support for Remoting, Video playback, and Flash Communication server. You can download the updated version here.

[via:Mesh on MX]

posted by Arul | link |<prev. | ^top | next> | comments [1]
Thursday, December 12, 2002

Update.Arul's Blog: Arul's Blog now syndicated in FLOG.

Today flog started syndicating my blog. Thanks to David Humphreys, now my blog has more wider coverage.

Also I've noticed that goggle ranking for the blog page is jumped from 4 to 7 (when I started this blog 4 months back it was only 3). Links given in MoiK78 Blog and onRelease() can be one of the reason. Thanks to Moises and Aral Balkan.

Search engines like google, and yahoo are also bringing in the traffic.

posted by Arul | link |<prev. | ^top | next> | comments [1]
Tuesday, December 10, 2002

Tips.General: Macromedia Tips Library.

I just noticed that Macromedia now has a Tips Library in the Designer & Developer Center, where we can share our favorite product tips.

Take a look and post your tips at http://www.macromedia.com/desdev/tips_library

posted by Arul | link |<prev. | ^top | next> | add comment
Saturday, December 07, 2002

Tools.Flash MX: Actionscript Syntax Highlighting with SciTE|Flash.

Many of you might already know how handy it is to edit ActionScript with SciTE|Flash, for those who do not know SciTE|Flash is a text editor from BomberStudios for editing ActionScript, free download is available in their website.

One of the nice features which attracted me is exporting the script as HTML or RTF, which can be used to syntax highlight actionscript instead of my ActionScript Highlighting Service. But the current colors used are not matching with the colors I use in actionscript highlighting so I modified the flash.properties file which contains the color info.


First picture shows SciTE|Flash with the default highlighting and the second one is the modified version. You can download the modified flash.properties file from here.

posted by Arul | link |<prev. | ^top | next> | add comment
Thursday, December 05, 2002

Code.Flash MX: 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 in my next post
//custom class for producing unique random numbers
_global.randomResponse = function(a, b) {
        this.set(a, b);
};
//use the set method to set the random value
//to be an array or range of numbers
randomResponse.prototype.set = function(a, b) {
        if (a instanceof Array) {
                this.Arr = a;
        } else if (!(isNaN(a) && isNaN(b))) {
                this.Arr = [];
                var step = a<b ? 1 : -1;
                for (i=a; i<=b; i += step) {
                        this.Arr.push(i);
                }
        } else {
                trace("Error: invalid parameters to randomResponse Object");
                return false;
        }
        this.ArrCopy = this.Arr.slice();
        return true;
};
//Use get method to get the random response
randomResponse.prototype.get = function() {
        do {
                var index = random(this.Arr.length);
        } while (this.response == this.Arr[index]);
        this.response = this.Arr[index];
        this.Arr.splice(index, 1);
        if (this.Arr.length == 0) {
                this.onCycleComplete();
                this.Arr = this.ArrCopy.slice();
        }
        return this.response;
};
/*Usage
Example 1 - Using Array*/
var myResponse = new randomResponse(["good", "super", "great"]);
trace(myResponse.get());
trace(myResponse.get());
trace(myResponse.get());
trace(myResponse.get());
trace(myResponse.get());
myResponse.onCycleComplete = function() {
        //trace("completed a cycle");
};
/*Usage
Example 2 - Using range of numbers*/
var myResponse = new randomResponse(5, 8);
trace(myResponse.get());
trace(myResponse.get());
trace(myResponse.get());
trace(myResponse.get());
trace(myResponse.get());

posted by Arul | link |<prev. | ^top | next> | add comment
Sunday, December 01, 2002

Examples.Flash MX: Creating a Talking Application in Flash.

Here I will show how to create a light weight talking application in flash. It is one of the Examples I showed in the Singapore User Group Session.

Our task is fairly simple,

  • Creating an audio file (preferably MP3) with all the words we want our application to speak.
  • Using that audio in a movieclip as a streaming audio and placing frame labels(to another empty layer) to split the whole audio in to the words
  • Using actionscript for playing the right portions of the audio to get right sentence out of it

To achieve this I've created a talker component which has the following main methods

  • NumberInWords(number) which converts the given number to words which it can speak
  • talk(data) which speaks the given number or string
    Example:-
    • myTalker.talk(101) will speak "Singapore Dollars One Hundred and One only"
    • myTalker.talk("SG$ Two Hundred and Twenty Two only") will speak "Singapore Dollars Two Hundred and Twenty Two only"

Using this component I've created a sample application [swf file size:50K] which speaks the number which is either random generated or typed in the Number field. Take a look at it below and the FLA source is available as a Ziped file [file size: 400K] here.

posted by Arul | link |<prev. | ^top | next> | comments [3]

footnote:-
Also check the recent entries and feel free to add your comments. I need your comments to improve this blog