# \[FMX\] CPU overusage problem

**URL:** <https://forum.kirupa.com/t/fmx-cpu-overusage-problem/27969>\
**Category:** flash\
**Created:** [August 8, 2003, 2:45pm UTC](https://forum.kirupa.com/t/fmx-cpu-overusage-problem/27969 "2003-08-08T14:45:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Psykloak1](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@Psykloak1](https://forum.kirupa.com/u/Psykloak1)\
**Post date:** [August 8, 2003, 2:45pm UTC](https://forum.kirupa.com/t/fmx-cpu-overusage-problem/27969/1 "2003-08-08T14:45:07Z")

</div>

I’ve been workning on this footer for a friend and its all working how its supposed to but I noticed that if I play the swf and listen to music at the same time, the music will jump and skip and lag and stuff like that.

I’m on WinXP so I hit Ctrl+Alt+Del to check how much of the CPU was being used and it was up at 100%, when I closed the flash player, the CPU Usage jumped back down to around 5%

Heres the code:

[AS]onClipEvent (load) {  
ch=0;  
}  
onClipEvent (enterFrame) {  
if (Math.ceil(Math.random()\*20)==1){//random number, if its “1” then change direction  
ch=Math.ceil(Math.random()\*3)-2;//sets ch to 1, 0 or -1  
}  
if(\_alpha\<-20)ch=1;// if ch gets too low, switch directions  
if(\_alpha\>80)ch=-1;// if ch gets too high, switch directions

```
_alpha+=ch*10;//add ch * 10 to the _alpha of the movie clip

```

}[/AS]

What it does is makes the movie clip get more or less Alpha’ed

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 8, 2003, 2:53pm UTC](https://forum.kirupa.com/t/fmx-cpu-overusage-problem/27969/2 "2003-08-08T14:53:00Z")

</div>

whoa…those are a lot of math functions…

why don’t you try this instead:

```auto
onClipEvent (load) {
_ch = ch = 10;
}
onClipEvent (enterFrame) {
ch = (!random(20)) ? _ch*(Math.random()*2-1) : ch;
ch = (_alpha > 80 || _alpha < -20) ? -ch : ch;
_alpha += ch;
}

```

Don’t worry, i’m pretty sure this code does the same thing.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 8, 2003, 2:57pm UTC](https://forum.kirupa.com/t/fmx-cpu-overusage-problem/27969/3 "2003-08-08T14:57:35Z")

</div>

reduce the FPS, reduce the size or increase your processor 😉

Flash is no speed demon. You’ll get a hit playing swfs

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 8, 2003, 3:29pm UTC](https://forum.kirupa.com/t/fmx-cpu-overusage-problem/27969/4 "2003-08-08T15:29:36Z")

</div>

thoriphes: The code works but its still eating up the cpu. I think it’s just because its too much for flash to handel or something.

Sen: I have a fairly new computer, 2.\<something\> Ghz P4 So I’m just worried about how it will act on other computers…

Anyway, I played with it some more and got it good enought for my needs. Check it out:

[Click here to see it.](http://neptunecircle.com/misc/sig2.html)
