Passing variables from PHP to Flash

This is a discussion on "Passing variables from PHP to Flash" within the Flash & Multimedia Forum section. This forum, and the thread "Passing variables from PHP to Flash are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 25th, 2007, 20:41
Reputable Member
Join Date: Jan 2004
Location: California
Age: 19
Posts: 232
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via AIM to tox0tes
Passing variables from PHP to Flash

Why doesn't this work?

Code in actionscript:
Code: Select all
loadVars.load("upload.php");
_root.imagePane._x+=width1;
Code in PHP file upload.php:
PHP: Select all

echo "width1=50"
It doesn't do anything, why not? I want it to create a new variable in the flash file called width1 with value of 50, but it seems this does not happen.
Reply With Quote

  #2 (permalink)  
Old Dec 25th, 2007, 22:55
marSoul's Avatar
Moderator
Join Date: Sep 2007
Location: Tehran - Iran
Age: 28
Posts: 411
Blog Entries: 2
Thanks: 3
Thanked 4 Times in 4 Posts
Send a message via MSN to marSoul Send a message via Yahoo to marSoul
Re: Passing variables from PHP to Flash

Its not a correct way to pass a variable to flash
You have 2 ways :

1) using flashvars (more info : http://kb.adobe.com/selfservice/view...6417&sliceId=2)
2) put your variable in the html file file like this :

HTML: Select all
<embed src="movie.swf?variablename=something">
<param name=movie value="movie.swf?variablename=something">
__________________
Designing For Communicating
Website : http://www.datisdesign.com
Weblog : http://blog.datisdesign.com

Last Blog Entry: Throughout IRAN (Dec 10th, 2007)
Reply With Quote
  #3 (permalink)  
Old Dec 26th, 2007, 01:54
Reputable Member
Join Date: Jan 2004
Location: California
Age: 19
Posts: 232
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via AIM to tox0tes
Re: Passing variables from PHP to Flash

the problem is that the user will be on the same HTML page with the same SWF while all this variable passing happens. I cannot use the methods you described because in my situation, where the value of the variable is generated uniquely by the user, i would have to use a PHP page with the value dynamically hardcoded into the HTML as the ?value=whatever or the FLashVars method. But, since PHP is server side, i cannot change the HTML while the user is on the page without refreshing, and that would cause the loss of all the user's color and style selections on the page. remember I am using http://www.momdadsquad.com.

So what I am saying is the variable passing has to happen internally, on the backend without making the user have to go to another page or refresh. Basically, I want the same SWF in the same instance to submit info to a PHP page, PHP to process the info, and then return it to the SWF. I'm sorry it's hard to explain complicated things like this, but thanks for trying to help me.
Reply With Quote
  #4 (permalink)  
Old Dec 29th, 2007, 03:51
New Member
Join Date: Dec 2007
Location: Maryland
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Passing variables from PHP to Flash

I think I understand. You want to process information from a SWF to the database using PHP WITHOUT refreshing the current page. I'm no guru, but you're limiting the options and hoping for more capability that Flash or any web page has to offer.

You can process the information using a secondard PHP page. Have Flash send a request to a new window (_blank) with the information you want to pass. That should be simple. The problem you'll run into is Flash CANNOT do anything with the processing. The page is required to do the processing first and forward it to Flash. If you don't want to refresh the page, then you can't update Flash. Using GET and POST, and FLASHVARS are the only three methods Flash has to receive (send) information. If you don't use then you're come up short.

If you are worried about losing the information the user has selected, have Flash send the information to PHP and store it in a cookie. This way it can be retrieved, process and returned to Flash on a refresh. Sorry I could help ya more.
Reply With Quote
  #5 (permalink)  
Old Dec 29th, 2007, 06:46
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Passing variables from PHP to Flash

You can definitely do this without refreshing the page...;

WIth actionscript you can use the loadVars class

Code: Select all
var loadExternal = new loadVars(); // instantiate

loadExternal.load('file.php'); // load the php file
Now in your PHP file, you need to send the urlencoded string as plain text

PHP: Select all



header
('Content-type: text/plain');

echo 
urlencode('var1=1&var2=2&var3=3'); 
Once loaded the variable "loadExternal" in actionscript will have properties with the loaded variable names..

eg.

loadExternal.var1 will be 1 etc...

This is the easiest way to do it -- loadvariables has been depreciated in actionscript 2.0

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variables values using POST sudhakararaog Web Page Design 2 Mar 18th, 2008 08:12
Passing Flash variables between frames lostnights Flash & Multimedia Forum 0 Jan 22nd, 2007 17:09
Passing variables from Flash to PHP LostProphet Flash & Multimedia Forum 6 Aug 31st, 2006 14:05
passing post variables benbacardi PHP Forum 5 Jul 5th, 2005 22:13
PLEASE HELP - Passing Variables in Querystring just_the_basix Classic ASP 40 Sep 3rd, 2004 10:46


All times are GMT. The time now is 22:46.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43