-
Error #1009!!
I know this topic is posted else where on the forums but im in desprate need of help, I don't understand Actionscript 3 that well but found a tutorial for an effect I want to use in a school project. For some reason Im getting this error,
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main/addListeners()
at main()
Like I said I don't understand much CS3 so its hard to decipher the other posts and fix my code. Here is the code.
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class main extends Sprite
{
var xPos:int;
var yPos:int;
public function main():void
{
addListeners(den);
}
private function getPosition(target:Object):void
{
xPos = target.x;
yPos = target.y;
}
private function dragObject(e:MouseEvent):void
{
getPosition(e.target);
e.target.startDrag(true);
}
private function stopDragObject(e:MouseEvent):void
{
if (e.target.hitTestObject(getChildByName(e.target.na me + "Target")))
{
e.target.x = getChildByName(e.target.name + "Target").x;
e.target.y = getChildByName(e.target.name + "Target").y;
}
else
{
e.target.x = xPos;
e.target.y = yPos;
}
e.target.stopDrag();
}
private function addListeners(... objects):void
{
for (var i:int = 0; i < objects.length; i++)
{
objects[i].addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
objects[i].addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
}
}
}
}
Any help would be great thanks!!!!!
-
There's something missing. What is den? It is not declared or defined in the code above. That alone would result in a different error, though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|