473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to get vars from PHP into Flash

Hey there guys,
After some research into PHP and Actionscript, I think I have come close to doing what I want to do. Except now I'm stuck.

Here is what I have in my header.php file:

<?php
$c_page = $_SERVER['PHP_SELF'];
$c_page = basename($c_page, ".php");
?>

So I have the current file name of the php page stored in a variable called $c_page. Right?

I want to pass it on to a single Flash file, which looks like this:

<object align="middle">
<param name="quality" value="high" />
<param name="movie" value="swf/index.swf?<? echo "cPage=$c_page"; ?>" />
<embed src="swf/index.swf?<? echo "cPage=$c_page"; ?>" quality="high" width="780" height="440" align="middle"></embed>
</object>

Now I want to dynamically load a different background image depending on which page the swf file is in.

But when I add this:

_root.bgHostAnim_MC.bgHost_MC.loadMovie('../images/'+cPage+'Bg.jpg');

to the parent of the movieclip that I want to load the image into, it won't recognise cPage as a variable and comes back as undefined.

Can anyone help?

Cheers.
Jun 15 '08 #1
3 3243
Also, in case this helps..

When I go to preview the swf, Flash gives me an error:

Error opening URL 'file:///....images/undefinedBg.jpg'

Which I understand because flash needs to get the data from the php file.

So I then refresh my browser. But the swf still file doesn't find the image.

It's called indexBg.jpg so it should work with the bit of actionscript I have but I still don't get it..

Any help much appreciated
Jun 15 '08 #2
Hello,

Passing variables to flash is not too difficult. Based on the code you put up their I think you are just missing a few lines to have it recognize the variable (flashvar). See this link for more information.

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16417


Thanks
Jul 2 '08 #3
Thanks. But I think I sorted it out by using an absolute path. Like so..

Expand|Select|Wrap|Line Numbers
  1. _root.bgHostAnim_MC.bgHost_MC.loadMovie("http://localhost/hopscotch/images/"+cPage+"Bg.jpg");
One thing I'm still trying to figure out is how Flash treats relative paths. Are they relative to where the SWF is or relative to where the .php or .html that it's embedded in is.. I've tried both and I still don't know. hmm..
Jul 5 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Drisco | last post by:
Hello, I realy need help,Searched the NG for a days with no vail. Sorry for the long script. I am trying to get a variable from php to flash. I have the following code in php <a...
3
by: jitu78 | last post by:
Hi, I want to pass some variable into flash on runtime. See this link, http://www.globtier.com/portfolio/in...?cat=webdesign If somebody clicks on any of project there, it should be...
2
by: xeo | last post by:
hey. am starting this really new web... its gonna be my very 1st ever since i always used to do it with flash but the thing is i need to learn how 2 design on dreamweaver (still websites) so lets...
8
by: Binx | last post by:
Please help! Does anyone know how to set up radio buttons to send their info from flash to a PHP script that will email me the results? I have been trying to get this thing to work for weeks, and...
2
by: Head In A Pan | last post by:
Hello! Here is something I assume is relatively simple but have never bothered to find out - I'm not finding the answer anywhere! All I am trying to do is this: Have a thumbnail image...
6
by: Ws | last post by:
Ok, so I have a question reguarding compilers and placing strings into the .rdata section of the PE. I was working on a program and couldn't figure out why I was getting a 0xc0000005 error...
1
by: Ronm | last post by:
Hey Guys, I have a problem which has been driving me crazy for the last days. I'm working on a small project involving: Visual Basic Acces Database ASP and adobe/macromedia Flash,
19
RMWChaos
by: RMWChaos | last post by:
Previously, I had used independent JSON lists in my code, where the lists were part of separate scripts. Because this method did not support reuse of a script without modification, I decided to...
6
anfetienne
by: anfetienne | last post by:
how can i post my $random_digit var to flash so that it can be used within flash actionscript?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.