PDA

View Full Version : help printing contents of scrollPane


Navarone
10-09-2005, 02:13 PM
I am trying to print the contents of myScrollPane but when I print all I get is blank sheet of paper. How can print the contents of myScrollPane :)


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
var xw = mc._width;
var 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)/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;
}
};
//
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() {
// load image into pictures scroll pane
//trace(this.location);
myScrollPane.content.myLoader.contentPath = "jetPlane/"+this.location;
myScrollPane.invalidate();
};
thumbs.invalidate();
}
} else {
trace("not loaded");
}
};


print code...

btn.onRelease = function() {
var pj = new PrintJob();
var success = pj.start();
if (success) {
pj.addPage("myScrollPane", {xMin:313, xMax:613, yMin:44, yMax:344});
pj.send();
}
delete pj;
};

Navarone
10-09-2005, 09:07 PM
ok, I figured out why I was getting a blank page, apperanlty the

xMin:0, xMax:550, yMin:0, yMax:555


are respective of the scrollPane. However, this does not solve my problem. If the image is larger than the scrollpane dimensions then the printed image gets cut off and the scrollbars get printed as well.

So I was trying to get the actual image dimensions so I tried this

trace(myScrollPane.content.myLoader.width);
trace(myScrollPane.content.myLoader.height);


The problem here is "myLoader" dimensions are 100x100 initially, until the after the first image loads, so in effect the actual image dimensions are alway one click behind. How can I get the actual image dimensions when the image loads.