views:

37

answers:

1

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 += 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;

}

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

+1  A: 

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;
michel
This is exactly what I mean, expect that now the moviclip "cloud" doesn't move with mouse. Any tips with it? I assume that I just have to remove some parts?
Martti Laine
Nope, I solved this. Thanks for this answer!
Martti Laine