PDA

View Full Version : [MX] Sending variables from PHP to Flash



Psykloak1
May 10th, 2003, 10:11 PM
I'll try to explain this as best as I can.
I have about 30 .jpg files, 1 .swf file and 1 .php file.
I want the PHP to load multiple copies of the SWF and have each copy load a diffrent JPG. I hope that makes sense. please try to steer me in the right direction. Thanks

eyezberg
May 11th, 2003, 03:39 PM
Don't need php for that, simply embed the same empty swf 30 times, in the swf, have o loadMovie(jpgName add ".jpg"), and in the embed tags, use flashvars to set the jpgName variable to the jpg file you want (without the extension).
(or use embed source=holder.swf?jpgName=first / second / etc..)

Psykloak1
June 18th, 2003, 04:11 PM
Originally posted by eyezberg
...and in the embed tags, use flashvars to set the jpgName variable to the jpg file you want (without the extension).
(or use embed source=holder.swf?jpgName=first / second / etc..)

Ok, I've tried both ways and neither work right. They pass the variable correctly but when I try to use loadMovie to load that jpg, it doesnt work.

Heres the code I have:

loadMovie(jpgName+".jpg",1);

Like I said, the variable is passed to the swf, it lets me display the variable with a dynamic text box but it doesn't work with my code.

Any ideas?

RvGaTe
June 18th, 2003, 08:18 PM
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=17037

in this xample, each link, wich is the same .swf... will highlight a different button...

im sure you can translate that to an .jpg being loaded

and what eyezberg tries to tell you here DOZ work, but he forgot to tell you to make the jpgName a _global variable...

its all xplained on that link

Psykloak1
June 18th, 2003, 09:38 PM
Hrm. I downloaded your example and that works but when I try to use it with loadMovie, it doesnt work some how. maybe its the way I'm using load movie. Any ideas?

RvGaTe
June 19th, 2003, 07:26 AM
did you made your var global ?

Psykloak1
June 19th, 2003, 11:58 AM
Yup, heres the Actionscript code:

_global.page="index";
loadMovie(page+".swf",1);

and heres the html code:


<EMBED src="highlight.swf" flashVars="page=contact" WIDTH="550" HEIGHT="400"></EMBED>

This dosen't wor either:


<EMBED src="highlight.swf?page=contact" WIDTH="550" HEIGHT="400"></EMBED>

RvGaTe
June 19th, 2003, 11:59 AM
_global.page="index";
loadMovie(page+".swf",1);

needs to be

_global.page="index";
loadMovie(_global.page+".swf",1);



edit: your movies wont load....

Jubba
June 19th, 2003, 12:01 PM
i edited his post. He was just trying to show the code...

Psykloak1
June 19th, 2003, 12:17 PM
Still not working. :(

I have a dynamic text box, fir the var of it, i put "page" and when I pass the page variable, it gets correctly displayed in the text box but the loadMovie() still doesnt work.

Im trying to pass the word "contact" but that doesnt work but when i hard code it to load "contact.swf" that does work:

loadMovie("contact.swf",1);
this works

loadMovie(_global.page+".swf",1);
This doesn't

RvGaTe
June 19th, 2003, 01:09 PM
are you testing it local or on the net ?

coz using these links:

file.swf?page=contact on a local machine, wont work...

Psykloak1
June 19th, 2003, 02:13 PM
I tried testing it from my server but its still not working. Look at this, I ran some tests, maybe it will shed some light on the problem.
if (page=="contact")
loadMovie("contact.swf",1);
//this works

if (_global.page=="contact")
loadMovie("contact.swf",1);
//this does not work

if (page=="contact")
loadMovie(page+".swf",1);
//this does not work

loadMovie(page+".swf",1);
//this does not work

What I dont understand is this,
when page=="contact"
why doesn't this work:
loadMovie(page+".swf",1);
while this does:
loadMovie("contact.swf",1);

Could there be some invisable charecters, like a line break or a space or som ething that gets passed along with the word "contact"? but if so then why does page=="contact"?
::confused::

lac
June 19th, 2003, 03:43 PM
Hi,

If loadMovie is looking for a string you could try something like...

newPage = String(page).concat(".swf");
loadMovie(newPage,1);

It may not be combining your variable and string correctly in the pass to the function.

Liz

Psykloak1
June 19th, 2003, 04:06 PM
Hmm. Still no luck.

lac
June 19th, 2003, 04:13 PM
What do you get if you trace the variable page? I have sometimes had success using eval to get the contents of a variable so take what I had before then do

loadMovie(eval(newPage),1);

may not work, I have used this to get a usable movie clip name out from a variable before.

Liz

Psykloak1
June 19th, 2003, 04:42 PM
Eval doesnt work.


Remember, the point was to be able to pass variables dynamicaly from outside of flash through a web browser. So since trace() wont work outside of flash I cant do it. Any other ideas?

eyezberg
June 19th, 2003, 04:52 PM
*when you have declared a var as being _global, as in _global.page, you do not need/should not use _global anymore, just the var name will do.
*did you make sure you're not trying to load progressive jpg's?
*start simple, make a test swf with a simple loadMovie("test.jpg",1); which should work. then try var = "test.jpg" and loadMovie(var,1); then..etc...it should work..

RvGaTe
June 19th, 2003, 05:01 PM
if you use the var inside functions, you do need to put the _global before it....

Psykloak1
June 19th, 2003, 05:15 PM
Ok this is getting weird.

I did what eyezberg said and started over...

loadMovie("contact.swf",1);
//this works

page="contact.swf";
loadMovie(page,1);
//this doesn't

:q:

RvGaTe
June 19th, 2003, 05:18 PM
can i c your .fla ? coz this should work...

Psykloak1
June 19th, 2003, 05:28 PM
ok attached is the fla, the html and the swf for the other movie i want to load. G/L

RvGaTe
June 19th, 2003, 05:31 PM
page = "contact.swf";
_root.loadMovie(page, 1);


here it imidiatly give an error that it cannot load contact.swf... coz it dozn't exists, meaning it works

Psykloak1
June 19th, 2003, 05:37 PM
_root. loadMovie(page, 1) ?

Dont know why but it works with _root..

Hmm.

:thumb: Well thanks for all the help every one! :thumb:

RvGaTe
June 19th, 2003, 05:39 PM
root

Availability

Flash Player 4.

Usage

_root.movieClip
_root.action
_root.property

Parameters

movieClip The instance name of a movie clip.

action An action or method.

property A property of the MovieClip object.

Description

Property; specifies or returns a reference to the root movie Timeline. If a movie has multiple levels, the root movie Timeline is on the level containing the currently executing script. For example, if a script in level 1 evaluates _root, _level1 is returned.

Specifying _root is the same as using the slash notation (/) to specify an absolute path within the current level.

Example

The following example stops the Timeline of the level containing the currently executing script:

_root.stop();

The following example sends the Timeline in the current level to frame 3:

_root.gotoAndStop(3);

Psykloak1
June 19th, 2003, 05:43 PM
But I thought actions in the main timeline were already at _root .

RvGaTe
June 19th, 2003, 05:44 PM
but the action ur using needs to have an target were to load the movie to...

in this case the main timeline.... wich is _root :)