Animator and downloaded images

I have a page that loads a couple graphics (one is 800x600, the other is 540x70). Both are loaded via url into a WebImageView control. On the 540x70 graphic, I am trying to run a WebAnimator. In the Shown event of the smaller graphic I have:

Animator1.Opacity(me,0,0)
Animator1.Play

After a few seconds, I run this from a Timer:

Animator1.Opacity(Graphic2,100,2)
Animator1.Play

Problem is, the first set of commands doesn’t work unless I delay the commands by about 1 second. No errors (which I don’t understand), it just doesn’t work. I have a feeling the graphic is not quite downloaded when the command is initiated (even though the commands are in the Shown event of the graphic being downloaded).

Is there any way to get a DownloadComplete event to fire when the graphic is downloaded? This would be better than just using a fixed delay.

A way to get around these timing issues is to fire off a single mode timer from the shown event that runs your first animator code, and from the animation complete start the second timer that kicks off the second set of animator code.

I think the hard part is picking the delay for first timer. Seems like this will vary quite a bit and it is hard to anticipate how much it will vary.

Also, the Shown event for the graphic is later than the Shown event for the Animator. So, when the Shown event for graphic fires, both will be Shown (but I realize I shouldn’t count on that). Because of this, shouldn’t stuff go in Shown event for graphic?

I forgot to mention that when you put the url to the graphic before the first Animator code (alpha to 0 lines), it doesn’t work. If you put the url after the alpha 0 code, it works.

When you use visible property, Animator doesn’t work but that is probably by design.

Thinking of trying to create a test app to demonstrate all these “problems.”

I created a separate test app to try to demonstrate the problems (I just copied the page out of my main app) but it works fine as a standalone page regardless of how animator is started, whether or not I use the visible property, or where the url occurs. Frustrating.

Just wanted to reiterate that everything works fine as long as I use a 1 second delay before trying to set Animator (setting alpha to 0 for graphic). Even so, I am hoping to find a better method to make this work reliably and with minimal delay on other (slower) computers with slower Internet speeds.

I am starting to wonder what the Shown event actually means. It seems like it is really PreShown (not the same as Open) since the Shown event can fire before controls are actually done loading. Can someone please clarify?

Is the Shown event for a web page always last? There needs to be some way of knowing when everything is fully downloaded and ready to go. Inserting a fixed timer delay is not the way to do this.

Shouldn’t there really be a PostShown event when everything settles down? I think the need for the timer implies controls aren’t quite done loading which seems to be a major problem for large apps. I think this is related to some other problems I have observed where inserting a timer fixes unexplained behavior.

[quote=88184:@Loren Staplin]I am starting to wonder what the Shown event actually means. It seems like it is really PreShown (not the same as Open) since the Shown event can fire before controls are actually done loading. Can someone please clarify?

Is the Shown event for a web page always last? [/quote]

WebControl.Shown should mean that the control is at the client. However, I do not believe that WebImageView.Shown takes into account image downloads. WebPage.Shown does not mean everything has loaded and is not guaranteed to be last.

I don’t know if there’s a way to verify that an image is at the client using just the Xojo framework. WebPicture.Downloaded, inherited from WebFile, fires when the client requests the file according to the docs, not when the file is there.

Web Custom Controls has a control which allows you to load any image by URL to the client. It fires an event when the image is at the client and ready for display.

Okay, that’s good to know. Being a novice Xojo user, my opinion doesn’t count for much. Nevertheless, this seems like a MAJOR problem. It essentially means cross-control coding is unreliable, especially in large apps. Splitting a large apps into multiple small apps might be an option for some people but in my opinion it is not desirable.

Why can’t every control have an IsShown property? I know I can do this myself but it seems like it should be built in. That way, you could check the IsShown status for all the objects on the page and get a PageLoaded event. The time it takes to load the page might be useful too.

Loren - it is an issue that Xojo web developers seem to run into. IMHO WebContainer.Shown should fire after all of its controls have fired Shown, and WebPage.Shown should fire after everything on the page has fired Shown.

I don’t think Shown should indicate image download in WebImageView, but I do think there should be a separate event to indicate this.

In my kit WebImageViewTD has an event to indicate that any/all changes to the image have taken effect (including new image download), and WebImageLoaderTD is the control that lets you load images into the client browser and receive events when they’re ready.