actionscript - targeting sprites from a method in the document class - null object reference -


i trying code flash app entirely in document class. using gestureworks touch screen. when user presses button calls method should hide specific graphic not graphic touched.

essentially need way refer graphic on screen using method besides 'e.target'.

i receiving error: error #1009: cannot access property or method of null object reference.

            //this code works              private function photo1spriteflickhandler(e:gestureevent):void {                     var opentween:tween = new tween(e.target, "x", strong.easeout, 232, 970, 5, true);             }              //this code gives me null object reference               private function photo1spriteflickhandler(e:gestureevent):void {                     var opentween:tween = new tween(photo1sprite, "x", strong.easeout, 232, 970, 5, true);             }              //photo1sprite has been programatically added screen so:             var photo1sprite = new touchsprite();                     var photo1loader=new loader();                     photo1loader.load(new urlrequest("media/photos1/photo1.jpg"));                     photo1loader.contentloaderinfo.addeventlistener(event.complete,loadercomplete);                      photo1sprite.x = 232;                     photo1sprite.y = 538;                     photo1sprite.scalex = .3;                     photo1sprite.scaley = .3;                     photo1sprite.blobcontainerenabled = true;                     photo1sprite.addeventlistener(touchevent.touch_down, startdrag_press);                     photo1sprite.addeventlistener(touchevent.touch_up, stopdrag_release);                      photo1sprite.addchild(photo1loader);                  addchild(photo1sprite); 

it can access photo1sprite 'e.target' when button click happens on photo1sprite.

the problem happens when click 1 button (not photo1sprite) , have effect photo1sprite.

so can make photo1sprite react if method attached directly using 'e.target' not if trying call method called element on screen.

i'm not sure tween class constructor expects first argument. sprite instance or name of sprite instance? in case make sure - in context of photo1spriteflickhandler - photo1sprite 1) defined! , 2) refers correct thing.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -