1

我一直在尝试在 Flash 中创建一个漩涡状的催眠动画,其中随机单词淡入然后缩小。最初,我设置了由计时器随机显示的补间动画,但计时器不可避免地与动画不同步,导致在动画中间切换单词。

经过一番研究,使用 ENTER_FRAME 事件触发 Actionscript 中编码的动画似乎是正确同步事物的解决方案。然而,虽然修改可见性和初始淡入非常容易编码,但在舞台上保持正确对齐的同时进行缩放已被证明是非常困难的。

据我所知,我应该使用 stage.stageWidth(and Height)/2 - 实例 /2 的宽度/高度来设置适当的 x/y 坐标,以便在重新对齐舞台中心的实例后重新对齐-通过调整实例的 scaleX/Y 来调整大小,但一切都略微不对齐。

我使用的每个实例在 Flash Professional CS5.5 中都作为 Text 对象开始,并已转换为具有下面代码中列出的实例名称的影片剪辑对象。

选择单词并修改它的初始函数

function runMany(event:Event):void {
if (cnt == 0) {
    randomWord = Math.floor(Math.random() * 10);
    scaling(randomWord, scale);
    setAlpha(randomWord, alphaLevel);
    visibility(randomWord, true);
    cnt++;
} else if (cnt <= 50) {
    alphaLevel = alphaLevel + .02;
    setAlpha(randomWord, alphaLevel);
    cnt++;

} else if (cnt < 97) {
    alphaLevel = alphaLevel - .02;
    scale = scale - .02;
    scaling(randomWord, scale);
    setAlpha(randomWord, alphaLevel);
    if (scale > 0) {
        cnt++;
    } else {
        cnt = 97;
    }
} else if (cnt == 97) {
    cnt = 0;
    alphaLevel = 0;
    scale = .8;
    visibility(randomWord, false);
    scaling(randomWord, scale);
    setAlpha(randomWord, alphaLevel);
}
}

应该是缩放和对齐单词的功能

function scaling(ref, setting):void {
    if (ref == 0) {
        if (setting == 1) {
            watch.width = 515.50;
            watch.height = 209;
        } else {
            watch.scaleX = setting;
            watch.scaleY = setting;
        }
    watch.x = stage.stageWidth/2 - watch.width/2;
    watch.y = stage.stageHeight/2 - watch.height/2;
}
if (ref == 1) {
    if (setting == 1) {
        slave.width = 552.55;
        slave.height = 266.75;
    }else {
        slave.scaleX = setting;
        slave.scaleY = setting;
    }
    slave.x = stage.stageWidth/2 - slave.width/2;
    slave.y = stage.stageHeight/2 - slave.height/2;
}
if (ref == 2) {
    if (setting == 1) {
        letGo.width = 574.45;
        letGo.height = 271;
    } else {
        letGo.scaleX = setting;
        letGo.scaleY = setting;
    }
    letGo.x = stage.stageWidth/2 - letGo.width/2;
    letGo.y = stage.stageHeight/2 - letGo.height/2;
}
if (ref == 3) {
    if (setting == 1) {
        obey.width = 536.95;
        obey.height = 339.15;
    } else {
        obey.scaleX = setting;
        obey.scaleY = setting;
    }
    obey.x = stage.stageWidth/2 - obey.width/2;
    obey.y = stage.stageHeight/2 - obey.height/2;
}
if (ref == 4) {
    if (setting == 1) {
        dontThink.width = 629.60;
        dontThink.height = 184.90
    } else {
        dontThink.scaleX = setting;
        dontThink.scaleY = setting;
    }
    dontThink.x = stage.stageWidth/2 - dontThink.width/2;
    dontThink.y = stage.stageHeight/2 - dontThink.height/2;
}
if (ref == 5) {
    if (setting == 1) {
        blank.width = 601.30;
        blank.height = 195.85;
    } else {
        blank.scaleX = setting;
        blank.scaleY = setting;
    }
    blank.x = stage.stageWidth/2 - blank.width/2;
    blank.y = stage.stageHeight/2 - blank.height/2;
}
if (ref == 6) {
    if (setting == 1) {
        mindless.width = 800.20;
        mindless.height = 187.25;
    } else {
        mindless.scaleX = setting;
        mindless.scaleY = setting;
    }
    mindless.x = stage.stageWidth/2 - mindless.width/2;
    mindless.y = stage.stageHeight/2 - mindless.height/2;
}
if (ref == 7) {
    if (setting == 1) {
        property1.width = 632.60;
        property1.height = 326.85;
    } else {
        property1.scaleX = setting;
        property1.scaleY = setting;
    }
    property1.x = stage.stageWidth/2 - property1.width/2;
    property1.y = stage.stageHeight/2 - property1.height/2;
}
if (ref == 8) {
    if (setting == 1) {
        owned.width = 670.65;
        owned.height = 209.75;
    } else {
        owned.scaleX = setting;
        owned.scaleY = setting;
    }
    owned.x = stage.stageWidth/2 - owned.width/2;
    owned.y = stage.stageHeight/2 - owned.height/2;
}
if (ref == 9) {
    if (setting == 1) {
        dontResist.width = 791.05;
        dontResist.height = 142.45;
    } else {
        dontResist.scaleX = setting;
        dontResist.scaleY = setting;
    }
    dontResist.x = stage.stageWidth/2 - dontResist.width/2;
    dontResist.y = stage.stageHeight/2 - dontResist.height/2;
}
if (ref == 10) {
    if (setting == 1) {
        submit.width = 793.40;
        submit.height = 244.35;
    } else {
        submit.scaleX = setting;
        submit.scaleY = setting;
    }
    submit.x = stage.stageWidth/2 - submit.width/2;
    submit.y = stage.stageHeight/2 - submit.height/2;
}
}
4

0 回答 0