View Full Version : Flash Remoting for Flash MX 2004 Problems
andremedeiros
11-09-2004, 11:53 AM
I'm trying to install Flash Remoting, but I'm not having success. I've downloaded the AS 2.0 components and the source code, as described on Macromedia's website, but when I try to run the examples I found on the web, they won't work.
import mx.remoting.*; throws an error and #include "NetServices.as" says file not found.
Are there any tweaks or something I must do? I have the files, I can see them, and I tried adding the directories to the AS 2.0 Path on the preferences dialog, and still no luck...
Ideas anyone?
Thanks in advance,
André Medeiros
whiterabbit
11-16-2004, 09:53 PM
Im having the same problem. I think its because I am using 2004 and the names of the classes have changed as well as the syntax.
In your Flash menu navigate to Windows/Other Panels/Common Libraries/Remoting and you will see the classes.
I Tried import instead of include but still was not working. Would sure like to see a tutorial on AMFPHP updated for 2004
maular
12-06-2004, 04:57 AM
The simplest solution is just to install the Flash Remoting Components for Actionscript 1.0 (if that's what you are familiar with), and the tutorial will work fine.
These are available for download from the same Macromedia page (http://www.macromedia.com/software/flashremoting/downloads/components/).
edit: and looking a couple of posts down, olioskar has given the link http://www.flashant.org/index.php?p=66&c=1 which says you need to drag a Remoting component to your movie before that'll work, or download the remoting components source from the macromedia link above.
hobbis
04-06-2005, 04:36 PM
Did anyone ever figure this out? I have just downloaded the AS 2.0 version which I would prefer to use and nothing works. I have installed the AS 2.0 components too. I guess I need to import the files instead of #include but documentation is scarce.
snapple
04-06-2005, 05:05 PM
Don't bother...use version 1 components.
Regards, snapple
hobbis
04-07-2005, 09:05 AM
Thanks Snapple. Could you tell me why you think I should stick to AS 1.0? I must admit, I've got it working in this version (AS1.0) which is a relief but I want to go down the AS 2.0 route. It seems when you install the latest components, it does not put anything in the include folder, so most examples using amfphp will fail.
snapple
04-07-2005, 09:08 AM
When you say "go down the AS 2.0" route, do you mean, the actionscript inside your fla? Because you can still write strictly typed actionscript using version 1 components. Your absolutely right about version 2.0 components not installing the relavent classes. Don't ask me why...i don't know much about remoting.
Regards, snapple :)
hobbis
04-07-2005, 10:05 AM
Ok, this is what I've discovered so far - forget the components, generally I avoid them like the plague anyway. Downloaded the classes source code and put them in the right places:
http://www.macromedia.com/software/flashremoting/downloads/components/
At this time the file is called: flashremoting_comp_sourcecode.zip
I have just installed an AS 2.0 HelloWorld and AMFPHP example and it works...
so far so good. Next stage database stuff. I reckon I'll be going nuts later today but I'll keep at it. Cheers.
hobbis
04-08-2005, 12:28 PM
For the benefit of the newcomers to Flash Remoting and AS2.0. I have written an example on how to create an AS2.0 version of a MySQL connection/RecordSet implementation:
the PHP:
class GrabData {
var $dbhost = "localhost";
var $dbname = "databasename";
var $dbuser = "generic_webuser";
var $dbpass = "generic_webuser";
function GrabData() {
$this->methodTable = array(
"getFLV" => array(
"description" => "Returns recordset",
"access" => "remote",
"arguments" => array ("arg1")
)
);
// Initialize db connection
$this->conn = mysql_pconnect($this->dbhost, $this->dbuser, $this->dbpass);
mysql_select_db ($this->dbname);
}
function getFLV($id) {
return mysql_query("SELECT * FROM flvs WHERE id=" . $id);
}
}
The ActionScript:
/*
* You can just use:
* import mx.remoting.*
* import mx.remoting.rpc.*
* but I prefer to explicitly refer to classes needed
* */
import mx.remoting.Service;
import mx.remoting.RecordSet;
import mx.services.Log;
import mx.remoting.PendingCall;;
import mx.rpc.RelayResponder;
import mx.rpc.FaultEvent;
import mx.rpc.ResultEvent;
import mx.remoting.debug.NetDebug;
class webvu.cms.remoting.GrabData
{
private var myService:Service
private var show:TextField
private var timeline:MovieClip //reference to the timeline
private var init:Boolean
private var myLogger:Log
//Constructor
public function GrabData(timeline){
NetDebug.initialize()
myLogger = new Log(Log.DEBUG, "logger1");
myService = new Service("http://yourUurlHere/cms/website/gateway.php", myLogger,"GrabData",null,null);
this.timeline = timeline
}
//Public methods
public function getFLV(id:Number):Void {
var pc:PendingCall = myService.getFLV(id)
pc.responder = new RelayResponder(this, "getFLV_onResult", "getFLV_onFault" );
}
//Private methods
private function getFLV_onResult(res:ResultEvent):Void{
NetDebug.trace( { level: "debug", message: "There's a result: "})
timeline.show.text = res.result.getLength() + " " + res.result.items[0].file;
}
private function getFLV_onFault(e:FaultEvent):Void{
NetDebug.trace( { level: "debug", message: "There was a problem: " + e.fault.faultstring})
}
}
for this test I had a very simple database with one table and two columns set up:
Columns: 'id' and 'file'
I realise most of you here will see this as basic stuff but when I started remoting in AS2.0, I couldn't find anything like this.
Hope this helps somebody!
johnw
05-12-2005, 09:59 AM
To use the AS2.0 version you need to do (once you have installed the remoting AS 2.0 components):
Window Menu > Other Panels > Common Libraries > Remoting
Then drag the RemotingClasses on the stage of your movie. You can delete it off the stage and it will stay in your library.
The RemotingDebugClasses is for debugging during testing. You may want to remove this from your library when you go to production to reduce the file size.
Hope that helps!
pavanathreya12
05-17-2005, 06:54 AM
Can we use Threads in Flash AS 2.0, if it is possible, please tell me How to use.
maglez
06-17-2005, 03:22 PM
I was using Macromedia code and I run in the same problem, #include "NetServices.as" throw an error while import NetServices doesn't.
The code I copied from Macromedia PDF Remoting manual is like...
//imports the NetServices ActionScript file
#include "NetServices.as"
//if statement creates the connection to the remote service and creates a service object
if (inited == null)
{
inited = true;
NetServices.setDefaultGatewayURL("gatewayURL");
serviceConnection = NetServices.createGatewayConnection();
serviceObject = serviceConnection.getService("serviceName", this);
}
//function executes when the user clicks the button
function button_Clicked()
{
//service function call to the remote service
serviceObject.serviceFunctionName();
}
//if the service function is successful, the _Result function of the same name
executes
function serviceFunctionName_Result(result)
{
messageDisplay.text = result;
}
//if the service function is unsuccessful, the _Status function of the same name executes
function serviceFunctionName_Status(result)
{
messageDisplay.text = error.description;
}
The problem is that the class NetServices haven't a method called "setDefaultGatewayURL" but "setDefaultGatewayUrl", notice the low case for the last two characters.
I hope it helps.
frdmsun
10-08-2005, 08:11 PM
I uploaded a free download that uses AMFPHP to pull data from a mambo database. It recreates the menu in Flash. You can see an example and download here:
http://www.flashblocks.com/index.php?option=com_remository&Itemid=79
for smaller projects I use Flashblocks CMS. It does not use a database so its simple to setup and backup.
pdoloi
06-06-2007, 10:14 PM
the remoting service problem was solved only by installing the remoting software. Thnks dude
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.