Hello everyone,
I’ve posted under a quite similar thread last week, where the problem was caused by a compiler setting in my Flashbuilder. Since that now works I’ve got new problems and and lot of fiddling around and using google didn’t help, so maybe some of you guys have a clever idea what to do.
I got a host application which is written in Flash Professional CS6 as an Air 3.4 Desktop Application. This host application can load previously generated locally stored .swf files with content (via a Loader and add’s them to the display list), based on a code that is entered (a little bit like a webbrowser).
Now I need to have some of these .swf files to display some 3D models via Away3D 4.1
The Away 3D swf is written in FlashBuilder and works perfectly on it’s own, but when I try to load the file in my host application I get Security Sanbox errors like this one:
SecurityError: Error #2070: Security sandbox violation: caller file:///C:/Users/Leo/Documents/DLB/content/DLB_Test/swf/DLB_Test_006.swf cannot access Stage owned by app:/DLB_Host.swf.
at flash.display::Stage/get stage3Ds()
at away3d.core.managers::Stage3DManager()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/managers/Stage3DManager.as:35]
at away3d.core.managers::Stage3DManager$/getInstance()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/managers/Stage3DManager.as:45]
at away3d.containers::View3D/onAddedToStage()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/containers/View3D.as:895]
at flash.display::DisplayObjectContainer/addChild()
at Basic_SkyBox/fnc_setupView()[C:\Users\Leo\Adobe Flash Builder 4.6\Basic_SkyBox\src\Basic_SkyBox.as:235]
at Basic_SkyBox/fnc_setupPage()[C:\Users\Leo\Adobe Flash Builder 4.6\Basic_SkyBox\src\Basic_SkyBox.as:192]
at classes.uiElements::ContentHolder/fnc_pageLoaded()[C:\Users\Leo\Desktop\Projekte\Liquid\Liquid\DLB_Entwicklung\DLB_Host\classes\uiElements\ContentHolder.as:452]
I understand, that the stage3D lies under the normal 2D display layer and can only be accessed through the stage. Is there a known possibility to access the stage from inside the loaded swf content, that bypasses the security sandbox?
Another thing I tried is to generate the stage 3D in the host application itself and to pass the view3D or the models from the loaded .swf file with getter/setter methods to the host application, but when I do this, I get such errors:
TypeError: Error #1034: Type Coercion failed: cannot convert away3d.containers::View3D@5cb8ed9 to away3d.containers.View3D.
at classes.uiElements::ContentHolder/fnc_view3Dready()[C:\Users\Leo\Desktop\Projekte\Liquid\Liquid\DLB_Entwicklung\DLB_Host\classes\uiElements\ContentHolder.as:876]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at TestClientMain/fnc_setupPage()[C:\Users\Leo\Desktop\Projekte\Liquid\Liquid\DLB_Entwicklung\DLB_Clients\Realtime3DClient\TestClient\TestClientMain.as:93]
at classes.uiElements::ContentHolder/fnc_pageLoaded()[C:\Users\Leo\Desktop\Projekte\Liquid\Liquid\DLB_Entwicklung\DLB_Host\classes\uiElements\ContentHolder.as:451]
or:
TypeError: Error #1034: Type Coercion failed: cannot convert away3d.entities::Mesh@eea9239 to away3d.entities.Mesh.
at classes.uiElements::ContentHolder/fnc_view3Dready()[C:\Users\Leo\Desktop\Projekte\Liquid\Liquid\DLB_Entwicklung\DLB_Host\classes\uiElements\ContentHolder.as:877]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at TestClientMain/fnc_setupPage()[C:\Users\Leo\Desktop\Projekte\Liquid\Liquid\DLB_Entwicklung\DLB_Clients\Realtime3DClient\TestClient\TestClientMain.as:93]
at classes.uiElements::ContentHolder/fnc_pageLoaded()[C:\Users\Leo\Desktop\Projekte\Liquid\Liquid\DLB_Entwicklung\DLB_Host\classes\uiElements\ContentHolder.as:451]
The code for the away3D swf testclient is as follows:
private var _view:View3D;
private var _torus:Mesh;
public function get view():View3D
{
return _view;
}
public function set view(inView: View3D):void
{
_view = inView;
}
public function get torus():Mesh
{
return _torus;
}
public function set torus(inTorus: Mesh):void
{
_torus = inTorus;
}
public function TestClientMain(){
}
public function fnc_setupPage():void {
_view = new View3D();
// commented out to prevent security sandbox errors
//addChild(_view);
_view.camera.z = -600;
_view.camera.y = 0;
_view.camera.lookAt(new Vector3D());
var material:ColorMaterial = new ColorMaterial(0xFF00FF);
_torus = new Mesh(new TorusGeometry(150,60,40,20),material);
_view.scene.addChild(_torus);
addEventListener(Event.ENTER_FRAME, fnc_onEnterFrame);
dispatchEvent(new Event("viewReady"));
}
private function fnc_onEnterFrame(e:Event):void {
_torus.rotationX += 2;
//_view.render();
dispatchEvent(new Event("renderView"));
}
The code in the host application looks for testing like this:
private function fnc_view3Dready(evt: Event): void{
var testView: View3D = new View3D();
testView = pageContainer.view;
var testTorus: Mesh = pageContainer.torus;
}
I hope anybody got a clever idea how to “fix” this. I need to get this working somehow without writing all 3D Code in host application context.
Thank you very much for your time!
Greetings, Leo