问题
let's assume that i'm detecting the number of mouse clicks in flash
for that ive used the code
import flash.events.MouseEvent;
plus.addEventListener(MouseEvent.CLICK,aaa)
var i:int=0;
function aaa(e:MouseEvent)
{
i++;
var a:Number= Number(input1.text)+Number(input2.text);
answer.text=String(i);
}
and i'm displaying it in answer
text box, i converted this to HTML5 using swiffy
and i want to get the value of the answer
text box in a javascript popop right after i click the plus button ? i tried converting it into swiffy and inspecting the textbox with chrome and it doesn't detect the text box it detects the whole canvas as an SVG
.
feel free to correct me if i'm wrong in AS3 (just a beginner).
回答1:
The trick is to spit your value out to a javascript function as follows.
function aaa(e:MouseEvent)
{
i++;
var a:Number= Number(5)+Number(4);
answer.text=String(i);
//getURL("javascript:swiffyClicked(" + answer.text + ")"); /* AS2 way */
navigateToURL(new URLRequest("javascript:swiffyClicked(" + answer.text + ");"), "_self"); /* AS3 way */
}
Then create the JS function at the top of your converted html file.
<script type="text/javascript">
function swiffyClicked(answer){
alert(answer);
}
</script>
来源:https://stackoverflow.com/questions/20649625/is-there-a-way-to-get-values-form-a-swiffy-animation