我无法复制在一个关键帧中起作用但在另一个关键帧上不起作用的代码

时间:2011-12-16 15:06:37

标签: flash flash-cs5

我被困住了。当然除了微小的变化(... page1和... page3)之外它是同样的事情,但它在另一个关键帧中不会再次工作。

停止();

import fl.transitions.Tween;

import fl.transitions.easing.Strong;
import fl.transitions.TweenEvent;
import flash.events.Event;

con_housingpage3.side1_housingpage3.flip.addEventListener(MouseEvent.CLICK,onflip);
con_housingpage3.side2_housingpage3.flip.addEventListener(MouseEvent.CLICK,onflip);
addEventListener(Event.ENTER_FRAME,loop);

var isStill:Boolean=true;
var arraytween:Array = new Array();

function onflip(e:Event) {
    if (isStill) {
        arraytween.push(new Tween(con_housingpage3,'rotationY',Strong.easeOut,con_housingpage3.rotationY,con_housingpage3.rotationY+180,1,true));
        arraytween[0].addEventListener(TweenEvent.MOTION_FINISH,reset);
        isStill=false;
    }
}

function reset(e:Event) {
    isStill=true;
    arraytween=[];
}

function loop(e:Event) {
    if (con_housingpage3.rotationY>=90 && con_housingpage3.rotationY<=270) {
        con_housingpage3.addChild(con_housingpage3.side2_housingpage3);
        con_housingpage3.scaleX=-1;
    } else {
        con_housingpage3.addChild(con_housingpage3.side1_housingpage3);
        con_housingpage3.scaleX=1;
    }
    if (con_housingpage3.rotationY>=360) {
        con_housingpage3.rotationY=0;
    }
}




the above code works just fine for that keyframe. Why can't i just duplicate it for another keyframe, like




import fl.transitions.Tween;
import fl.transitions.easing.Strong;
import fl.transitions.TweenEvent;
import flash.events.Event;

con_housingpage1.side1_housingpage1.flip.addEventListener(MouseEvent.CLICK,onflip);
con_housingpage1.side2_housingpage1.flip.addEventListener(MouseEvent.CLICK,onflip);
addEventListener(Event.ENTER_FRAME,loop);

var isStill:Boolean=true;
var arraytween:Array = new Array();

function onflip(e:Event) {
    if (isStill) {
        arraytween.push(new Tween(con_housingpage1,'rotationY',Strong.easeOut,con_housingpage1.rotationY,con_housingpage1.rotationY+180,1,true));
        arraytween[0].addEventListener(TweenEvent.MOTION_FINISH,reset);
        isStill=false;
    }
}

function reset(e:Event) {
    isStill=true;
    arraytween=[];
}

function loop(e:Event) {
    if (con_housingpage1.rotationY>=90 && con_housingpage1.rotationY<=270) {
        con_housingpage1.addChild(con_housingpage1.side2_housingpage1);
        con_housingpage1.scaleX=-1;
    } else {
        con_housingpage1.addChild(con_housingpage1.side1_housingpage1);
        con_housingpage1.scaleX=1;
    }
    if (con_housingpage1.rotationY>=360) {
        con_housingpage1.rotationY=0;
    }
}

0 个答案:

没有答案