csk0921 / tweener

Automatically exported from code.google.com/p/tweener
0 stars 0 forks source link

draft for tween properties extension mechanism #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi folks.

I've hack an implementation for the "inheritance" mechanism of tween
objects properties.
This thread started at
http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/2007-May/000074.h
tml

The idea is that a new property will be check when adding a tween, the
"base" property.
The "base" property can be an object or an array with object to extend.
Properties will be copied to the tween from left to right, meaning that
objects with higher indexes will overwrite previous objects.

For example if we have:
var obj1 : Object = { time:3, delay = 2, transition: "linear"};
var obj2 : Object = { time:null, delay = 4, _x: 20};
var final : Object = {_y= 30, base: [obj1, obj2]};
Tweener.addTween(someObj, final);
In this case, the final object will look like this:
final = {
    _y: 30,
    _x: 20,
    delay: 4, 
    transition: "linear"
}

The base property can also be a single object, in which case:
var obj1 : Object = { time:3, delay = 2, transition: "linear"};
var final : Object = {_y= 30, base: obj1};
Tweener.addTween(someObj, final);
In this case, the final object will look like this:
final = {
    _y: 30,
    delay: 2, 
    time:3,
    transition: "linear"
}

If an object with higher precedence has a property set to null, that
property will be removed from the composite object.
No objects are modified, but only a shallow copy is made.

Zeh: I've decided not to mangle with Tweener's code. Instead I moved the
inheritance to a function:
public static function makePropChain(p_obj : Object) : Object

This way this can be used in addCaller and addTween alike.

For me, it would make sense if it lived on the TweenListObj.

I've done some initial testings for as2 and as3, and it looks okay.
If you find this any issues, please let me know,

cheers
arthur

Original issue reported on code.google.com by debert on 12 May 2007 at 10:37

Attachments:

GoogleCodeExporter commented 8 years ago
This has been applied in version 1.26.60 ( [rev 302])

Original comment by debert on 26 Aug 2007 at 6:34