ok, now that I have this AI targeting script that I wrote, it enables allied players vehicles to scan around and whenever their scanner comes around and hits a target it locks on and tells the weapon to fire. Now this doesnt sound to complicated to me, but flash sure is having a hard time with it. Heres an example of the code I wrote onClipEvent (load) { //ts = target sequence //ts 1 = targeted //ts 2 = target locked //ts 0 = finding target this._x=random(501) _y=60+random(80) movespeed=-2 drag=1 missileloaded = 1; hit._xscale = 100; hit._yscale = 100; } onClipEvent (enterFrame) { if (this._x<=90){ ts=3 } if (ts == 3) { missileloaded = 1; hit._xscale = 100; hit._yscale = 100; ts = 0; drag=1 } if (ts == 0) { if (drag==1){ this._x += movespeed; if (this._x>=900) { movespeed=-3 _y=90-random(60) } if (this._x<=400){ movespeed=3 _y=90-random(60) } } if (hit._xscale<=10){ hit._xscale +=.5; hit._yscale +=.5; } //A10 for (i=1; i<=_parent._parent.numA10; i++) { if (hit.hitTest(_parent._parent["a10"+i].craft)) { movespeed=-.5 hit._rotation -= 5; if (hit._xscale>70) { hit._xscale -=1; hit._yscale -=1; } if (hit._xscale <= 70) { if (missileloaded == 1) { hit._xscale=10 hit._yscale=10 missileloaded = 0; _parent.body.launcher.fire=1 } drag=0 this._x = _parent._parent["a10"+i]._x; this._y = _parent._parent["a10"+i]._y; } } } //UAV for (i=1; i<=_parent._parent.numUav; i++) { if (hit.hitTest(_parent._parent["uav"+i].uav)) { movespeed=-.5 hit._rotation -= 5; if (hit._xscale>70) { hit._xscale -=1; hit._yscale -=1; } if (hit._xscale <= 70) { if (missileloaded == 1) { hit._xscale=10 hit._yscale=10 missileloaded = 0; _parent.body.launcher.fire=1 } drag=0 this._x = _parent._parent["uav"+i]._x; this._y = _parent._parent["uav"+i]._y; } } } } } I think this may be way too complicated for flash to run on everyframe several times. but what could I possibly replace it with thats simpler
How many times per frame are the for loops going? (numA10 and numUav are not defined in the code sample you've given) And using the _xscale and _yscale properties of objects is horribly inefficient.
it runs 30 times a second, just running enterFrame (because the game is set to run at 30fps) I think that would be great if I reduced it to maybe 15, but how would I do that? is there a enterFrame/2? lol also I will take out the _xscale and _yscale, thanks for the advice
thanks for every1's help, I think I found a solution, which was to lower the variety of detectables, which is working for now ya, I tried soemthing like that Louissi it was kinda funny, the game would run fast litereally every time it paused, wasnt practical, i lol'd