I have been working on your problem to improve my understanding. I
managed to have it work in one case (Method1), but would like to
understand why it doesn't update the resource in the other cases
(Methods 2 and 3) :
<canvas debug="true" >
<include href="lz/combobox.lzx" />
<resource name="r1" src="resources/dash_icon_com.swf"/>
<resource name="r2" src="resources/dash_icon_daily.swf"/>
<resource name="r3" src="resources/dash_icon_media.swf"/>
<resource name="r4" src="resources/dash_icon_people.swf"/>
<resource name="r5" src="resources/dash_icon_planner.swf"/>
<class name="skindef">
<attribute name="btnrsc" type="string"/>
</class>
<skindef name="skin1" btnrsc="r1"/>
<skindef name="skin2" btnrsc="r2"/>
<skindef name="skin3" btnrsc="r3"/>
<skindef name="skin4" btnrsc="r4"/>
<skindef name="skin5" btnrsc="r5"/>
<simplelayout axis="y"/>
<text text="Select your resource"/>
<combobox name="stylechoice" width="120" editable="false">
<method event="onselect" name="switchskin">
// Method 1 -- this one works
canvas.view1.setResource(canvas[this.getText()].btnrsc);
// Method 2 -- this one does not
canvas.setAttribute('curskin',this.getText());
// Method 3 -- this one does not either
canvas.thedata.setAttribute('skin',this.getText());
</method>
<textlistitem text="skin1" selected="true"/>
<textlistitem text="skin2"/>
<textlistitem text="skin3"/>
<textlistitem text="skin4"/>
<textlistitem text="skin5"/>
</combobox>
<!-- Method 1 - resource changed in the combobox -->
<view name="view1" resource="${skin1}"/>
<!-- Method 2 - curskin not changed, neither from the constraint nor
from the combobox 'onselect' -->
<attribute name="curskin" value="${stylechoice.text}"/>
<view name="view2"
resource="${canvas[canvas.getAttribute('curskin')].btnrsc}"/>
<!-- This one is updated -->
<text width="400" text="${'stylechoice.text = '+stylechoice.text}" />
<!-- This one is not ??? -->
<text width="400" text="${'curskin =
'+canvas.getAttribute('curskin')}" />
<!-- Method 3 - working class attribute not changed, same tests as
with the canvas attribute -->
<class name="mydata">
<attribute name="skin" type="string"/>
</class>
<mydata name="thedata" skin="${stylechoice.text}" />
<view name="view3" resource="${canvas[thedata.skin].btnrsc}"/>
<!-- This one is updated -->
<text width="400" text="${'canvas[thedata.skin] =
'+canvas[thedata.skin]}" />
<!-- This one is not ??? -->
<text width="400" text="${'canvas[thedata.skin].btnrsc =
'+canvas[thedata.skin].btnrsc}" />
</canvas>
Scott Evans a écrit :
> I'm working on some skinnable-app stuff, and I'd like to change resources
> willy-nilly at runtime. This doesn't seem to quite work, though I'm
> having pretty good luck if I do things like this:
>
> target.setResource(rsc);
> if (stretches) {
> target.setAttribute('stretches', stretches);
> } else {
> target.setWidth(target.resourcewidth);
> target.setHeight(target.resourceheight);
> }
>
>
> But what I *really* want to do is something like this:
>
> <resource name="r1" src="1.swf"/>
> <resource name="r2" src="2.swf"/>
>
> <class name="skindef">
> <attribute name="btnrsc" type="string"/>
> </class>
>
> <skindef name="skin1" brnrsc="r1"/>
> <skindef name="skin2" brnrsc="r2"/>
>
> <attribute name="curskin" value="$once{skin1}"/>
>
> ...
>
> <view name="v1" resource="${curskin.btnrsc}"
>
> ...
>
> <method name="switchskin">
> canvas.setAttribute('curskin', canvas.skin2);
>
> // resources magically change!
> </method>
>
>
> Right now when I do this, nothing happens - no warning, but no resource
> change either. How far is the platform from supporting something like this?
>
>
>
> gse
> _______________________________________________
> Laszlo-dev mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-dev
>
> __________ NOD32 1.1447 (20060316) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>
>
>
_______________________________________________
Laszlo-dev mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-dev