PDA

View Full Version : [FMX] CPU overusage problem



Psykloak1
August 8th, 2003, 10:45 AM
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:

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
}

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

thoriphes
August 8th, 2003, 10:53 AM
whoa...those are a lot of math functions...

why don't you try this instead:

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.

senocular
August 8th, 2003, 10:57 AM
reduce the FPS, reduce the size or increase your processor ;)

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

Psykloak1
August 8th, 2003, 11:29 AM
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)