-
Variables
How can i pass variables from one swf to another?
I tried this, but it do not work:
I have two swf files.
1.swf action
-----------------------
var thisdata = "hello world!";
loadMovieNum("2.swf", 4, "POST");
2.swf action
-----------------------
_root.createTextField("txtfield", 1, 500, 500, 1000, 1000);
_root.txtfield.text = _root.thisdata
Thank You,
Joni
-
These are two seperate SWFs? Are they in the same page? OR are they in the same movie?
-
Two separate files, they are in the same movie. First one loads second one.
If i would not want to send variables it will work nicely.
I just need a method to pass variables between swf files. I cannot find solution anywhere and im nearly desperate. So, am i in right track here? What is the common way of passing variables?
-
Well I am not sure if this is related, but when you load one movie into another, the root level changes to the movie LOADING the second movie. Hence the code:
_root.createTextField("txtfield", 1, 500, 500, 1000, 1000);
_root.txtfield.text = _root.thisdata
in the second movie would (I believe) actually try to create a texfield in the root timeline of the first movie (since that is now the root). Is this what you are trying to do?
Also, I am not sure why you are specifying a POST method for loading a movie in:
loadMovieNum("2.swf", 4, "POST");
this is generally only done if you are sending variables. Here you are trying to access internal variables.
-
Thank you, i learned from your post.
However, I changed my way to solve my problem complitely, because i just realised that passing variables through files is not the right way. Because i load swf files dynamically.
At present moment I am still in the corner.
I have two files, "index.swf" and "valikko.swf" (1.swf and 2.swf in previous post). I read database with LoadVars.load to get content for the flash.
Loading data to "index.swf" works fine but it do not work from "valikko.swf".
That is the reason i tried to pass variables loaded from db.
I Thought previously:
"Damn! This dont work.. OK, loading data wont work from valikko.swf, but it works from index - so do not panic, just pass them to index. "
-- and then i got new problems
Now i Thought:
"Because loading works from index, theres no any good reason why it wont work from another file. Actionscript is same in both files. And this makes me feel odd."
SCRIPT: (yes, there Is onload evenhandler above)
---------------------------------------------------------------------
try {
select_lv2.load("http://localhost/flashdata/?site=www.xxx.fi")
}
catch (myError:Error) {
trace("error caught: "+myError);
}
finally {
trace('finally here')
}
---------------------------------------------------------------------
BUT
I do not get any apache log - so apache do not ever even get that load command! Flash just prints "finally here" without errors.
From index.swf it works.
Thank You,
Joni
-
Answer!
Hey!
I found the solution. The second swf file had publish setting of actionscript 1.0. Works when set to 2.0.. :yikes:
Later,
Joni
:smoov: