Hi all,
the attached code works on an empty flash8-stage (size about 1024*768) (just put the code in the first frame and run). You might notice the problem: The simulation speed is slowing down quite quickly. Has anybody a solution or knows what might be the cause? I've got no idea what to do!
Thanks very much in advance! -
var startx:Number = 100;
-
var starty:Number = random(100)+200;
-
moveTo(startx, starty);
-
var positionX:Array = new Array(75);
-
var positionY:Array = new Array(75);
-
positionX[0]=startx;
-
positionY[0]=starty;
-
-
for (ii:Number=1; ii<76; ii++){
-
moveTo(positionX[ii-1], positionY[ii-1]);
-
positionX[ii] = startx+(ii*10);
-
positionY[ii] = positionY[ii-1] + random(20)-10;
-
lineStyle (5, 0x888888, 100);
-
lineTo(positionX[ii], positionY[ii]);
-
}
-
-
// all 100ms new part of line
-
timeint = setInterval(this, "drawline", 100);
-
-
var pass : Number = 1;
-
var posx : Number = 1;
-
function drawline() {
-
posx=1;
-
for (i:Number=1; i<76; i++) {
-
moveTo(positionX[posx-1], positionY[i-1]);
-
lineStyle (5, 0xFFFFFF, 100);
-
lineTo(positionX[posx], positionY[i]);
-
posx++;
-
}
-
for (arraypos:Number=1; arraypos<76; arraypos++) {
-
positionY[arraypos-1] = positionY[arraypos];
-
}
-
positionY[75]=positionY[74] + random(20)-10;
-
pass++;
-
posx=1;
-
for (i:Number=1; i<76; i++) {
-
moveTo(positionX[posx-1], positionY[i-1]);
-
lineStyle (5, 0x888888, 100);
-
lineTo(positionX[posx], positionY[i]);
-
posx++;
-
}
-
-
//quit timeinterval after 75 loops
-
pass>=75?clearInterval(timeint):0;
-
trace(pass);
-
}
-
3 1631
Hi, strombose.
The solution is very simple, you were not clearing the stage when redrawing the lines and that was eating too much memory. You just need to add clear(); in the fisrt line of your drawline function. -
function drawline() {
-
clear();
-
//[the rest of the function here]
-
}
-
The clear method literally clears the stage of any previous drawings made by actionscript, making also release memory.
Best regards,
The_Nephilim
Hi all,
the attached code works on an empty flash8-stage (size about 1024*768) (just put the code in the first frame and run). You might notice the problem: The simulation speed is slowing down quite quickly. Has anybody a solution or knows what might be the cause? I've got no idea what to do!
Thanks very much in advance! -
var startx:Number = 100;
-
var starty:Number = random(100)+200;
-
moveTo(startx, starty);
-
var positionX:Array = new Array(75);
-
var positionY:Array = new Array(75);
-
positionX[0]=startx;
-
positionY[0]=starty;
-
-
for (ii:Number=1; ii<76; ii++){
-
moveTo(positionX[ii-1], positionY[ii-1]);
-
positionX[ii] = startx+(ii*10);
-
positionY[ii] = positionY[ii-1] + random(20)-10;
-
lineStyle (5, 0x888888, 100);
-
lineTo(positionX[ii], positionY[ii]);
-
}
-
-
// all 100ms new part of line
-
timeint = setInterval(this, "drawline", 100);
-
-
var pass : Number = 1;
-
var posx : Number = 1;
-
function drawline() {
-
posx=1;
-
for (i:Number=1; i<76; i++) {
-
moveTo(positionX[posx-1], positionY[i-1]);
-
lineStyle (5, 0xFFFFFF, 100);
-
lineTo(positionX[posx], positionY[i]);
-
posx++;
-
}
-
for (arraypos:Number=1; arraypos<76; arraypos++) {
-
positionY[arraypos-1] = positionY[arraypos];
-
}
-
positionY[75]=positionY[74] + random(20)-10;
-
pass++;
-
posx=1;
-
for (i:Number=1; i<76; i++) {
-
moveTo(positionX[posx-1], positionY[i-1]);
-
lineStyle (5, 0x888888, 100);
-
lineTo(positionX[posx], positionY[i]);
-
posx++;
-
}
-
-
//quit timeinterval after 75 loops
-
pass>=75?clearInterval(timeint):0;
-
trace(pass);
-
}
-
Thanks a lot for your help! It works.
Thanks a lot for your help! It works.
You're welcome.
Good luck!
Best regards,
The_Nephilim
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rob Ristroph |
last post by:
I have tried out PHP 5 for the first time (with assistance from this
group -- thanks!).
The people I was working with have a site that uses lots of php
objects. They are having problems with...
|
by: lkrubner |
last post by:
Are there any benchmarks on how much an extra, unneeded VARCHAR, CHAR,
INT, BIGINT, TEXT or MEDIUMTEXT slows down a database call with MySql?
PostGre info would also be useful.
I'm trying to...
|
by: Jonny |
last post by:
Netscape 7.02 is giving me a headache with a downloaded snow script.
Starting with a blank page, I inserted the script and checked it in IE
6 and Netscape 7.02. Everything worked and looked fine. A...
|
by: zheenma |
last post by:
There is a program that speed up your typing and avoid spelling errors.
My friends use it ,their averege is more than 100 wpm.
You can download it from www.wamasoft.com.
And It has a library for...
|
by: Larry R Harrison Jr |
last post by:
I have a database I'm designing in Access 97. I have a custom field in a
query which looks in {Table of Documents} and shows them all. It then needs
a "latest revision number," stored in another...
| |
by: WoodenSword |
last post by:
Hi,
I am trying to read a huge text file (2GB) using
StreamReader.
I do this:
Read a line (readline())
I process the line a bit (split it with delimeter and
change fields a bit)
execute...
|
by: FBM |
last post by:
Hi,
I am working on a program that simulates one of the elements of ATM.
The simulation stores events which occurs every some milliseconds for a
certain amount of time. Every time that an event...
|
by: Pitaridis Aristotelis |
last post by:
I have a large file which has to be downloaded from a user using the
Internet Explorer. The problem is that when someone downloads this file, the
server slows down and the other users can not see...
|
by: Surya Dutt |
last post by:
Hello,
Did someone happen to come accross and algorithm or a C++ program that simulates the Smith Collge Diploma problem?
"At Smith College, the graduation exercises traditionally proceed as...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |