crimsonsmeagol
02-25-2009, 05:19 PM
I am loading images into a scroll pane from an XML file and I need to center it inside the scroll pane if the image is smaller then the scroll pane. How can I do this?
This is the code I have but it says it cannot access a property or method of a null object reference.
private function onImageSelected(event:Event):void
{
var image:Image = event.target.selectedItem.data as Image;
var index:int = event.target.selectedIndex;
_thumbnails_tl.selectedIndex = index;
_title_lbl.text = image.name + "\n" + image.desc;
_imagePane_sp.source = image.file;
var desiredWidth = 800;
if(_imagePane_sp.content.width < desiredWidth) {
_imagePane_sp.content.x = (desiredWidth - _imagePane_sp.content.width)/2;
} else {
_imagePane_sp.content.x = 0;
}
}
Thank you in advance for all of your help.
This is the code I have but it says it cannot access a property or method of a null object reference.
private function onImageSelected(event:Event):void
{
var image:Image = event.target.selectedItem.data as Image;
var index:int = event.target.selectedIndex;
_thumbnails_tl.selectedIndex = index;
_title_lbl.text = image.name + "\n" + image.desc;
_imagePane_sp.source = image.file;
var desiredWidth = 800;
if(_imagePane_sp.content.width < desiredWidth) {
_imagePane_sp.content.x = (desiredWidth - _imagePane_sp.content.width)/2;
} else {
_imagePane_sp.content.x = 0;
}
}
Thank you in advance for all of your help.