Jump to content
GreenSock

jeremyhoss

A little dissapointed with the tweening speed/tearing

Recommended Posts

Hi

 

I noticed the TweenMax can tween thousands of objects very nicely however I'm looking to get just 20 flash bitmaps on the screen to scroll smoothly. I have the main document class for my flash cs4 project set to Main.as so it has a class file with it. I placed the 20 bitmaps onto the screen and Instead of tweening all 20 bitmaps, I decided to tween just the Main.as object by tweening the this.x and this.y property. Here is my result, although it's quite smooth, I thought it would be amazingly smooth lol

 

Am I doing anything wrong or can I do anything to make it even faster/smoother?

 

I uploaded the swf file to this free swf host I found on google, http://megaswf.com/view/87311edf2ec5998 ... c8665.html

 

press the left/right arrow keys to make use of the tween. Here is my source code,

 

http://actionscript.pastebin.com/m4baad918

Link to comment
Share on other sites

Forgot to mention, i'm using AS3 with TweenMax and the framerate of my movie is 60fps

Link to comment
Share on other sites

Ok, after re-reading my post, I realize this is an earlier version of my tween testing that doesn't use bitmaps, it actually uses a custom class Square which extends Sprite but I tried using bitmaps and thought it would perform better, but it's about the same. Perhaps I'm not utilizing the tween properly or something?

Link to comment
Share on other sites

ok after reading around on the forum, it appears the problem is that i'm creating a new tween every single frame by using the enterframe handler. what is the alternate solution. I simply want to tween this.x either way depending on whether or not i'm pressing the arrow keys. Basically move super smoothly and concistantly

Link to comment
Share on other sites

Check out the new updateTo() method in TweenMax, and you might want to look into speeding things up a little with FastEase.

 

function yourEnterFrameHandler(event:Event):void {
   yourTween.updateTo({x:newX, y:newY}, true);
}

Link to comment
Share on other sites

When trying to use TweenMax.updateTo({ x:"50"}, true);

 

1061: Call to a possibly undefined method updateTo through a reference with static type Class.

 

I'm getting that. Do i need to instantiate the Tween to a new instance before I can use this? Before I was using tween staticly

Link to comment
Share on other sites

You call updateTo() on a particular TweenMax instance, not on the class itself (otherwise how would it know which tween to udpate?). Like:

 

var myTween:TweenMax = new TweenMax(mc, 1, {x:400});
//then later...
myTween.updateTo({x:100}, true);

Link to comment
Share on other sites

Ok, I've fooled around trying to get it to be a fast and smooth tween. Do you want to see if you can get it any smoother than what I've got so far? I used flashdevelop, just open up the TweenTest.as3proj file and edit TweenTest.as, you'll see where I put the tween code there.

 

If you press the left/right arrow keys, I have it moving about the speed that I want which is good, but the smoothness is quite choppy, especially on the ends. Maybe were reaching flash's limitations or maybe we are reaching Greensock limitations?

 

Link to comment
Share on other sites

I'm not a FlashDevelop guy - can you throw this into an FLA or something? Not that I can't figure out how to put that together, but I'm VERY pressed for time and I'm more likely to look at something that's super quick for me to download, open and hit CTRL-ENTER to look at. :)

 

I highly doubt that TweenMax is the culprit here - in 98% of the cases, graphics rendering in the Flash Player accounts for FAR more of the CPU load than any ActionScript code execution. Literally 100:1 ratio. Also watch out for the fact that when any filter is applied to a DisplayObject, Flash forces cacheAsBitmap to true which will only render the object on whole pixels, so it can appear to be jerky when the object is moving slowly but that has nothing to do with the actual tweening. It's just that the values are snapping to whole numbers when Flash displays it.

Link to comment
Share on other sites

Ok, here is a new zip file that contains all the code in the timeline in the .fla file. I commented out the rightTween that works smoothly but it's slow to move across the screen. The tween I want that has the right speed, moves choppy and is not smooth, can you fix it so it's smooth and still moves at good speed?

 

http://rickydoesit.com/wp-content/uploa ... tFlash.zip

Link to comment
Share on other sites

Regarding what you said about whether or not any of these Square Sprites have cacheAsBitmap set to true or false, I did some checking.

 

//traces false. targets the Sprite's cacheAsBitmap property

trace(tileArray[0][0].cacheAsBitmap);

 

//traces false also. targets the Sprite's first child (the shape)

trace(tileArray[0][0].getChildAt(0).cacheAsBitmap);

Link to comment
Share on other sites

Ok, yes I realize the object i'm tweening is actually the the keyword this so I traced out that instead, trace(this.cacheAsBitmap); traces false.

Link to comment
Share on other sites

Did you figure it out? I just tried to download your FLA and it was gone.

Link to comment
Share on other sites

ok, here is my problem. I have a new test tween file that you can download to see what I'm doing. As you can see I do not make use of the updateTo at all and I'm using a bunch of booleans to keep track of things. Can you show me how to make use of updateTo method so I dont have to do what I'm doing?

 

http://rickydoesit.com/wp-content/uploa ... Proper.zip

 

the new example just uses a Sprite

Link to comment
Share on other sites

Yeah, you're running at 60fps and asking the tween to re-adjust itself constantly when the key is down which is a lot of work for any engine. If you want maximum performance, you might want to consider using some basic physics stuff and doing the motion directly in your ENTER_FRAME handler. See the attached file for an example applied to your FLA. I also included a cleaned-up one with TweenMax in place, but again, what you're trying to do isn't really something that's ideal for a tweening engine.

Link to comment
Share on other sites

  • 1 month later...

I'm not sure what I'm missing here, but anytime I try to use a updateTo I get a 1195 error: Attempted access of inaccessible method updateTo through a reference with static type com.greensock:TweenMax.

 

At first I figured I wasn't importing something correctly, so I found the TweenTest_w-TweenMax.zip attachment that Jack had added to this thread, and tried that, and I STILL get the same error!! The description directly refers to line 33 and 35 where the updateTo reside. Jeremy downloaded it and mentioned they both work fine. What am I doing wrong?

 

:x

 

JR

Link to comment
Share on other sites

Using a tween to move an object every frame is kind of a weird solution.

 

Normally all you do is yourObject._x += StepAmount;

and that's it! Why invoke a tween?

 

I also wanted to add that Flash doesn't do monitor refresh syncing, so you're gonna get tearing regardless, even if you are the best actionscripter on the planet.

Link to comment
Share on other sites

I'm not sure what I'm missing here, but anytime I try to use a updateTo I get a 1195 error: Attempted access of inaccessible method updateTo through a reference with static type com.greensock:TweenMax.

 

At first I figured I wasn't importing something correctly, so I found the TweenTest_w-TweenMax.zip attachment that Jack had added to this thread, and tried that, and I STILL get the same error!! The description directly refers to line 33 and 35 where the updateTo reside. Jeremy downloaded it and mentioned they both work fine. What am I doing wrong?

 

You must have some stale version on your system that Flash is using instead of the latest version that's in your document folder (you do have it there, right?). Have you deleted your ASO files? If you're still running into trouble, please zip your whole directory and post it here so we can download it and publish it and see if we get the error too. It sure sounds like a problem with your Flash install, though. Definitely get the latest download from http://www.tweenmax.com just to be sure too.

Link to comment
Share on other sites

I also wanted to add that Flash doesn't do monitor refresh syncing, so you're gonna get tearing regardless, even if you are the best actionscripter on the planet.

 

Can you explain exactly what you mean by "tearing"?

Link to comment
Share on other sites

i think he mean theres no V-sync, Flash player doesn't support it i think, not until it supports proper hardware rendering

Link to comment
Share on other sites

You must have some stale version on your system that Flash is using instead of the latest version that's in your document folder (you do have it there, right?).

 

That was it... thanks Jack!!

 

JR

:mrgreen:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×