Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
onEnterFrame() versus setInterval()

onEnterFrame() versus setInterval()

2004-02-11       - By ilteris kaplan

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

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&nbsp;was silent and
wanted to bite with some issues, I have returned to my outlook express and what
do I see :) Jesse&nbsp;has began to&nbsp;type on clouds LOL :=)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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)&nbsp;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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>my_btn.onRelease = function()
{<BR>&nbsp;scaleBox(mybox_mc, 500, 10, 10);<BR>};<BR>scaleBox = function (name,
newWidth, newHeight, duration) {<BR>&nbsp;name.onEnterFrame = function()
{<BR>&nbsp;&nbsp;if (name._width == newWidth &amp;&amp; name._height ==
newHeight) {<BR>&nbsp;&nbsp;&nbsp;delete
this.onEnterFrame;<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;name._width +=
(newWidth-name._width)/duration;<BR>&nbsp;&nbsp;name._height +=
(newHeight-name._height)/duration;<BR>&nbsp;};<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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>scaleBox = function (name, newWidth, newHeight,
speed) {<BR>&nbsp;if(name._width &gt;= newWidth &amp;&amp; name._height &gt;=
newHeight)
{<BR>&nbsp;&nbsp;trace("yo")<BR>&nbsp;&nbsp;clearInterval(makerI);<BR>&nbsp;}
<BR>&nbsp;<BR>&nbsp;name._width
+= (newWidth-name._width)/speed;<BR>&nbsp;name._height +=
(newHeight-name._height)/speed;</FONT></DIV>
<DIV>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</DIV></BODY></HTML>

Earn $52 per hosting referral at Lunarpages.