开发者

AS2 switching from movieclip to frame?

I've coded a little game, but now I realized that I should include all the actions to frame on layer called "actions". This far I've written my code to movieclip. Any help on transforming this to frame?

onClipEvent (load) {
    yspeed = 0;
    lastx = 0;
    gravity = 0.2;
    speed = 5;
}

onClipEvent (enterFrame) {
    yspeed += g开发者_如何学Cravity;

    if (_root.flake.hitTest(_root.cloud._x, _root.cloud._y, true)) {
        yspeed = -9;
    }

    _root.cloud._x += (_root._xmouse-lastx+10)/speed;
    lastx = _root.cloud._x;
    _root.cloud._y += yspeed;

    function asd() {
        this._x += 2;
    }

    _root.flake.duplicateMovieClip("flake1",1,{_x:50, _y:350});
    _root.flake1.onEnterFrame = asd;

}

Hope you understood. So no those onClipEvents, just a frame where I write all actions.

Also, I'm a beginner so any advice could be nice!

Thanks in advance, Martti Laine


i don't understand your problem exactly.

do you want to put de code above simple in the first frame of your whole scene, or in the first frame of a movieclip.

if it is on your first frame on your scene then your code will synchronous:

    if(counter == undefined){
        yspeed = 0;
        lastx = 0;
        gravity = 0.2;
        speed = 5;
        counter = "def";
    }


    yspeed += gravity;

    if (_root.flake.hitTest(_root.cloud._x, _root.cloud._y, true)) {
        yspeed = -9;
    }

    _root.cloud._x += (_root._xmouse-lastx+10)/speed;
    lastx = _root.cloud._x;
    _root.cloud._y += yspeed;

    function asd() {
        this._x += 2;
    }

    _root.flake.duplicateMovieClip("flake1",1,{_x:50, _y:350});
    _root.flake1.onEnterFrame = asd;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜