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
[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

Reply via email to