Sunday, June 11, 2006

SmurfLib Update-- Templates

Download:
SmurfLib.zip

I added two template classes to com.object.utils: StaticTemplate and Template.
JavaDocs:
StaticTemplate.html
Template.html


StaticTemplate is unique because it transpose all the values changed within a template instance onto all templated objects.
For example:


import com.object.utils.StaticTemplate;

var obj1:Object = {};
var obj2:Object = {};

var sTemplate:StaticTemplate = new StaticTemplate({vector:new Point(10, 15)});

sTemplate.applyTo(obj1);
sTemplate.applyTo(obj2);

trace("o1.vector.x: "+obj1.vector.x); //10
sTemplate.vector.x = 20;

trace("o1.vector.x: "+obj1.vector.x); //20
trace("o2.vector.x: "+obj2.vector.x); //20



As you can see when the values in the template change all the instances that have the template applied change aswell.

The Template class only applies all the values to the templated object and changes to the template don't corrispond to the object templated.
Ex:


import com.object.utils.Template;

var myTemplate:Template = new Template({lol:"LMAO"});

var myObj:Object = {};

myTemplate.applyTo(myObj);
myTemplate.lol = "OMG";

trace(myObj.lol); //LMAO



Download and enjoy!

1 Comments:

Blogger Lo Lo said...

http://www.ju.edu.jo/home.aspx
Jordan University
[url]http://www.ju.edu.jo[/url]

Sunday, October 30, 2016 3:00:00 AM  

Post a Comment

<< Home