I am using the freeTransform script found at senocular.com. First, here is what I have; a combo box, thumbs scrollpane and a room scrollPane. When the movie starts I load an XML file into the combo box.
If I click on a label in the combo box, those items appear in the thumbs scrollPane. If I click on one of these thumb items, that item’s swf is loaded into the room scrollPane. Everything so far so good.
The freeTransform script is part of the swf that get loaded. So if I click on a swf in the room scrollPane the freeTransform script fires and everything runs ok.
I have 3 problems, any mouse events applied to the room.content prohibits the freeTransfrom script from running. I am not sure why. I am not sure if having the freeTransform script embedded in the swf is the correct application of this script. Although it seems work ok this way. If I remove this mouse events the script runs correctly as stated earlier.
The second problem I need help on is how to keep the swf constrained to the boundries of the room.
The thrid issue, I want to be able to click on an item in the room and clear it or remove it. I have this working somewhat in the clear_btn function only it removes the items in the order they were added which I don’t want, I want to click on an item and remove it.
My code is pretty simple so I’ll post it here, maybe someone can help.
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.name;
libraryList_ar*.data = libraries.childNodes*;
//save reference here
}
}
};
myXML.load("myXML.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.source);
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 item image into the thumbs scrollPane
_root["mc"+idx] = new MovieClipLoader();
_root["mc"+idx].addListener(mclListener);
_root["mc"+idx].loadClip(itemXML.childNodes[idx].attributes.image, t_mc.Container_mc);
//
t_mc.idx = idx;
t_mc.now = itemXML.childNodes[idx].attributes.source;
//
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(this.now+".swf", tmp);
tmp._x = 50;
tmp._y = 50;
room.invalidate();
trace("tmp= "+tmp);
_global.temp_mc = tmp;
};
}
};
combo_list.addEventListener("change", combo_list);
//
clear_btn.onRelease = function() {
trace(count);
count--;
room.content["myLoader"+count]._visible = 0;
if (count == -1) {
mx.controls.Alert.show("The room is empty!");
count = 0;
}
};