Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange Flex callLater x position Behavior
    primarykey
    data
    text
    <p>I'm not sure exactly where this is happening, but what I'm trying to do is make a scrolling ticker using flex, and it works fine when there is one of them on the screen, but when there are two, strange things happen. </p> <p>The way I have designed this for live updating, when the child of my hbox goes off the screen, I remove it and add another child to the end of it. This happens to reset the X position of the hbox, which isn't too bad, but it also resets the X position of any other hbox I have on the screen. Here is code that demonstrates what I'm seeing:</p> <p>To use this, run the flex program, then click in the first hbox to set its x position to your mouseX. When the x position of the second hbox (hbox3) is reset, so will the first hbox's (hbox2) X position.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application creationComplete="addToBoxes()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" &gt; &lt;mx:Script&gt; &lt;![CDATA[ import mx.controls.Button; private const speed:Number = 1; private function moveBox3():void{ box3.move(box3.x + speed, box3.y) if(Math.random() &gt; .99 &amp;&amp; box3.numChildren &gt; 0) box3.removeChildAt(0) callLater(moveBox3) } private function addToBoxes():void{ for(var i:int = 0; i &lt; 8; i++){ var a:Button = new Button; box2.addChild(a); a.label = "Box2:" + String(i) } for(var j:int = 0; j &lt; 8; j++){ var b:Button = new Button; box3.addChild(b) b.label = "Box3: " + String(j) } } ]]&gt; &lt;/mx:Script&gt; &lt;mx:HBox id="box2" width="100%" click="box2.x = mouseX" borderStyle="solid"/&gt; &lt;mx:HBox id="box3" width="100%" creationComplete="moveBox3()" borderStyle="solid"/&gt; &lt;/mx:Application&gt; </code></pre> <p>How can I prevent this from happening, or what is a better way to make an updating ticker like I am trying to do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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