Hello everyone.
I have an error code #1009 and have been googling around and found a lot of links, yet I’m not sure where to put the Event.ADDED_TO_STAGE to make my project work.
The error code is
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at be.boulevart.google.ajaxapi.translation::GoogleTranslation/onResponse()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
and my as3 code is:
package{
import flash.display.*;
import flash.events.*;
import gs.*;
import fl.motion.easing.*;
import framework.utils.LoadXML;
import be.boulevart.google.ajaxapi.translation.*;
import be.boulevart.google.ajaxapi.*;
import be.boulevart.google.ajaxapi.search.*
import be.boulevart.google.apicore.GoogleApiKeyStore;
import be.boulevart.google.events.*;
public dynamic class wotd_widget extends MovieClip{
//vars
var loadXML:LoadXML = new LoadXML('http://wordsmith.org/awad/rss1.xml',onComplete);
private var mc01:MovieClip;
private var mclayout:MovieClip;
//constructor
public function wotd_widget():void{
trace('wotd');
init_btn();
}
private function onComplete($xml:XML):void{
trace($xml.channel.item[0].title);
trace($xml.channel.item[0].description);
wotd_In.text = $xml.channel.item[0].title;
des_In.text = $xml.channel.item[0].description;
var gt:GoogleTranslation = new GoogleTranslation();
gt.translate($xml.channel.item[0].title,'en','de');
gt.addEventListener(GoogleApiEvent.TRANSLATION_RESULT,onTranslate);
}
private function onTranslate(e:GoogleApiEvent):void{
trans_In.text = e.data.result;
}
private function init_btn():void{
this.mc01 = new trans_btn;
this.mc01.x = 340.9;
this.mc01.y = 234.4;
addChild(this.mc01);
TweenMax.to(this.mc01,1,{x:340.9, y:234.4, ease:Cubic.easeOut,onComplete:onComplete1});
}
private function onComplete1():void{
this.mc01.buttonMode = true;
this.mc01.addEventListener(MouseEvent.ROLL_OVER,mEvent01);
this.mc01.addEventListener(MouseEvent.ROLL_OUT,mEvent01);
this.mc01.addEventListener(MouseEvent.CLICK,mEvent01);
}
function mEvent01(e:MouseEvent):void{
switch(e.type){
case 'rollOver':
//this executes when you rollover the target
TweenMax.to(MovieClip(e.target),0,{tint:0xFF75B6});
break;
case 'rollOut':
//this executes when you rolloff the target
TweenMax.to(MovieClip(e.target),0,{removeTint:true});
break;
case 'click':
//this executes when you click the target
onClick01();
break;
}
}
private function onClick01():void{
var gt:GoogleTranslation = new GoogleTranslation();
gt.translate(input_trans.text,'en','de');
gt.addEventListener(GoogleApiEvent.TRANSLATION_RESULT,onTranslation);
}
function onTranslation(e:GoogleApiEvent):void{
trace(e.data.to);
trace(e.data.orig);
trace(e.data.from);
trace(e.data.result);
output_trans.text = e.data.result;
}
}
}
NEED YOUR HELP REALLY REALLY FAST! thanks