Flash sendandload – XML

I am using Flash 8. this is the only thing you need if you need to follow this example 

 On the flash IDE – stage need to have a Button Component (button name – submit_button)  and Dynamic text with (result_ta)
If you want to send xml data from flash to your dynamic page,

you know the syntax – send("url","POST/GET")

if you want to load an XML data from a url you still know the syntax load("URL"); 

well how about sending an XML data to a server page and receiving the same as XML. Yes you are right it is sendAndLoad("URL", receiving Object, "GET/POST");

All of the above you can find in flash HELP, but there is a tricky part which has been left out.  

Let me place the Actionscript first and then the PHP serverside script and explain in detail.

ActionScript:

var submitListener:Object = new Object();
submitListener.click = function(evt:Object) {
    var result_lv:LoadVars = new LoadVars();
    result_lv.onLoad = function(success:Boolean) {
        if (success) {
            result_ta.text = result_lv.welcomeMessage;

        } else {
            result_ta.text = "Error connecting to server.";
        }
    };

    var result_xml:XML = new XML();
    result_xml.ignoreWhite = true;
    result_xml.onLoad = function(s){
        if(s){
            result_ta.text = this.firstChild;
        }else{
            result_ta.text = "Error connecting to server.";
        }
    }

    var send_lv:LoadVars = new LoadVars();
    var xm:XML = new XML("<root><name>vinod</name></root>");
    xm.ignoreWhite = true;
    xm.contentType = "text/xml";
    send_lv.xm = xm;
    send_lv.sendAndLoad("http://vinodvv/test/sendandloadxml.php&quot;, result_lv, "GET");
    send_lv.sendAndLoad("http://vinodvv/test/sendandloadxml.php&quot;, result_xml, "GET");
};
submit_button.addEventListener("click", submitListener);

PHP Script:

 <?PHP
$xml = $_GET['xm'];
echo $xml;
?>

Ok let us discuss the flash help, type the keyword "sendAndLoad" and select the same in your flash IDE and press F1, well you will read the above pasted Actionscript with few lines of code which I have added extra. 

point 1 to remember if your server page doesn't recognise the data what you are sending

xm.contentType = "text/xml";

This is the reason, the data what you send is of string type you need to specify as xml type.

Point 2 to remember server side page just responds to your command and sends you the XML data, but the XML data on the flash side becomes irrelevant as it needs a parameter to accept data as string in the flash example. 

result_lv.welcomeMessage; 

 welcomeMessage=XML should be the way you serverpage need to write data, but this is absurd, and this is nothing but string type and not XML, you will have create a new XML object to embrace this string to an XML typ, so Avoid this and try this one.

I am using the same way you load the normal XML data from a URL, all you have to do is define a new XML variable and declare most of the commands

var result_xml:XML = new XML();
    result_xml.ignoreWhite = true;
    result_xml.onLoad = function(s){
        if(s){
            result_ta.text = this.firstChild;
        }else{
            result_ta.text = "Error connecting to server.";
        }
    }

and don't specify the command result_xml.load("url") instead specify it over here

send_lv.sendAndLoad("http://vinodvv/test/sendandloadxml.php&quot;,

This should do the job. try it yourself, if you find any other better approach do make a comment. 

Lego Toys

Mathematical Lego Sculptures

I had talked about lego in my company blog the one I am going to talk about is “Mathematical Lego Sculptures” Andrew Lipson has done few logo of different companies using lego structures. You can even find more links from his site to the Gurus of LEGO, If you a LEGO fan don’t miss this site.

Mathematical Lego Sculptures

More resource on LEGO can be found here at pogotv fan club

Update: A new post on LEGO can be found here

Angel Fashion Jewellers

I had been to Thrissur – Kerala, India (Gods Own Country) my native town, while I was travelling in Bus I happened to see a banner hoarding of this Jewellery, When you this image from a distance it is not that great neigther not amusing. Let me capture the exact scene on how I saw the hoarding. 

I was on left side Aisle and looking at the amazing greenery of my native place, the bus took a sharp turn and all I could see is this girl with this expression "State of Shock" it got captured in my mind. Nicely done ad, but not sure whether it was to captivate the minds of viewers when travelling on the bus. 

Angel - Click on the image to view a larger version