Hello.
Question on Action Script 3.
I want to find out one problem. How to call a method of another class from one class? In the example shown here, for some reason, the picture does not appear to me. In the FirstClass class, the qwadrat method of the SecondClass class is called. In this method there should be a green square on the stage. But I do not have it. What's wrong?
Or, better write a template to call a method of another class.
package { import flash.display.Sprite; import SecondClass; public class FirstClass extends Sprite { public function FirstClass() { var kartinka:SecondClass = new SecondClass(); kartinka.qwadrat(); } } } package { import flash.display.Sprite; public class SecondClass extends Sprite { public var qw:Sprite = new Sprite(); public function qwadrat():void { qw.graphics.lineStyle(1); qw.graphics.beginFill(0x00ff00); qw.graphics.drawRect(20, 20, 200, 200); qw.graphics.endFill(); addChild(qw); } } }
kartinka
=>image
qwadrat
=>rectangle
- Specter