views:

331

answers:

3

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 button 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?

A: 
  1. An accessibility tip: avoid Flash when possible; it causes usability issues.
  2. If you want to add a POST variable before submitting:
    1. I don't think that Flash is allowed to access the DOM so this is JavaScript:
    2. Create an input element appended as a child of the form
    3. Set its type to hidden
    4. 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)

Delan Azabani
1. Yeah, I know... It's kind of a limited appeal application. Haha2. Hmm.. That doesn't really help, I need flash to set the variable. It's gonna be determined by an interactive thing. Maybe flash could return a line of javascript though?
RobHardgood
Updated post with more data.
Delan Azabani
Interesting... You'll have to excuse the fact that I'm a javascript and actionscript noob, but... I'm assuming if the flash object can pass a variable, those functions can grab the value without having to refresh the page or anything?
RobHardgood
Exactly. JavaScript can grab/set Flash vars with these funcs.
Delan Azabani
That sounds very handy, I'll look into these. Thanks
RobHardgood
+1  A: 

Look at ExternalInterface for calling JavaScript from ActionScript and vice versa.

Lars
+1  A: 

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.

5566
Interesting... I will look into this too
RobHardgood