我已将ActionScript 2用于Flash文件,但由于ActionScript 2不支持任何浏览器,因此我需要将ActionScript 2代码更改为ActionScript 3.
当我尝试使用Adobe Animate进行转换时,它开始在预加载器,初始设置,垂直/水平对齐等图像加载中显示一些错误。
代码和错误消息如下:
//Controls Default
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
controls.zo.useHandCursor = false;
controls.zi.useHandCursor = false;
controls.br.useHandCursor = false;
controls.bl.useHandCursor = false;
controls.bu.useHandCursor = false;
controls.bd.useHandCursor = false;
controls.bres.useHandCursor = false;
resized_ = false;
cursor._visible = panWithinBoundary ? false : true;
//Image loading with preloader (if the settings made to load the image dynamically)
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (image ne undefined and image ne "" and image ne null) {
//If image path specified:
controls._visible = false;
mcl = new MovieClipLoader();
tempMc = content_clip.inner_clip.ImageHolder.Content.createEmptyMovieClip("temp", 1);
mcl.loadClip(image, tempMc);
mcl.onLoadStart = function() {
//Image loading progress
loader.start_(tempMc);
};
mcl.onLoadInit = function(mc) {
//After loading the image:
if (imageSmoothing and image.substr(image.lastIndexOf(".")+1) ne "swf") {
//If imageSmoothing is set 'true' and the content is not swf, we need to capture the bitmap data
//for better look:If imageSmoothing is set 'false' or the content is not an image (but swf),
//we should show the content 'as is' without bitmap capture.
myBmp = new flash.display.BitmapData(mc._width, mc._height, true, 0x00CCCCCC);
myBmp.draw(mc);
removeMovieClip(mc);
content_clip.inner_clip.ImageHolder.Content.attachBitmap(myBmp, 0, "auto", true);
}
loader.unloadMovie();
bgShade.unloadMovie();
init();
run();
};
} else {
//If image path not specified, then assuming image is placed directly to the library:
loader.unloadMovie();
bgShade.unloadMovie();
init();
run();
}
//Initial settings
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function init() {
recent = 0;
posx = posy=0;
canvasSize();
iw = cW;
ih = cH;
mask_._width = hit._width=iw;
mask_._height = hit._height=ih;
cr_width = iw;
cr_height = ih;
ease = ease<1 ? 1 : ease;
zoomFactor = zoomFactor<.3 ? .3 : zoomFactor;
panSpeed = panSpeed<1 ? 1 : panSpeed;
mSP = 1;
mPX=_xmouse, mPY=_ymouse;
//Aligning Control box+++++++++++++++++++++++++++++++++++++++++++++
//Vertical Align
controls._visible = true;
if (controlBoxVAlign.toLowerCase() eq "top") {
controls._y = controlBoxSpace;
} else if (controlBoxVAlign.toLowerCase() eq "middle" or controlBoxVAlign.toLowerCase() eq "center" or controlBoxVAlign.toLowerCase() eq "centre") {
controls._y = (ih/2)-(controls._height/2);
} else {
controls._y = ih-controls._height-controlBoxSpace;
}
//Horizontal Align
if (controlBoxHAlign.toLowerCase() eq "left") {
controls._x = controlBoxSpace;
} else if (controlBoxHAlign.toLowerCase() eq "middle" or controlBoxHAlign.toLowerCase() eq "center" or controlBoxHAlign.toLowerCase() eq "centre") {
controls._x = (iw/2)-(controls._width/2);
} else {
controls._x = iw-controls._width-controlBoxSpace;
}
//Initial Zoom level detection. By default, the image gets scaled to the variable value "sc" to fit it within stage atleast to one side
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sc = (ih/content_clip.inner_clip.ImageHolder._height)*100;
if (!zoomOutToExtreme) {
if (content_clip.inner_clip.ImageHolder._width*(sc/100)<iw) {
sc = (iw/content_clip.inner_clip.ImageHolder._width)*100;
}
} else {
if (content_clip.inner_clip.ImageHolder._width*(sc/100)>iw) {
sc = (iw/content_clip.inner_clip.ImageHolder._width)*100;
}
}
错误消息是:
Scene 1, Layer 'Actions', Frame 10, Line 14, Column 11 1084: Syntax error: expecting rightparen before ne.
Scene 1, Layer 'Actions', Frame 10, Line 26, Column 22 1084: Syntax error: expecting rightparen before and.
Scene 1, Layer 'Actions', Frame 10, Line 26, Column 63 1084: Syntax error: expecting semicolon before rightparen.
Scene 1, Layer 'Actions', Frame 10, Line 67, Column 37 1084: Syntax error: expecting rightparen before eq.
Scene 1, Layer 'Actions', Frame 10, Line 69, Column 44 1084: Syntax error: expecting rightparen before eq.
Scene 1, Layer 'Actions', Frame 10, Line 69, Column 93 1008: Attribute is invalid.
Scene 1, Layer 'Actions', Frame 10, Line 69, Column 102 1084: Syntax error: expecting rightbrace before or.
Scene 1, Layer 'Actions', Frame 10, Line 71, Column 4 1083: Syntax error: else is unexpected.
需要知道,如何修复上述错误?
答案 0 :(得分:1)
您需要在代码中有错误的部分进行研究并使用AS3 Operators。
例如,您的代码似乎映射到以下内容:
您的ne
相当于AS3运营商:!=
(请参阅:Not Equal
)。
您的eq
相当于AS3运营商:==
(请参阅:EQuality
)。
您的and
相当于AS3运营商:&&
(请参阅:AND
)。
您的or
相当于AS3运营商:||
(请参阅:OR
)。
示例#1:(AS2代码):
if (image ne undefined and image ne "" and image ne null)
确实应该是(AS3):
if (image != undefined && image != "" && image != null)
示例#2:(AS2代码):
else if (controlBoxVAlign.toLowerCase() eq "middle" or controlBoxVAlign.toLowerCase() eq "center" or controlBoxVAlign.toLowerCase() eq "centre") {
确实应该是(AS3):
else if (controlBoxVAlign.toLowerCase() == "middle" || controlBoxVAlign.toLowerCase() == "center" ||controlBoxVAlign.toLowerCase() == "centre") {