-
yeah yeah yeah
[RESOLVED] [MX04] How do I fix this function?
code:
flowerButtons = function () {
this.onEnterFrame = function() {
if (buttonPlaying == true) {
if (lyricsFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
lyricsFlower.doPress();
} else {
buttonPlaying = false;
}
} else {
buttonArea.onRelease();
delete this.onEnterFrame;
}
};
};
buttonArea.onPress = function() {
buttonPlaying = true;
flowerButtons();
};
buttonArea.onRelease = function() {
buttonPlaying = false;
//there's more stuff in here that isn't useful for this question...
};
The problem with the "flowerButtons" function is that the onEnterFrame keeps resetting the "lyricsFlower.doPress" function so it never does what it's supposed to do, but I need the onEnterFrame in there for another reason. How can I fix it so that it enables the lyricsFlower function once and that's it?
Hoepfully that gives you enough information without me having to go into a diatribe of everything that's going on in this code. If however, you need more info to answer the question at hand, I'm happy to explain.
Thanks for any insight!
-Sandy
-
Maybe try something like this...
Code:
flowerButtons = function () {
this.onEnterFrame = function() {
if (buttonPlaying == true) {
if (!lyricsFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
buttonPlaying = false;
}
} else {
buttonArea.onRelease();
delete this.onEnterFrame;
}
};
};
buttonArea.onPress = function() {
buttonPlaying = true;
if (lyricsFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
lyricsFlower.doPress();
}
flowerButtons();
};
-
yeah yeah yeah
Hey dawsonk, thanks for the reply! For some reason I didn't get emailed...
Anyway I was coming back to this post to say that I fixed it.
I changed the function name to buttonDragOut and removed it from the onPress function.
code: buttonDragOut = function () {
this.onEnterFrame = function() {
if (lyricsFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
over = true;
} else if (downloadsFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
over = true;
} else if (contactFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
over = true;
} else if (homeFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
over = true;
} else if (aboutFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
over = true;
} else if (datesFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
over = true;
} else if (catalogFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
over = true;
} else {
over = false;
}
if (over == false) {
new Tween(myBird, "_rotation", Regular.easeInOut, myBird._rotation, 0, 2, false);
stopParticles();
}
};
};
buttonArea.onPress = function() {
if (lyricsFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
lyricsFlower.doPress();
} else if (downloadsFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
downloadsFlower.doPress();
} else if (contactFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
contactFlower.doPress();
} else if (homeFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
homeFlower.doPress();
} else if (aboutFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
aboutFlower.doPress();
} else if (datesFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
datesFlower.doPress();
} else if (catalogFlower.hitTest(_root._xmouse, _root._ymouse, true)) {
catalogFlower.doPress();
}
};
buttonArea.onRelease = function() {
new Tween(myBird, "_rotation", Regular.easeInOut, myBird._rotation, 0, 2, false);
if (_root.particlePlay == "play") {
myInterval = setInterval(stopParticles, 500);
}
};
Not as pretty as yours, but it works so I'm happy.
Thanks for taking the time to help!
-Sandy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|