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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.