Can I sync HTML text or divs with SWF (Flash character animation)?

青春壹個敷衍的年華 提交于 2019-12-13 18:04:08

问题


I have flash animation (swf) in my HTML Page.

Now, I like to have my flash animated character (700kb) to speak dialogues, the related text should pop and go in the html side of the page.

I've already used this amazing cool script from Text highlight with audio sync in Jquery by Marnix van Valen & HTML5 works cool as he says. BUT, what about flash???.

Is there any way to do this? thanks in advance.


回答1:


Perhaps you need to run some code from flash file, there is a good tool for it - ExternalInterface

for example as3 code:

class Character {
  public function say(msg:String):void
  {
    trace(msg);
    ExternalInterface.call('say', msg);
  }
}

js code on the html page where your swf embedded:

<script>
function say(msg) {
  alert('character says: ' + msg);
}
</script>

So when you run character.say('hi') you'll get new message in flash console (from trace) and popup with your message.

Hope this helps.



来源:https://stackoverflow.com/questions/9596862/can-i-sync-html-text-or-divs-with-swf-flash-character-animation

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