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, June 27, 2005

News.Flash MX: XMLShortcuts Version 2 coming soon.

I'm already working on version 2 of this XMLNode easy access component.

It will give better performance than the previous version. It will have two components, XMLShortcuts Lite and XMLShortcuts Pro. Both provide the same functionality.

XMLShortcuts Lite is optimized for file size & memory, it is recommended for Small Projects.

XMLShortcuts Pro is optimized for processor & performance, recommended for medium and large projects

What else is new?
1) __text - now it can be used for easily adding text nodes. for example
var my_xml=new XML('<a/>');
my_xml.a.__text='apple';
trace(my_xml)
//<a>apple</a>

2) nodeIndex - unique node index for the node with a unique name in the order of appearance in the xml. for example
var my_xml=new XML('<x><a id="1"/><a id="2"/><a id="3"/><a id="4"/></x>');
trace(my_xml.x.lastChild)
//<a id="4" />
trace(my_xml.x.lastChild.nodeIndex);
//3

It will be great if some one can take initiative to do performance test on both

posted by Arul | link | ^top | next> | comments [9]
Wednesday, June 15, 2005

Code.Flash MX: 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 node with the specified node name
childNode_index Get the specific child node with the specified node name and index
$childNode Get all the child nodes with the specified node name as an array.
_attribute Get the value for specific attribute name
__text Get the text node
rootNode Access the root node of XML from any node using this shortcut
Note: Replace childNode, index, and attribute with their respective values. See the example below

my_xml:
<english>
 <a word="apple">a for apple</a>
 <a word="Arul">a for Arul</a>
 <b word="ball">b for ball</b>
 <b word="bee">b for bee</b>
 <c word="cat">c for cat</c>
 <c word="cow">c for cow</c>
</english>

Using the XML above

Property Example Trace output
childNode
trace(my_xml.english.a)
<a word="apple">a for apple</a>
childNode_index
trace(my_xml.english.a_1)
<a word="Arul">a for Arul</a>
$childNode
trace(my_xml.english.$b)
<b word="ball">b for ball</b>,
<b word="bee">b for bee</b>
_attribute
trace(my_xml.english.c._word)
cat
__text
trace(my_xml.english.c.__text)
c for cat
rootNode
trace(my_xml.english.c.rootNode instanceof XML)
true

Caution: Avoid data type declaration while initializing XML and XMLNode
for example the following code will throw a compiler error "There is no property with the name 'x'"

var myXML:XML = new XML ("<x><y/><x>");
trace (myXML.x);
Where as the following code works fine
var myXML = new XML ("<x><y/><x>");
trace (myXML.x);
Hope it is of some use to everyone using flash and xml in their day to day life. Feel free to express your views in the comment, I will be glad to hear from you :)

Download: XMLShortcuts.mxp

posted by Arul | link |<prev. | ^top | next> | comments [16]
Monday, June 13, 2005

Demo.Flash MX: XML Shortcut - Accessing XMLNode easily as a Object.

If you hate accessing XMLNodes using myXML.firstChild.childNodes[3] approach, there are already couple of other approaches to deal with.

Before getting to know my new approach lets examine the other possibilities.
Solution Pros Cons
XPath from XFactor Studio
  • Standards based
  • Easy to use
  • Dynamically resolves at runtime
  • Bit heavy
Usage Example:-
import com.xfactorstudio.xml.xpath.*;
var _xml:XML = new XML ();
_xml.onLoad = function (done) {
        if (done) {
                var title = XPath.selectNodes(this,"/rss/item/title");
                trace(title);
                /* variable title is populated with the following value
                title=[
                     "<title>Tools.Flash MX: Actionscript Syntax Highlighting with SE|PY Editor v.1.0.5.4</title>",
                     "<title>Update.Arul&apos;s Blog: I'm back again</title>",
                     "<title>Code.Flash MX: PriorityQueue Class </title>"
                ];
                */
        }
};
_xml.load ('http://www.shockwave-india.com/blog/example/sample.xml');
      
XML to Object Prototype
  • Easy to use
  • May not be able to handle big xml files
  • Pre-Processing required
  • Generates new Objects
  • Mixed type access is not possible (like myXML.rss.firstChild.attributes etc)
Usage Example:-
#include "XMLSA.as"
//
var _xmlsa= new XMLSA ();
_xmlsa.onLoad = function (done) {
        if (done) {
                trace (this.item.title.getValue());
                //Tools.Flash MX: Actionscript Syntax Highlighting with SE|PY Editor v.1.0.5.4
                trace (this.item[1].title);
                //<title>Update.Arul&apos;s Blog: I&apos;m back again</title>
        }
};
_xmlsa.load ('http://www.shockwave-india.com/blog/example/sample.xml');
    
XMLNode easy access by tatsuo kato
  • Easy to use
  • Pre-Processing required
  • Modifies the XMLNodes by adding new attribute called 'id'
  • Generates new XML object for every result which brakes the hierarchy
Usage Example:-
#include "XMLNodeEasyAccess.as"
//
var _xml:XML = new XML ();
_xml.onLoad = function (done) {
        if (done) {
                //pre-process
                this.tagID();
                //easy access samples
                trace(this.rss.item_0.title.firstChild)
                //Tools.Flash MX: Actionscript Syntax Highlighting with SE|PY Editor v.1.0.5.4
                trace(this.rss.item_1.title)
                //Update.Arul's Blog: I'm back again
        }
};
_xml.load ('http://www.shockwave-india.com/blog/example/sample.xml');
    
XML Shortcuts Component (Yet to be released)
  • Easy to use
  • Dynamically resolves at runtime (So processor load is distributed among requests)
  • Mixed type access is possible
  • No pre processing required
  • Very lite
  • Yet t o be found ;)
Usage Example:-
/*
Simply drag and drop XML Shortcuts component to Library
*/
var _xml:XML = new XML ();
_xml.ignoreWhite=true
//ignoreWhite is defined to help normal access, not needed for shortcut component
_xml.onLoad = function (done) {
        if (done) {
                /*
                normal access
                */
                trace(this.firstChild.firstChild.firstChild.firstChild)
                //Tools.Flash MX: Actionscript Syntax Highlighting with SE|PY Editor v.1.0.5.4
                /*
                shortcut access
                */
                trace (this.rss.item.title.__text);
                //Tools.Flash MX: Actionscript Syntax Highlighting with SE|PY Editor v.1.0.5.4
                /*
                mixed access
                */
                trace (this.rss.firstChild.title.firstChild);
                //Tools.Flash MX: Actionscript Syntax Highlighting with SE|PY Editor v.1.0.5.4
                /*
                access an attribute using _ also accessing the second 'item' using unique id
                */
                trace(this.rss.item_1.guid._isPermaLink)
                //false
                /*
                get all 'item' nodes as an array using $
                */
                var items:Array = this.rss.$item;
                for(var i=0; i<items.length; i++){
                        trace(items[i].category)
                }
                //<category>Flash MX/Tools</category>
                //<category>Arul&apos;s Blog/Update</category>
                //<category>Flash MX/Code</category>
        }
};
_xml.load ('http://www.shockwave-india.com/blog/example/sample.xml');
    
What do you think?
Will XML Shortcuts component be of any use to you?
Express your views in the comments, based on the demand I will release the component

posted by Arul | link |<prev. | ^top | next> | comments [18]
Saturday, June 11, 2005

Update.Arul's Blog: Added a new section - ActionScript2.

To better organize my blog, I've added a new section called actionscript2, all the AS2 class files will be placed here for download.
I will also convert some of my as1 functions into as2 class files and place them here

posted by Arul | link |<prev. | ^top | next> | comments [2]
Wednesday, June 08, 2005

Examples.Flash MX: 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
Tree Before Hiding Text Nodes
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
tree.labelFunction = function (node) {
        return node.nodeType == 1 ? node.nodeName : node.nodeValue;
};
var sample_xml:XML = new XML ();
sample_xml.ignoreWhite = true;
sample_xml.onLoad = function (done) {
        if (done) {
                tree.dataProvider = limitByDepth (this, 2);
        }
};
sample_xml.load ('http://www.shockwave-india.com/blog/example/sample.xml');
//
function limitByDepth (x, limit, depth) {
        if (depth == undefined) {
                depth = 0;
        }
        for (var i = 0; i < x.childNodes.length; i++) {
                if (depth < limit) {
                        if (x.childNodes[i].nodeType == 1) {
                                arguments.callee (x.childNodes[i], limit, depth + 1);
                        }
                } else {
                        if (x._node == undefined) {
                                x._node = x.cloneNode(true);
                        }
                        x.childNodes[i].removeNode ();
                        i--;
                }
        }
        return x;
}

then write the following on the tree
on (change) {
        var n = this.selectedNode._node;
        if (n == undefined) {
                n = '';
        }
        _parent.textArea.text = n;
}

here is the resulting swf :)

Try changing the depth and see the result yourself.

posted by Arul | link |<prev. | ^top | next> | comments [1]
Tuesday, June 07, 2005

Examples.Flash MX: 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
Tree Before Hiding Text Nodes
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
import mx.controls.Tree;
var tree:Tree;
//icon function is added here
tree.labelFunction = function (node) {
        return node.nodeType == 1 ? node.nodeName : node.nodeValue;
};
var sample_xml:XML = new XML ();
sample_xml.ignoreWhite = true;
sample_xml.onLoad = function (done) {
        if (done) {
                tree.dataProvider = hideTextNodes (this);
        }
};
sample_xml.load ('http://www.shockwave-india.com/blog/example/sample.xml');
//
function hideTextNodes (x) {
        for (var i = 0; i < x.childNodes.length; i++) {
                if (x.childNodes[i].nodeType == 1) {
                        arguments.callee (x.childNodes[i]);
                } else {
                        //text node found, hide it as property text
                        x.text == undefined ? x.text = x.childNodes[i].nodeValue : x.text += x.childNodes[i].nodeValue;
                        x.childNodes[i].removeNode ();
                        i--;
                }
        }
        return x;
}

then write the following on the Tree
on (change) {
        var t = this.selectedNode.text;
        if (t == undefined) {
                t = '';
        }
        _parent.textArea.text = t;
}
here is the resulting swf :)

posted by Arul | link |<prev. | ^top | next> | add comment
Monday, June 06, 2005

Tools.Flash MX: 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.
Click to Show in Real Size

You can download the tool from here! [0.9mb]

posted by Arul | link |<prev. | ^top | next> | add comment

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