flash - Passing variables between classes in Actionscript 3 -
i'm not terribly @ modern object coding lark , think may have misunderstood how meant to work:
this test.as in flash builder 4.7 project called test
package { import flash.display.sprite; public class test extends sprite { public var myvar:int = 10; public function test() { var mytestsub:testsub = new testsub; } } }
and testsub.as file:
package { public class testsub { public function testsub() { trace(myvar); } } }
flash builder tells me in testsub.as "possible access of undefined variable myvar" , not compile.
from limited, , incorrect, understanding, making myvar public in test.as should allow testsub.as utilize it. can explain going wrong? give thanks in advance.
you need wirte var this:
public class the_var { public function the_var { public static var my_var:number = 10; } }
and phone call var in other classes this:
public class the_test { public function the_test { trace(the_var.my_var); } }
actionscript-3 flash
No comments:
Post a Comment