View Full Version : event handling
joeri
02-11-2004, 05:35 PM
Hi Guys,
I'm trying to handle two events on the same time on one MC.
Here's the code(dont look at all the i variables...forloop) :
+++++++++++++++++++++++++++++++
var base = _root.createEmptyMovieClip("base", 10);
dup_butt = base.attachMovie("button","button"+(10+i),100+i);
dup_butt.onPress = buttonfunc;
dup_butt.onRollOver = id_indicator;
++++++++++++++++++++++++++++++++++++++++
This is not working and I want to avoid the hit test function.
Is there a way to get around this?
Thanx! Joeri
senocular
02-11-2004, 05:39 PM
you may need to display more code
joeri
02-11-2004, 06:56 PM
well :
those functions, buttonfunc() and id_indicator(), are actually for controlling a button from frame one to frame two and back and indicating which button was pressed.
function id_indicator(){
trace(this.id);
}
function buttonfunc(){
this.gotoAndStop(2);
}
so what do you need to know more?
thanx! Joeri
agent81
02-11-2004, 08:12 PM
try
function id_indicator(){
trace("hello");
}
see if that traces.
joeri
02-18-2004, 02:10 AM
Of course that will work. But not if you use the two events, the same time. onPress and onRollover are hard to combine.........
Joeri
senocular
02-18-2004, 05:14 AM
thats not the code I meant... how about "Can you be more descriptive?"
what do you mean two events at the same time? onRollOver happens when you roll over the clip and onPress happens when you press it. Rollover will always happen before a press and neer at the same time. If they were at the same time they wouldnt be two events, just one - though technically by definition you cant press something unless you're first over that something. So Im failing to see the issue.
divarch
02-18-2004, 06:06 AM
Originally posted by joeri
onPress and onRollover are hard to combine.........
Impossible would be the right word!
As Senocular said, two different types of events completely.
Have you defined your 'id' property you're tracing? The code works as expected, I don't know what the problem is.
Also, you haven't defined 'onRelease' to return the button to initial state, :rolleyes:
joeri
02-18-2004, 02:36 PM
What I wanted to create is a textbox which shows some info about the object when a user rolls over. When the user clicks,
another action should be performed. I understand Senoculars point. Unfortunately it's just not possible........
agent81
02-18-2004, 04:50 PM
it is totally possible. Of course you can have both an onPress, and onRelease.
I'm putting my money on the fact that this.id is referenced wrong in your id_indicator function
thats what i meant by try
trace("hello")
try this
function id_indicator(){
trace("I've been pressed")
trace(this.id);
}
function buttonfunc(){
trace("I've been rolled Over")
this.gotoAndStop(2);
}
now work backwards from there, make sure you keep a generic trace (e.g. a string, not a variable that may not exist) in each function.
they definately work together, its something else that you are doing wrong.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.