Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Animation on Page

Reply
Thread Tools

Animation on Page

 
 
=?Utf-8?B?c2lhag==?=
Guest
Posts: n/a
 
      05-04-2005
Hello,
I am trying to put a very simple animation on a page. I want two images to
show alternately in a defined area. I tried to have an image control and a
timer control on a page. I am setting the Imageurl property of the image
control to two difeent images at fixed time interval. but the image remains
fixed on my page. It never resets to other image. Perhaps I need to Refresh
the page at every timeinterval.

My code is as


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
SetTimer()
End Sub


Private Sub SetTimer()
Try
AddHandler Timer1.Elapsed, AddressOf OnTimer
Timer1.Enabled = True
Timer1.Interval = 1000

Timer1.Start()
Image1.ImageUrl = "C:\Sunset.jpg"
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub


Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
Try
If Image1.ImageUrl = "C:\Sunset.jpg" Then
Image1.ImageUrl = "C:\Winter.jpg"
Else
Image1.ImageUrl = "C:\Sunset.jpg"
End If


Catch ex As Exception
Response.write(ex.Message)
End Try
End Sub



Any suggestion shall be appreciated.

Cheers,
siaj
 
Reply With Quote
 
 
 
 
Joseph Byrns
Guest
Posts: n/a
 
      05-04-2005
You should do it in the JavaScript on the client so:

function init()
{
timer = setInterval("TrackFrame()",500);
}

function TrackFrame()
{
//toggle image here
}

and call the init function from the body.

"siaj" <> wrote in message
news:00591208-1D98-41B2-8088-...
> Hello,
> I am trying to put a very simple animation on a page. I want two images
> to
> show alternately in a defined area. I tried to have an image control and a
> timer control on a page. I am setting the Imageurl property of the image
> control to two difeent images at fixed time interval. but the image
> remains
> fixed on my page. It never resets to other image. Perhaps I need to
> Refresh
> the page at every timeinterval.
>
> My code is as
>
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> SetTimer()
> End Sub
>
>
> Private Sub SetTimer()
> Try
> AddHandler Timer1.Elapsed, AddressOf OnTimer
> Timer1.Enabled = True
> Timer1.Interval = 1000
>
> Timer1.Start()
> Image1.ImageUrl = "C:\Sunset.jpg"
> Catch ex As Exception
> Response.Write(ex.Message)
> End Try
> End Sub
>
>
> Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
> Try
> If Image1.ImageUrl = "C:\Sunset.jpg" Then
> Image1.ImageUrl = "C:\Winter.jpg"
> Else
> Image1.ImageUrl = "C:\Sunset.jpg"
> End If
>
>
> Catch ex As Exception
> Response.write(ex.Message)
> End Try
> End Sub
>
>
>
> Any suggestion shall be appreciated.
>
> Cheers,
> siaj



 
Reply With Quote
 
 
 
 
=?Utf-8?B?c2lhag==?=
Guest
Posts: n/a
 
      05-04-2005
Thanks for quick reply...
I tried the way u suggested though I had two doubts..

My Javascript code goes as
<script language ="javascript" >
var flag = true;
function init()
{
alert("I m here!");
timer = setInterval("TrackFrame",500);

}
function TrackFrame()
{
if flag == false
{
alert("toggling");
flag = true;
}
else
{
alert("toggled");
flag = false;
}


}
</script>

I call from the body as

<body MS_POSITIONING="GridLayout" onload = "init()">

My doubts are that I get an error Expected "("
also If you can tell me how to toggle the image in javascript.

Let me confess that I am a beginner in web development.

Appreciate your help..
Cheers,
siaj

"Joseph Byrns" wrote:

> You should do it in the JavaScript on the client so:
>
> function init()
> {
> timer = setInterval("TrackFrame()",500);
> }
>
> function TrackFrame()
> {
> //toggle image here
> }
>
> and call the init function from the body.
>
> "siaj" <> wrote in message
> news:00591208-1D98-41B2-8088-...
> > Hello,
> > I am trying to put a very simple animation on a page. I want two images
> > to
> > show alternately in a defined area. I tried to have an image control and a
> > timer control on a page. I am setting the Imageurl property of the image
> > control to two difeent images at fixed time interval. but the image
> > remains
> > fixed on my page. It never resets to other image. Perhaps I need to
> > Refresh
> > the page at every timeinterval.
> >
> > My code is as
> >
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > SetTimer()
> > End Sub
> >
> >
> > Private Sub SetTimer()
> > Try
> > AddHandler Timer1.Elapsed, AddressOf OnTimer
> > Timer1.Enabled = True
> > Timer1.Interval = 1000
> >
> > Timer1.Start()
> > Image1.ImageUrl = "C:\Sunset.jpg"
> > Catch ex As Exception
> > Response.Write(ex.Message)
> > End Try
> > End Sub
> >
> >
> > Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
> > Try
> > If Image1.ImageUrl = "C:\Sunset.jpg" Then
> > Image1.ImageUrl = "C:\Winter.jpg"
> > Else
> > Image1.ImageUrl = "C:\Sunset.jpg"
> > End If
> >
> >
> > Catch ex As Exception
> > Response.write(ex.Message)
> > End Try
> > End Sub
> >
> >
> >
> > Any suggestion shall be appreciated.
> >
> > Cheers,
> > siaj

>
>
>

 
Reply With Quote
 
Joseph Byrns
Guest
Posts: n/a
 
      05-05-2005
Here is a simple example (the error you got was because you missed the
brackets in the if statement).

<HEAD>
<script language ="javascript" >
var flag = true;
var img = null;
function init()
{
img = document.getElementById("TheImage");
timer = setInterval("TrackFrame()",500);
}

function TrackFrame()
{
if (flag == false)
{
img.src="pic1.jpg";
flag = true;
}
else
{
img.src="pic2.jpg";
flag = false;
}
}

</script>
</HEAD>

<BODY onload="init()">

<img src="pic1.jpg" id="TheImage">

</BODY>

"siaj" <> wrote in message
news:0469420E-B27E-4D92-A52B-...
> Thanks for quick reply...
> I tried the way u suggested though I had two doubts..
>
> My Javascript code goes as
> <script language ="javascript" >
> var flag = true;
> function init()
> {
> alert("I m here!");
> timer = setInterval("TrackFrame",500);
>
> }
> function TrackFrame()
> {
> if flag == false
> {
> alert("toggling");
> flag = true;
> }
> else
> {
> alert("toggled");
> flag = false;
> }
>
>
> }
> </script>
>
> I call from the body as
>
> <body MS_POSITIONING="GridLayout" onload = "init()">
>
> My doubts are that I get an error Expected "("
> also If you can tell me how to toggle the image in javascript.
>
> Let me confess that I am a beginner in web development.
>
> Appreciate your help..
> Cheers,
> siaj
>
> "Joseph Byrns" wrote:
>
>> You should do it in the JavaScript on the client so:
>>
>> function init()
>> {
>> timer = setInterval("TrackFrame()",500);
>> }
>>
>> function TrackFrame()
>> {
>> //toggle image here
>> }
>>
>> and call the init function from the body.
>>
>> "siaj" <> wrote in message
>> news:00591208-1D98-41B2-8088-...
>> > Hello,
>> > I am trying to put a very simple animation on a page. I want two
>> > images
>> > to
>> > show alternately in a defined area. I tried to have an image control
>> > and a
>> > timer control on a page. I am setting the Imageurl property of the
>> > image
>> > control to two difeent images at fixed time interval. but the image
>> > remains
>> > fixed on my page. It never resets to other image. Perhaps I need to
>> > Refresh
>> > the page at every timeinterval.
>> >
>> > My code is as
>> >
>> >
>> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> > System.EventArgs) Handles MyBase.Load
>> > 'Put user code to initialize the page here
>> > SetTimer()
>> > End Sub
>> >
>> >
>> > Private Sub SetTimer()
>> > Try
>> > AddHandler Timer1.Elapsed, AddressOf OnTimer
>> > Timer1.Enabled = True
>> > Timer1.Interval = 1000
>> >
>> > Timer1.Start()
>> > Image1.ImageUrl = "C:\Sunset.jpg"
>> > Catch ex As Exception
>> > Response.Write(ex.Message)
>> > End Try
>> > End Sub
>> >
>> >
>> > Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
>> > Try
>> > If Image1.ImageUrl = "C:\Sunset.jpg" Then
>> > Image1.ImageUrl = "C:\Winter.jpg"
>> > Else
>> > Image1.ImageUrl = "C:\Sunset.jpg"
>> > End If
>> >
>> >
>> > Catch ex As Exception
>> > Response.write(ex.Message)
>> > End Try
>> > End Sub
>> >
>> >
>> >
>> > Any suggestion shall be appreciated.
>> >
>> > Cheers,
>> > siaj

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preloader and photo animation script in the same page gealover Javascript 2 12-15-2008 03:55 AM
Display animation during page-load Mantorok ASP .Net 4 06-20-2007 08:27 AM
while posting information on a page containing an animated image, animation not working nemesis.saurabh@gmail.com ASP .Net 3 02-12-2007 06:47 PM
upload animation on web page Brian Henry ASP .Net 4 03-22-2005 04:46 AM
Off subject - Know of an Gif Animation Program? Axl Firefox 1 09-08-2003 08:39 PM



Advertisments