Re: [Flashcoders] ComboBox troubles
Hey Glen, Thanks for that, but I am not using a class in this case to get the items, just a function. Maybe I should be, but I could never figure out how to use classes and there may lie-in the problem. Think Flash 8. :) Sorry if that hurts a little.. Here is what I have //shortened AS2 Code::: import mx.controls.ComboBox; import mx.utils.Delegate; var thumbHolder:Object = new Object(); var picBox:MovieClip = new MovieClip(); var colorBox:ComboBox = new ComboBox(); var picturesArry = []; var colorHolder = []; //Code for loading above arrays not included, but they load fine. var pr:Number = -1; function loadItems() { if (pr (numimages - 1)) { pr++; thumbHolder = attachMovie(Affiliate_MC, Affiliate_MC + pr, pr); thumbHolder.ID = pr; var parentID = thumbHolder.ID; thumbHolder.LoadVars(parentID); thumbHolder._x = 0; thumbHolder._y = pr * spacing; picBox = thumbHolder.attachMovie(picture_box, picture_box, thumbHolder.getNextHighestDepth()); picBox._width = 192; picBox._height = 152; picBox._x = 14; picBox._y = 11; colorBox = thumbHolder.attachMovie(FComboBoxSymbol, os1_ + pr, thumbHolder.getNextHighestDepth()); colorBox._width = 100; colorBox._height = 17; colorBox._x = 264; colorBox._y = 110; colorBox.enabled = true; thumbHolder.pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(thumbHolder.pic,0); var Colors:Array = new Array({label:Choose Color, data:}); colorBox.rowCount = colorHolder[pr].length; // populate dataProvider var colorBoxLength:Number = Colors.length; for (n = 0; n colorHolder[pr].length; n++) { Colors.push({label:colorHolder[pr][n], data:colorHolder[pr][n]}); colorBoxLength++; } // set dropdown list colorBox.setDataProvider(Colors); if (colorBoxLength 3) { colorBox.selectedItem = 1; } else { colorBox.selectedItem = 0; } var changeObj:Object = new Object(); changeObj = function(evt_obj:Object) { var num:Number = thumbHolder.ID; var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[num][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else if (selectNum 1) { var pic = picturesArry[num][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { _root.itemSelection_mc.satusTXT.htmlText = ComboBox did not change; } }; colorBox.addEventListener(changeObj,this); } } I am thinking that I need every colorBox to have its own changeObj or I need to be able to reference the picBox that is inside with that colorBox thats being changed. Structure of a single item is as follows: Main Stage - - thumbHolder (Main item MC) - picBox (preview MC) - colorBox (comboBox selection for this item) Karl On Nov 19, 2009, at 7:08 PM, Glen Pike wrote: Hi, Are you doing something like the following - you need to use the Delegate.create function to attach scope to your event handlers. I can't remember if you can pass in the event object or not - try it? HTH Glen import mx.utils.Delegate; class MyMovieClip extends MovieClip { private var colorBox:ComboBox; //... function stuffHasLoaded():Void { colorBox.addEventListener(change, Delegate.create(this, change)); } function change():Void { trace(Hello from + this + .change); var selected:Number = colorBox.selectedIndex; //... } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Have you tried: colorBox.addEventListener(change, changeObj); or colorBox.addEventListener(change Delegate.create(this, changeObj); I think you got your listener the wrong way around, but might be wrong? Karl DeSaulniers wrote: Hey Glen, Thanks for that, but I am not using a class in this case to get the items, just a function. Maybe I should be, but I could never figure out how to use classes and there may lie-in the problem. Think Flash 8. :) Sorry if that hurts a little.. Here is what I have //shortened AS2 Code::: import mx.controls.ComboBox; import mx.utils.Delegate; var thumbHolder:Object = new Object(); var picBox:MovieClip = new MovieClip(); var colorBox:ComboBox = new ComboBox(); var picturesArry = []; var colorHolder = []; //Code for loading above arrays not included, but they load fine. var pr:Number = -1; function loadItems() { if (pr (numimages - 1)) { pr++; thumbHolder = attachMovie(Affiliate_MC, Affiliate_MC + pr, pr); thumbHolder.ID = pr; var parentID = thumbHolder.ID; thumbHolder.LoadVars(parentID); thumbHolder._x = 0; thumbHolder._y = pr * spacing; picBox = thumbHolder.attachMovie(picture_box, picture_box, thumbHolder.getNextHighestDepth()); picBox._width = 192; picBox._height = 152; picBox._x = 14; picBox._y = 11; colorBox = thumbHolder.attachMovie(FComboBoxSymbol, os1_ + pr, thumbHolder.getNextHighestDepth()); colorBox._width = 100; colorBox._height = 17; colorBox._x = 264; colorBox._y = 110; colorBox.enabled = true; thumbHolder.pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(thumbHolder.pic,0); var Colors:Array = new Array({label:Choose Color, data:}); colorBox.rowCount = colorHolder[pr].length; // populate dataProvider var colorBoxLength:Number = Colors.length; for (n = 0; n colorHolder[pr].length; n++) { Colors.push({label:colorHolder[pr][n], data:colorHolder[pr][n]}); colorBoxLength++; } // set dropdown list colorBox.setDataProvider(Colors); if (colorBoxLength 3) { colorBox.selectedItem = 1; } else { colorBox.selectedItem = 0; } var changeObj:Object = new Object(); changeObj = function(evt_obj:Object) { var num:Number = thumbHolder.ID; var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[num][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else if (selectNum 1) { var pic = picturesArry[num][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { _root.itemSelection_mc.satusTXT.htmlText = ComboBox did not change; } }; colorBox.addEventListener(changeObj,this); } } I am thinking that I need every colorBox to have its own changeObj or I need to be able to reference the picBox that is inside with that colorBox thats being changed. Structure of a single item is as follows: Main Stage - - thumbHolder (Main item MC) - picBox (preview MC) - colorBox (comboBox selection for this item) Karl On Nov 19, 2009, at 7:08 PM, Glen Pike wrote: Hi, Are you doing something like the following - you need to use the Delegate.create function to attach scope to your event handlers. I can't remember if you can pass in the event object or not - try it? HTH Glen import mx.utils.Delegate; class MyMovieClip extends MovieClip { private var colorBox:ComboBox; //... function stuffHasLoaded():Void { colorBox.addEventListener(change, Delegate.create(this, change)); } function change():Void { trace(Hello from + this + .change); var selected:Number = colorBox.selectedIndex; //... } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Could it be because I am using the class below? Not sure if I need it or not. On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: import mx.controls.ComboBox; Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Yes. I tried both of those and nothing.. actually the one below gets an error Error: type mismatch colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
I think the scope is lost in the colorBox not knowing which picBox to associate itself with. :-/ Karl On Nov 20, 2009, at 4:16 AM, Karl DeSaulniers wrote: it is actually colorBox.addEventListener(change, Delegate.create (this, changeObj)); just forgot the ), but still does not work On Nov 20, 2009, at 4:12 AM, Karl DeSaulniers wrote: Yes. I tried both of those and nothing.. actually the one below gets an error Error: type mismatch colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
If I put this code in, I dont get the type mismatch error but it still doesn't work. On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(changeObj, Delegate.create(this,change)); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
it is actually colorBox.addEventListener(change, Delegate.create (this, changeObj)); just forgot the ), but still does not work On Nov 20, 2009, at 4:12 AM, Karl DeSaulniers wrote: Yes. I tried both of those and nothing.. actually the one below gets an error Error: type mismatch colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Karl DeSaulniers wrote: If I put this code in, I dont get the type mismatch error but it still doesn't work. On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(changeObj, Delegate.create(this,change)); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Hi, I think part of the problem is scope, but also your first argument to addEventListener should be the event type, not the function that is called. Did you try the call without Delegate - colorBox.addEventListener(change, changeObj); ? Glen ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Hey Glen, Yes I agree with you on how it should be, but for some reason flash allows it the other way. Yes I did try it the way you suggested when I first started working on it. That is the text book way. that is why I am puzzled. I went to the source and the source isn't working. plus the whole allowance of the malformed event listener. weird. still doesn't work though.. **Sigh** Karl On Nov 20, 2009, at 4:31 AM, Glen Pike wrote: Karl DeSaulniers wrote: If I put this code in, I dont get the type mismatch error but it still doesn't work. On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(changeObj, Delegate.create (this,change)); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Hi, I think part of the problem is scope, but also your first argument to addEventListener should be the event type, not the function that is called. Did you try the call without Delegate - colorBox.addEventListener (change, changeObj); ? Glen ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
If you are doing multiple anonymous functions, you might have to use the naming convention for the combo boxes and picture boxes - if you have multiple instances of these - so when you get a change event on combo1, that's associated with picture_box_1, etc? Karl DeSaulniers wrote: I think the scope is lost in the colorBox not knowing which picBox to associate itself with. :-/ Karl On Nov 20, 2009, at 4:16 AM, Karl DeSaulniers wrote: it is actually colorBox.addEventListener(change, Delegate.create(this, changeObj)); just forgot the ), but still does not work On Nov 20, 2009, at 4:12 AM, Karl DeSaulniers wrote: Yes. I tried both of those and nothing.. actually the one below gets an error Error: type mismatch colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Right! How to do that though I guess is my main issue. I cant assign pr to picBox or colorBox. Karl On Nov 20, 2009, at 4:43 AM, Glen Pike wrote: If you are doing multiple anonymous functions, you might have to use the naming convention for the combo boxes and picture boxes - if you have multiple instances of these - so when you get a change event on combo1, that's associated with picture_box_1, etc? Karl DeSaulniers wrote: I think the scope is lost in the colorBox not knowing which picBox to associate itself with. :-/ Karl On Nov 20, 2009, at 4:16 AM, Karl DeSaulniers wrote: it is actually colorBox.addEventListener(change, Delegate.create (this, changeObj)); just forgot the ), but still does not work On Nov 20, 2009, at 4:12 AM, Karl DeSaulniers wrote: Yes. I tried both of those and nothing.. actually the one below gets an error Error: type mismatch colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Do I need to be using colorBox.handleEvent(); ? Karl On Nov 20, 2009, at 4:39 AM, Karl DeSaulniers wrote: Hey Glen, Yes I agree with you on how it should be, but for some reason flash allows it the other way. Yes I did try it the way you suggested when I first started working on it. That is the text book way. that is why I am puzzled. I went to the source and the source isn't working. plus the whole allowance of the malformed event listener. weird. still doesn't work though.. **Sigh** Karl On Nov 20, 2009, at 4:31 AM, Glen Pike wrote: Karl DeSaulniers wrote: If I put this code in, I dont get the type mismatch error but it still doesn't work. On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(changeObj, Delegate.create (this,change)); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Hi, I think part of the problem is scope, but also your first argument to addEventListener should be the event type, not the function that is called. Did you try the call without Delegate - colorBox.addEventListener(change, changeObj); ? Glen ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
I think you can use the _name of the clip to assign pr: You might even be able to set this as a property on MovieClip as it's not a closed class... I am not sure about ComboBox though - try setting a property ID on it like you do with thumbHolder. From your code though, I can't work out how you are attaching the combobox as a valid clip... Here is what I managed to do by hacking your code to get the combo box to trace out the message onChange... import mx.controls.ComboBox; var thumbHolder:Object = new Object(); var picBox:MovieClip = new MovieClip(); var colorBox:ComboBox = new ComboBox(); var picturesArry = []; var colorHolder = []; var spacing:Number = 50; var numimages:Number = 2; for(var i = 0;i numimages;i++) { picturesArry[i] = i + .jpg; colorHolder[i] = []; for(var j = 0;j 10;j++) { colorHolder[i][j] = Colour + j; } } //Code for loading above arrays not included, but they load fine. var pr:Number = -1; function loadItems() { if (pr (numimages - 1)) { pr++; trace(loadItems + pr); thumbHolder = attachMovie(Affiliate_MC, Affiliate_MC + pr, pr); thumbHolder.ID = pr; var parentID = thumbHolder.ID; //thumbHolder.LoadVars(parentID); thumbHolder._x = 0; thumbHolder._y = pr * spacing; picBox = thumbHolder.attachMovie(picture_box, picture_box, thumbHolder.getNextHighestDepth()); picBox._width = 192; picBox._height = 152; picBox._x = 14; picBox._y = 11; //colorBox = thumbHolder.attachMovie(FComboBoxSymbol, os1_ + pr, thumbHolder.getNextHighestDepth()); colorBox = this.createClassObject(mx.controls.ComboBox, os1_ + pr, thumbHolder.getNextHighestDepth()); colorBox._width = 100; colorBox._height = 17; colorBox._x = 264; colorBox._y = 110; colorBox.enabled = true; thumbHolder.pic = picturesArry[thumbHolder.ID][0]; //thumbHolder[picture_box].loadMovie(thumbHolder.pic,0); var Colors:Array = new Array({label:Choose Color, data:}); colorBox.rowCount = colorHolder[pr].length; // populate dataProvider var colorBoxLength:Number = Colors.length; for (n = 0; n colorHolder[pr].length; n++) { Colors.push({label:colorHolder[pr][n], data:colorHolder[pr][n]}); colorBoxLength++; trace(item + pr + Adding color + colorHolder[pr][n]); } // set dropdown list colorBox.setDataProvider(Colors); if (colorBoxLength 3) { colorBox.selectedItem = 1; } else { colorBox.selectedItem = 0; } var changeObj:Object = new Object(); changeObj = function(evt_obj:Object) { trace(changeObj + this); var num:Number = thumbHolder.ID; var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[num][0]; //thumbHolder[picture_box].loadMovie(pic,0); //thumbHolder.LoadVars(pic); } else if (selectNum 1) { var pic = picturesArry[num][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); //thumbHolder.LoadVars(pic); } else { _root.itemSelection_mc.satusTXT.htmlText = ComboBox did not change; } }; colorBox.addEventListener(change,changeObj); } } for(var i = 0;i numimages;i++) { loadItems(); } Karl DeSaulniers wrote: Right! How to do that though I guess is my main issue. I cant assign pr to picBox or colorBox. Karl On Nov 20, 2009, at 4:43 AM, Glen Pike wrote: If you are doing multiple anonymous functions, you might have to use the naming convention for the combo boxes and picture boxes - if you have multiple instances of these - so when you get a change event on combo1, that's associated with picture_box_1, etc? Karl DeSaulniers wrote: I think the scope is lost in the colorBox not knowing which picBox to associate itself with. :-/ Karl On Nov 20, 2009, at 4:16 AM, Karl DeSaulniers wrote: it is actually colorBox.addEventListener(change, Delegate.create(this, changeObj)); just forgot the ), but still does not work On Nov 20, 2009, at 4:12 AM, Karl DeSaulniers wrote: Yes. I tried both of those and nothing.. actually the one below gets an error Error: type mismatch colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl On Nov 20, 2009, at 4:03 AM, Glen Pike wrote: colorBox.addEventListener(change, Delegate.create(this, changeObj); Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
Re: [Flashcoders] ComboBox troubles
Hey Glen, If it wouldn't be a trouble and I know this may sound odd, but could you send me a FLA with a combo box in it? no code, just the component on a blank stage? I am wondering if its just the combo box component that I have that isn't working. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Hi, Done that... Glen Karl DeSaulniers wrote: Hey Glen, If it wouldn't be a trouble and I know this may sound odd, but could you send me a FLA with a combo box in it? no code, just the component on a blank stage? I am wondering if its just the combo box component that I have that isn't working. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Glad to help. Karl DeSaulniers wrote: HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl On Nov 20, 2009, at 6:04 AM, Glen Pike wrote: Hi, Done that... Glen Karl DeSaulniers wrote: Hey Glen, If it wouldn't be a trouble and I know this may sound odd, but could you send me a FLA with a combo box in it? no code, just the component on a blank stage? I am wondering if its just the combo box component that I have that isn't working. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
One last thing. How do I get the first item in the combo box to show up? I got the text in the dropdown to show, but nothing in the main. Yours tested fine from your fla. so did the text?? Karl On Nov 20, 2009, at 6:23 AM, Glen Pike wrote: Glad to help. Karl DeSaulniers wrote: HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
...but also, I think you created your data provider Colors object with an empty / dummy row so make sure you are wanting to do that. Karl DeSaulniers wrote: One last thing. How do I get the first item in the combo box to show up? I got the text in the dropdown to show, but nothing in the main. Yours tested fine from your fla. so did the text?? Karl On Nov 20, 2009, at 6:23 AM, Glen Pike wrote: Glad to help. Karl DeSaulniers wrote: HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
I think you can set the selected index or something like that. Karl DeSaulniers wrote: One last thing. How do I get the first item in the combo box to show up? I got the text in the dropdown to show, but nothing in the main. Yours tested fine from your fla. so did the text?? Karl On Nov 20, 2009, at 6:23 AM, Glen Pike wrote: Glad to help. Karl DeSaulniers wrote: HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Empty data, but not label. not sure why it doesn't populate in my fla. it works fine when I publish the fla you sent (test1) and that has the same code. Karl On Nov 20, 2009, at 6:55 AM, Glen Pike wrote: ...but also, I think you created your data provider Colors object with an empty / dummy row so make sure you are wanting to do that. Karl DeSaulniers wrote: One last thing. How do I get the first item in the combo box to show up? I got the text in the dropdown to show, but nothing in the main. Yours tested fine from your fla. so did the text?? Karl On Nov 20, 2009, at 6:23 AM, Glen Pike wrote: Glad to help. Karl DeSaulniers wrote: HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Make sure you are using createClassObject rather than attaching the FComboBox movie? Karl DeSaulniers wrote: Empty data, but not label. not sure why it doesn't populate in my fla. it works fine when I publish the fla you sent (test1) and that has the same code. Karl On Nov 20, 2009, at 6:55 AM, Glen Pike wrote: ...but also, I think you created your data provider Colors object with an empty / dummy row so make sure you are wanting to do that. Karl DeSaulniers wrote: One last thing. How do I get the first item in the combo box to show up? I got the text in the dropdown to show, but nothing in the main. Yours tested fine from your fla. so did the text?? Karl On Nov 20, 2009, at 6:23 AM, Glen Pike wrote: Glad to help. Karl DeSaulniers wrote: HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
yes, that I stole from your code. :) that was part of it. my component was not working with mx.control.ComboBox. It is a UI component and not a compiled clip. When I copied your comboBox to my fla and used the createClassObject(mx.control.ComboBox it worked except the first item does not show and my dropdown box is very small... if its not one thing its another.. lol Karl On Nov 20, 2009, at 7:29 AM, Glen Pike wrote: Make sure you are using createClassObject rather than attaching the FComboBox movie? Karl DeSaulniers wrote: Empty data, but not label. not sure why it doesn't populate in my fla. it works fine when I publish the fla you sent (test1) and that has the same code. Karl On Nov 20, 2009, at 6:55 AM, Glen Pike wrote: ...but also, I think you created your data provider Colors object with an empty / dummy row so make sure you are wanting to do that. Karl DeSaulniers wrote: One last thing. How do I get the first item in the combo box to show up? I got the text in the dropdown to show, but nothing in the main. Yours tested fine from your fla. so did the text?? Karl On Nov 20, 2009, at 6:23 AM, Glen Pike wrote: Glad to help. Karl DeSaulniers wrote: HAHA Looks like that may be it. It doesn't load the data or label text, but it tries to call the picture change. Whoo hoo... well looks like you got me a little closer. Now I have to set my styles i guess? Thanks a lot for your input and time. Karl ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Are you targeting FP6 - if I set my Publish Settings to that, it does not select the first item... Karl DeSaulniers wrote: yes, that I stole from your code. :) that was part of it. my component was not working with mx.control.ComboBox. It is a UI component and not a compiled clip. When I copied your comboBox to my fla and used the createClassObject(mx.control.ComboBox it worked except the first item does not show and my dropdown box is very small... if its not one thing its another.. lol ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
no flash 8 and I got it to work with .setFocus(); and setting the styles. :) going to go see if it will work online. I finally figured out how to get the ID of the parent MC (thumbHolder) LYK Karl On Nov 20, 2009, at 8:07 AM, Glen Pike wrote: Are you targeting FP6 - if I set my Publish Settings to that, it does not select the first item... Karl DeSaulniers wrote: yes, that I stole from your code. :) that was part of it. my component was not working with mx.control.ComboBox. It is a UI component and not a compiled clip. When I copied your comboBox to my fla and used the createClassObject(mx.control.ComboBox it worked except the first item does not show and my dropdown box is very small... if its not one thing its another.. lol ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Well finally got it. Thank you for your help Glen, you put me in the right direction. Here's what got it to work finally... var selectNum:Number; var num:Number; var pict:String; var changeObj:Object = new Object(); changeObj.change = function(evt_obj:Object) { trace(parent ID = + evt_obj.target._parent.ID); trace(selectedIndex = + evt_obj.target.selectedIndex); num = evt_obj.target._parent.ID; selectNum = evt_obj.target.selectedIndex; if (selectNum 1) { pict = picturesArry[num][evt_obj.target.selectedIndex - 1]; evt_obj.target._parent[picture_box].loadMovie(pict,0); evt_obj.target._parent.LoadVars(pict); trace(New picture url is: + pict + newline + Picture Array: + picturesArry[num]); } else if (selectNum = 1) { pict = picturesArry[num][0]; evt_obj.target._parent[picture_box].loadMovie(pict,0); evt_obj.target._parent.LoadVars(pict); trace(New picture url is: + pict + newline + Picture Array: + picturesArry[num]); } else { _root.itemSelection_mc.satusTXT.htmlText = CobmoBox did not change; } }; colorBox.addEventListener(change, changeObj); **Whew** Best, Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Actually this is better. It checks to see if there are multiple pictures before trying to load one even if the combobox has more than one selection. Thanks Barry, thanks Glen. I'm done. Good night... var selectNum:Number; var num:Number; var pict:String; var changeObj:Object = new Object(); changeObj.change = function(evt_obj:Object) { trace(parent ID = + evt_obj.target._parent.ID); trace(selectedIndex = + evt_obj.target.selectedIndex); num = evt_obj.target._parent.ID; selectNum = evt_obj.target.selectedIndex; var checkPics:Number = picturesArry[num].length; if (checkPics 1) { if (selectNum 1) { pict = picturesArry[num][evt_obj.target.selectedIndex - 1]; evt_obj.target._parent[picture_box].loadMovie(pict,0); evt_obj.target._parent.LoadVars(pict); trace(New picture url is: + pict + newline + Picture Array: + picturesArry[num]); } else if (selectNum = 1) { pict = picturesArry[num][0]; evt_obj.target._parent[picture_box].loadMovie(pict,0); evt_obj.target._parent.LoadVars(pict); trace(New picture url is: + pict + newline + Picture Array: + picturesArry[num]); } else { _root.itemSelection_mc.satusTXT.htmlText = CobmoBox did not change; } } }; colorBox.addEventListener(change, changeObj); **Whew** Best, Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Nice one - hometime for me too :) Karl DeSaulniers wrote: ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
LOL its 11:45 am here. been up all night.. :P Karl On Nov 20, 2009, at 11:37 AM, Glen Pike wrote: Nice one - hometime for me too :) Karl DeSaulniers wrote: ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
I think the problem is that it is nested inside a function loadItem (). But not entirely sure. I am aware that this is not the best practice, so I tried moving it out of the function, but to no avail. I have created the code by the book but it still does not work. What am I doing wrong here??? Karl On Nov 18, 2009, at 10:40 PM, Karl DeSaulniers wrote: Nope. Those didn't work either. Its just not registering the change ?? Karl On Nov 18, 2009, at 9:32 PM, Barry Hannah wrote: Hey Karl. The issue you are facing is that the function on the comboListen object (comboListen.change) steals your scope - so you don't have any access to all the things you need: picturesArry, thumbHolder etc. So, you can either, forget creating an object to handle events and just put your change function right there: function change(evt_obj:Object) { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, this); Or, use the Delegate class to set the correct scope: import mx.utils.Delegate; var comboListen = new Object(); comboListen.change = Delegate.create(this, onChange); function onChange() { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, comboListen); Barry. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: Thursday, 19 November 2009 2:28 p.m. To: Flash Coders List Subject: Re: [Flashcoders] ComboBox troubles Oh and this is an AS2 project too. Karl Sent from losPhone On Nov 18, 2009, at 7:22 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello List, Have a little snag on my hands. I am trying to get the value of a selected comboBox to change the picture of another MC. My code: var comboListen = new Object(); comboListen.change = function(evt_obj:Object) { trace(evt_obj.selectedIndex); var selectNum:Number = evt_obj.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } }; colorBox.addEventListener(change,comboListen); thumbHolder = main MC that holds the picture and the comboBox [picture_box] = the picture MC inside thumbHolder that I want to load into. colorBox = the comboBox inside thumbHolder that I want to change the picture MCs contents with. FYI, by the time I get to using the listener, [picture_box] has already been loaded with the first image in the array of pictures. thumbHolder, colorBox and [picture_box] are dynamically loaded onto the stage at run time. How do I get colorBox's selection to change the picture in thumbHolder[picture_box]? Any help would be greatly appreciated at this point. this is my third day with this and I'm going crazy. Is there something I need to import to control the comboBox? I have import mx.control.ComboBox; already imported, do I need it? Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo
Re: [Flashcoders] ComboBox troubles
Hi, Are you doing something like the following - you need to use the Delegate.create function to attach scope to your event handlers. I can't remember if you can pass in the event object or not - try it? HTH Glen import mx.utils.Delegate; class MyMovieClip extends MovieClip { private var colorBox:ComboBox; //... function stuffHasLoaded():Void { colorBox.addEventListener(change, Delegate.create(this, change)); } function change():Void { trace(Hello from + this + .change); var selected:Number = colorBox.selectedIndex; //... } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] ComboBox troubles
Hello List, Have a little snag on my hands. I am trying to get the value of a selected comboBox to change the picture of another MC. My code: var comboListen = new Object(); comboListen.change = function(evt_obj:Object) { trace(evt_obj.selectedIndex); var selectNum:Number = evt_obj.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } }; colorBox.addEventListener(change,comboListen); thumbHolder = main MC that holds the picture and the comboBox [picture_box] = the picture MC inside thumbHolder that I want to load into. colorBox = the comboBox inside thumbHolder that I want to change the picture MCs contents with. FYI, by the time I get to using the listener, [picture_box] has already been loaded with the first image in the array of pictures. thumbHolder, colorBox and [picture_box] are dynamically loaded onto the stage at run time. How do I get colorBox's selection to change the picture in thumbHolder [picture_box]? Any help would be greatly appreciated at this point. this is my third day with this and I'm going crazy. Is there something I need to import to control the comboBox? I have import mx.control.ComboBox; already imported, do I need it? Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Oh and this is an AS2 project too. Karl Sent from losPhone On Nov 18, 2009, at 7:22 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello List, Have a little snag on my hands. I am trying to get the value of a selected comboBox to change the picture of another MC. My code: var comboListen = new Object(); comboListen.change = function(evt_obj:Object) { trace(evt_obj.selectedIndex); var selectNum:Number = evt_obj.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } }; colorBox.addEventListener(change,comboListen); thumbHolder = main MC that holds the picture and the comboBox [picture_box] = the picture MC inside thumbHolder that I want to load into. colorBox = the comboBox inside thumbHolder that I want to change the picture MCs contents with. FYI, by the time I get to using the listener, [picture_box] has already been loaded with the first image in the array of pictures. thumbHolder, colorBox and [picture_box] are dynamically loaded onto the stage at run time. How do I get colorBox's selection to change the picture in thumbHolder[picture_box]? Any help would be greatly appreciated at this point. this is my third day with this and I'm going crazy. Is there something I need to import to control the comboBox? I have import mx.control.ComboBox; already imported, do I need it? Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] ComboBox troubles
Hey Karl. The issue you are facing is that the function on the comboListen object (comboListen.change) steals your scope - so you don't have any access to all the things you need: picturesArry, thumbHolder etc. So, you can either, forget creating an object to handle events and just put your change function right there: function change(evt_obj:Object) { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, this); Or, use the Delegate class to set the correct scope: import mx.utils.Delegate; var comboListen = new Object(); comboListen.change = Delegate.create(this, onChange); function onChange() { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, comboListen); Barry. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: Thursday, 19 November 2009 2:28 p.m. To: Flash Coders List Subject: Re: [Flashcoders] ComboBox troubles Oh and this is an AS2 project too. Karl Sent from losPhone On Nov 18, 2009, at 7:22 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello List, Have a little snag on my hands. I am trying to get the value of a selected comboBox to change the picture of another MC. My code: var comboListen = new Object(); comboListen.change = function(evt_obj:Object) { trace(evt_obj.selectedIndex); var selectNum:Number = evt_obj.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } }; colorBox.addEventListener(change,comboListen); thumbHolder = main MC that holds the picture and the comboBox [picture_box] = the picture MC inside thumbHolder that I want to load into. colorBox = the comboBox inside thumbHolder that I want to change the picture MCs contents with. FYI, by the time I get to using the listener, [picture_box] has already been loaded with the first image in the array of pictures. thumbHolder, colorBox and [picture_box] are dynamically loaded onto the stage at run time. How do I get colorBox's selection to change the picture in thumbHolder[picture_box]? Any help would be greatly appreciated at this point. this is my third day with this and I'm going crazy. Is there something I need to import to control the comboBox? I have import mx.control.ComboBox; already imported, do I need it? Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] ComboBox troubles
Thanks for that Barry. I will test and see. Thats funny, it seems I was so close at one point. I had function comboListen(evt_obj:Object) { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(comboListen); Guess I forgot the this also.. Will let you know if one of these work. Thanks again, Karl On Nov 18, 2009, at 9:32 PM, Barry Hannah wrote: Hey Karl. The issue you are facing is that the function on the comboListen object (comboListen.change) steals your scope - so you don't have any access to all the things you need: picturesArry, thumbHolder etc. So, you can either, forget creating an object to handle events and just put your change function right there: function change(evt_obj:Object) { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, this); Or, use the Delegate class to set the correct scope: import mx.utils.Delegate; var comboListen = new Object(); comboListen.change = Delegate.create(this, onChange); function onChange() { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, comboListen); Barry. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: Thursday, 19 November 2009 2:28 p.m. To: Flash Coders List Subject: Re: [Flashcoders] ComboBox troubles Oh and this is an AS2 project too. Karl Sent from losPhone On Nov 18, 2009, at 7:22 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello List, Have a little snag on my hands. I am trying to get the value of a selected comboBox to change the picture of another MC. My code: var comboListen = new Object(); comboListen.change = function(evt_obj:Object) { trace(evt_obj.selectedIndex); var selectNum:Number = evt_obj.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } }; colorBox.addEventListener(change,comboListen); thumbHolder = main MC that holds the picture and the comboBox [picture_box] = the picture MC inside thumbHolder that I want to load into. colorBox = the comboBox inside thumbHolder that I want to change the picture MCs contents with. FYI, by the time I get to using the listener, [picture_box] has already been loaded with the first image in the array of pictures. thumbHolder, colorBox and [picture_box] are dynamically loaded onto the stage at run time. How do I get colorBox's selection to change the picture in thumbHolder[picture_box]? Any help would be greatly appreciated at this point. this is my third day with this and I'm going crazy. Is there something I need to import to control the comboBox? I have import mx.control.ComboBox; already imported, do I need it? Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
Re: [Flashcoders] ComboBox troubles
Nope. Those didn't work either. Its just not registering the change ?? Karl On Nov 18, 2009, at 9:32 PM, Barry Hannah wrote: Hey Karl. The issue you are facing is that the function on the comboListen object (comboListen.change) steals your scope - so you don't have any access to all the things you need: picturesArry, thumbHolder etc. So, you can either, forget creating an object to handle events and just put your change function right there: function change(evt_obj:Object) { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic, 0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, this); Or, use the Delegate class to set the correct scope: import mx.utils.Delegate; var comboListen = new Object(); comboListen.change = Delegate.create(this, onChange); function onChange() { var selectNum:Number = colorBox.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } } colorBox.addEventListener(change, comboListen); Barry. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl DeSaulniers Sent: Thursday, 19 November 2009 2:28 p.m. To: Flash Coders List Subject: Re: [Flashcoders] ComboBox troubles Oh and this is an AS2 project too. Karl Sent from losPhone On Nov 18, 2009, at 7:22 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello List, Have a little snag on my hands. I am trying to get the value of a selected comboBox to change the picture of another MC. My code: var comboListen = new Object(); comboListen.change = function(evt_obj:Object) { trace(evt_obj.selectedIndex); var selectNum:Number = evt_obj.selectedIndex; if (selectNum = 1) { var pic = picturesArry[thumbHolder.ID][0]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } else { var pic = picturesArry[thumbHolder.ID][selectNum]; thumbHolder[picture_box].loadMovie(pic,0); thumbHolder.LoadVars(pic); } }; colorBox.addEventListener(change,comboListen); thumbHolder = main MC that holds the picture and the comboBox [picture_box] = the picture MC inside thumbHolder that I want to load into. colorBox = the comboBox inside thumbHolder that I want to change the picture MCs contents with. FYI, by the time I get to using the listener, [picture_box] has already been loaded with the first image in the array of pictures. thumbHolder, colorBox and [picture_box] are dynamically loaded onto the stage at run time. How do I get colorBox's selection to change the picture in thumbHolder[picture_box]? Any help would be greatly appreciated at this point. this is my third day with this and I'm going crazy. Is there something I need to import to control the comboBox? I have import mx.control.ComboBox; already imported, do I need it? Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders