How do you assign drag properties to items added to a scrollPane? This is my code.
Thanks for any help
[COLOR=#808080]*[COLOR=#000000]var myXML:XML = new XML();
myXML.ignoreWhite = true;
libraryList_ar = new Array();
combo_list.dataProvider = libraryList_ar;
myXML.onLoad = function(success) {
if (success) {
//trace(this);
var libraries = this.firstChild;
var dValue = this.firstChild.attributes.name;
//trace(dValue);
combo_list.textField.label.text = "Library";
var libCount = libraries.childNodes.length;
trace(libCount);
var libItems = libraries.firstChild.childNodes.length;
//trace(libItems);
for (var i = 0; i<libCount; i++) {
//libraryList_ar* = libraries.childNodes*.childNodes[0].firstChild.nodeValue;
libraryList_ar* = new Object();
libraryList_ar*.label = libraries.childNodes*.attributes.Text;
libraryList_ar*.data = libraries.childNodes*;
//save reference here
}
}
};
myXML.load("itemMenu.xml");
//
loading_txt.autoSize = true;
loading_txt.text = "";
loading_txt._visible = false;
// resize loading images to thumbnail size
var MAX_WIDTH:Number = 50;
var MAX_HEIGHT:Number = 50;
//
var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadInit = function(mc:MovieClip) {
loading_txt.text = "Loading...";
// set variables to keep the original image dimensions
var xw = mc._width;
var xh = mc._height;
//
// where image width is greater than image height
if (mc._width>mc._height) {
mc._width = MAX_WIDTH;
mc._height = (mc._height*MAX_WIDTH)/xw;
// center image
mc._y = (75-mc._height)/2;
}
//where image height is greater than image width
if (mc._height>mc._width) {
mc._height = MAX_HEIGHT;
mc._width = (mc._width*MAX_HEIGHT)/xh;
mc._x = (75-mc._width)/2;
}
//
//
loading_txt._visible = false;
};
//
_global.count = 0;
//
combo_list.change = function(eventObj) {
thumbs.invalidate();
thumbs.refreshPane();
//
var selItem:Object = eventObj.target.selectedItem;
//trace("Item selected was: "+selItem.label);
var itemXML:XMLNode = selItem.data;
//use saved reference to iterate through childNodes
for (var idx = 0; idx<itemXML.childNodes.length; idx++) {
trace("Item includes: "+itemXML.childNodes[idx].attributes.Text);
var t_mc:MovieClip;
t_mc = thumbs.content.attachMovie("thumb_mc", "thumb"+idx, idx, this.getNextHighestDepth());
t_mc._x = 5;
t_mc._y = 5+(idx*80);
//this loads the swf into the thumbs scrollPane
_root["mc"+idx] = new MovieClipLoader();
_root["mc"+idx].addListener(mclListener);
_root["mc"+idx].loadClip("decals/"+itemXML.childNodes[idx].attributes.ItemSWF+".swf", t_mc.Container_mc);
//
t_mc.idx = idx;
t_mc.piece = itemXML.childNodes[idx].attributes.ItemSWF;
//
t_mc.onRelease = function() {
//trace(this.now)
// this adds the item to the room
var tmp:MovieClip = room.content.createEmptyMovieClip("myLoader"+count, count+100);
count++;
mcl.loadClip("decals/"+this.piece+".swf", tmp);
tmp._x = 100;
tmp._y = 100;
room.invalidate();
trace("tmp= "+tmp);
_global.temp_mc = tmp;
//_global.temp_mc = room.content;
};
}
};
combo_list.addEventListener("change", combo_list);
//
clear_btn.onRelease = function() {
//trace(count);
count--;
room.content["myLoader"+count]._visible = 0;
//room.content.temp_mc._visible = 0;
if (count == -1) {
mx.controls.Alert.show("The room is empty!");
count = 0;
}
};
//
room.content["myLoader"+count].onPress = function() {
this.startDrag();
};
[/COLOR]*[/COLOR]