Double buffer program is slowing down, help.

Hello, I have a small program of lines of dance as an old Windows screen saver program, and it seems to slow down after about 30 seconds to a minute. I have 'clear' my buffer by copying a symbol in black screen size of the buffer. If anyone has any ideas on how to make it more efficient and above all to stop the slow down, let me know, thanks.

// Variables
var x0:int;
var y0:int;
var x1:int;
var y1:int;
var x2:int;
var y2:int;
var x3:int;
var y3:int;
var dx0:int;
var dy0:int;
var dx1:int;
var dy1:int;
var dx2:int;
var dy2:int;
var dx3:int;
var dy3:int;
var counter:int = 0;
var clearBuffer:Buffer = new Buffer();
var drawing:Shape = new Shape();
var color1:uint = uint(0xFFFFFF * Math.random());

// Initialize Line Values
x0 = int(Math.random() * 320);
x1 = int(Math.random() * 320);
y0 = int(Math.random() * 200);
y1 = int(Math.random() * 200);
x2 = x0;
x3 = x1;
y2 = y0;
y3 = y1;

// Initializing Line Velocities
dx0 = int(Math.random() * 5);
dx1 = int(Math.random() * 5);
dy0 = int(Math.random() * 5);
dy1 = int(Math.random() * 5);
dx2 = dx0;
dx3 = dx1;
dy2 = dy0;
dy3 = dy1;

// Double Buffer Setup
var bitmap:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xff000000);                          
var buffer:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,true,0xff000000);
var image:Bitmap = new Bitmap(bitmap);
addChild(image);

// Listeners
addEventListener(Event.ENTER_FRAME,onEnterFrame);

function onEnterFrame(event:Event):void {
     
     // Clear The Sreen
     buffer.draw(clearBuffer);
     
     // Logic
     drawing.graphics.lineStyle(1, color1);
     drawing.graphics.moveTo(x0,y0);
     drawing.graphics.lineTo(x1,y1);
     if ((x0 += dx0) >= 315 || x0 < 5)
          dx0 *= -1;
     if ((y0 += dy0) >= 195 || y0 < 5)
          dy0 *= -1;
     if ((x1 += dx1) >= 315 || x1 < 5)
          dx1 *= -1;
     if ((y1 += dy1) >= 195 || y1 < 5)
          dy1 *= -1;
          
     if (++counter > 50) {
          drawing.graphics.lineStyle(1, 0x000000);
          drawing.graphics.moveTo(x2,y2);
          drawing.graphics.lineTo(x3,y3);
          if ((x2 += dx2) >= 315 || x2 < 5)
               dx2 *= -1;
          if ((y2 += dy2) >= 195 || y2 < 5)
               dy2 *= -1;
          if ((x3 += dx3) >= 315 || x3 < 5)
               dx3 *= -1;
          if ((y3 += dy3) >= 195 || y3 < 5)
               dy3 *= -1;
     }
     
     if (counter > 250)
          counter = 51;
               
     // Draw The Screen
     buffer.draw(drawing, drawing.transform.matrix);
     bitmap.draw(buffer);
}

P.S. - Is there a way I can post my code in a small box with a scroll bar?

You get a slow down because you are filling the shape to your drawing with vectors and never cleaning. You need to publish periodically a drawing.graphics.clear () to clear all these vector lines. You can play with it, but as a simple solution, you can replace the line:

If (counter > 250)

counter = 51;

with this:

If {(counter > 250)
counter = 51;
Drawing.Graphics.Clear ();
Color1 = uint (0xFFFFFF * Math.random ());

}

Tags: Adobe Animate

Similar Questions

  • I can't get connected to Windows Live Messenger.__Everytime I connect happens __Can "Windows Live Messenger has stopped working, a problem caused the program to close down" help please

    I can not get connected to Windows Live Messenger.
    Whenever I connect it comes up "Windows Live Messenger has stopped working, a problem caused the program to close down."
    Can you help me please

    http://www.windowslivehelp.com/forums.aspx?ProductID=2

    They will help you with your WLM questions when repost you your questions in the Forums above Windows Live Messenger.

    See you soon.

    Mick Murphy - Microsoft partner

  • Latest Vista updates have picked up my use of the internet and slowed down my system

    Last week, I had several automatic updates. In the meantime, updates have been loading on my computer all landed and froze. After the updates, I'll have a terrible time in AOL. The program has slowed down and often gives me an error message that the system is not responding. I contacted AOL who gave me many suggestions that I follow, but I still have problems (more my overall system is slow now). Says to contact Microsoft. It may be a problem with acceleration. I don't have these problems until the updates installed this week.

    Now my system restore no longer works. I can't go back to before the updates. What can I do?

    Hi andrewgpig,

    Thank you for writing to Microsoft answers Community Forums.

    Possible cause would be that updates might conflict with other programs on the computer. Also could have damaged some system files on the computer.

    I suggest to try in safe mode and check the performance of the pc first.

    To start the computer in safe mode, do in the link below

    http://windowshelp.Microsoft.com/Windows/en-us/help/323ef48f-7b93-4079-a48a-5c58eec904a11033.mspx

    If it works fine in safe mode, then find the program that is in conflict. The link below shows you how to do a clean boot

    http://support.Microsoft.com/kb/331796

    If the steps above fail. Try to do a scan sfc

    Try to run a SFC scan, to do this, follow these steps:

    Open an elevated command prompt. To do this, click Start, click programs, accessories principally made, right-click Guest, and then click Run as administrator. If you are prompted for an administrator password or a confirmation, type the password, or click on allow.

    Type the following command and press ENTER:

    sfc/scannow

    The sfc/scannow command. analysis of all protected system files and replaces incorrect versions with appropriate Microsoft versions

    I hope this helps. .

    Let us know if this doesn't work or if you need further assistance.

    Kind regards

    Sharath

    Microsoft Answers Support Engineer

  • PROGRAM SLOWS DOWN WHEN IT ENTERS A BUSINESS STRUCTURE

    OK, so here is the problem I have do this output pid controller is between 0-100 in this program, I'm just trying to make it work so I made a function to compare that when the controller output is 0 and the constant 0 I'm starting a business loop which transform the output for a second and turn off for a second.   When I go into the structure of the case, the rest of my program slows down

    I don't know why, I tried to do a while loop and a structure outside my main loop but I can't get my signal of my statement to compare to enter the second loop where I get my output to bike in 1 second intervals

    This is the VI please help

    I'm still learning how to use labview in passing

    Thank you

    Gary

    Gary,

    The next thing you want to learn more about LabVIEW dataflow. This is the fundamental paradigm of LV and explain your slowdown problems.

    The basic concept of data flow is any node (node = function, Subvi, structure) can begin to run when the data is present on all its entries and no data will be present at its outputs to execution comopletes of knot.

    How will this affect your VI? The real deal has a wait 1000 ms (actually two, one in each case of the internal structure of the housing = redundant code). The structure of the case will not complete execution until the wait ends. And the while loop does not complete its repetition until the end of the structure of the case. The result: at the exit of the PID.vi = 0, the loop runs at 1 second per iteration.

    What is the solution? Continue execution of the loop at intervals of 100 ms. sure in the structure of matter (true case) and another register to shift of how number of intervals of 100 ms is passed. When the count reaches ten, toggle the output line.  Do not use the 1000 ms of waiting.

    All the code in your internal structure is not necessary. Connect the output remains directly to the digital Arduino write VI.

    Be careful with the comparison to zero with floating point data. If the calculation which produces data has round off errors you could get a value such as 0.573E - 15, but which is not equal to zero. It is better to compare to a small range of values above and below zero.

    Right to left wiring is much easier to follow in trying to understand what makes a program. Using the tool to clean occasionally will help (although he eventually frustrate you also).

    Lynn

  • All programs crash or slow down 2 minutes after the start.

    My computer works fine for a few minutes. After that everything started crashing or slowing down. The computer is pretty useless. I tried disk cleanup, I close all unnecessary processes, I installed Kaspersky security too.after I close all there are about 58% free.my C drive is 19.5 and 2.95 GB of physical memory is free in that. Here is my card

    OS: Windows Vista Home Basic (2006 edition)

    Processor: Intel (R) Core (TM) Duo Cpu [email protected]

    RAM: 2 550 MB

    System type: 32-bit operating system

    For advanced users,

    Here is the link to my information system:https://drive.google.com/file/d/0B57Wl4BRLLWcUzZlbVJpU2d6U28/edit?usp=sharing

    I downloaded my files on google reader

    Help, please

    Thank you

    If you bought new when Vista is out and it's a brand name computer (Dell, HP, etc.), are you on your C: partition is only 19.5GBs?

    You have the Vista installation, years of updates and Service Packs, your data and your installed programs, etc.

    ______________________________________

    And when you installed Kaspersky?

    ______________________________________

    To keep a computer, these are the normal steps, I would advise you to take.

    Download, install, update and scan your system with the free version of Malwarebytes AntiMalware in Mode safe mode with networking:

    http://www.Malwarebytes.org/products/malwarebytes_free

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    You can clean your hard drive using these two methods.

    "Delete files using Disk Cleanup"

    http://Windows.Microsoft.com/en-us/Windows-Vista/delete-files-using-disk-cleanup

    Using the free CCleaner program:

    http://www.Piriform.com/CCleaner

    In NO case use the registry cleaning Option in CCleaner

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    Update drivers:

    Access the site on your computer or equipment manufacturing > Driver and Software Support Section > search your computer or hardware model number > then your operating system > locate the correct drivers > download and install.

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    "Optimize Windows for better performance.

    http://Windows.Microsoft.com/en-us/Windows/optimize-Windows-better-performance#optimize-Windows-better-performance=Windows-Vista

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    It would be a good idea to run the System File Checker tool if you have corrupted files

    "How to use the System File Checker tool to fix the files on system missing or corrupted on Windows Vista or Windows 7"

    http://support.Microsoft.com/kb/929833

    Use the (SFC.exe) System File Checker tool to determine which file is causing the problem and then replace the file. To do this, follow these steps:

    1. Open an elevated command prompt. To do this, click Start, click principally made programs, Accessories, right-click guest, and then click run as administrator. If you are prompted for an administrator password or a confirmation, type the password, or click allow.
    2. Type the following command and press ENTER:
      sfc/scannow

      The sfc/scannow command analyzes all protected system files and replaces incorrect versions with appropriate Microsoft versions

    See you soon...

  • I want to slow down the pace. When I move the cursor at the end of the tween, to drag the end of the Tween to the right to lengthen the interpolations, the cursor does not change to a double-headed arrow, as it should to.

    Hello.

    I want to slow down the pace in an animation frame-to-frame hand drawn at 24 frames per second. When I move the cursor at the end of the Tween (24 images), in order to drag the end of the Tween to the right to lengthen the interpolations, the cursor does not a double arrow as it should, but changes to a black arrow with a small white rectangle with a border dotted, to the lower right of the cursor. Therefore, I can't extend the interpolations. Can anyone say about this?

    I am on the 20th day of a trial of Adobe Flash Professional CC, on an iMac osx 10.11.2 El Capitan. I use a Wacom pen.

    Thanks for any help. (I'm a complete newbie to the animation)

    Thanks for this very useful information and thanks to other members of the forum who also gave me great advice.

    I will experience more away, using the excellent information, I have now.

    Thank you all.

  • my pc slows down whenever I want to play a game. has got more ram czec and new nvidia card don't know what else to do. can you help me?

    my computer slows down whenever I want to play a game. GRIP more memory ram and a new nvidia card.dont not know what else to do. can you help me? game comes on and goes back to the desktop wallpaper.

    What games do you play?

    the 3200 + is OOOOLLD and you would be difficult to run whatever be done in recent years at all

    and you get drivers like that who already have your computer or MB, realtek can be obtained from the realtek site

    Since you don't list the exact model of each card, we cannot say whether you are running a GF2 MX or what

    and uninstall the nvidia cp stuff, then run http://www.guru3d.com/category/driversweeper/ to clear what is not respected

  • Is to install a large number of programs slow down a laptop

    I use HPg6-1004TX. I have a lot of program installed on my laptop (nearly 150). Is it slow down down/slow down my laptop? Thanks in advance!

    Without a doubt!     Especially if the program starts a process every time that you start Windows.   I suggest to use Control Panel to uninstall programs you no longer use.

  • Hi my book mac like work that slow down of should I please help me 0402771512

    Hi dear Sir / Madam

    I have a Mac Book Pro

    He works to slow down, I don't know what to do to get faster.

    Hi Sam, download and run EtreCheck, created by one of his own assistants here in CSA. It is a diagnostic tool that is very useful for us to find problems. It will also give us additional specifications on your Mac. After his execution after the logfile here. It will never contain any personal information.

  • Pavilion 15 - ab219tx: Internet slows down after connecting the mobile to WiFi.

    Previously, I had a problem where internet connection slowed down painfully when cell phone charges. I tried to reset the power settings. Now I can connect to the laptop... However, now the problem is that if connect you to WiFi via the laptop, regardless of if its loading or not, the internet becomes ridiculously slow. And if the wifi is turned off, it returns to normal. Help, please.

    . Hi @ARD09,

    Thanks for your reply. I review the post. I understand that drivers are a bit old. I first want to eliminate hardware issues with the computer's wireless card by performing all the steps which are associated software.

    I understand perfectly that WiFi and wired Ethernet connection both seem to be slow.

    A few steps to try:

    I hope this helps. I would like to know how this happens. I hope the problem is solved without hassle and the unit works very well. I'm always here for you help. Please reach out at any time.

    Just to say thank youPlease click the ' Thumbs Up ' button to give a Kudos to appreciate my efforts to help me. If it helps, Please mark this "accepted Solution" because it will help many other people with the same problem to get it resolved without hassle.

    Now carefully and have a wonderful week ahead.

  • Slow down with games and video on a Satellite P100-286

    When to play games and watch the video of the computer really slow down. This does not happen immediately, but after a little while.

    I check the Task Manager to see if anything else is running and the dwrm.exe has a heavy load of CPU, add to the use of the processor of the game and the two pocessors are struggling, as seen on the gadget processors. The games are unplayable and video very bad when this happens.

    When none of those who are running, dwrm.exe is 02 CPU usage when either run dwrm.exe is 45 CPU.

    Is this a Vista problem? If anyone can help, I would be grateful or should I call Toshiba?

    Hello

    can you describe the programs you have on your system? Maybe theres some program that looks at your other programs (perhaps an Antivirus or a private firewall or something else) and suck your platform performance.

    A suggestion from me: try to uninstall some programs that you have installed and beware of what your machine.

    So, I have to say that Vista needs a lot of resources, and there are so many people who is angry and frustrated of stand-alone and Vista, so I am too.
    But let´s wait, because out of XP, it was the same thing with the first service pack they solve so many problems and triggered the performance of this system for anyone who can work now and is enjoying XP.

  • Slow down the automatic transition

    Hello!

    I'm working on an introductory presentation with automatic switching between slides. I want to slow down the presentation (I tried to put a 15 seconds delay) but it keeps on changing every second...

    Can someone help me?

    (I must say that my speech is in french... so I hope I used the right conditions...!)

    The procedure is:

    Select all of the slides in the Panel of the browser (click on a slide and then use: control)

    Inspector > Animation > add an effect of > select the effect in the list

    on the start menu, transition drop-down list box select automatically

    change the time of 15 seconds (double-click the entry, type in 15 and then on enter)

    This not work?

  • Satellite P35-S605 slows down after a few minutes, then BSOD

    I am running Windows XP Pro and have contributed the most to the RAM on my P35.

    I had a local computer repair shop disassemble, clean all the dust and junk on, remove the processor and reinstall using thermal transfer compound. The computer has worked fine until I did this. When I came back and turned it on it started OK but started to slow down until the barley by working, and then I got the BSOD. After the memory dump, it restarted and repeat the process. After having tried several reboots, I finally gave up and called the computer repair shop I had used and returned to them. After a day, they said, it must be my drive hard because they replaced my hard drive with one of their and he ran all night with no problems. I had an old hard drive that I had removed from this machine, a few weeks before to move to a bigger so I put the old back road. The same problem remained. I again called the repair shop and told them what I had done, but they said they couldn't help me. I'm not recommedn this shop to anyone.

    I was myself so after that reading many articles on the Internet, I desided to try to fix it myself. I erased the hard disk using a set 0 wipe the program. I did a disk image using Acronis before I took the computer to the repair shop, so I have restored the image. I still have the same problem!

    Someone at - it suggestions on what I might try (other than a clean reinstall of Windows).

    Say the event viewer when you start after an accident?

    Personally I'll be back to the top of what you need and try a new installation of windows.

    Check Device Manager and see if there is something contradictory too...

    In fact what would be useful is if you can list the steps you have tried so far, so we don't waste your time with useless suggestions :)

    I'll be watching this thread for an answer, so I'll get back to you.

  • VISA reading significantly slows down to 20 Hz (Labview, Arduino + Xbee project)

    Hello

    I am quite new to Labview and Arduino, so I apologize if I use the incorrect terms. I'm having some trouble with the next project, I hope that you guys can give me some advice!
    I have 16 sensors connected to the 16 analog pins on an Arduino mega Board. This Council has a shield mounted upon him, with a Xbee module wireless. I have another Xbee module that communicates with him and it is mounted on a USB dongle that plugs into a PC with Labview 2015.

    The A/D analog Arduino pin output is read and sent every 50ms to the Xbee module connected to the PC. So every 50ms (that is, a frequency of 20 Hz), a new line of analog readings by commas is sent, using AnalogRead and Serialprint in the Arduino. These data are fed to a Labview code with architecture of producer-consumer. Copy the following code configures a serial port of VISA, reads the data, it converts a voltage value and writes the data to a text file (see block_diagram.jpg).

    The problem is that at a frequency of 20 Hz (with the configuration of the attached jpg) when you reach 400 treatment iterations the code slows down considerably and values are not parsed correctly. It behaves as if the queue is full (but the queue of elements indicators show 0) or memory or the buffers were full. It seems quite surprising to me given that the sampling rate is so slow. I tried a few configurations setting the buffer size, empty the buffer by using the queue time, but nothing seemed to work. Is it because the processor loop takes too much time to iterate? I tried to disable data analysis, conversion of voltage and the generation of text file, just keep reading and still have the same behavior.

    This may be the cause? Suggestions to change the block diagram are welcome! Is there a better way to do this than with VISA or queues...?

    I use Labview 2015 on Windows 7.

    Thank you!!

    sminanog wrote:

    It behaves as if the queue is full (but the queue of elements indicators show 0) or memory or the buffers were full.

    You think along the good things. But the big problem I see here is that you have a table growing up to stop the program.  You must move the file writing to be inside the loop of your consumption.  This will eliminate the need to constantly develop your table in the shift register, with tons of memory and causing copies of memory (which is very expensive).

    The other concern I have is the speed at which data is available.  If you have a baud rate 9600, then in the 50ms debit you can pass 48 bytes.  This leaves 3 bytes per sample, including the comma.  If you have a debit 115 200 baud baudrate, it turns into 576 bytes, you can send the 50ms.  So the lesson here is to make sure that you use a transmission speed which is fast enough to handle the data that you want to send.

  • DaqMX wait the next sample causing slow down Clock.vi

    Hello

    I have a question about the proper use of DaqMX wait for next sample clock.

    I read channels analog voltage on a map or pcie-6259.

    I would like to read as soon as possible make your comments between each of these points of single data points.

    I wish I had an error generated if I miss a data point.

    From reading the forums, I've gathered that the best way to do it is using the Timed Single Point material.

    A simplified program that I use to test this is attached.

    If I remove the DaqMX wait for next sample Clock.vi, my program seems to work.

    I added a counter to check the total time is as expected.

    For example, the program seems to work at the speed appropriate for 120.

    However, without that vi, it seems that the program does not generate a warning if I missed a sample.

    So I thought that the next sample clock waiting vi could be used to determine if a single data point has been missed using the output "is late."

    However, when I add inside as shown in the joint, the program seems to slow down considerably.

    At high rates as 120000, I get the error:-209802

    14kHz is the approximate maximum rate before you start to make mistakes.

    My question is: is this the right way to check a missed sample? I don't understand why the wait next sample Clock.vi is originally a slow down. Without this vi, the program does just what I want except that I do not have strict error control.

    My confusion may be based on a lack of understanding of real-time systems. I don't think I do 'real time' as I run on an ordinary pc, so maybe I use some features that I wouldn't.

    Thank you

    Mike

    Mike,

    You should be able to read to return delays errors and warnings by setting the DAQmx real-time-> ReportMissedSamp property.  I think that if you enable this, you will see errors or warnings (according to the DAQmx real-time-> ConvertLateErrorsToWarnings) in the case where you use read-only.  I'm a little surprised that you have measured your application works at 120 kHz without waiting for next sample clock (WFNSC), although I'm not surprised that it would be significantly faster.  I think if you call read-only, you'll read the last sample available regardless of whether you would of missed samples or not.  When you call WFNSC, DAQmx will always wait for the next, if you are late or not sample clock.  In this case, you will wait an additional sample clock that is not the case in read-only.  Once again, I expect that, in both cases, your loop would not go to 120 kHz.

    Features real-time DAQmx (hardware Timed Single Point - HWTSP) are a set of features that are optimized for a one-time operation, but also a mechanism to provide feedback as to if a request is following the acquisition.  There is nothing inherently wrong with using this feature on a non real-time OS.  However, planner of a non real-time OS is not going to be deterministic.  This means that your app 'real time' may be interrupted for a period not confined while the BONE died in the service of other applications or everything he needs to do.  DAQmx will always tell you if your application is to follow, but can do nothing to guarantee that this will happen.  Thus, your request * must * tolerant bet of this type of interruption.

    There are a few things to consider.  If it is important that you perform the action at a given rate, then you should consider using a real-time operating system, or even with an FPGA based approach.  If it is not essential to your system, you might consider using is HWTSP, where you do not declare lack samples (DAQmx simply give you the most recent example), or you could avoid HW timing all together and just use HAVE request to acquire a sample at a time.  What is appropriate depends on the requirements of your application.

    Hope that helps,

    Dan

Maybe you are looking for

  • I thought that 4 new but it has finished downloading 5. What is a beta? and should I have downloaded 4?

    Fire Fox 4 reminders kept popping up and finally I had time to download. FF5 was available so I download it, but I was wondering why FF5 was not shown or mentioned in the video. Now, wonder if it is a Beta?

  • Want to HP all in one pc Wireless: connecting to a network printer

    Printers HP 7520 has good router connect. Router to PC connect, but lists the printer as offline. Just installed new router and everything WAS fine printing. When to re-enter the WP program it says the status of the printer ready but does not print a

  • How to set properly contrast of the display on a Satellite A200 - 19L

    Dear all,Day before yesterday I bought a Toshiba A200 - 19L.When I play DVDs and movies, as well as photos I look at the picture is very pale, no contrast.I asked already brightness with FN/F5 I think (Ido has no computer available here now)The image

  • Scanning Photosmart 7520 problems

    I just tried I scan a document to the printer. I get a message indicating it found no computer.  I can scan OK computer. Also, how I'd get an icon of the scanner showing on the bottom of my screen? Helen Helen

  • Timers and Singletons

    A little history about what I want my app to do first.  I am writing a program to turn on my wifi on and off at a scheduled time.  For example, to turn on the wifi at 19:30, turn it off at 08:00 the next day.  Here's how the program works.  There are