473,385 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

clearInterval - Problem

To all,

I posted this question in svg group twice already - and got no answer.

Q: why does the animation not stop when a height of 10 is reached ?


<?xml version="1.0"?>
<svg width="1280" height="800">
<script type="text/javascript">

<![CDATA[

var height = 0;
var timer1;

function startAction()
{
timer1 = setInterval("doIpl()",500 )
}

function doIpl()
{
obj = svgDocument.getElementById( "rect11" );
obj.setAttribute("height", height);
height = height + 1

if ( height == 10 )
{
stop();
}

}

function stop()
{
clearInterval(timer1);
alert(height);
}


]]>
</script>

<g>

<rect id="rect12" x="190" y="55" width="100" height="65"
fill="lightgrey"
stroke-width="1" stroke="black" />
<text x="200" y="70" font-size="12">SAG_BCPII</text>

<rect id="rect11" x="190" y="55" width="100" height="65" fill="pink"
stroke-width="1" stroke="black" />
<text x="200" y="70" font-size="12">SAG_BCPII</text>
<!--************************************************** *****************
-->
<rect onclick="startAction()" x="100" y="450" width="10" height="10"
fill="pink" stroke-width="1" stroke="black" />
<text x="110" y="475" text-anchor="middle">Start</text>

<rect onclick="stop()" x="65" y="450" width="10" height="10"
fill="pink" stroke-width="1" stroke="black" />
<text x="65" y="475" text-anchor="middle">Stop</text>

</g>
</svg>
Jul 23 '05 #1
1 2010
emerson wrote:
<?xml version="1.0"?>
<svg width="1280" height="800">
<script type="text/javascript">
<![CDATA[
var height = 0;
var timer1;
function startAction() {
timer1 = setInterval("doIpl()",500 )
}
function doIpl() {
obj = svgDocument.getElementById( "rect11" );
obj.setAttribute("height", height);
height = height + 1
if ( height == 10 ) {
stop();
}
}
function stop() {
clearInterval(timer1);
alert(height);
}
]]>
</script>
<g> <snip> </g>
</svg>


Does your animation run at all?
Does it continue to run after height has exceeded 10?
If it does run, what happens when you click stop?
Post details.

The code below worked for me in IE6. I modified it to set the width of a
textbox in html because I don't know xml or svg.

I added a line setting newheight to 0 each time you start the code in
case you want to run it more than once.

I don't think it's wise to name variables the same as properties so I
renamed "height" to "newheight".

I used document.getElementById, window.setInterval, window.clearInterval.

Does this code work correctly for you in IE6? If so, maybe make the
changes I mentioned above and see if that makes any differrence.

<html>
<head>
<script type="text/javascript">
var newheight;
var timer1;
function startAction(){
newheight = 0;
timer1 = window.setInterval("doIpl()",500);
}
function doIpl(){
myobj = document.getElementById("rect11");
//obj.setAttribute("height", height);
myobj.width=newheight*11;
newheight += 1;
if ( newheight == 10 )
stop();
}
function stop(){
window.clearInterval(timer1);
alert('now in function stop(), newheight = '+newheight);
}
</script>
</head>
<body>
<input type="text" id="rect12" name="rect12"> rect12
<p>
<input type="text" id="rect11" name="rect11"> rect11
<p>
<input type="button" onclick="startAction()" value="Start">
<p>
<input type="button" onclick="stop()" value="Stop">
</body>
</html>

Good Luck,
Mike

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
9
by: Sudesh Sawant | last post by:
Hello, We have an application which communicates using remoting. There is a server which is a Windows Service. The server exposes an object which is a singleton. The client is a Web Application...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.