Hi all,
its me again with simple questions if you don’t mind answering.
-
i have 1 fla and 1 class file.
-
inside fla, i’ put one instance called “main” on the stage. And i put this code in frame 1:
[AS]var obj:StageHandler = new StageHandler(main);[/AS]
- inside class file, i put this code:
[AS]package {
import flash.display.MovieClip;
import flash.display.Stage;
public class StageHandler {
var _stage;
var _main;
public function StageHandler(main_obj) {
_stage = main_obj.stage;
_main = main_obj;
trace(_stage.stageHeight); // output: 400
trace(_main.height); // output: 200
}
}
}
[/AS]
it works perfectly. However i’m still confused with the as3 concept. in this class file, i successfully trace stage’s height and main’s height.
but, if i change the code in fla to:
[AS]var obj:StageHandler = new StageHandler(stage);[/AS]
and in class file to:
[AS]package {
import flash.display.MovieClip;
import flash.display.Stage;
public class StageHandler {
var _stage;
var _main;
public function StageHandler(thisStage) {
_stage = thisStage;
_main = thisStage.main;
trace(_stage.stageHeight);
trace(_main.height); //1120: Access of undefined property main.
}
}
}
[/AS]
i cannot trace any main’s properties. why is that? isn’t “main” inside stage?
How do i access “main” via _stage?
Thankyou all.
attached is the source.