How to disable an animation that has hitTest

  • stblink
  • Novice
  • Novice
  • stblink
  • Posts: 22

Post 3+ Months Ago

Hi there.

I have an MC with a tween motion in it.

I have actionscript associated to it:

onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}

on (release) {
this.gotoAndStop(20);
}

When a user releases it should go to frame 20, a static frame, where the background of the button turns white.

http://www.pedroquental.org/scala/index_template.html

I use prevFrame() and nextFrame() so that the animation runs smoothly back and forward.

The only problem is "saying" that when released the background of the MC remains white.

Does anyone can help? I've tryed this using variables and didn't worked out the way i did it.

Thanks in advance.
Peter
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Your problem is that the hit test is always running (onEnterFrame) So you need to delete the code checking for your mouse position before you send the movie to another frame

So you need something like this

Code: [ Select ]
on (release) {
delete this.onEnterFrame;
this.gotoAndStop(20);

}
  1. on (release) {
  2. delete this.onEnterFrame;
  3. this.gotoAndStop(20);
  4. }


I'm not sure if thats the exact code you need because I don't ever put my code on a button but its the general idea.
  • stblink
  • Novice
  • Novice
  • stblink
  • Posts: 22

Post 3+ Months Ago

Hi

I see where u're getting at...

I usually insert the code in the frames, and not associated to objects. But i'm no actionscript expert and don't know how to do this in another way.

anyway your code didn't worked out, i've also tryed this:

Code: [ Select ]
on (release) {
delete this.onClipEvent;
this.gotoAndStop(20);
}
  1. on (release) {
  2. delete this.onClipEvent;
  3. this.gotoAndStop(20);
  4. }


And nothing worked, no errors but didn't work.

I'll wait and see if someone knows or find another way.

Thanks anyway
Peter
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Hmmm Guess I've never tried to delete a frame event thats called on an object. I'm hoping someone else can give some pointers. However the other option is to remove the code from the button. Give the button an instance name and then use code like this on the timeline

Code: [ Select ]
buttonInstanceName.onEnterFrame = function(){
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}

buttonInstanceName.onRelease = function() {
delete this.onEnterFrame;
this.gotoAndStop(20);
}
  1. buttonInstanceName.onEnterFrame = function(){
  2. if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
  3. this.nextFrame();
  4. } else {
  5. this.prevFrame();
  6. }
  7. }
  8. buttonInstanceName.onRelease = function() {
  9. delete this.onEnterFrame;
  10. this.gotoAndStop(20);
  11. }


That way your actually creating a function for the frame event and you should be able to delete it.

Your other option is to set a varialbe when the mouse over occurs. I can see that getting messy though.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 6 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.