on my timeline i create a new instance of the class FirstClass
with the following code:
var firstObject:FirstClass = new FirstClass();
the class looks like this:
package {
public class FirstClass extends MovieClip {
public function FirstClass() {
var tempObject:SecondClass = new SecondClass();
tempObject.x = 100;
tempObject.y = 200;
}
public function getTempObjectXpos():Number{
return tempObject.x;
}
}
}
On my timeline i would like to acces the x position of the object tempObject
can anyone help me ?
You must declare tempObject as a member of FirstClass. You cannot use objects (object references if be exact) between different methods of a class if they aren't members of this class.
Corrected code:
package {
public class FirstClass extends MovieClip {
public function FirstClass() {
tempObject = new SecondClass();
tempObject.x = 100;
tempObject.y = 200;
}
public function getTempObjectXpos():Number{
return tempObject.x;
}
private var tempObject:SecondClass = null;
}
}