Skip to main content
Participating Frequently
March 12, 2014
Question

Using Multiple Actions in Flash CC

  • March 12, 2014
  • 1 reply
  • 1704 views

Hello. I am new to Flash CC. I am trying my hand at a simple dress up doll game. I have made a doll base, with different skin types in their respective frames, and next and previous buttons to move from skin color to skin color. This is the code I am using for the next and previous buttons:

stop()

btn1prev.addEventListener(MouseEvent.CLICK, backward);
btn2next.addEventListener(MouseEvent.CLICK, forward);

function forward(event:MouseEvent) {
    if (this.currentFrame == this.totalFrames) {
        gotoAndStop(1);
    }
    else {
        nextFrame();
    }
}


function backward(event:MouseEvent) {
    if (this.currentFrame == 1) {
        gotoAndStop(this.totalFrames);
    }
    else
    {
        prevFrame();
    }
}

Then I added 3 new layers, each with a different eye color on them (brown, blue, and green). I want these to be dragged and dropped onto the doll. I started with the brown and added this action to the layer:

browneyes.addEventListener(MouseEvent.MOUSE_DOWN, dragbrowneyes);

function dragbrowneyes(eyt:MouseEvent):void{

     addChild(MovieClip(evt.currentTarget));//to place above other content

     evt.currentTarget.startDrag();

     stage.addEventListener(MouseEvent.MOUSE_UP, dropbrowneyes);

}

function dropbrowneyes(evt:MouseEvent):void{

     stopDrag();

     stage.removeEventListener(MouseEvent.MOUSE_UP, dropbrowneyes);

}

When I try each of these codes on their own, they work fine. But when I try to use them both in the same file, none of them work. The eyes I cannot move and the skin types flash by instead of moving when I press the buttons.

Here is a video of me adding the drag and drop action then pressing Ctrl+Enter to play the game (so that you can see how the dragndrop does not work and neither do the buttons, skin types flash by) :

This shows up in the Compiled Errors :

Again, I'm new, so I don't really understand these actions. I just found them online.

Any and all help would be mucho appreciated. I am using Flash through the Creative Cloud on a PC (windows 7), it is updated, and I am using Action Script 3.

I will try to attach screen shots. Hopefully they show up

My Timeline : showing my layers and frames

My actions for the next and previous buttons

My whole screen : The actions window is minimized

*I also plan on adding multiple items of clothing later on that I would like to move to it's place whne clicked on. help for that would be appreciated as well

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
March 12, 2014

show the code you're trying to use when coding for the 3 eye colors.

Participating Frequently
March 13, 2014

I am trying to use the drag and drog code :

browneyes.addEventListener(MouseEvent.MOUSE_DOWN, dragbrowneyes);

function dragbrowneyes(eyt:MouseEvent):void{

     addChild(MovieClip(evt.currentTarget));//to place above other content

     evt.currentTarget.startDrag();

     stage.addEventListener(MouseEvent.MOUSE_UP, dropbrowneyes);

}

function dropbrowneyes(evt:MouseEvent):void{

     stopDrag();

     stage.removeEventListener(MouseEvent.MOUSE_UP, dropbrowneyes);

}

I just replace "browneyes" with blueeyes or greeneyes, depending on which layer I'm putting the code

kglad
Community Expert
Community Expert
March 13, 2014

put all your code in the same layer.

then copy and paste the code with two or more drag/drop functions that's causing a problem.

or just use:

browneyes.addEventListener(MouseEvent.MOUSE_DOWN, drageyes);

greeneyes.addEventListener(MouseEvent.MOUSE_DOWN, drageyes);

blueeyes.addEventListener(MouseEvent.MOUSE_DOWN, drageyes);

function drageyes(eyt:MouseEvent):void{

     addChild(MovieClip(evt.currentTarget));//to place above other content

     evt.currentTarget.startDrag();

     stage.addEventListener(MouseEvent.MOUSE_UP, dropeyes);

}

function dropeyes(evt:MouseEvent):void{

     stopDrag();

     stage.removeEventListener(MouseEvent.MOUSE_UP, dropeyes);

}