ActionScript Accessing Functions/Vars From Outside Of Class
Posted
by TheDarkIn1978
on Stack Overflow
See other posts from Stack Overflow
or by TheDarkIn1978
Published on 2010-05-29T19:51:01Z
Indexed on
2010/05/29
20:02 UTC
Read the original article
Hit count: 244
actionscript-3
how can i call public functions or vars of a sprite class from another class (or frame script)? i keep getting 1061: Call to a possibly undefined method (function i'm trying to call) through a reference with static type flash.display:Sprite.
//Framescript
var a:Sprite = new customRect();
addChild(a);
a.getSide();
//.as file
package
{
import flash.display.Sprite;
public class customRect extends Sprite
{
public var side:Number;
private function customRect()
{
var box:Sprite = new Sprite();
box.graphics.beginFill();
box.graphics.drawRect(0, 0, 200, 200);
box.graphics.endFill();
side = box.width;
}
public function getSide():void
{
trace(side);
}
}
}
© Stack Overflow or respective owner