Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
wimw #1
interval function not working
Hello,
Does anybody have an idea why the delay function in the script below is not
working?
I'm trying to slowly move an image horizontally.
Another movie generates the value for "p'".
If p==2, the trace "test 01" is executed, so that's all right. After that, the
delay function should be executed (and I should see the trace "test 02", but is
isn't.
Funny thing is, if I put the interval call and the delay function outside the
if-construction, it works.
Any ideas?
Thanks,
Wim
onClipEvent (enterFrame) {
//P1
if (_root.p == 1) {
_root.screen._x = 100;
//P2
} else if (_root.p == 2) {
intID = setInterval(delay, 100);
_root.x = 100;
trace ("test 01")
function delay() {
trace ("test02")
_root.x = _root.x-1;
_root.screen._x = _root.x;
updateAfterEvent();
if (_root.screen._x<=-500) {
clearInterval(intID);
_root.pfree = true;
}
}
//P3
} else if (_root.p == 3) {
_root.screen._x = -1100;
//P4
} else if (_root.p == 4) {
_root.screen._x = -1700;
//P5
} else if (_root.p == 5) {
_root.screen._x = -2300;
}
}
wimw Guest
-
Using the interval data type
I'm using a query that returns a value as an 'interval' data type. When I run that query through CF only an is returned. I've tried casting the... -
to_char(interval, text) deprecated in future - how do we getconsistent interval output without it?
I saw the note in the docs that to_char(interval, text) is deprecated, and will be removed. I searched the archives and saw more mentions of this,... -
Interval Question
Greetings: I am working on a function which returns an interval value. The work of the function is to calculate the difference between the... -
Date Interval Functions
On a form I have Date_Start Date_End I have a new Date_Start1 Date_End1 which the use... -
INTERVAL FUNCTION
On Wed, 23 Jul 2003 12:44:47 -0400, tomL wrote: Because you did not specify the resolution/size of the seconds interval which defaults to 2... -
Jeckyl #2
Re: interval function not working
do not declare functions inside an event.
declare the function separately and preferably before the event.
The problem is more specifically that you are using the function 'delay'
before you have defined it.
Jeckyl Guest
-
wimw #3
Re: interval function not working
Yes, I expected something like that. Wat would be the best place for the function? Should it be in the same movie as frome where it is called?
Thx,
Wim
wimw Guest
-
CesareRocchi #4
Re: interval function not working
also consider declaring your functions as local my means of 'var' like:
var f = function () {
trace("test");
}
setInterval(...
Also, less readable for non coders, u can exploit lexical closure like:
setInterval(function f() {
trace("test");
},
100);
HTH,
-c.
CesareRocchi Guest



Reply With Quote

