Jump to content

[SOLVED] My text flasher doesn't seem to start at array index 0...!?


Yesideez

Recommended Posts

First here's my Javascript:

var colors=array('000000','110000','220000','330000','440000','550000','660000','770000','880000','990000','aa0000','bb0000','cc0000','dd0000','ee0000','ff0000','ee0000','dd0000','cc0000','bb0000','aa0000','990000','880000','770000','660000','550000','440000','330000','220000','110000','444444','888888','bbbbbb','ffffff','bbbbbb','888888','444444','END');
var i=0;
function flash() {
  document.getElementById('flashme').style.color='#'+colors[i];
  i++;
  if (colors[i]=='END') {i=0;}
}
setInterval('flash()',40);

 

The HTML part is here:

<body onload="flash();">

Then I use it by inserting it using this:

<span id="flashme">ALL TICKETS HAVE NOW SOLD OUT</span>

 

The Javascript itself is in a small file which is included like this:

<script src="includes/functions.js"></script>

 

First let me say I hate Javascript. I didn't want to use CSS to make it blink as I understand not all browsers support it, primarily early versions of IE. How true that is I've no idea. I avoid using Javascript where possible but the flashing I wanted I could only do using Javascript. After a bit of searching all I could find was a routine to alternate flashing two colors, a script to flash random colors or a routine to flash random colors stored in an array.

 

Here is where the code is being used:

http://beardedtheory.pictureinthesky.net/php/tickets.php

 

When I first load the page the the color looks like it starts its cycle half-way through - am I right or is this just an illusion?

When I first load the page the the color looks like it starts its cycle half-way through - am I right or is this just an illusion?

 

it looks like to me; that it is going through all of your colors very fastly, but test it and see - mix the colors up and use several: bright, medium, and dark colors through out the array. then set the interval to a longer amount of time and preview the script to see if it is going through each color.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.