Flash Form and Navigation Button Issue (DoFSCommand)
6 Message(s) by 2 Author(s) originally posted in flash and cfml
| From: bryn50 |
Date: Friday, July 20, 2007
|
Hi,
In short, How can I get a
<CFINPUT type ="button" to send out a JAVAscript
command to change the current page location.
I have this code:
When I click on the HTML type button, the relocation happens as expected.
When I click on the equivalent CFFORM button, it doesn't.
I'm guessing it is something in the syntax of the onClick event, but I have to
say I'm lost. Flash MX documentation says this should work right (?)
Cheers,
<script language="JAVAScript">
function fred_DoFSCommand(command, arguments){
alert("Caught Command:" + command + " arguments:" + arguments);
var mytarget=parent.window.document.getElementById('mainarea');
if (command == "goURL") {
mytarget.src=arguments;
}
}
</script>
</head>
<body>
<form action="" name="freddy" id="freddy">
<input type="button" name="mybutton" id="mybutton" value="MyButton"
onClick="JAVAscript:fred_DoFSCommand('goURL', 'http://news.bbc.co.uk');"
visible="Yes" enabled="Yes">
</form>
<CFFORM action="#self#" method="POST" target="mainarea" name="fred"
height="100" width="100" format="Flash" skin="haloBlue" id="fred">
<CFINPUT type="Button" name="mybutton" value="MyButton" visible="Yes"
enabled="Yes" onClick="{ fscommand('goURL', 'http://news.bbc.co.uk') };">
</CFFORM>
| From: bryn50 |
Date: Wednesday, July 25, 2007
|
Replying to my own posts again...
the answer came in the Flex 1.5 documents for Actionscript 3 (I assume this is
what
ColdFusion 8 has behind the scenes).
The doc says:
"In ActionScript 3.0, the functionality of the External
API (
application programming interface )is provided by the
ExternalInterface class."...
"If you need to use the old fscommand() function--for example, to maintain
compatibility with older applications or to interact with a third-party SWF
container application or the
stand-alone Flash Player--it is still available as
a package-level function in the flash.system package."
However I'd like to make the
point that no-where anywhere in the ColdFusion
documentation is even one tiny example of the use of action script coding to
enhance the basic functionality of CFForm. To much to ask ?
Oh yes, and one other thing, it seems as though the getURL actionscript
command does what I needed to do in this case.
Cheers,
| From: Alain Levy |
Date: Thursday, August 09, 2007
|
Hi,
In
relation to communication issues between Flash and JAVAscript: I am trying
to get JAVAscript to
talk to my Flash form, but I can not get it to work.
I'd like at least to be able to change the value of a hidden
field in my
form, or even better to
execute an actionscript function, from JAVAscript.
I believe the answer lies somewhere around the ExternalInterface.addCallback
function, but I just can not get it to work.
I am trying to do this because I have a flash form with a tab navigator and
the showing tab is bound to a hidden field.So far so good...I am now trying to
use the new CF8 CFMENU functionality to
control which tab shows. That's why I
need it!
Any direction appreciated! Thanks a lot!
Alain
| From: bryn50 |
Date: Thursday, August 09, 2007
|
Hi Alain,
Not sure if I can help directly however I found the following.
a) biggest issue was deciding which
version of actionscript documentation to
read. I decided upon Flex Actionscript version 1.5 and this seems to hold out,
even with CF8. Not happy with Adobe's lack of any kind of example for
actionscripting within CFFORM/Flash which would've helped just to get me
started. I found not even one tiny example in all the docs I read.
b) I never got JAVAscript talking to the flash form or vice-versa. I went for
purely actionscript within the flash form and it seems to work.
c) I can see why you need it to work, and if you find out please let me know,
I'll be fascinated as I had in mind to do some things like that for my own
App (e.g. I suspect will sooner or later not be able to avoid this issue
myself.).
Cheers and best of luck..
BP.
| From: bryn50 |
Date: Thursday, August 09, 2007
|
Try the attached script.
I remain convince that for some reason Adobe have nobbled (technical term) the
functiningf of the external interface in flash
forms Dont know why, but
unexplained.
Neither externalinterface nor fscommand seem to work as best I can tell. (see
attached).
Cheers,
BP
<html>
<head>
<title>my test page
</title>
<CFAJAXIMPORT tags = "cfform">
<script language="JAVAScript" charset="utf-8">
<!--
function callApp() {
alert("Hello ?");
var x = myflashform.myFlexFunction();
alert(x);
}
function myJAVAScriptFunction() {
alert("Hello World");
}
function myflashform_DoFScommand(command, parameters) {
alert("Flash called me" + command);
}
//-->
</script>
</head>
<body>
<CFFORM action="p2action.cfm" method="POST" name="myflashform" height="100"
width="500" format="Flash" style="themeColor:##2B52FF;" skin="haloBlue"
id="myflashform" wmode="transparent">
<CFFORMITEM type="script">
import mx.external.*;
public function myFunc():Number {
return 42;
}
function initApp() {
alert("Hello from initApp" + myFunc() );
if (mx.external.ExternalInterface.available) {
alert("external interface is available..");
var f:String = "myJAVAScriptFunction";
var m:String = mx.external.ExternalInterface.call(f);
mx.external.ExternalInterface.addCallback("myFlexFunction",myFunc);
} else {
// Handle
failure here.
alert("external interface isn't available..");
}
}
function myClick() {
alert("Calling JAVAscript Now");
fscommand("fred", 1);
fscommand("showmenu", true);
}
</CFFORMITEM>
<CFINPUT type="Text" name="fred" value="12" label="myFlashformitem"
required="No" visible="Yes" enabled="Yes" size="10">
<CFINPUT type="Button" name="mybutton" visible="Yes" enabled="Yes"
onclick="initApp();" value="Clickme">
<CFINPUT type="Button" name="mybutton2" visible="Yes" enabled="Yes"
onclick="myClick();" value="fscommand">
</CFFORM>
<form>
<button onclick="callApp();">Call App
</button>
</form>
</body>
</html>
| From: Alain Levy |
Date: Thursday, August 09, 2007
|
Hi, and thanks +++ for your
reply and the code... I can not get it to work
either, it drives me mad...
I wish asfusion'd get their teeth on it, they are just the best!
Unfortunately, they aren't much into flash forms these days, just flex...
Will keep you posted - and everyone else! - if I can get it to work!
Alain
Next Message: Flex 2, FDS 2.5 and ColdFusion 8