ActiveDen

Flash Optimalisation

55 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Netherlands
  • Sold between 100 and 1 000 dollars
Rumboon says

Hello there,

Im working on a flash project, and i need a little optimalisation.

First, the example: http://www.studiosteen.nl/clients/windsor/#/baden and click on a thumbnail (sorry, second deeplink for the fullscreen image doesnt work yet :))

The image should move on MouseMove, that is working. But if you check your CPU , its going WILD ! sometimes even up to 140%! Thats not what i want of course..

This is the function in the full image class:

private function onMouseMove(e:MouseEvent):void {

var rapW:Number = (stage.stageWidth/2)/((_photo.width-stage.stageWidth)/2);
var rapH:Number = (stage.stageHeight/2)/((_photo.height-stage.stageHeight)/2);
var speed:Number = ConfigManager.SPEED*2.5;

if (_photo.width>stage.stageWidth) {
      TweenLite.to(_photo, speed, {x:-mouseX/rapW, ease:Quart.easeOut});
       }

if (_photo.height>stage.stageHeight) {
      TweenLite.to(_photo, speed, {y:-mouseY/rapH, ease:Quart.easeOut});
      }
}

Maybe some of you has some good tips for me ?

510 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Portugal
plusquare says

That’s because you’re creating a TweenLite instance for each cicle. With around 30 cicles a sec it’s normal the cpu consumption will be high. Why don’t you use something like this:

if(_photo.height>stage.stageHeight){
      moveToY = -(stage.mouseY/stage.stageHeight)*(_photo.height-stage.stageHeight);
      _photo.y += (moveToY - _photo.y)/easeAmount;
}

It’ll ease the motion without the use of tweenLite. Do the same for X. Just coded this here in a min, don’t be surprised if something isn’t right :p

510 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Portugal
plusquare says

Oh, and my cpu only got to 21% with your file :p

55 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Netherlands
  • Sold between 100 and 1 000 dollars
Rumboon says

21% with my code? or your code?

hmm… weird stuff! But thanks :) gonna try yours tomorrow! Hope it helps :) Thanks!

510 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Portugal
plusquare says

21 with your code. Give it a try with mine..

by
by
by
by
by