Issue with scrollrect

Hello there!
I am adding a graphic to a sprite and then assigning a scrollrect to it. The graphic scrolls just fine inside the sprite, but a copy of the exact same graphic appears underneath. What can be the issue?
issue

Would you mind sharing a little bit of example code? Does it work as you expect on the Flash target?

My bad, something was bit off with my code and i could not reproduce it afterward. Everything seems normal now. Feeling dump for wasting your time asking :confused: . Just 1 question if you don’t mind. Is it possible to manipulate the scrollrect within the sprite without assigning a new rect to the sprite every frame?

This:

sprite.scrollRect.x += 5;

And not do this:

var rect.x += 5;
sprite.scrollRect = rect;

Sadly no. When you access sprite.scrollRect, OpenFL returns a copy of the underlying object. Any changes you make to this object will be totally ignored.

1 Like

Even if the Flash API is like that. Can we improve performance by avoiding creating a copy of the rectangle each time?
I don’t think it will break anything.

PS: I don’t have performance issue with scrollrect, it was just a thought.

1 Like

Well i agree with “loudo”, there is no reason creating a new rectangle each time. I know that OpenFL mimics the Flash API but still it could be a good improvement.

Perhaps we can have one object instance we return, and re-use, with a define to disable, so it’s still different than our internal rectangle, but multiple calls would be the same