PDA

View Full Version : dynamic positioning


digibrix
03-22-2004, 08:18 AM
if i have an object that is on a page in a certain position.. but it is not placed there by using X and Y... if i drag it.. is there a way to dynamically position it back to its "original" position without coding an X and Y???

antun
03-22-2004, 01:11 PM
You could record its x and y positions using the onmousedown event:


<method event="onmousedown">
this.origX = this.x;
this.origY = this.y;
</method>


-Antun

digibrix
03-22-2004, 03:36 PM
i know i am close on this.. can u help.. thanks..


<view id="toptab" onmousedown="this.dragger.apply();this.bringtofront(true);" onmouseup="this.dragger.remove()">
<dragstate name="dragger" />
<method event="onmousedown">
this.origX = this.x;
this.origY = this.y;
</method>

<attribute name="oldX" value="${this.x}" type="expression" />
<attribute name="oldY" value="${this.y}" type="expression" />
<animatorgroup name="returnToStartingState" process="simultaneous" start="false" >
<animator attribute="x" to="${this.parent.parent.oldX}" duration="20" />
<animator attribute="y" to="${this.parent.parent.oldY}" duration="20" />
</animatorgroup>


<tabs width="180" height="150" style="goldcolors">


<tabpane text="Greeting" bgcolor="white">
<view name="greeting" width="165" height="105" clip="true">
<text multiline="true">
asfdsdfsdfafs<br/><br/>Edit Profile<br/>Customize
</text><scrollbar/>
</view>
</tabpane>


<tabpane text="Online Peers">
<view name="contents" width="165" height="105" clip="true">
<view layout="axis:y;spacing:5">
<list style="customlistcolors" spacing="2" bgcolor="${iceblue4}" width="165">
<textlistitem onclick="im.setVisible(true)">Peter</textlistitem>
<textlistitem>Bret</textlistitem>
<textlistitem>Sarah</textlistitem>
<textlistitem>Christian</textlistitem>
<textlistitem>Pablo</textlistitem>
<textlistitem>Lyndon</textlistitem>
<textlistitem>Adam</textlistitem>
<textlistitem>Eric</textlistitem>
<textlistitem>David</textlistitem>
</list>
</view><scrollbar/>

</view>
</tabpane>
</tabs>
<button y="150" onclick="toptab.returnToStartingState.dostart()">Go Back</button>

</view>

antun
03-22-2004, 03:43 PM
You want to use type=number for constrained variables, and you don't want to constrain it for good, just once, right ($once{})?




<canvas debug="true">

<view id="toptab" onmousedown="this.dragger.apply();this.bringtofront(true);" onmouseup="this.dragger.remove()">
<dragstate name="dragger" />
<method event="onmousedown">
this.origX = this.x;
this.origY = this.y;
</method>

<attribute name="oldX" value="$once{this.x}" type="number" />
<attribute name="oldY" value="$once{this.y}" type="number" />
<animatorgroup name="returnToStartingState" process="simultaneous" start="false" >
<animator attribute="x" to="${this.parent.parent.oldX}" duration="200" />
<animator attribute="y" to="${this.parent.parent.oldY}" duration="200" />
</animatorgroup>


<tabs width="180" height="150" style="goldcolors">


<tabpane text="Greeting" bgcolor="white">
<view name="greeting" width="165" height="105" clip="true">
<text multiline="true">
asfdsdfsdfafs<br/><br/>Edit Profile<br/>Customize
</text><scrollbar/>
</view>
</tabpane>


<tabpane text="Online Peers">
<view name="contents" width="165" height="105" clip="true">
<view layout="axis:y;spacing:5">
<list style="customlistcolors" spacing="2" bgcolor="${iceblue4}" width="165">
<textlistitem onclick="im.setVisible(true)">Peter</textlistitem>
<textlistitem>Bret</textlistitem>
<textlistitem>Sarah</textlistitem>
<textlistitem>Christian</textlistitem>
<textlistitem>Pablo</textlistitem>
<textlistitem>Lyndon</textlistitem>
<textlistitem>Adam</textlistitem>
<textlistitem>Eric</textlistitem>
<textlistitem>David</textlistitem>
</list>
</view><scrollbar/>

</view>
</tabpane>
</tabs>
<button y="150" onclick="toptab.returnToStartingState.start()">Go Back</button>

</view>

</canvas>


-Antun