A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: swapping images in uiloader using code ?

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    20

    swapping images in uiloader using code ?

    I'm working in flash Cs4 and I just learned cash and I'm wondering if there's a way to use the Uiloader to load multiple images and have them change every couple of secondes like msn or actionvillage. This is my code so far:

    next_btn.addEventListener(MouseEvent.CLICK, nextImage);

    var imageNumber:Number = 1

    function checkNumber():void
    {
    next_btn.visible=true;
    back_btn.visible=true;

    if(imageNumber>3){
    trace(imageNumber);
    //next_btn.visible = false;
    imageNumber = 1;
    }
    }
    function checkNum():void
    {
    if(imageNumber<1){
    imageNumber = 3;
    }
    }


    function nextImage (evtObj:MouseEvent):void
    {
    imageNumber++;
    checkNumber();
    largeImageLoader.source = "images/poster"+imageNumber+".png";
    }

    back_btn.addEventListener(MouseEvent.CLICK, backImage);

    function backImage (evtObj:MouseEvent):void
    {
    imageNumber--;
    checkNum();
    largeImageLoader.source = "images/poster"+imageNumber+".png";

    }


    I have buttons below my uiloader that changes the images when you click on the manually but when you don't click on the arrows I would like the images to change automatically.

    Any help would be appreciated, thank you.

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    var myInterval:uint = setInterval(changeImageFunction,5000);

    Above runs the function every 5 secs. The following source has more on it.

    http://www.republicofcode.com/tutori...s3setinterval/

  3. #3
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    moved to AS 30.0

    gparis

  4. #4
    Junior Member
    Join Date
    Jun 2010
    Posts
    20
    THANK YOU! It really helped I have part of it working. Much thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center