Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple viewports of the same DisplayObject
    text
    copied!<p>Is it possible to have multiple view of the same display object? (e.g. same-computer multi-player game using split screen)</p> <p>The sample code that failed to work follows:</p> <pre><code> var content: Sprite = new Sprite(); var v1: Sprite = new Sprite(); var v2: Sprite = new Sprite(); with(content.graphics) { lineStyle(2, 0xff0000); drawCircle(100, 100, 80); lineStyle(5, 0x009999); drawRect(50, 80, 200, 30); } v1.addChild(content); v1.x = 0; v1.y = 0; v1.scrollRect = new Rectangle(0, 0, 100, 100); addChild(v1); v2.addChild(content); v2.x = 100; v2.y = 0; v2.scrollRect = new Rectangle(0, 0, 100, 100); addChild(v2); </code></pre> <p>I thought this would make two viewports (<code>v1</code> and <code>v2</code>) of the same object (<code>content</code>). But when I checked the docs, DisplayObjectContaner/addChild method, it says,</p> <p>"If you add a child object that already has a different display object container as a parent, the object is removed from the child list of the other display object container."</p> <p>Is there a solution for this?</p> <hr> <p>Obtained result</p> <p><a href="http://img530.imageshack.us/img530/4611/111jd8.png" rel="nofollow noreferrer">Obtained result http://img530.imageshack.us/img530/4611/111jd8.png</a></p> <p>Expected result (simulated)</p> <p><a href="http://img337.imageshack.us/img337/7914/222mq4.png" rel="nofollow noreferrer">Expected result (simulated) http://img337.imageshack.us/img337/7914/222mq4.png</a></p> <hr> <p>Rendering to a bitmap as suggested by Antti is a great idea, but the rendered sprites will not be able to catch mouse events. Is there a way to redirect the mouse clicks on the bitmap to trigger clicks on the original sprites?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload