PDA

View Full Version : Problem with resource


malay
12-05-2007, 03:34 AM
Hi,

I am implementing drag and drop functionality similar to how it has been implemented for web creation sites such as www.webjam.com (only this has been implemented in PHP) and I am trying to do this OL

I have managed to implement a basic drag functionality by using the following code……….
<canvas>
<font name="helmet" src="fonts/helmetb.ttf"/>
<resource name="img1" src="images/1.jpg"/>
<resource name="img2" src="images/2.jpg"/>
<resource name="img3" src="images/3.jpg"/>
<!--draggable image view-->
<class name="draggedimage" bgcolor="0x93A5FF" visible="false">
<dragstate name="dragger"/>
<text name="txt" width="100"/>
<handler name="onmousedown">
this.showFloater(this.getAttributeRelative("x", canvas),
this.getAttributeRelative("y", canvas),
this.width,
this.txt.getText());
</handler>
<method name="showFloater" args="xpos, ypos, itemwidth, itemlabel ">
myimage.bringToFront();
this.setX(xpos);
this.setY(ypos);
this.setWidth(itemwidth);
this.txt.setText(itemlabel);
this.setResource(img1);
this.setVisible(true);
this.gm = new LzDelegate(this, "cancelFloater", LzGlobalMouse,"onmouseup");
this.setVisible(true);
this.dragger.apply();
</method>
<method name="cancelFloater">
this.dragger.remove();
this.txt.setText('');
<!--this.setVisible(false);-->
</method>

</class>

<!-- An instance of the draggedimage -->

<draggedimage id="myimage"/>
<!-- An image view that will get clicked and dragged -->

<class name="imageview" bgcolor="0x93A5FF" >

<attribute name="text" type="text"/>
<text name="txt" text="${parent.text}" resize="true"/>

<handler name="onmousedown">
myimage.showFloater(this.getAttributeRelative("x", canvas),
this.getAttributeRelative("y", canvas),
this.width,
this.txt.getText() );
</handler>
</class>

<!-- view for imagesresource="img1-->

<view id="img" x="30" y="150" width="400" height="400" bgcolor="aqua">
<text font="helmet" fontsize="10"
fgcolor="#175DDE">IMAGES</text>
<wrappinglayout spacing="10" xinset="10" yinset="10" />
<imageview resource="img1" >1</imageview>
<imageview resource="img1" >2</imageview>
<imageview resource="img1" >3</imageview>
</view>

<!-- view for custom design-->

<view id="costum" x="500" y="150" width="200" height="200" bgcolor="aqua"

visible="true">
<text font="helmet"
fontsize="10"
fgcolor="#175DDE">Customise Setting</text>
</view>
</canvas>
How can I take a resource that is attached in a
view and set that image resource to another view at run time.
I mean , when I drag one image the original image will be the same position and draggable view will be the same image.

Any suggestion to take this forward will be welcome , Thanks .

Malay

rcyeager
02-13-2008, 08:33 PM
If looks like your sample is dragging views that contain images. Why not set the draggable view's "source" attribute to point at the image file for the view at the start of the drag?

Robert
http://www.qrowd.com
http://www.cooqy.com