Go Back   Dynamic Drive Forums > General Coding > Flash
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 02-10-2007, 07:11 PM
danielbento danielbento is offline
Junior Coders
 
Join Date: Jan 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default flash php basics with loadvars

I'm using loadvars to get and retrieve data from flash to php.

I need some help in how can i call php functions from flash normally and with parameters.
Reply With Quote
  #2  
Old 02-10-2007, 08:10 PM
danielbento danielbento is offline
Junior Coders
 
Join Date: Jan 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To be more specific, i would like to know how the comunication works.

I know how flash retrive vars from php, but how php retrive data from flash?

I have this example:

var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
aleatorio.text = result_lv.rand;
} else {
aleatorio.text = "Error connecting to server.";
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.name = input_al.text;
send_lv.sendAndLoad("http://localhost/vinhos/test.php", result_lv, "GET");

I have a button, that when i click, it gets from php a random number. This works fine.

In fllsh i have an input box instance "input_al". If i put a number it sends it to php but it is not working.

In php i'm getting the flash var this way: $_GET['input_al']

This is just an example for me to know how this work.

Can anyone help me?
Reply With Quote
  #3  
Old 02-10-2007, 09:09 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,158
Thanks: 1
Thanked 62 Times in 62 Posts
Default

Check Out what it won't work with

And then follow this tutorial for how it is done with php files

Hope it helps!
Reply With Quote
  #4  
Old 02-10-2007, 09:46 PM
danielbento danielbento is offline
Junior Coders
 
Join Date: Jan 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Has i see there is no problem in my case. The output is a standalone player, and it wont play in a browser. The operating system is a MAC OSX 10.4, which is not refered in the "won't work" list.

I've tryed just doing it only with php and it worked. The problem is how php receive the vars from flash.

I've tryed this ways:
the object of Loadvars calls send_lv and the var i want to send calls input_aleatorio.
I have:
send_lv.input_aleatorio = 5;
send_lv.sendAndLoad("http://localhost/vinhos/test.php", result_lv, "POST");


In php i tryed:
$tab = $HTTP_POST_VARS['input_aleatorio'];
$tab = $_POST['input_aleatorio'];

None of this worked
Reply With Quote
  #5  
Old 02-10-2007, 09:48 PM
danielbento danielbento is offline
Junior Coders
 
Join Date: Jan 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's working with this:

$tab = $_POST['input_aleatorio'];

Thanks
Reply With Quote
  #6  
Old 02-10-2007, 10:00 PM
danielbento danielbento is offline
Junior Coders
 
Join Date: Jan 2007
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i have another question. How can i call a php function from flash?

For example:


i have in php

function some_name(){
echo "success";
}

What should i have i flash? And if i want to send arguments from flash to php function?

I haven't found yet an example for this and it is very important.
Reply With Quote
  #7  
Old 02-11-2007, 03:20 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,158
Thanks: 1
Thanked 62 Times in 62 Posts
Default

You can try with the $_GET var inside flash with all references pointing to the file in question.

You can also try variations of the load() vars or encapsulate the sting in it's own page using <?php include(); ?> and call that page...

Not sure exactly wqhat you are after though.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Forum Jump


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

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.