  | |  | onEnterFrame() versus setInterval() | onEnterFrame() versus setInterval() 2004-02-11 - By ilteris kaplan
Back Hello, Just when I thought the list was silent and wanted to bite with some issues, I have returned to my outlook express and what do I see :) Jesse has began to type on clouds LOL :=)
anyways here is my deal; I have a 100X100 mc(mybox_mc) and -a button (my_btn) for testing purposes- on the stage, I can invoke my function with onEnterFrame without any problems like below.
my_btn.onRelease = function() { scaleBox(mybox_mc, 500, 10, 10); }; scaleBox = function (name, newWidth, newHeight, duration) { name.onEnterFrame = function() { if (name._width == newWidth && name._height == newHeight) { delete this.onEnterFrame; } name._width += (newWidth-name._width)/duration; name._height += (newHeight-name._height)/duration; }; };
but what I want to achieve and cannot succeed is to do this process with setInterval. Here is my dirty code;
scaleBox = function (name, newWidth, newHeight, speed) { if(name._width >= newWidth && name._height >= newHeight) { trace("yo") clearInterval(makerI); } name._width += (newWidth-name._width)/speed; name._height += (newHeight-name._height)/speed;
}; my_btn.onRelease = function() { makerI = setInterval(scaleBox,20,"mybox_mc",500,100,2); }
I think the problem occurs at the last line, because I am calling the interval with parameters, maybe it confuses and don't give me the exact intervals. I am not sure at this point. Besides I can take all the ciritisms of creation of the functions in terms of syntax and methods.
thanks in advance, ilteris.
?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=utf-8"> <META content="MSHTML 6.00.2800.1400" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2>Hello,</FONT></DIV> <DIV><FONT face=Arial size=2>Just when I thought the list was silent and wanted to bite with some issues, I have returned to my outlook express and what do I see :) Jesse has began to type on clouds LOL :=)</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>anyways here is my deal;</FONT></DIV> <DIV><FONT face=Arial size=2>I have a 100X100 mc(mybox_mc) and -a button (my_btn) for testing purposes- on the stage, I can invoke my function with onEnterFrame without any problems like below.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>my_btn.onRelease = function() {<BR> scaleBox(mybox_mc, 500, 10, 10);<BR>};<BR>scaleBox = function (name, newWidth, newHeight, duration) {<BR> name.onEnterFrame = function() {<BR> if (name._width == newWidth && name._height == newHeight) {<BR> delete this.onEnterFrame;<BR> }<BR> name._width += (newWidth-name._width)/duration;<BR> name._height += (newHeight-name._height)/duration;<BR> };<BR>};<BR></FONT></DIV> <DIV><FONT face=Arial size=2>but what I want to achieve and cannot succeed is to do this process with setInterval. Here is my dirty code;</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>scaleBox = function (name, newWidth, newHeight, speed) {<BR> if(name._width >= newWidth && name._height >= newHeight) {<BR> trace("yo")<BR> clearInterval(makerI);<BR> } <BR> <BR> name._width += (newWidth-name._width)/speed;<BR> name._height += (newHeight-name._height)/speed;</FONT></DIV> <DIV> </DIV> <DIV><FONT face=Arial size=2>};<BR>my_btn.onRelease = function() {<BR>makerI = setInterval(scaleBox,20,"mybox_mc",500,100,2);<BR>}</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>I think the problem occurs at the last line, because I am calling the interval with parameters, maybe it confuses and don't give me the exact intervals. I am not sure at this point. Besides I can take all the ciritisms of creation of the functions in terms of syntax and methods.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>thanks in advance,</FONT></DIV> <DIV><FONT face=Arial size=2>ilteris.</DIV></FONT> <DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>
Earn $52 per hosting referral at Lunarpages.
|
|
 |