0

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?

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

Interesting... I will look into this too
0
  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)

4 Comments

1. Yeah, I know... It's kind of a limited appeal application. Haha 2. 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?
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?
Exactly. JavaScript can grab/set Flash vars with these funcs.
That sounds very handy, I'll look into these. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.