4 Replies Latest reply on Sep 11, 2008 12:20 PM by bitwyse

    Timing and me...please help

    charger Level 1

      I'm creating a basic slideshow and am having an issue with the first image in the show:

      I read in a list of image urls from a xml file and populate an array with the urls. Then I use a for() loop to create an image object for each source url with the visible attribute set to false a la:

      image=new Image();
      I have defined the imagefadein/out effects earlier to fade from one image to another.
      Once the images are all added to the container canvas, I set the first image to be visible:
      And start the timer to rotate through the images:

      The problems are twofold:

      First, when I set the first image to visible=true it becomes visible but the fadein effect doesn't play. If I make the list of images only one image, then the effect plays fine. (I tried the same thing without the timer starting and the same result)

      Second, the timer starts before the images seem to be loaded, that is: the display time of the first image gets cut short as it seems that timer event to display the second image fires before or very shortly after the first image is displayed. I've tried using a custom event handler on the creationComplete event of the last image to start the timer, using the effectDone event on the first image to start the timer...etc.

      Nothing seems to work.

      Any help would be greatly appreciated.


        • 1. Re: Timing and me...please help
          EvolvedDSM Level 2
          Yikes! First off, to my knowledge if you want something to load after your application has finished all of it's loading, use the applicationComplete property instead of creationComplete. I've read a few articles in the past about the loading order that Flash player takes with Flex apps and most of them agree that applicationComplete does happen after creationComplete.

          I hope atleast this much helps. And actually the issue with your first picture not fading and your timer starting prematurely could both be solved with my suggestion (atleast in my head this works out =P)!

          Post back on your findings :)
          • 2. Re: Timing and me...please help
            charger Level 1

            Thanks for the reply. I guess I need to flesh out my app a little more:

            The slideshow is a component in a larger app. The app consists of:

            5 canvases controlled by a menu bar.
            One of these canvases (the slideshow) is displayed by selecting the "Photos" menu pick.
            The "Photos" canvas has one child, the slideshow component.
            All of the image loading etc. is done in the slideshow component.

            I've been lazy and haven't exposed any slideshow component methods.

            And I don't want the timer to start until the user clicks on the "Photos" menu pick and displays the canvas.

            Any more help?

            Here is the app in question:


            • 3. Re: Timing and me...please help
              EvolvedDSM Level 2
              Hmm, well I would have to do some look-ups on calling events on a menubar change. I haven't worked with menubar enough myself to have a deep knowledge of this component. Atleast from what I can tell, you need either an event listener to detect when you change canvases and call a function that could determine which menu you are on
              if (menu choice == 'Photo'){
              //add your start timer here

              or you need the "Photos" menu link itself to call a function that will start your timer.

              Since I haven't worked much with menubars, I'll check out event listeners for canvas changes. If anything I've said in this post as sparked thoughts on your end, try things out and post back.
              • 4. Re: Timing and me...please help
                bitwyse Level 1
                I think I can help you with the timer starting correctly but not the effects. I don't see any code that actually loads the image. I'm assuming your using some sort of httpService to fetch the image. If you add a resultHandler to the httpService call and start your timer in the result handler that should resolve the issue.

                I haven't done much with effects so I'm not sure how to get them to start / stop on demand.