2013-12-13 56 views
0

我已將.fla文件轉換爲.js文件,我在該文件中的多個元素上添加了多個偵聽器。其中'點擊','mousedown'&'鼠標懸停'工作正常,但'pressmove'&'新聞'事件沒有響應,他們甚至沒有產生任何錯誤。這裏是我的代碼片段:EaselJS CreateJS'pressmove','pressup'not working

/****this snippet is from converted .js file *********/ 

(lib.knob_rot_but = function(mode,startPosition,loop) { 
    this.initialize(mode,startPosition,loop,{}); 

    // Layer 2 
    this.shape = new cjs.Shape(); 
    this.shape.graphics.f().s("#999999").ss(0.5,1,1).p("ABlhlQArArAAA6QAAA7grAqQgqArg7AAQg6AAgrgrQgqgqAAg7QAAg6AqgrQArgqA6AAQA7AAAqAqg"); 
    this.shape.setTransform(26.4,0); 

    this.shape_1 = new cjs.Shape(); 
    this.shape_1.graphics.rf(["#FFFFFF","#CCCCCC","#999999","#666666"],[0.239,0.8,0.941,1],-0.2,0.2,0,-0.2,0.2,14.8).s().p("AhlBlQgqgqAAg7QAAg6AqgqQArgqA6gBQA7ABAqAqQAqAqAAA6QAAA7gqAqQgqAqg7AAQg6AAgrgqg"); 
    this.shape_1.setTransform(26.4,0); 

    this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape}]}).wait(4)); 

}).prototype = p = new cjs.MovieClip(); 

/******* My Listeners ******/ 
var helpButtonDown = DeviceService.getHelpButtonDown(); 
helpButtonDown.addEventListener("click", function(){alert("helpButtonDown button clicked")}); //works fine 

var powerButtonUp = DeviceService.getPowerButtonUp(); 
powerButtonUp.addEventListener("click", function(){alert("powerButtonUp clicked")});//works fine 


/*** Knob Listener***/ 
var knob = DeviceService.getKnob(); 
knob.addEventListener("mousedown", function(){console.log("mousedown on knob")}); //woks fine 
knob.addEventListener("pressmove", function(evt){console.log("proess move on knob evt :" + evt)}); // doesn't work :(
+0

量變到質變到V0.7.0爲我工作。非常感謝。 :) – user3099736

回答

2

事件pressmovepressup是在版本v0.7.0推出而CreateJS發佈者發佈到v0.6.0。嘗試在標籤中更改爲v0.7.0版。

4

觸摸事件,如pressmovepressup需要您啓用觸摸類,見以下示例與文檔。

var stage = new createjs.Stage("canvasId"); 
createjs.Touch.enable(stage); 

http://www.createjs.com/Docs/EaselJS/classes/Touch.html

+0

觸摸事件需要此操作,如果沒有 – Tom

+0

,按下移動按鈕仍然可以正常工作。這應該是公認的答案。添加後我的腳本開始工作! – supersan