PDA

View Full Version : listener problems


lpx
12-12-2005, 12:05 PM
Hi,

I'm making a shoping cart in flash.

First i get the elements from a database and for each item i create textfields for describing them and at last a combobox to choose the quantity.

I need a listener to each combobox to make the update to the total price when a combobox is changed.

my actual configuration is:

- a container movie clip to put all the cart
- a scrollpane to contain all the item

i put all my actionscripting inside the movieclip that contains everything and it looks like this:

import mx.containers.ScrollPane;
var transact_sp:ScrollPane;

transact_sp.contentPath = "transact_container";
var path:MovieClip = transact_sp.content;

lo = new Object();
lo.change = function (evt){
trace("i'm here");
}
_root.transact_mc.path["transact_item"+i].quantity_cb.addEventListener("change",lo);

tractionData = new LoadVars();
tractionData.load(mainurl+"transact.php");
tractionData.onLoad = function() {
_global.ntransact = this.ntransact;
for (i=0;i<this.ntransact;i++) {
_root.transact_mc.path.attachMovie("transact_item","transact_item"+i,_root.transact_mc.path.getNextHighestDepth())
_root.transact_mc.path["transact_item"+i]._y = 10 + (30*i);
_root.transact_mc.path["transact_item"+i].transact_description.text = this["transact"+i+"Title"];
_root.transact_mc.path["transact_item"+i].transact_price.text = this["transact"+i+"Price"] + " ";
_root.transact_mc.path["transact_item"+i].quantity_cb.addEventListener("change",_root.transact_mc.lo);
_root.transact_mc.transact_sp.invalidate();
}
}

the problem is that i'm not having sucess in putting the items combobox's responding to the events.

i have a combobox in the movieclip that contains everything and it works fine with the listener, but the ones that are referenced by this:

_root.transact_mc.path["transact_item"+i].quantity_cb.addEventListener("change",_root.transact_mc.lo);

Dont work...

Any tips?

Many thx