View Full Version : hitTest and set Interval
mediablitz
September 18th, 2006, 06:55 PM
I have an interesting problem;
I have an initial movieclip (movieclip_1) loaded and I want to be able to time the length spent with the mouse down over movieclip_1 and then load movieclip_2 after, say, 10 seconds have elapsed.
If the mouse is pushed outside the active area then after the 10 seconds have elapsed, movieclip_3 is loaded instead.
Any ideas?
I would be very grateful.
My coding skills are abyssmal.
SacrificialLamb
September 19th, 2006, 02:13 AM
i would use onRollOver and onRollOut insted of hitTest. and i don't really know set Interval o i use a counter in onEnterFrame i.e.
t==FPS ? (t=0) (time++) : t++;
and have mouse down clear time so it starts from 0
so you might get some thing like
Name.onRollOver = function() {
mmOver = 0;
};
Name.onRollOut = function() {
mmOver = 1;
};
Name.onReleaseOutside = function() {
mmOver = 1;
};
Name.onMouseDown = function() {
mmdown = 1;
time = 0
};
Name.onMouseUp = function() {
mmdown = 0;
};
Name.onEnterFrame = function() {
if (mmdown) {
t == FPS ? (t=0)(time++) : t++;
if (time > 10) {
if (mmOver) {
Name.gotoAndStop(2);
} else {
Name.gotoAndStop(3);
}
}
}
};
mediablitz
September 19th, 2006, 11:17 AM
Thanks Sacrificial.
However In my ignorance, I need even more clues. Obviously I should have an MC or button with the instance name of "name" but the output window gives me an error for each of the:
Name.onRollOver = function() {
mmOver = 0;
};
for a total of 6 errors. I feel like an idiot.
Any pointers?
mediablitz
September 19th, 2006, 12:05 PM
Thanks Sacrificial.
However In my ignorance, I need even more clues. Obviously I should have an MC or button with the instance name of "name" but the output window gives me an error for each of the:
Name.onRollOver = function() {
mmOver = 0;
};
for a total of 6 errors. I feel like an idiot.
Any pointers?
Actually those errors were because I put the code on an object instead of a frame... er!
Now that I have put the code on the first frame, there are no errors but still I am unclear how to structure this thing.
I have a Movie clip on frame one and a different one on frame 2 of the main timeline but the movie does stop on frame 1 and wait until the mouse is clicked or removed from the movieclip area, it just cycles.
Can you be more specific about where to put the code. I'm sorry I am so ignorant.
Joppe
September 19th, 2006, 12:15 PM
Yerr. That is frame code.
Put it on the frame and name a movieclip to menu, and have three frames in it with an stop on the first frame.
That should do it mate.
mediablitz
September 19th, 2006, 12:49 PM
Yerr. That is frame code.
Put it on the frame and name a movieclip to menu, and have three frames in it with an stop on the first frame.
That should do it mate.
I realised that it was frame code (my mistake...)
and have now tried putting my movieclip (with 3 frames in it with a stop action on frame 1) into the main timeline, but I can't get it to jump to frame 2 of the movieclip no matter how long I hold the mouse down over it.
I name the instance of the movieclip in the main timeline "Name", yes?
What did you mean "name a movieclip to menu"
Fanx again.
Joppe
September 19th, 2006, 01:09 PM
Haha sorry i ment name a movieclip to name xD
mediablitz
September 19th, 2006, 02:03 PM
why won't the movieclip jump to frame 2 when the mouse is held down?
Anybody?
Testing, testing.
Joppe
September 20th, 2006, 10:19 AM
With that code I dont get the time over 1...
Try this
Name.onRollOver = function() {
mmOver = 0;
};
Name.onRollOut = function() {
mmOver = 1;
};
Name.onReleaseOutside = function() {
mmOver = 1;
};
Name.onMouseDown = function() {
mmdown = 1;
time = 0
};
Name.onMouseUp = function() {
mmdown = 0;
};
Name.onEnterFrame = function() {
if (mmdown) {
trace(time)
time++
if (time > 10) {
if (mmOver) {
Name.gotoAndStop(2);
} else {
Name.gotoAndStop(3);
}
}
}
};
nathan99
September 21st, 2006, 05:05 AM
movieclip_1.onPress = function(){
goto2 = true;
myInt = setInterval(function invalid(){
target.gotoAndStop(goto2 ? 2 : 3);
clearInterval(myInt);
}, 10000);
}
movieclip_1.onRollOut = function(){
goto2 = false;
}
try that.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.