-
Hi,
I have two question about the same:
1. Is there a way to Load Variables from a Perl script - that will send variable values back like in PHP and VB
2. Is there a way to Load Variables from a Javascript file - that will send variable values back...
Thank you in advance...
-
The only way I know of is to append a URL encode string to the source attribute of the OBJECT/EMBED tags on the page that will display the movie.
...src=movie.swf?variable=value&variable=value...
You can use server side Perl or JavaScript in an Active Server Page to attach the string before the movie is delivered to the client.
I am doing something similar with a slider I created in Flash. The user slides in a value and on the mouse release event I do a Load Variables to an ASP page that plugs those values into a COM object I wrote. Then when the user submits the form on that page where they used the slider, it runs some server side code that pulls the values out of the COM object and puts them into a string that I append to the source attribute of the OBJECT/EMBED tag of the swf. That way when the page goes away and comes back, the slider is back to the position where they left it because I loaded that info into the movie....
Does this help?
-
I was speaking about just loading variables from a ,js or .pl - non asp.
I know asp, but perl too, so i just wanted to ask...
-
The Supreme Shaman and Keeper of Polar Lights
Hi !
I think that the easiest way is calling
get url javascript:functionname()
and using JS SetVariable inside that function
-
Does that require LiveConnect? Or: Does it work on IE 4.5 on the Mac? (Wait, nothing works on IE 4.5 on the Mac
-
I know the JS reguler way. But what I want to know is if there is a way to load varaible from a .js file.
Aperently, there isn't...
I'll just stick to the regular way..
Thanks anyway everyone!
-
Hiya MasterShin,
I myself had the same problem when I was writing a flash-to-email CGI and wanted to return information to the calling Flash movie.
It turns out that it was a simple case of printing the variable list from the CGI script as they would appear in a text file. This way, once the script had done what it needed to, it could return a list of variables to the movie, which would then be loaded! The only other thing that needed doing was to output the content type for the server to know how to deal with the data.
I did it like this (code fragment only):
Code:
print "Content-type: text/plain\n\n";
print "&result=okay";
I then used the LoadVariables ActionScript command from the Flash movie and voila. It worked!
Maybe you could do the same thing in JavaScript with the document.write('&result=okay');???.
Hope this helps!
NETbreed
[Edited by NETbreed on 08-28-2000 at 12:23 PM]
-
NETbrees your a guniess(can't spell)!!!!
That's so great!!! Printing from Perl to Flash!!!
Thanks!!!
-
Excellent NETbreed!
Could you be more specific as to how you loaded the variables after the script had processed? What was the url or expression you used to load the processed variables from your example?
Thanks
-
Actually you can do a load movie command (w/ send variables) and point to a script (asp, perl, etc) This load movie action will BOTH post any variables from the movie to the script AND recieve any variables you have written out to the page in the script.
Sample ASP code:
...
variable1 = Request.Form("variable1")
variable2 = Request.Form("variable2")
variable1 = variable1 + 10
variable2 = variable2 + 10
Response.Write "variable1=" & variable1 & "&" & "variable2=" & varaible2
...
If variable1 was 1 and variable2 was 2, then they will now be 11 and 12 in the Flash movie; all in one action! If the script takes along time to process, you can create a loop in Flash that examines the contents of a variable and does not move on until it changes.
One thing to note is when you provide the url in the load movie action be sure to append a random number to the end to avoid caching:
"http://www.myserver.com/loadvariables.asp" & random(100) & random(100)
-
Hiya foley!
Technically, I didn't load the variables AFTER the script was processed. All I did was to call the script directly from within flash using the LoadVariables command. Then, in the script, I just used print commands to output variable names/values to flash. Basically, as far as Flash was concerned, it was loading the variables from a text file because the CGI script is processed by the server and only printed output is shown to the movie.
If you need your Perl script to process variables from your Flash movie then select to send the variables by either POST or GET depending on your CGI script.
I hope this helps. i would post the script/movie for all to see but I've just had my system go belly up without any backups. I can write it again for you but I'm in the middle fo a web design job so it'll be a while.
NETbreed
-
Thanks NetBreed,
But I already found a way to print variables from Perl to Flash:
print "&variable=$message";
I tried that, and it worked...
-
Thanks for this entire thread
This is an extremely valuable thread. Thanks guys.
-
Quick Q...
MasterShin,
So in your above example ---couls one use a text field with a property of variable to display the value or does it need to be concoctenated with a set variable command?
Thanks,
Foley
-
I think, when you wrote
PRINT $your_variable
in Perl, the PERL script will return the value of $your_variable to the user's browser. You just have to tell the swf to always load variables from the PERL script. If you provide a text field with the variable name set to your_variable, then you can display the result of the PERL processing. If you don't, then you can still process the variable in your action script within flash, with commands like
Set variable "your_variable" = your_variable + 1
CMIIW
-
Re: Quick Q...
Originally posted by foley
MasterShin,
So in your above example ---couls one use a text field with a property of variable to display the value or does it need to be concoctenated with a set variable command?
Thanks,
Foley
Foley, I realise this was posted to MasterShin but I'm here so I'll answer it. Yes, you could use a text field with the name of a returned variable to display it. Basically, as soon as the CGI script has printed the variables your Flash movie is free to use them just like any other variable set from within Flash.
I hope this helps!
NETbreed
P.S. Has anyone been to my website and used the feedback form? I only say this because I have a few feedback emails today with just test entered everywhere. I'm not too bothered about it, it's just if it's not any of you poeple then I want to know how someone found my site. It's not even listed with the search engines yet!!!
-
That's right. When you load variables in Flash, it looks to see if it has any varibles of the same name on _level0. If it does, it populates them with values from the script. If no matching variable names are found, it creates those variables on level0. Flash never destroys variables......
-
A useful tip for displaying multiple print lines from perl
After working with perl a bit it seems as though you can assign a variable name to one of the print functions as per MasterShin's example:
print "&variablename=$var1\n";
with other lines following in the script
print "Some text-$var2\n";
print "Some more text -$var3\n";
Now to show the results in flash as:
var1
var2
var3
just point load variables to the perl script and use a text box with a property of variablename and display ALL the print commands in the script. No need for multiple variables if you are returning data in this format.
I'm still working with processing and returning scripts with load variables using post instead of using geturl. If anyone has done this successfully I would appreciate any comments or notes.
Thanks,
foley
-
Thanks NETbreed
You have been most helpful. I have done this with some success at this point and am trying to process scripts and send variables at the same time now using load variables. All comments on this subject are greatly appreciated and I will update my own progress and notes along the way as well.
Thanks again,
foley
-
Setting up Flash form on Interland's Linux or Windoze servers
Here's a little offer for any users out there who are setting up Flash forms on Interland's servers. The "SendMail" script that comes with all their LINUX and Windows server configs works great with a simple Flash form using a "loadmovie/loadvariables" action, but only if you modify the the ASP or Perl script. Fortunately, a buddy of mine (who is the best programmer in the world) wrote the necessarry Perl modifications and I then translated it to ASP. SO, if anyone needs a copy of the script, e-mail me at "brett@brettbrewer.com". Also, check out my site in progress....www.brettbrewer.com.
If there's enough interest, I may just post the source on my site along with the flash movie. It's got built-in error detection and the script is set up to return the variables from PERL or ASP into the Flash movie into a clip called "variables".
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|