Is there a way to get values form a swiffy animation

泄露秘密 提交于 2019-12-11 23:27:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!