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/flashcoders

Reply via email to