Welcome, Guest. Please login or register.
Did you miss your activation email?
02/08/12, 08:15
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  Flash Remoting with AMF (Moderators: Flash-db, Musicman, Jorge Solis, papachan, nothingGrinder)
| | |-+  AMF / Flash remoting for PHP (Musicman!)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: 1 [2] 3 4 ... 6 Print
Author Topic: AMF / Flash remoting for PHP (Musicman!)  (Read 123848 times)
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #15 on: 01/12/03, 13:45 »

Hi,

fkash objects become php "named arrays", so yu wpuld have
$property1 = $data['prop1'];

Musicman
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #16 on: 01/13/03, 01:10 »

I put together a sample of using 'amfdata' with web services:

http://www.flash-db.com/Board/index.php?board=19&action=display&threadid=3190&start=0

I don't think it's explained that great - but at least it's a start.

Logged

-Jeff.
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #17 on: 01/13/03, 02:47 »

I noticed that in some of the Flash remoting examples there was a function called:

this.onStatus = function(error)
{
   trace("Error : " + error.description);
}

Would it be possible to add something to 'amfdata.php' which would also handle error messages, such as:
Code:

function sendresult($data)
{   
header('Content-type: application/x-amf');

print "\0\0\0\0\0\1" . $this->sendstr($this->fnseq . "/onResult") .
// ......  Some logic to handle errors....  "/onStatus" .....
$this->sendstr("null") . pack("N", -1) . $this->sendobj($data);
}


To handle error messages.  


I noticed that if I looked at what 'amfdata.php' was returning it looked something like:

    .    /onResult .null˙˙˙˙. - depending on what is being sent back and forth.

Does that make any sense - and could we add in something to handle error messages if we wanted to.  Thanks.
Logged

-Jeff.
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #18 on: 01/13/03, 03:38 »

Hi,

of course the packet format seems to support a lot more, but I do not know what the player can do....
There is that "null" entry which probably  provides more capabilities

As for the onResult - the requests from flash are numbered by the NetConnection class, and the result is sent back with a matching number. Maybe you could put any function name in there, provided there is a matching function defined in your scripts

Apart from that, if you are sending an object back, what about adding an error variable to it - if the service fails completely, there would only be the error value....

Musicman
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #19 on: 01/13/03, 20:42 »

Alessandro over at sephiroth.it recently Posted a New example of this, you can view it at:

http://www.sephiroth.it/index.php

Thanks Alessandro for putting that together.  
Logged

-Jeff.
sephiroth
Server what's that
*
Posts: 6



View Profile Email
« Reply #20 on: 01/14/03, 14:20 »

Thanks for the mail Jeff Wink

I think this class is incredible, I was so excited when I view the onResult working!
The onstatus handler is very useful in remoting, not only for error handling, but for every response...
i try to add it in the php class but again without success..
in flash remoting, once you create the onStatus responder for the listener object, it will be called everytime there's a server response. Not only for errors.

but, if i try to make a nc.call inside a for loop it seems to work only for the first time of the loop..  Huh




anyway, it's a great thing at all
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #21 on: 01/15/03, 02:31 »

Any luck with the onStatus? It would be nice to have.   Musicman any idea?

It's not working in a for loop?  I think this has to do with the time it takes to recieve the response before making the next call - I wonder if there is a way around this.

Code:

nc.call('somefunc', reply, data); // pass one of more data items - arbitrary objects
   // note that this sends data to server via http and calls the result func when done
   // no permanent connection but some precautions so that results from multiple calls
   // do not mix up


I think this has to do with the 'multiple call mix up'.  Is there someway to avoid this - with some type of locking or ordering of the requests?  I'm really not sure on this one.




Yeah this has to be one of the most amazing php scripts I've seen.  

I wish I understood Binary!

Logged

-Jeff.
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #22 on: 01/15/03, 04:26 »

Hi Jeff,

did you try the other script I mailed you? You will notice that requests from your movie will have /1, /2 etc  as part of the message, and the responses come back as /1/onResult etc.
I am not sure what this is good for, because normally http connections do not mix up ... maybethe same thing can work via a permanent socket connection, and the server is allowed to send responses out of order

Musicman
Logged
Beat Takeshi
Server what's that
*
Posts: 5



View Profile Email
« Reply #23 on: 01/15/03, 05:06 »

Hello there!

ok, this sounds very interesting to me. I´m a newbie in flash remoting but to sum it up quickly the way I got it:
call serverside php function from flash, receive return values,  without worrying about data formats.
Sounds great!

But could someone explain to the pros and cons of this class compared to the NKConnect PHP Connector  (http://nuthing.com/flashconnect/).
As far as I understood both classes do the same thing, except that AMF converts the data to a binary macromedia format and NKConnect does this using wddx.
I used NKConnect in a project once and thought it was quite nice. Any disadvantages compared to this AMF class? Didn´t find a discussion about the NKConnector yet, so I would really like to hear your opinion about NKConnector.

Thanks a lot,
Beat
Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #24 on: 01/15/03, 05:52 »

Hi,

Macromedia make much ado about the advantages of the amf format on their site
The ones I can see: using a builtin function, you do not have to add code to the movie - smaller files
using a binary format, you avoid numeric conversion errors
If you are loading much data, there may be a real time savings in getting binary across the link. On this particular subject: I have built another method that uses binary from the server to the client only. In a particular project of mine, this method saves quite an amount of data versus the amf method

Musicman
Logged
justin
Server what's that
*
Posts: 6



View Profile Email
« Reply #25 on: 01/15/03, 11:33 »

I haven't seen any updates to the code, but I'm pretty confident I can add dates, xml, ... to the de/serialization of the data.  I'll post back any updates that I come up with.  This is excellent.
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #26 on: 01/15/03, 20:14 »

Hi Justin,
Yes - definitly post back if you come up with any updates or interesting use's.  Passing native Date Objects between Flash and PHP would be really useful.  

Musicman - will the script handle dates correctly as it is now?  I havn't tried yet.
Logged

-Jeff.
frank otoole
Server what's that
*
Posts: 2



View Profile Email
« Reply #27 on: 01/15/03, 20:21 »

Hi,

Start off by saying, the contributors on this site really seem to know there stuff, and special cheers to musicman as this AMF thing looks brilliant, the thought of transferring all data as text then convert  was daunting to say the least. Cheers. back to the point

 just started learning flash yesterday, jumping right in at the deep end I think, I know php fairly well, and am looking into converting a HTML/php/mysql project into flash.  I've managed to get return some data back from the database using the AMF.

On further testing scalability I run into a problem, out of 2890 rows in the database only 137 arrive back at flash.  Php code is fine, testing using echo '' etc, even if I change the where clause in the database query.

select name_id, name from pnames; 2890 rows
select name_id, name from pnames where name_id > 200; 2690 rows

both statements I only get 137 rows back

I believe this to be the case when I run


myarray = result;
_root.myresult="found "+myarray.length+"strings";

Any idea's, I know info is a bit vague, but will supply more info if anyone would like to help further, I can also see in my apache log that it appears that only 137 records were passed back to flash, so it would point to be a problem in the php layer

Cheers

Frank


Frame data, pos 1, has the reply.onResult etc
« Last Edit: 01/15/03, 20:34 by frank otoole » Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #28 on: 01/15/03, 20:41 »

Hi,

@frank otoole: I have not tried a big dataset yet, but I am successfully transferring 3000 rows of data using the swfdata method.
Do you hve an url to that movie of yours?

@Jeff: there are two more known data types which could be added - a dte object which is a unix timestamp plus some encoding of the time zone (this would be useful if you want to tell the server your local timezone)
- registered class where the class name is sent along with the other data. Now, these only seem to make sense if the class definition exists on the server as well ... it would be equivalent toa php object (which also knows its type). Now, since your php code may use objects that do not correspond to named classes in flash, how would you choose which objects should be transmitted in that format?

Musicman
Logged
frank otoole
Server what's that
*
Posts: 2



View Profile Email
« Reply #29 on: 01/15/03, 20:52 »

thanks for the quick reply musicman, I've found the problem, a typo on my point, I'll let you know how the large datasets come out.
Logged
Pages: 1 [2] 3 4 ... 6 Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!