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
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl DeSaulniers
Design Drumm
http://designdrumm.com

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl DeSaulniers
Design Drumm
http://designdrumm.com

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl DeSaulniers
Design Drumm
http://designdrumm.com

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to