PDA

View Full Version : Triggering HTML FORM from actionscript?


jameschaucer
07-29-2009, 11:44 AM
I'm asking this question 'in the dark', so to speak. I have had a nice FLASH menu system built for me that I now want to tie to my standard HTML. My FLASH developer doesn't appear to know how this is done so, since I've written zillions of lines of HTML and JAVASCRIPT, I thought I'd try to lend a hand on the fact finding. I don't know the FLAH/actionscript terminology so forgive me.

Given an .swf that has some clickable objects/regions. One of these controls is labeled with the word 'pants'. When I click on 'pants' I want an HTML FORM named 'pantsForm' to be submitted. By doing it this way I can send all my hidden variables and HTML objects on to the next page in the POST array.

My thought is that I should be able to write a piece of javascript like this:

function pageAction (inVar) {
switch(inVar) {
case 'pants':
document.pantsForm.submit();
break;
}
}

And then from within the actionscript the following call:
ExternalInterface.call("pageAction", "pants"));
could _somehow_ be linked to the onClick action for the 'pants' object in the FLASH movie.

Is this true? If so, is there a trick to hooking the call to the FLASH object? Can you provide an example of what the code would look like?

Thanks for any tips/suggestions.

RelaxGuy
07-29-2009, 12:29 PM
Please use CODE tags

function pageAction (inVar) {
switch(inVar) {
case 'pants':
document.pantsForm.submit();
break;
}
}

Here is the flash that will make it work:
//if submitButton is your button name
submitButton.addEventListener(MouseEvent.CLICK, onClickSubmitForm,false, 0, true);

function onClickSubmitForm(event:MouseEvent):void {
ExternalInterface.call("pageAction", "pants");
}

If the button is named 'pants' in actionscript then replace simpleButton with pants and you will get what you need.

jameschaucer
07-29-2009, 12:35 PM
I shall forward this immediately. Thank you for such a quick reply!!!