View Full Version : onChange event problem with components
Daevid
08-28-2005, 01:34 PM
I've been trying to declare an onChange-function to a combobox component like this (from an extended movie clip that contains the combobox "Type"):
Type.onChange = function (){
trace ("changed!")
}
This works with with onRelease-event for buttons etc, but for some reason flash ignores this function. If I instead attach a similar function directly to the combobox:
on(change) {
this.onChange ()
}
... it sends the event correctly. I can't understand why, and would rather not have any code internally in the fla-file.
Can anybody explain why this is?
/David
hi and welcome to As.Org
the combobox has NO "onChange"
BUT
ComboBox.change
Availability
Flash Player 6 (6.0 79.0).
Daevid
08-28-2005, 05:00 PM
Thanks for both the help and the welcoming! Unfortunatley I can't get it working with the "change" event either:
Type.change = function (){
trace ("changed!")
}
I've tried the more conventional listener syntax aswell, but i guess i'll have to stick to my "ugly" solution.
/David
listenerObject = new Object();
listenerObject.change = function(eventObject) {
trace("changed!");
};
Type.addEventListener("change", listenerObject);
Daevid
08-29-2005, 09:48 AM
Thanks,
this works if I put the script attached to a movie clip in flash (in a onClipEvent(load)-event), BUT it still doesn't work when I try to attach it through an external .as class (within the MC:s creator function). Is it possible that the change event isn't supported in AS2?
Sorry for being so picky but I try to avoid having scripts inside the fla-file...
I really appreciate you help, though.
/David
upload the files so i can test
Daevid
08-29-2005, 01:00 PM
Here is a fla and an as file where the problem is isolated. Thanks.
/David
class testMovieClip extends MovieClip {
var type;
var listenerObject = new Object();
function testMovieClip() {
mx.events.EventDispatcher.initialize(type);
listenerObject.change = function(eventObject) {
trace("changed!");
};
type.addEventListener("change", listenerObject);
}
}
Daevid
08-29-2005, 03:26 PM
Sorry, still no success. Have you tried the files on your system?
Any clues on why you need to initialize the change-event for comboboxes, when button event work OK without?
Thanks anyhow!
/David
no i dint test you files because you was uploading an SWF
there you see so or so no traces
i have a slight idea why you need to initialize but
if you realy wana know you need to ask senocular
Daevid
08-30-2005, 09:04 AM
Sorry for uploading the SWF... not the first time I've made that mistake! I'm still new to flash so I'm really grateful for you helping me out.
I think I've found what was my problem: I had given the MC an instance name, for some reason this stops the change-event. If I remove the instance name everything works OK!
I can't figure out why this is though.
Thanks for your help! Hope to learn fast so I can contribute constructively to this forum myself!
/David
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.