actuate icon indicating copy to clipboard operation
actuate copied to clipboard

Issues with Actuate and Reflect API on HTML5 target

Open dimumurray opened this issue 11 years ago • 3 comments

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 avatar Jan 06 '15 18:01 dimumurray

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) {

dimumurray avatar Jan 06 '15 19:01 dimumurray

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

jgranick avatar Jan 06 '15 22:01 jgranick

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

dimumurray avatar Jan 07 '15 02:01 dimumurray