Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DLC
Visitor

layer.Clear()

Hello,

Just a simple question on roImageCanvas, in the doc you can find :

Void ClearLayer(Integer zOrder)
Clear all content from a layer (see SetLayer for the layer definition)

Void Clear(Void)
Clear all content from all layers.


Do these functions also delete the layer itself? In my app, the number of layers is dynamic and I sometimes face weird behavior. For example, I have lines of text that appear where they shouldn't, i have rectangles that are supposed to be separate and that are not. It is just like if what i had drawn before was not really cleared and remained on the screen.
I tried using AllowUpdates() and put some Sleep() to be sure to let the time to the box to clear everything before drawing again, but it didn't change.
Any idea of what can cause this? A function I have forgotten maybe?

Thank you.

Denis
0 Kudos
6 REPLIES 6
DLC
Visitor

Re: layer.Clear()

Does someone faced unexpected behavior with those two functions? I tried removing them from my code and i don't have problems anymore. I just create my layers without clearing the ones already created and it is ok. Looks like they are bugged, or maybe it is the roImageCanvas that has a problem? Or maybe there is still something I am missing but I really don't see what.
Any idea?

Denis
0 Kudos
MSGreg
Visitor

Re: layer.Clear()

I've run into a problem where I overwrite a specific file using roUrlTransfer and roImageCanvas caches the previous image.

In that case, the workaround is to call PurgeCachedImages() BEFORE you clear the layer or AFTER you reset the layer because the purge only happens to the images referenced in the layer at time of the call to purge.

That could lead to what you describe, but it doesn't sound like that is quite the issue you've found.

It might help if you created a function that replicated the problem.
0 Kudos
DLC
Visitor

Re: layer.Clear()

Ok i'll try it.
Thanks.
0 Kudos
DLC
Visitor

Re: layer.Clear()

Well I've been working on it till you propose that and it works fine now, though the screen needs one second to show each time i click on one of the remote button. It is a bit disappointed but i will do with it.
Thank you very much.
0 Kudos
MSGreg
Visitor

Re: layer.Clear()

No problem. If there are speed issues, you may want to consider re-implementing that particular screen using an roScreen, which has its own usage requirements on what you can and can't do, but in general roScreen is much faster but less convenient/less easy to use.
0 Kudos
DLC
Visitor

Re: layer.Clear()

I tried using roScreen a few weeks ago and i gave up, though i can't remember why :oops: ... Maybe i'll take another look.
Thanks.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.