Hello guys!
Today i tried to attach a movieclip using AS3, but i wanted to make the positioning inside the class.
And i obtained an error:
First file(Document class)
package
{ import test;
import flash.display.*;
public class main extends MovieClip
{
public function main()
{
var mc:test=new test();
mc.q=Math.random()*100;
trace(mc.q)
addChild(mc)
}
}
}
Second(MovieClip class):
package
{
import flash.display.*;
public class test extends MovieClip {
public var q:Number
public function test():void
{
setCoords()
}
public function setCoords():void
{
trace(q);
this.y=q;
this.x=q;
}
}
At sequence mc.q=Math.random()*100; in the trace from test.as it displays ‘NaN’. How can I modify the value of ‘q’ (public variable) via instance?
If i use a function like mc.setCoords(x,y) the script works fine.
Thank you!