how to assign a target in this case? (html5 canvas)
Hello everyone!
i'm working in html5 canvas projectvand i'd like to add some feature at this code that for now work fine.
In short, i have 7 movieclips with instance name button1, button2, button3, ...etc and these lines of code highlight the button that is pressed.
Now I need to add, according to the button pressed, a specific action, in my case a goToandStop() in the main timeline.
here the code:
- this.stop();
- // required only if no actual buttons are used
- stage.enableMouseOver(20);
- // variables
- var numButtons = 7;
- var i, b, curButton;
- // initialize
- for (i = 1; i <= numButtons; i++) {
- b = this["button" + i];
- b.cursor = "pointer";
- b.mouseChildren = false;
- b.addEventListener("click", buttonClickHandler.bind(b));
- b.addEventListener("mouseover", buttonRollOverHandler.bind(b));
- b.addEventListener("mouseout", buttonRollOutHandler.bind(b));
- }
- // event handlers
- function buttonClickHandler() {
- if (curButton) {
- curButton.gotoAndStop(0);
- }
- this.gotoAndStop(2);
- curButton = this;
- }
- function buttonRollOverHandler() {
- if (this != curButton) {
- this.gotoAndStop(1);
- }
- }
- function buttonRollOutHandler() {
- if (this != curButton) {
- this.gotoAndStop(0);
- }
tnx a lot
