PDA

View Full Version : Issue with dynamic images in Popup window


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=-

trujuice
02-09-2005, 04:10 PM
I don't mean to be a bother but does anyone have ANY thoughts on this issue?

Thanks!!
-=JuicE=-

trujuice
02-17-2005, 04:43 PM
Is this just out of anyone's scope or have I just not helped enough others to warrent some suggestions on my problems? :confused:
-=JuicE=-

bob_la_matraque
02-17-2005, 05:17 PM
See this :
http://www.actionscript.org/forums/showthread.php3?t=65393

trujuice
02-17-2005, 08:34 PM
I think you have linked to the wrong thread. My problem is using the Flash 2005 Popup component to make custom windows within the flash movie that can be resized dynamically and centered to screen. I know how to make it work using an external javascript popup window. However, I feel that the custom windows look far more professional and allows for a higher degree of control. And my code works correctly its just the event listener for complete sometimes runs before it is actually complete. This is very strange the only thing I can think is that the complete event runs after the component itself is finished loading not necessarily after the content of the window is finished loading.
If this is the case is there a way to listen for the content load completed event.

Thanks for atleast a reply, maybe you have a different thread you wanted to refer me to.

-=JuicE=-

bob_la_matraque
02-18-2005, 08:26 AM
Soorry Juice I read your thread too fast... I Don't know how to solve your problem. Good luck, hope you'll find.

bob_la_matraque
02-18-2005, 01:14 PM
But the subjet hightly interests me! Do u know where I could find a tutorial to use those inner windows?

thx a lot...

JohnF
02-18-2005, 04:28 PM
In the thumbnail1.onRelease function, how does the thumbnail1 object resolve the address to the newWindow object?

I have had problems with references from inside components to other components, as the button, etc, is a movieclip and any other components it uses have to have a _parent or other pre-fix to tell it where the component actually is. Otherwise, you end up working with a variable that only exists within the scope of the function you are working in.

Is your code creating a variable called newWindow that is unrelated to the var newWindow=Null you set up in the timeline?

trujuice
02-21-2005, 06:34 PM
bob_la_matraque
Do u know where I could find a tutorial to use those inner windows?
Sorry I do not I just figured it out on my own using macromedia's online referrence.

JohnF
In the thumbnail1.onRelease function, how does the thumbnail1 object resolve the address to the newWindow object?

newWindow is defined on the same level that it is referenced in otherwise I would have to use some sort of _level[i]x[/] prefix.

Thanks guys for the thoughts thus far, I just think that these components are still fairly young and have not been used much. After awhile I'm sure that I will be able to find a solution. I truly think it is because the popup window sends the load complete event once it has created the containers "shell" for all the objects not actually loaded everything in these containers.

-=Juice=-