我正在尝试使用Javascript interrop来使用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作为args发送。你可以在这里找到我在Dart中用于插入的swiffy 5.4 JS脚本:
http://www.gstatic.com/swiffy/v5.4/runtime.js
谢谢!
答案 0 :(得分:0)
try 01应该有效:
swiffy.callMethod('Stage',[html5DivContainer,new JsObject.jsify(html5logoJSon)]);