I can’t sort out what’s wrong with my code (see below). Basically, I have two mc and two buttons in the library. One movieclip linked to “Card” class and has multiple frames with images in it. The other mc is empty and linked to “CardObject” class. The goal through button clicks, user can keep flipping the card and getting new image each time (or prevBtn to go back to prev frame).
OOP is new to me, I’ve done mostly timeline animations and simple coding right on the timeline, so excuse the mess LOL. Any and all help highly appreciated!
public class CardObject extends MovieClip {
[COLOR=Gray]//add variables for card and buttons[/COLOR]
public var thisCard:Card = new Card();
public var NextBtn:NextBtn = new NextBtn();
public var PrevBtn: PrevBtn = new PrevBtn();
public function CardObject():void {
[COLOR=Gray]//stop card on first frame, add to center of stage, and add listeners
//to buttons in library[/COLOR]
thisCard.stop();
thisCard.x = stage.stageWidth.x/2;
thisCard.y = stage.stageHeight.y/2;
NextBtn.addEventListener(MouseEvent.CLICK,clickNext);
PrevBtn.addEventListener(MouseEvent.CLICK,clickPrev);
addChild(thisCard);
function clickNext(event:MouseEvent) {
[COLOR=Gray]//when btn clicked, startFlip (function in Card.as class and go
//to next/prev frame inside Card mc in library ("Card" class) [/COLOR]
thisCard.startFlip();
thisCard.nextFrame();
}
function clickPrev(event:MouseEvent) {
thisCard.startFlip();
thisCard.prevFrame();
}
}
}
}