Advertisement

09.14.2004 at 05:04AM PDT, ID: 21130222
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

passing data / variables between flash and php - beginner - newbie - noob - n00b

Asked by kevindolan in Macromedia Flash

Tags: , , , ,

Please forgive the long-winded post; I wanted to be thorough and not waste anybody's time...

I have been googling for 2 days and I have no hair left.  I am fairly new to programming and love php.  I have done some really cool things with PHP/MySQL relatively easy.  I have been using Flash for a while but not much ActionScripting thus far.

I got this code from the tutorial I am following here:
http://www.kirupa.com/developer/actionscript/flash_php_mysql.htm

the utterly simple AS:

onClipEvent (load) {
  //assuming you have a personal web server and PHP installed locally
  loadVariables("test.php", this, "GET"); <--- note: I changed this from the original. <---
}

the utterly simple php:

<?php
//The value of $x would be printed to the screen but the SWF would not read the data
$x = "abc";
print $x;  <---SHOULD THIS BE REMOVED FROM THE SCRIPT ?

//The value of $x would be printed to the screen and because of the prefix 'myVar=', the SWF will //interpret this as being the intended value for the variable myVar in the SWF
print "myVar=$x";
?>

The second comment in the code above is a lie :)  Flash does not see it 'myVar='.

This tutorial seems to walk you through step by step and I couldn't think of anything easier to start with.  Yet, it does not work for me!  I have tried other tutorials out there (login/authentication) and end up in the same place... a flash text area (dynamic) with NO TEXT!

I think the PHP code is working but under some circumstances, the test.php pops up in a new window and prints "myVar=123" ...as in... <? echo ("myVar=123") ?> (when I modify the code that is)

Relative points...

1. Should my SWF be in the PHP page or in a seperate HTML file?  I have it in an HTML file (index.htm) but I've tried it in both the HTML file and the PHP file.

2. I have seen the code I am trying to use in several scripts <? print "myVar=$x"; ?> except EVERY time I have seen it, it looks like this <? print "&myVar=$x&"; ?> or atleast 1 of the added ampersands.

3. Another thing I tried was to add this parameter to the embeded flash object:
    <param name="allowScriptAccess" value="sameDomain" />

4. Would this extremely basic simple script vary for different versions of Flash/ActionScript?

5.  Should I be using the loadVariables or should it be loadVariablesNum? I've tried both...

6.  If I copy and paste this simple code you would think it WOULD work!  It does not!!!

I have been able to bring text into a Flash dynamic text area from a .txt file easy enough.  I understand the "&" is what Flash uses to seperate elements from the external text.

If I can figure out how to pass vars between Flash and PHP I am on to great things :)

No kidding, I have tried every combination between everything mentioned above.  I have looked everywhere I know of on the web.  I have not been able to find anything to get me started that is as simple as this code ( SHOULD BE )!

I'm desperate (no, really)! This is the first time I have had to post to find the answers I seek!

Please help, thanks in advance, and if I could offer more than 500 points I would!!!

Thanks again,

Kevin

P.S. Some good (Flash/PHP) n00b resources would be greatly appreciated.  Lot's of great PHP resources out there but not too much using the combination, for n00bs anyway :)
Start Free Trial
[+][-]09.14.2004 at 09:04PM PDT, ID: 12061311

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Macromedia Flash
Tags: flash, php, passing, variables, between
Sign Up Now!
Solution Provided By: vickerleung
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09.15.2004 at 02:26PM PDT, ID: 12069910

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.15.2004 at 02:27PM PDT, ID: 12069926

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.15.2004 at 03:07PM PDT, ID: 12070216

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.15.2004 at 08:12PM PDT, ID: 12071636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.15.2004 at 11:34PM PDT, ID: 12072306

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.15.2004 at 11:40PM PDT, ID: 12072330

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32