我正在尝试使用Javascript查询swiffy swf转换器的使用。
在Javascript中,当你在swiffy网站上转换swf动画时,你会收到一个代表你的动画的JSon脚本,你应该使用两种方法在javascript中运行它:
var DOMElement = document. getElementById("#Html5logo")
var JSonString = {/*JSon swiffy annimation*/}
Swiffy.Stage(DOMElement,JSonString)
Swiffy.Start();我尝试将其集成到Dart聚合物元素中,如我的示例中所述:
//Grab the DOMElement with querySelector('#ID') or $['ID']
Element html5DivContainer = $['html5logo'];
//Put JSon Swiffy Logo into a MAP
Map html5logoJSon = {/*Valid JSonObject*/}
//Load swiffy Javascript library by using context JsObject Interrop from Dart
JsObject swiffy = context['swiffy'];
//This test is ok in my case.
if(swiffy.hasProperty('Stage')){
print('Swiffy well loaded and Stage methods is found.');
}
//TRY 01 : Try to load Stage Methods by parsing my DOMElement and my jsify Swiffy JSon Object.
//
// Result as an Exception :
// TypeError: Object #<Object> has no method 'Xe'
// CtrlHeader.CtrlHeader.created (http://127.0.0.1:3030/MySwiffyExample/web/ctrlheader.dart:19:24)
swiffy.callMethod('Stage', [html5DivContainer,new JsObject.jsify(html5logoJSon)]);
//TRY 02 : Try to load Stage Methods by parsing my jsify DOMElement and my jsify Swiffy JSon Object.
//
// Result as an Exception :
// Exception: Illegal argument(s): object must be a Map or Iterable
// CtrlHeader.CtrlHeader.created (http://127.0.0.1:3030/MySwiffyExample/web/ctrlheader.dart:33:39)
swiffy.callMethod('Stage', [new JsObject.jsify(html5DivContainer),new JsObject.jsify(html5logoJSon)]);
//Any idea??完整测试用例:http://pastebin.com/XGhL9ejf
我想我不能把DomElement作为参数发送出去。您可以在这里找到我在Dart中用于询问的swiffy 5.4 JS脚本:
http://www.gstatic.com/swiffy/v5.4/runtime.js谢谢你!
发布于 2014-01-27 16:37:45
try 01应该可以正常工作:
swiffy.callMethod('Stage',[html5DivContainer,new JsObject.jsify(html5logoJSon)]);https://stackoverflow.com/questions/21364472
复制相似问题