Results 1 to 9 of 9

Thread: Auto increment problem?

  1. #1
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Auto increment problem?

    I am ashamed that I can't seem to figure this out. I just need AS code that sets a variable starting at 1 and then auto increments to 7 then resets back to 1.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Code:
    var num:Number = 1;
    function increaseByOne() {
       if(num > 7) {
          num = 1;
       }
       else {
          num++;
       }
    }

  3. #3
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    How do I get the function to loop and then call the variable

    e.g.

    gotoAndStop(num);

  4. #4
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Please advise on why this is not working?

    Code:
    	var num:Number = 1;
    	function increaseByOne() {
       	if(num > 7) {
          num = 1;
       	}
       	else {
          num++;
       	  }
    	}
    	
    	i = num;
    	increaseByOne(i);
    	_root.partners.logos.gotoAndStop(i);

  5. #5
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Please explain what you're trying to do in exact terms. I can't make sense of the extra code you've posted.

  6. #6
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have a mc that just has a fade in, pause, then fade out...

    Within this mc I have 7 frames, each with a different logo.

    I am trying to just direct the mc to that logo and do it sequentially from frame 1 (logo 1).

  7. #7
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Alright...try this:
    Code:
    var frame:Number = 1;
    function playNext() {
       if(frame > 7) {
          gotoAndStop(1);  // or gotoAndPlay(), whatever you need
       }
       else {
          frame++;
          gotoAndStop(frame)
       }
    }
    Then, call playNext() wherever/however you're going to the next frame. If you want it on a timer, use setInterval.

  8. #8
    Join Date
    May 2007
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is doing the same thing that I already had? If I place the AS in my mc tween area and then call the function within an onEnterFrame function it doesn't work. If I do the same from the mc itself that contains all my logos it just rapidly cycles through the logos without any sort of fade in/out tween.

  9. #9
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    You shouldn't be calling this with an onEnterFrame. That calls the function once per frame -- overkill!

    Use setInterval to have a continuous loop.

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
  •