I convert my AS3 database to TypeScript and run this error:
AS3 Code:
private function loadDataXml(assetsXml : String) : void { var loader : URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, handleDataLoaded); loader.load(new URLRequest(assetsXml)); } private function handleDataLoaded(event : Event) : void { var xml_data : XML = new XML(event.target.data); parseData(xml_data); ......... } private function parseData(xml_data : XML) : void { ...... }
TypeScript code
private loadDataXml(assetsXml : string) { var xmlRequest:XMLHttpRequest = new XMLHttpRequest(); xmlRequest.addEventListener("load",this.handleDataLoaded, false); xmlRequest.open("GET", assetsXml, false); xmlRequest.setRequestHeader("Content-Type", "text/xml"); xmlRequest.send(null); } private handleDataLoaded(evt:Event) { var xmlDoc:Document = (<XMLHttpRequest> evt.target).responseXML; this.parseXMLData(xmlDoc); ...... } private parseData(xmlDoc:Document):void { ...... }
and I get this error "Uncaught TypeError: Object # does not have a method" parseData "because of this line xmlRequest.addEventListener .....
I tried using the arrow function, but still could not fix it (and I donβt think I am using it correctly)
scope typescript
user2694951
source share