Okay, I'm sorry that this is pretty complicated, but it shouldn't be that hard to solve...
Here's what I want to do. I have an HTML form that I want to upload to MySQL with PHP. That part's easy, but the thing is I want the submit butt开发者_JAVA百科on to be a Flash object. Somehow I need the Flash button to submit the form, but I think I can figure that out. The tricky part is that I need it to set another PHP variable before submitting the form. The variable will be determined by a bunch of stuff, but I can code that in actionscript later. I just need to figure out how to pass the variable back to the webpage. A $_POST variable would probably be fine.
Thanks!! Let me know if I need to clarify more...
edit: What if the flash object returned some javascript and set a variable that way? Can anyone help with making it submit the form as well while still catching a variable?
Look at ExternalInterface for calling JavaScript from ActionScript and vice versa.
Lars is right about it. It may look like this
ExternalInterface.call('passmyvariables','value1','value2');
Your javasscript would be something like this
function passmyvariables(var1,var2){
//process myvar
form.submit();
}
you can have multiple variables.
- An accessibility tip: avoid Flash when possible; it causes usability issues.
- If you want to add a POST variable before submitting:
- I don't think that Flash is allowed to access the DOM so this is JavaScript:
- Create an
input
element appended as a child of theform
- Set its
type
tohidden
- Set its
value
to whatever you want to send.
That's only part of the equation; I don't know how to get Flash to trigger a script in the page.
EDIT
These functions can help get data from Flash objects.
flashObject.GetVariable(variableName)
flashObject.SetVariable(variableName, value)
精彩评论