Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Supporting Technologies > Flash Remoting

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-12-2003, 06:12 PM   #1
butterbur
Barman
 
butterbur's Avatar
 
Join Date: Aug 2002
Location: UK (the shires)
Posts: 113
Send a message via ICQ to butterbur
Default Sorry....

I saw a virgin topic and just had to go for it.
Could someone please give a simple explination of what flash remoting could be used for.
Ta.
butterbur is offline   Reply With Quote
Old 03-12-2003, 06:45 PM   #2
Prozail
Registered User
 
Join Date: Mar 2003
Posts: 6
Default

I quote Macromedia (from their website):

"Macromedia Flash Remoting MX provides the connection between Macromedia Flash and your web application server, making it fast and easy to create Rich Internet Applications. With its powerful yet simple programming model, you can easily integrate rich Macromedia Flash content with applications built using Macromedia ColdFusion MX, Microsoft .NET, Java, and SOAP-based web services."

I havn't been able to try it out yet.. downloaded the demo today, as i will prob. be involved in a project that require it....

reading manual now.....



/Prozail
Prozail is offline   Reply With Quote
Old 03-12-2003, 07:22 PM   #3
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Tons of things

Here is an example
http://www.irq11.com/~louie/webService/irecipe.html

A PHP class lives on the server. Its function is to query a recipe database via a web service sitting in some other location. Remoting allows me to pass data to PHP and have the data type automatically converted to a PHP data type, run the functions on the server and pass back the data automatically ocnverting it from PHP data types back to Flash data types. All with about 5 lines of code in flash.
freddycodes is offline   Reply With Quote
Old 03-12-2003, 08:29 PM   #4
butterbur
Barman
 
butterbur's Avatar
 
Join Date: Aug 2002
Location: UK (the shires)
Posts: 113
Send a message via ICQ to butterbur
Default

I'm sorry to be dense but what is the difference between what you're describing and using sendAndLoad().
If this is a case of just go and read www.whatever then please say.
Thanks for taking the time, I'm keen but somewhat mentally challenged
butterbur is offline   Reply With Quote
Old 03-12-2003, 08:44 PM   #5
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

The difference is with sendAndLoad the PHP is responsible for getting the data from Flash figuring out what to do with it and doing it then getting the response into some format flash can understand and sending back. On the other flash must figure out what to do with it and create a flash data type to store the result. With remoting you can call the functions in the php class if you were in PHP passing the arguments. I guess I am having a hard time putting this into terms you can understand. Does what is below make more sense?

The PHP
PHP Code:
<?php

class people extends PHPRemoting
{
    function 
people() {
        
$this->db mysql_connect(DBHOST,DBUSER,DBPASS);
        
mysql_select_db(DBNAME);
        
$this->PHPRemoting(); 
    }

    function 
getPersonById($id) {
        return 
mysql_query("SELECT * from test WHERE id = ".$id);
    }    
    
    function 
getCityList()
    {
        
$sql "SELECT DISTINCT City from test ORDER by City";
        return 
mysql_query($sql);
    }
    function 
updatePerson($obj)
    {
        
$sql "UPDATE test set ";
        
$a = array();
        foreach(
$obj as $key => $val) {
            if (
$key != 'id' && $key != '__ID__') {
                
$a[] = "$key = '".addslashes($val)."'";
            }
        }
        
$sql .= implode(","$a);
        
$sql .= " WHERE id = ".$obj['id'];
        
$q mysql_query($sql);
        if(
mysql_affected_rows()) 
        {
            return 
"Record updated successfully";
        
        }
        else 
        {
            return 
"Error updating record";
        }
    }
    
    function 
getPeopleByCity($City$fields) {
        
$sql "SELECT ";
        if(!
is_array($fields)) {
            
$sql .= "*";
        }
        else {
            
$sql .= implode(","$fields);
        }
        
$sql .=  " from test WHERE City = '".$City['City']."'";
        return 
mysql_query($sql);
    }

}
?>
The Actionscript

ActionScript Code:
<?php class people extends PHPRemoting {     function people() {         $this->db = mysql_connect(DBHOST,DBUSER,DBPASS);         mysql_select_db(DBNAME);         $this->PHPRemoting();     }     function getPersonById($id) {         return mysql_query("SELECT * from test WHERE id = ".$id);     }            function getCityList()     {         $sql = "SELECT DISTINCT City from test ORDER by City";         return mysql_query($sql);     }     function updatePerson($obj)     {         $sql = "UPDATE test set ";         $a = array();         foreach($obj as $key => $val) {             if ($key != 'id' && $key != '__ID__') {                 $a[] = "$key = '".addslashes($val)."'";             }         }         $sql .= implode(",", $a);         $sql .= " WHERE id = ".$obj['id'];         $q = mysql_query($sql);         if(mysql_affected_rows())         {             return "Record updated successfully";                 }         else         {             return "Error updating record";         }     }         function getPeopleByCity($City, $fields) {         $sql = "SELECT ";         if(!is_array($fields)) {             $sql .= "*";         }         else {             $sql .= implode(",", $fields);         }         $sql .=  " from test WHERE City = '".$City['City']."'";         return mysql_query($sql);     } } ?>
freddycodes is offline   Reply With Quote
Old 03-12-2003, 09:02 PM   #6
butterbur
Barman
 
butterbur's Avatar
 
Join Date: Aug 2002
Location: UK (the shires)
Posts: 113
Send a message via ICQ to butterbur
Default

Dear freddycodes,
I think I'm beginning to see a chink of light however I would like to see the actionscript. Sorry but I think you pasted the same bit.
If the light bulb does go on then you will have done your good deed for the day
butterbur is offline   Reply With Quote
Old 03-12-2003, 09:20 PM   #7
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Right sorry

ActionScript Code:
#include "NetServices.as" #include "NetDebug.as" #include "DataGlue.as" init = false; if(defaultGateway == undefined) defaultGateway = "http://freddy/amf/freddyServer.php"; function connect() {     if(init == false) {         init = true;         NetServices.setDefaultGatewayURL(defaultGateway);         conn = NetServices.createGatewayConnection();         myservice = conn.getService("people", this);         loadCities();     } } connect(); function loadCities() {     myservice.getCityList(); }
freddycodes is offline   Reply With Quote
Old 03-13-2003, 01:30 AM   #8
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

Freddy man, quit bursting my bubble! My tutorial isn't even out yet and you're outdoing it!
From my upcoming tute:
Quote:
What is Flash Remoting?
Flash Remoting is a Flash MX specific feature which allows you to execute Remote Procedural Calls (RPCs) via Flash MX and transfer serialized, type-persistent objects directly between the server and a Flash MX client.
In more simple terms, Flash Remoting allows your Flash MX movie to exchanged typed data directly with a server-side language, allowing for increased and more easy integration between the front-end and backend of your site. For example, you can send an array from your server-side language into Flash as an array, instead of as an XML object or a String representing an array (which you process within Flash to turn it back into an actual, Flash readable array).
The major use for Flash Remoting is in creating Rich Internet Applications (RIAs). In other words, using Flash not just as an animation tool, or even a jazzy HTML interface, but as the GUI and Client for a full-scale, service providing, Internet application.

What Flash MX Remoting isn’t.
Flash MX Remoting is not the same as Flash Communication server, which is also receiving a lot of attention now (February, 2003). Communication Server is the new Flash technology which allows for video and audio streaming and recording, Server Side ActionScript, Remote Shared Objects and “Data Push”, among other things. Both Flash MX Remoting and Flash Communication Server are going to go a long way to making Flash an even more dominant player in the market than it already is, but it’s important not to get the two confused.

What is PHP Remoting?
Macromedia designed Flash MX Remoting as a direct link between Flash MX and Cold Fusion MX. The protocol used in Flash MX Remoting is called ActionScript Message Format (AMF) and is (at the time of writing) a proprietary format (non open-source). After the release of Flash MX Remoting (for Cold Fusion) certain open-source developers who favored PHP as their server-side language of choice over Cold Fusion, decided to investigate the binary AMF format and create their own Gateway (or ‘translator’) so that Flash MX Remoting could be integrated with PHP in a similar manner to Cold Fusion. The result is the AMFPHP project. A PERL implementation is also available (http://www.simonf.com/flap/) based on the PHP project.

Why use Remoting?
Remoting will drastically reduce the amount of work you have to do when exchanging large volumes of data between Flash and a server because it allows for direct exchange of Objects; meaning you don’t have to break down delimited strings or pass lengthy XML.
Further, the AMF format used in Remoting is binary, so it is considerably less verbose than XML and XML-based methods such as WDDX serialization. That is not to say that XML isn’t great – keep in mind that a binary AMF file, unlike an XML file, is not at all human-readable; one of the key pros for using XML.
And yes, it's going to be a LONG tutorial. It's about 5,000 words already and not yet finished
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder
Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.

Last edited by Jesse; 03-13-2003 at 01:32 AM..
Jesse is offline   Reply With Quote
Old 03-13-2003, 03:14 AM   #9
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Come one now , thats everything I wanted to say but couldn't translate into words from my over-stressed code-filled brain.
freddycodes is offline   Reply With Quote
Old 03-21-2003, 11:17 AM   #10
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

Further to this and subject to some adaptation which will doubltessly be needed to improve it, my PHP Remoting tutorial is now online via http://www.actionscript.org/tutorial...ng/index.shtml

Enjoy!
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder
Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:01 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.