PDA

View Full Version : changing resource attribute on view


ryanpape
11-18-2003, 09:58 PM
I am playing with the dataimage example, which has:


<resource src="btn_camera.png" name="button_camera" />
<resource src="btn_animation.png" name="button_animation" />
...


and then


<view resource="button_animation" stretches="both" x="2" y="2"/>


if I have moved this into a class something like


<class name="anibu">
<attribute name="resourcename"/>
....
<view resource="***" stretches="both" x="2" y="2"/>
...


I cannot get any combination of parent.resourcename, ${parent.resourcename}, etc to work for *** when the class is used as:


<anibu resourcename="button_animation"/>


What am I doing wrong?

Thanks in advance.

antun
11-19-2003, 09:50 AM
You can't/don't want to try and set a view's resource. Instead you want to use setSource() to set the src of a view at runtime. See this thread:

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=480&highlight=setsource

-Antun

ryanpape
11-19-2003, 10:37 AM
I was hoping to be able to set the resource from a class attribute.

What I was hoping to be able to accomplish was to represent a button with certain characteristics by creating a class containing the code but where the image and text would be passed in as an attribute.

antun
11-19-2003, 10:38 AM
How many variable states are there likely to be? One model that I would recommend would be to use a multi-frame resource, and set the frame number based on the passed argument.

Would that work for you?

-Antun