[TIMOB-5340] Android: event listener is not found when passed 'this'
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2016-08-22T17:13:24.000+0000 |
Affected Version/s | Release 1.8.0 |
Fix Version/s | n/a |
Components | Android |
Labels | android, animate, eventlistener |
Reporter | Alan Vaghti |
Assignee | Ingo Muschenetz |
Created | 2011-09-22T15:45:58.000+0000 |
Updated | 2017-03-16T21:37:00.000+0000 |
Description
1) Use the app.js below in a new project
2) Launch application
Expected results: View animates from red to orange to black.
Actual results: View remains red.
Notes:
Logcat keeps returning "listener not found for eventName 'complete'"
Issue was discovered when testing iOS fix for TIMOB-3160
Code sample is essentially the example from: http://developer.appcelerator.com/apidoc/mobile/1.0/Titanium.UI.Animation
var win = Ti.UI.createWindow({ backgroundColor: 'purple' });
var view = Titanium.UI.createView({
backgroundColor:'red'
});
var animation = Titanium.UI.createAnimation();
animation.backgroundColor = 'black';
animation.duration = 4000;
animation.addEventListener('complete',function()
{
animation.removeEventListener('complete',this);
animation.backgroundColor = 'orange';
view.animate(animation);
});
view.animate(animation);
win.add(view);
win.open();
Bug persists on: SDK build: 1.8.0.1.v20111216124633 Devices: LG Slate (3.1) on V8, Droid 1 (2.2.2) on Rhino
this
does not refer to the reference to callback function, but rather the global scope.removeEventListener()
expects the second argument to be a function, not an object. You need to name the function and pass in the reference to the function like this:Closing ticket as invalid.