Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-26-2003, 03:13 PM   #1
stealthelephant
The Thread Collector
 
Join Date: May 2003
Location: the far side
Posts: 1,409
Send a message via AIM to stealthelephant Send a message via MSN to stealthelephant
Default passing arrays back to flash

i am currently sending a string back to flash and parsing out the data in it using actionscript. Is there any way to pass the array back and obtaining an array variable in flash?
currently this is what im doing

[PHP]
echo "&returnvars=";
for($i = 0; $i < $length; $i++)
{
echo $returnvars[$i];
echo " ";
}
i want to just be able to return $returnvars and have flash use the array. cause the way im doing it now, flash has to a lot of extra work just to reformat the values and it seems like its kinda stupid doing it like this......
stealthelephant is offline   Reply With Quote
Old 05-26-2003, 05:47 PM   #2
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Not natively, since data types are different in flash than they are in PHP. But using something like amfphp, its very easy.

http://amfphp.sourceforge.net


You can use other things like WDDX, but there is overhead involved with all of them.
freddycodes is offline   Reply With Quote
Old 05-26-2003, 06:18 PM   #3
stealthelephant
The Thread Collector
 
Join Date: May 2003
Location: the far side
Posts: 1,409
Send a message via AIM to stealthelephant Send a message via MSN to stealthelephant
Default

great stuff, thanx
stealthelephant is offline   Reply With Quote
Old 05-27-2003, 12:06 PM   #4
stealthelephant
The Thread Collector
 
Join Date: May 2003
Location: the far side
Posts: 1,409
Send a message via AIM to stealthelephant Send a message via MSN to stealthelephant
Question flash remoting package!

downloaded the docs for afmphp. It says that i need flash remoting packages installed, but this costs 1k so i assume that downloading the components will do the trick?
the amfphp docs also state that they arent sure if afmphp is legal any toughts on that anyone?

Last edited by stealthelephant; 05-27-2003 at 12:13 PM.
stealthelephant is offline   Reply With Quote
Old 05-27-2003, 12:18 PM   #5
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

I think you need this one...
http://www.macromedia.com/software/f...ds/components/

__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-27-2003, 04:06 PM   #6
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Yep like CyanBlue said, those components are a free download. As far as the legality issues go, I had the same concern, however Macromedia has yet to comment on the legal issues of this product. If you are concerned you could try PHPObject, there is a tutorial o nthat one in the tutorials section of this site. I myself and not too worried since its been out for some time now and MM has not said they have a problem with it. They claim that amfphp does a fraction of what the 1K version they have does, which is probably true, if you care about ColdFusion and .NET interaction. But for just getting data in and out of flash it does the trick.
freddycodes is offline   Reply With Quote
Old 05-27-2003, 10:27 PM   #7
stealthelephant
The Thread Collector
 
Join Date: May 2003
Location: the far side
Posts: 1,409
Send a message via AIM to stealthelephant Send a message via MSN to stealthelephant
Cool

probably, but it seems to me that loadvars could become legacy pretty quickly (unless used for tiny transfers....)
although i think i will try and solve the problem with both versions - my actionscript could use the practice
stealthelephant is offline   Reply With Quote
Old 05-27-2003, 10:29 PM   #8
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Yes LoadVars can be used for quite a bit including loading in recordsets, its just a whole lot easier to hook existing PHP classes up to flash with remoting.
freddycodes is offline   Reply With Quote
Old 05-29-2003, 09:16 PM   #9
deadlydentures
Registered User
 
Join Date: May 2003
Posts: 15
Send a message via ICQ to deadlydentures
Default

Hey, i was finally able to upload arrays without anything extra!!

ActionScript Code:
status = "Logging in" ; forum = function(id, name) {     this.id = id ;     this.name = name ; } forums = new Array() ; f_php = new LoadVars() ; f_php.load("http://localhost/board/viewboard.php?username=Clinton&password=*****") ; f_php.onLoad = function(success) {     if( success )     {         i=0 ;         offset = 0 ;         for( var temp in f_php )         {             switch( offset )             {                 case 0 :                 tmp_name = f_php[temp] ;                 offset ++ ;                 break ;                             case 1 :                 forums[i] = new forum( f_php[temp], tmp_name ) ;                 offset = 0 ;                 i++ ;             }         }             }     else {         status="NOOOOO!!!" ;     } }

It uses the for...in loop, and while it returns it somewhat backwards, i easily worked around it. What do you guys think?
It works perfectly, and i can upload any amount or complexity of data i want!
deadlydentures is offline   Reply With Quote
Old 05-29-2003, 09:23 PM   #10
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

That is just one of many many ways to upload complex data types from PHP to Flash. Again, whatever works for you is fine, whether it be LoadVars(), XML, AMF. Whatever suits your fancy.

The advantage to remoting is the automatic conversion of native data types form one platform to another.
freddycodes 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Associative arrays Mortimer Jazz ActionScript 2.0 23 05-12-2004 05:11 AM


All times are GMT. The time now is 10:31 AM.

///
Follow actionscriptorg on Twitter

 


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