trujuice
02-03-2005, 11:51 PM
I am having trouble getting a dynamic image popup window to work correctly. Here is a sample of the code.
import mx.managers.PopUpManager;
import mx.containers.Window;
var newWindow=Null;
windowListener = new Object();
windowListener.click = function(evt){
newWindow.deletePopUp();
}
windowListener.complete = function(evt){
if(newWindow.content._height>0)
{
newWindow.setSize(newWindow.content._width+6,newWi ndow.content._height+34);
center();
newWindow.title="Image Loaded";
}
else
{
newWindow.title="Couldn't Load Image";
}
}
function center()
{
newWindow._x=(400-(newWindow._width/2));
newWindow._y=(300-(newWindow._height/2));
}
thumbnail1.onRelease = function() {
newWindow.deletePopUp();
newWindow = PopUpManager.createPopUp(this, Window, false, {title:"Loading Image", closeButton:true,contentPath:"/images/largeimage1.jpg"});
newWindow.setSize(150,30);
center();
newWindow.addEventListener("click", windowListener);
newWindow.addEventListener("complete", windowListener);
}
What is happening is the "complete" event is being returned before the image is completely loaded. This results in the window not centering and the title reading as if the image couldn't load.
But ofcourse this doesn't occur everytime, its really dependent on how large the image being loaded is.
What I am trying to accomplish is center the image after it loads and some form of error checking which would indicate if the image couldn't be found.
Any thought and or suggestions would be greatly appreciated.
-=JuicE=-
import mx.managers.PopUpManager;
import mx.containers.Window;
var newWindow=Null;
windowListener = new Object();
windowListener.click = function(evt){
newWindow.deletePopUp();
}
windowListener.complete = function(evt){
if(newWindow.content._height>0)
{
newWindow.setSize(newWindow.content._width+6,newWi ndow.content._height+34);
center();
newWindow.title="Image Loaded";
}
else
{
newWindow.title="Couldn't Load Image";
}
}
function center()
{
newWindow._x=(400-(newWindow._width/2));
newWindow._y=(300-(newWindow._height/2));
}
thumbnail1.onRelease = function() {
newWindow.deletePopUp();
newWindow = PopUpManager.createPopUp(this, Window, false, {title:"Loading Image", closeButton:true,contentPath:"/images/largeimage1.jpg"});
newWindow.setSize(150,30);
center();
newWindow.addEventListener("click", windowListener);
newWindow.addEventListener("complete", windowListener);
}
What is happening is the "complete" event is being returned before the image is completely loaded. This results in the window not centering and the title reading as if the image couldn't load.
But ofcourse this doesn't occur everytime, its really dependent on how large the image being loaded is.
What I am trying to accomplish is center the image after it loads and some form of error checking which would indicate if the image couldn't be found.
Any thought and or suggestions would be greatly appreciated.
-=JuicE=-