The title says what I want to achieve.
My code is this :
package
{
import flash.display.*;
import flash.events.*;
public class Sample extends MovieClip {
public function Sample():void {
var c:Rreth = new Rreth ;
c.x = 275;
c.y = 205;
c.buttonMode = true;
c.addEventListener(MouseEvent.MOUSE_DOWN,MouseDown);
addChild(c);
}
public function MouseDown(e:MouseEvent):void {
c.addEventListener(Event.ENTER_FRAME, moveMyRreth);
}
public function moveMyRreth(event:Event):void {
var thisRreth:Rreth = (event.target as Rreth);
thisRreth.x -= thisRreth.x - mouseX;
thisRreth.y -= thisRreth.y - mouseY;
}
}
}
The error thrown is :
C:\Users\Adi\Desktop\Sample\Sample.as, Line 15 1120: Access of undefined property c.
Who can help me achieve the result I want ?
The error is telling you. c is a undefined property. Try capitalise c.
so :
package
{
import flash.display.*;
import flash.events.*;
public class Sample extends MovieClip {
public function Sample():void {
var c:Rreth = new Rreth ;
C.x = 275;
C.y = 205;
C.buttonMode = true;
C.addEventListener(MouseEvent.MOUSE_DOWN,MouseDown);
addChild(C);
}
public function MouseDown(e:MouseEvent):void {
C.addEventListener(Event.ENTER_FRAME, moveMyRreth);
}
public function moveMyRreth(event:Event):void {
var thisRreth:Rreth = (event.target as Rreth);
thisRreth.x -= thisRreth.x - mouseX;
thisRreth.y -= thisRreth.y - mouseY;
}
}
}
I dont know what c is, if it is in the library look at it see exactly what you named it, AS3 is a case sensative language.
It might be the case that you did not give the object a instance name
If you did not give it a instance name, drag it onto the stage give it a instance then delete it.
North America
Europe, Middle East and Africa
Asia Pacific