我已經使用Actionscipt2.0做了一個拖動和匹配閃存的東西,但現在我需要將其更改爲3.0。我改變它後,閃光燈不能再拖動東西,任何人都可以看看代碼,看看我錯誤地將它轉換成了哪一部分。謝謝。Drag stuffs,Actionscript 2.0 to 3.0
的ActionScript 2.0版本:
stop();
var randomPositionFrame = int(Math.random()*9)+1;
content_mc.gotoAndStop(randomPositionFrame);
for(var i=1; i<=5; i++){
eval("content_mc.matching_term_"+i)._alpha = 0;
eval("content_mc.matching_term_"+i).onPress = function(){
if(this._currentframe == 1){
this.startDrag();
}
}
eval("content_mc.matching_term_"+i).onRelease = onMouseUp = function(){
this.stopDrag();
}
eval("content_mc.matching_desc_"+i)._alpha = 0;
eval("content_mc.matching_desc_"+i).onPress = function(){
if(this._currentframe == 1){
this.startDrag();
}
}
eval("content_mc.matching_desc_"+i).onRelease = onMouseUp = function(){
this.stopDrag();
}
}
的ActionScript 3.0版本:
stop();
var randomPositionFrame = int(Math.random()*9)+1;
content_mc.gotoAndStop(randomPositionFrame);
for(var i=1; i<=5; i++){
this["content_mc.matching_term_"+i]._alpha = 0;
this["content_mc.matching_term_"+i].addEventListener(MouseEvent.MOUSE_DOWN,function():void {
if(this._currentframe == 1){
this.startDrag();
}
}
);
this["content_mc.matching_term_"+i].addEventListener(MouseEvent.MOUSE_UP,function():void {
stage.addEventListener(MouseEvent.MOUSE_UP, doMouseUp, false, 0, true);
function doMouseUp($evt:MouseEvent):void
{
this.stopDrag();
}
}
);
this["content_mc.matching_desc_"+i]._alpha = 0;
this["content_mc.matching_term_"+i].addEventListener(MouseEvent.MOUSE_DOWN,function():void {
if(this._currentframe == 1){
this.startDrag();
}
}
);
this["content_mc.matching_desc_"+i].addEventListener(MouseEvent.MOUSE_UP,function():void {
this.stopDrag();
}
);
}
http://stackoverflow.com/questions/14374089/actionscript-2-0-to-3-0-please-give-a-hand-am-i-converting-wrong的重複問題,其中一個適當的解決方案是發現 –