Reply to Re: sending flash variable to php file

Your name:

Reply:


Posted by Daedalus.OS on 06/08/05 02:38

[NOTICE: It's a pretty long post]
Basically LoadVars can achieve the same things as getURL in your case, but
as you might notice getURL is far more simple than LoadVars. It's perfect
when you're want to use GET method, you have few variables to send, and you
want it to link to URL (not execute the script behind the scene). On the
other hand LoadVars can accomplish more than getURL. Lets see how LoadVars
works.
LoadVars is an ActionScript Class for data transfert between a flash
application and a server (via a php script for exemple).

var objName:LoadVars = new LoadVars();
This create a LoadVars object named objName. This object now contains the
methods, handlers and properties defined in the class.

objName.field1 = "first";
objName.field2 = "second";

These 2 lines declares two custom properties. These properties we add are in
fact the key/value pair flash will be sending to the server. In this case
flash will build something like this: field1=first&field2=second. Basicaly
the name of the property is the key and the content of the property is the
value.

Now we can send, Load or both send and load data from a server.

objName.send('http://www.domain.com/script.php');

This one will only send the data (with post method by default I think),
discarding the result. So this is done by the flash application and unless
you specify otherwise, the viewer doesn't even know that it's done.
Anyway you can use it to achieve the same result as a getURL by specifying
some optional parameters:

objName.send('http://www.domain.com/script.php', '_self','GET' );
Now we're specifying to use GET method and since we precise a target window
in wich to send the result (_self=replace the current window), it will be no
more transparent and will act the same way as getURL would do.

But LoadVars have more features. First as I already said, it can
transparently execute a script on a server. (increment an invisible counter
for exemple). But it can also retrieve data from a script or both send and
receive at the same time.

objName.load('http://www.domain.com/price_list.php');

or

objOut:LoadVars = new LoadVars();
objIn:LoadVars = new LoadVars();
objOut1.productID = "5332004";
objOut.sendAndLoad('http://www.domain.com/product_list.php', objIn, 'GET');

Basically it send the the data of objOut to
'http://www.domain.com/product_list.php' as GET, and take the result back in
objIn. The result should be a a url-like string, for exemple:
productID=5332004&price=99.99&description=Pretty funny
These key/value pair will then be available in flash as properties of the
objIn object.


That's it. For more information I suggest you post on a flash newsgroup:
macromedia.flash and/or macromedia.flash.actionscript

Dae


"WhiteJediGuy" <Blader18x2005@cox.net> wrote in message
news:cdnpe.3328$7s.537@fed1read01...
> If you want to explain what it is, I would be much appreciative. As much
> as I can learn, the better. Thanks Greatly!
>
> I yet to still test out the code given last.. Thanks again though..
>
>>> would the format be something like this?
>>> var q:LoadVars = new LoadVars();
>>> q.search = search;
>>> q.send('http://catalog.playersmusic.com/catalog/search.php');
>>>
>>> Thanks again. Hope I didnt put too much this time!
>>>
>>
>> No it wouldn't. I can explain it if want (even if it's not what you
>> need).
>>
>> Dae
>>
>>
>>
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация