2 Replies Latest reply on Aug 27, 2009 4:46 PM by Flex harUI

    Image scrolling

    Marlene Level 1

      Again, a noobie question. My question regards a pages that can be seen at http://www.alexisjean.com/yumyum/yumyum.html. The image is a single jpg image that I put together in Photoshop and measures 1600px by 181. I want the image to scroll smoothly and if the user can change its directions by click and dragging over it. Clicking does NOT open it into anything. It is really just there for decoration. Obviously I want the image to automatically scroll and scroll smoothly. I have been reading about the Bitmap class but that does not seem to matter here. The image lives in an mxml component and this is the code that makes it work. Appreciate any help, advice or direction. I could load the images separately if that makes a difference. Would I be better off working in Flash?

      import flash.events.TimerEvent;

          import flash.utils.Timer;

      private var scrollTimer:Timer = new Timer(1000);

       

      public function init():void {

       

      scrollTimer.addEventListener(TimerEvent.TIMER, scrollImages);

      scrollTimer.start();

      }

      public function scrollImages(event:Event):void {

      foodImages.x++;

       

      }

        • 1. Re: Image scrolling
          Flex harUI Adobe Employee

          How is foodImages defined?  Did you set includeInLayout=false?  Or put it in a Canvas with scrollbars?

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Image scrolling
            Marlene Level 1

            This is the whole code for the custom component. I used a canvas with scrollbars turned off.

             

             

            <?xml version="1.0" encoding="utf-8"?>

            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"

            creationComplete="init()" width="800" horizontalScrollPolicy="off" verticalScrollPolicy="off">

            <mx:Script>

             

            <![CDATA[

            import flash.events.TimerEvent;

                import flash.utils.Timer;

            private var scrollTimer:Timer = new Timer(1000);

             

            public function init():void {

             

            scrollTimer.addEventListener(TimerEvent.TIMER, scrollImages);

            scrollTimer.start();

            }

            public function scrollImages(event:Event):void {

            foodImages.x++;

             

            }

             

            ]]>

            </mx:Script>

             

            <mx:Image source="assets/images.jpg" id="foodImages"/>

            </mx:Canvas>