Navarone
10-12-2005, 11:02 PM
This might be a component question but I'll start here. First I am trying to get the actual image size of the image when I click on my thumbnail before it getloaded into my pictures scrollPane. I have set up global variables to capture the image sizes and attempted to set up an array. This only gives me the first image size in the array, if I click on another thumbnail, I get the same image size. I am not sure what I am doing wrong and would appreciate any help. :)
var myScrollPane:mx.containers.ScrollPane;
myScrollPane.contentPath = 'Holder_mc';
//
this.zoom_out.onPress = function() {
myScrollPane.content.myLoader.scaleX /= 1.5;
myScrollPane.content.myLoader.scaleY /= 1.5;
trace(myScrollPane.content.myLoader.scaleX);
myScrollPane.invalidate();
};
this.zoom_in.onPress = function() {
myScrollPane.content.myLoader.scaleX += 100;
myScrollPane.content.myLoader.scaleY += 100;
trace(myScrollPane.content.myLoader.scaleX);
myScrollPane.invalidate();
};
//
var MAX_WIDTH:Number = 65;
var MAX_HEIGHT:Number = 65;
var mclListener:Object = new Object();
mclListener.onLoadInit = function(mc:MovieClip) {
// set variables to keep the original image dimensions
_global.xw = mc._width;
_global.xh = mc._height;
//trace(xw);
//trace(xh);
// where image width is greater than image height
if (mc._width>mc._height) {
mc._width = MAX_WIDTH;
mc._height = (mc._height*MAX_WIDTH)/_global.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)/_global.xh;
mc._x = (75-mc._width)/2;
}
};
//
MyPicVars = new LoadVars();
MyPicVars.load("jetPlane.txt");
MyPicVars.onLoad = function(success) {
if (success) {
var t_mc:MovieClip;
Rc = this["Rc"];
//trace(Rc);
for (i=0; i<=Rc-1; i++) {
t_mc = thumbs.content.attachMovie("thumb_mc", "thumb"+i, i, this.getNextHighestDepth());
t_mc._x = 5;
t_mc._y = 5+(i*80);
// load images into thumbs scroll pane
_root["mc"+i] = new MovieClipLoader();
_root["mc"+i].addListener(mclListener);
_root["mc"+i].loadClip("jetPlane/"+this["pic"+i], t_mc.Container_mc);
//
t_mc.i = i;
t_mc.location = this["pic"+i];
t_mc.onRelease = function() {
//
img_size = new Array(_global.xw, _global.xh);
trace(img_size.join(","));
//
// load image into pictures scroll pane
//trace(this.location);
myScrollPane.content.myLoader.contentPath = "jetPlane/"+this.location;
myScrollPane.invalidate();
//trace(_global.xw)
//trace(_global.xh)
//trace(myScrollPane.content.myLoader.width);
//trace(myScrollPane.content.myLoader.height);
};
thumbs.invalidate();
}
} else {
trace("not loaded");
}
};
var myScrollPane:mx.containers.ScrollPane;
myScrollPane.contentPath = 'Holder_mc';
//
this.zoom_out.onPress = function() {
myScrollPane.content.myLoader.scaleX /= 1.5;
myScrollPane.content.myLoader.scaleY /= 1.5;
trace(myScrollPane.content.myLoader.scaleX);
myScrollPane.invalidate();
};
this.zoom_in.onPress = function() {
myScrollPane.content.myLoader.scaleX += 100;
myScrollPane.content.myLoader.scaleY += 100;
trace(myScrollPane.content.myLoader.scaleX);
myScrollPane.invalidate();
};
//
var MAX_WIDTH:Number = 65;
var MAX_HEIGHT:Number = 65;
var mclListener:Object = new Object();
mclListener.onLoadInit = function(mc:MovieClip) {
// set variables to keep the original image dimensions
_global.xw = mc._width;
_global.xh = mc._height;
//trace(xw);
//trace(xh);
// where image width is greater than image height
if (mc._width>mc._height) {
mc._width = MAX_WIDTH;
mc._height = (mc._height*MAX_WIDTH)/_global.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)/_global.xh;
mc._x = (75-mc._width)/2;
}
};
//
MyPicVars = new LoadVars();
MyPicVars.load("jetPlane.txt");
MyPicVars.onLoad = function(success) {
if (success) {
var t_mc:MovieClip;
Rc = this["Rc"];
//trace(Rc);
for (i=0; i<=Rc-1; i++) {
t_mc = thumbs.content.attachMovie("thumb_mc", "thumb"+i, i, this.getNextHighestDepth());
t_mc._x = 5;
t_mc._y = 5+(i*80);
// load images into thumbs scroll pane
_root["mc"+i] = new MovieClipLoader();
_root["mc"+i].addListener(mclListener);
_root["mc"+i].loadClip("jetPlane/"+this["pic"+i], t_mc.Container_mc);
//
t_mc.i = i;
t_mc.location = this["pic"+i];
t_mc.onRelease = function() {
//
img_size = new Array(_global.xw, _global.xh);
trace(img_size.join(","));
//
// load image into pictures scroll pane
//trace(this.location);
myScrollPane.content.myLoader.contentPath = "jetPlane/"+this.location;
myScrollPane.invalidate();
//trace(_global.xw)
//trace(_global.xh)
//trace(myScrollPane.content.myLoader.width);
//trace(myScrollPane.content.myLoader.height);
};
thumbs.invalidate();
}
} else {
trace("not loaded");
}
};