In the AFTC article Away3D 4 VideoMaterial @:
http://www.allforthecode.co.uk/aftc/forum/user/modules/forum/article.php?index=4&subindex=3&aid=332
Demo and source is all there…
I have used what I call my standard application structure.
1. Application entry class.
2. Defines stage in Variables.stage (via public static var stage;) so it becomes a singleton and can be called any time you need it. But I only put it there for quick fix purposes when stage has been lost.
But my typical flow would be:
1. Entry class extends sprite
2. Application class extends sprite (The spine of the application)
3. Away3DScene class extends sprite
In each only assemble when added to stage listener is fired thus ensuring you have access to the stage in each of the classes. EG:
Application.as
class Application {
private var away3DScene:Away3DScene;
public function Application()
{
this.addEventListener(Event.ADDED_TO_STAGE,init);
}
public function init():void
{
this.removeEventListener(Event.ADDED_TO_STAGE,init);
away3DScene = Away3DScene.getInstance(); // Singleton pattern
addChild(away3DScene); // As this class has access to the stage so will this one ensuring it has been added to the stage
// Build a mesh code
away3DScene.scene.addChild(MyMesh);
}
Also Instantiating Away3D as a singleton view allows you to call the view from anywhere at any time via:
var away3DScene:Away3DScene;
away3DScene = Away3DScene.getInstance();
So even access to the stage is not really necessary.
But if you did need it, and you defined it as a static variable in Variables.as you would be able to simply use.
Variables.stage.stageWidth; //etc Just make sure it's defined
Anywere in your application with no problems.
But there are many ways….