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,  :smiling_face_with_sunglasses: 

                   end if

Where a button press can change the value of chooseStreams.
Has any one else had similar problems?

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.

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.