SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with image rotation

    Hi all,

    I've got an action script that doesn't seem to work .
    the script runs and the traces show all the pictures but it skips one picture.

    here's what I got.

    any help would be asume..

    peanuts
    Code:
    var pictures:Array;
    var totalPictures:Number;
    var delay:Number;
    var idx:Number = 0;
    
    var LV:LoadVars = new LoadVars();
    LV.onLoad = function(ok)
    {
     if(ok)
     {
      delay = this.phpDelay * 1000;
      trace("delay loaded from php:" + delay);
      pictures = this.Response.split("|");
      totalPictures = pictures.length-1;
      trace("TotalPictures : " + totalPictures);
      showPicture();
     }
     else
     {
      trace("Error connecting to server");
     }
    }
    LV.load("http://url/flashvariables.php");
    function showPicture()
    {
     trace("idx start showPicture:"+idx);
     
     
     content_mc.contentPath = pictures[idx];
     trace("path:" + pictures[idx]);
     trace("idx aftercontent:"+idx);
     if(idx == totalPictures-1)
     {
      idx = 0;
     }else
     {
      idx++;
     }
     trace("idx aftercountercheck "+idx);
      setInterval(showPicture, delay);
     
    }
    the neigbours (free) WIFI makes it just a little more fun

  2. #2
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it skipping the same picture all the time? ie: always the first or last picture? Or does it just randomly skip one picture?

  3. #3
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should init your variables first, it's important with AS2:
    Code:
    var totalPictures:Number = 0;
    var delay:Number = 0;

  4. #4
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi it's as3

    and the tracer clearly shows that the variables are loaded..

    the thing is that it's skipping the same picture each time and I've checked with traces and the functions actually run all pictures but it just skipps 1 of them ..
    could it have to do with a missing interval clear?

    peanuts
    the neigbours (free) WIFI makes it just a little more fun

  5. #5
    SitePoint Member
    Join Date
    Apr 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    LV.load("http://url/flashvariables.php");
    as an example, this is clearly not AS3 ...

  6. #6
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What number image is it skipping? The first or last in the chain will indicate an iteration issue, if it's in the middle of the chain it'll be something more devious.

  7. #7
    SitePoint Wizard jim_morrison3's Avatar
    Join Date
    Apr 2004
    Location
    UK
    Posts
    2,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its certainly not an AS3 code as LoadVars class has been replaced by the Loader and the URLLoader class.
    Good Luck!
    There are things known and Things unknown
    And in between are the Doors.
    I love hand Coding.

  8. #8
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm
    In flash it says it's AS3

    I solved it .. I misread the reference on interval. I was calling interval to often as I thought it was a pause function which it clearly isn't ..

    It's working now..

    Thanks!
    the neigbours (free) WIFI makes it just a little more fun


Bookmarks

Posting Permissions

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