I refocused on your other response about persisting common values but not common objects. Until I discover how to persist one of my own Object subclasses, I'm just sort of unpackaging and repackaging my complex objects on the morph for now and I have that working. I'm probably making things too difficult by not using models and the Widget class but I'll revisit those soon. Everything will get easier when I embrace coding directly inside a World - I keep going back and forth between my local editor and the wiki.
On Wed, Mar 4, 2009 at 1:46 AM, Robert Krahn < [email protected]> wrote: > Hi Phil, > the getTrait and setTrait methods are used by shapes, not morphs. All > instance variables of morphs are persistent a priori. I modified your test > code a bit: > > Morph.subclass("MyPersistedMorph", { > > handlesMouseDown : Functions.True, > > initialize : function($super) { > > console.log('PersistedMorph.initialize'); > $super(new lively.scene.Rectangle(new Rectangle(100, 100, 200, > 200))); > > this.setFill(Color.green); > console.log('PersistedMorph.initialize weight: ' + > this.weight); // will always be undefined because > > // > initialize isn't called for deserialization > > }, > > > onDeserialize: function() { > > console.log('PersistedMorph.onDeserialize weight: ' + > this.weight); // This works > > }, > onMouseDown : function($super, event) { > > console.log('PersistedMorph.onMouseDown'); > console.log('PersistedMorph.onMouseDown weight: ' + > this.weight); > this.weight = 100; > > return true; > } > }); > > > > Robert > > >
_______________________________________________ General mailing list [email protected] http://livelykernel.sunlabs.com/mailman/listinfo/general
