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: 
idunno
Visitor

SwapLayers Problem

Sometimes when I use swaplayers, it can cause unexpected things to happen, for example, make the video on the left of the screen disappear even though they are not on the same layer, or not swap back when I use, for example


if chooseStreams = 0

m.canvas.swapLayers(8, -7)

end if

if chooseStreams = 0
m.canvas.swapLayers(-7, 😎

end if

Where a button press can change the value of chooseStreams.
Has any one else had similar problems?
0 Kudos
2 REPLIES 2
TheEndless
Channel Surfer

Re: SwapLayers Problem

Without knowing the content of your layers it's hard to say what's happening, but in order for video to be visible all layers on top of it have to be transparent and use the "Source" CompositionMode.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
destruk
Streaming Star

Re: SwapLayers Problem

Rather than using swaplayers(1,2) to switch 1 and 2 between each other, running a multi-staged swap tends to work best in my experience.
ie
swaplayers(1,-1) 'note negative z-orders might not work, simply used as an example - move layer 1 to layer -1
swaplayers(2,1) ' move layer 2 to layer 1
swaplayers(-1,2) 'move -1 layer to layer 2

This way you don't overwrite one of the layers - they are retained intact, and you don't have to redraw anything.
Swap the content Meta-Data stored in zOrderA with the content Meta-Data stored in zOrderB.
Enables the developer to change which layer is displayed “On Top”
It is possible to SwapLayers with empty (unspecified) layers.
Your performance may vary.
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.