openfl / actuate

Actuate is a flexible, fast "tween" library for animations in Haxe
MIT License
158 stars 66 forks source link

Issues with Actuate and Reflect API on HTML5 target #49

Closed dimumurray closed 9 years ago

dimumurray commented 9 years ago

NOTE: Issue also posted HERE


Having a few issues with the HTML5 target of a project I'm working on. Specifically w.r.t. to the Actuate tweening engine and the Reflect API.

The app in question parses a JSON file for tween parameters, referencing easing classes and functions as strings. I use the Reflect API to turn the strings into the appropriate instances.

Here are some snippets of code from the JSON file and the Haxe source to provide some context

JSON Source:

"tweenData":{
    "delay":0,
    "duration":1,
    "from":{"y":-60},
    "to":{"y":-430},
    "ease":{"type":"motion.easing.Cubic", "func":"easeIn"}
}

Haxe Source:

actuator = Actuate
    .tween(node.transform, tweenData.duration, tweenData.to)
    .delay(tweenData.delay)
    .ease(Reflect.field(Type.resolveClass(tweenData.ease.type), tweenData.ease.func));

The above code works fine on the windows target. But with the html5 target I get the following error:

TypeError: this.target.__properties__ is undefined

Which is triggered from the javascript equivalent of the motion.actuator.SimpleActuator::initialize() function. The following line from that method raised the TypeError:

if(Object.prototype.hasOwnProperty.call(this.target,i) && !(this.target.__properties__ || !this.target.__properties__["set_" + i]))

Is there a work-around for this?

dimumurray commented 9 years ago

Managed to fix this myself...Updated the line #172 in motion.actuators.SimpleActuator to read:

        if (Reflect.hasField (target, i) #if flash && !untyped (target).hasOwnProperty ("set_" + i) #elseif html5 && !(untyped (target).__properties__ && untyped (target).__properties__["set_" + i]) #end) {
jgranick commented 9 years ago

Thanks for the fix, I was expecting this to be a bigger deal, somehow, with the Haxe generics or something :wink:

dimumurray commented 9 years ago

Welcome...Just DeMorgan's laws in action... DeMorgan's laws