将Actionscript 2代码传输到Actionscript 3

时间:2014-07-26 04:04:08

标签: actionscript-3 flash actionscript actionscript-2

几年前我开始使用动作脚本3,当我离开学校并完成第一份真正的工作时,我必须进入动作脚本2.所以在将动作编写成动作脚本2大约三年之后,我已经忘记了动作脚本3.这真的令人麻木,主要是因为我一直在寻找的所有教程和等等都使用了类和公共函数等。

这个基本幻灯片的整个想法表明我们可以作为swf文件或exe运行。大多数代码都是gotoAndStop或gotoAndPlay命令。由于as3的严格级别功能,切换和导航mebu让我有点慌张。

我有一个目标菜单,当swf文件开始时出现。您单击它以转到下一步或前进到其他步骤。 这是导航菜单,如下面的代码所示。 单击时,一个按钮(称为“菜单”)可以切换该菜单。 prev_btn和next_btn位于菜单按钮的相邻两侧,允许它移动到下一个帧标签或优先帧标签。

然后,您可以随时点击菜单按钮并调出主菜单。从这里你可以移动到时间轴的各个阶段。

所以我无法弄清楚如何保持相同的图形和易用性。

//fscommands that set up the exit and fullscreen functions
fscommand("fullscreen", "true");
fscommand("allowscale", "false");
fscommand("showmenu", false);

navmenu._visible=0;
menu_btn.onRelease=function()
    {
        navmenu._visible=1;
    }

//******************Initialization When Program first starts*********************

_global.initialize=function(){
    gotoAndStop("sc1-step0-0");
};


exit_btn.onRelease = function() {
    fscommand("quit");
};


reset_btn.onRelease = function() {
    initialize();
};


callouts_btn.onRelease = function(){
    if (callouts_mc._visible == true) {
        callouts_mc._visible = false;
    }else{
        callouts_mc._visible = true;
    }
};


highlight_btn.onRelease=function(){
    ToggleHighlights();
}


function ToggleHighlights(){
    showHighlights = !showHighlights;
    if(showHighlights){
        highlights_mc.gotoAndPlay("show");
    }
    else{
        highlights_mc.gotoAndPlay("hide");
    }
}

function ShowHighlights(){
    if( showHighlights ){
        highlights_mc.gotoAndPlay("show");
    }
    else{
        highlights_mc.gotoAndPlay("hide");
    }
}

//*******Start Program**********

initialize();

prev_btn.onRelease=function(){
    gotoAndPlay("sc1-step1-0");
}

next_btn.onRelease=function(){
    gotoAndPlay("sc1-step3-0");
}

1 个答案:

答案 0 :(得分:0)

翻译成AS3,你在这里显示的代码给出了:

stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.showDefaultContextMenu = false;

var showHighlights:Boolean = false;
navmenu.visible = false;

menu_btn.addEventListener(MouseEvent.MOUSE_UP, menuVisible);

function menuVisible(e:MouseEvent):void {
    navmenu.visible = true;
}

exit_btn.addEventListener(MouseEvent.MOUSE_UP, toQuit);

function toQuit(e:MouseEvent):void {
    fscommand("quit");
}

reset_btn.addEventListener(MouseEvent.MOUSE_UP, init);

function init(e:MouseEvent):void {
    initialize();
}

function initialize():void {
    gotoAndStop("sc1-step0-0");
}

callouts_btn.addEventListener(MouseEvent.MOUSE_UP, callouts_mcVisible);

function callouts_mcVisible(e:MouseEvent):void {
    callouts_mc.visible = !callouts_mc.visible;
}

highlight_btn.addEventListener(MouseEvent.MOUSE_UP, ToggleHighlights);

function ToggleHighlights(e:MouseEvent):void {
    showHighlights = !showHighlights;
    if (showHighlights)
    {
        highlights_mc.gotoAndPlay("show");
    }
    else
    {
        highlights_mc.gotoAndPlay("hide");
    }
}

function ShowHighlights(e:MouseEvent) {
    if (showHighlights)
    {
        highlights_mc.gotoAndPlay("show");
    }
    else
    {
        highlights_mc.gotoAndPlay("hide");
    }
}

//*******Start Program**********

initialize();

prev_btn.addEventListener(MouseEvent.MOUSE_UP, gotoPrev);

function gotoPrev(e:MouseEvent):void {
    gotoAndPlay("sc1-step1-0");
}

next_btn.addEventListener(MouseEvent.MOUSE_UP, gotoNext);

function gotoNext(e:MouseEvent):void {
    gotoAndPlay("sc1-step3-0");
}