Re: rotate a graphic in html or asp?

by =?iso-8859-1?Q?St=E9phane?= Bergeron <stephberg(at)videotron.ca>

 Date:  Tue, 28 Mar 2000 23:38:42 -0500
 To:  hwg-techniques(at)hwg.org
 Cc:  pbabcock(at)bgsgroup.com
 In-Reply-To:  felix
  todo: View Thread, Original
At 04:43 PM 28/03/00 -0500, you wrote:
>Is there a way, either in HTML (doubtful) or thru ASP to dynamically rotate
>an image?  I know I could create separate graphics *but* for this
>application I need to do it with one graphic, rotated.

This is easily achieved in ASP with the AdRotator component.  This=20
component should be installed on most if not all NT servers running IIS 4=20
and above.  The AdRotator object is set in two parts:  first is the code=20
you insert in the page where the image will appear and then you have to=20
write the schedule file which is a simple text file where you define the=20
images and the the relative frequency at which you want them to be=20
rotated.  The code which you add to the HTML goes like this:

<%
Dim objRot, varImage
Set objRot =3D Server.CreateObject("MSWC.AdRotator")
varImage =3D objRot.GetAdvertisement("includes/RotSchedule.txt")
Response.write varImage
  %>

Of course you should change the "includes/RotSchedule.txt" part to the=20
actual folder and file names you  set on your server for this.  The=20
schedule file is a plain text file should be written in the following=20
format (explanation below):

border 0
height 300
width 250
*
images/img1.gif
http://www.foo.com
Text description
25
images/img2.gif
http://www.foo2.com
Text description
25
images/img3.gif
http://www.foo3.com
Text description
50

The schedule file is comprised of two parts.  The first part up to the *=20
symbol sets the basic properties of the image tag the component will=20
create.  The * symbol serves as a separator between the two parts and=20
should be alone on a single line with no blank lines above and below and no=
=20
spaces before or after.  The second section has 4 parameters for each image=
=20
which you repeat as many times as you have images to rotate.  The first=20
sets the path and filename for the image.  The second parameter is the URL=
=20
the user will be directed to if they click on that particular image.  If=20
you don't want the image to be a link, insert a  -  (dash) symbol instead=20
but don't leave the line blank and don't omit it.  The third parameter is=20
the text description for the image that will be inserted in the ALT=20
attribute of the image tag.  Finally is the number that will set the=20
frequency at which the image will be displayed in relation to the other=20
images.  In the above example, the image "img3.gif" would be shown 50% of=20
the time which is twice as often as the two others.  You could also use the=
=20
numbers 1, 1 and 2 to achieve the same effect or 1 for each image which=20
would give all 3 images the same importance.  There should be no blank=20
lines between the parameter definitions for each image.

That's all there is to it and it works very well too.

HTH!

St=E9phane Bergeron

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA