Away3D Stage 3D View Errors

Software: Away3D 4.x

sjweekes, Newbie
Posted: 10 April 2014 03:39 PM   Total Posts: 4

Hi there.
I am just starting using ActionScript/ Flash/ Away3D.
I am trying to create a little app for iOS, which loads in a .obj file, adds its textures and then allows the user to rotate the camera around the object.
I am using Flash Builder CC, with Flex SDK 4.6, Air SDK 3.1.
I have built the app and it runs fine on the Air Simulator for the iphone/ipad.. However when i debug it to an actual device (iPhone 5s) i am getting an error saying “Error: Too many Stage3D instances used!”

Going through all the forum, people have suggested using .dispose() on the view3d object. (http://away3d.com/forum/viewthread/2489/) however when i do that i get an error ‘-1009-Cannot-access-a-property-or-method-of-a-null-object-reference’
I feel like i am going round in circles.

This is where i declare the my view/camera/scene etc in my constructor

“private function initEngine():void{
  stage.scaleMode = StageScaleMode.NO_SCALE;
  stage.align = StageAlign.TOP_LEFT;
  scene = new Scene3D();
  camera = new Camera3D();
  view = new View3D();
  view.antiAlias = 4;
  view.scene = scene;
  view.camera = camera;
  view.addSourceURL(“srcview/index.html”);
      addChild(view);
................ and so on”
when i add the dispose i am doing so by adding view.dispose() one line above the addChild(view);

I am completely stuck and have no clue what is wrong.
Please help

Many thanks

sam

   

Avatar
theMightyAtom, Sr. Member
Posted: 10 April 2014 05:52 PM   Total Posts: 669   [ # 1 ]

You shouldn’t need to dispose of the view.
Is this all the code?

On the device you can only use one instance of Stage3D, which in Away3D terms means one view (on a PC you can have up to 4 at a time).

Could it be that you are calling this part of the script more than once?
Even if you want to show different models, it doesn’t mean you have to create another View3D, you can re-use the same one.

Good Luck!

   

sjweekes, Newbie
Posted: 22 April 2014 10:08 AM   Total Posts: 4   [ # 2 ]

Hi theMightyAtom, thanks for your reply. sorry it has taken me so long to get back to you.

No that isnt the whole code. i was just trying to avoid posting the whole thing to save room. i will put it all at the end of this reply.

I am only looking at one model. The idea for now is to just have the model appear and rotate slightly with the movement of the touch.

From my attempts of debugging, the error only occurs on my device when i call the ‘new View3D()’ function.
When i debug the application using my iPhone i get the following error

Error: Too many Stage3D instances used!
at away3d.core.managers::Stage3DManager/getFreeStage3DProxy()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/core/managers/Stage3DManager.as:98]
at away3d.containers::View3D/onAddedToStage()[/Users/robbateman/Documents/Adobe Flash Builder 4.7/away3d-core-fp11/src/away3d/containers/View3D.as:929]
at flash.display::DisplayObjectContainer/addChild()
at R2D2Main()[/Users/samweekes/Documents/Adobe Flash Builder 4.7/MOBILE/src/R2D2Main.as:186]


at line 186 is where i call the new View3D(); the other ones are parts of the scripts that i include to help my code run.

i have absolutely no idea what to do.

cheers

sam

   

sjweekes, Newbie
Posted: 22 April 2014 10:08 AM   Total Posts: 4   [ # 3 ]

I know i said i would give my code.. but its too long to post the reply.

here is the part of the code that includes the view3D()

public function R2D2Main() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
scene = new Scene3D(); 
camera = new Camera3D();
view = new View3D();
view.antiAlias = 4;
view.scene = scene;
view.camera = camera;

cameraController = new HoverController(camera, null, 45, 10, 800);
view.addSourceURL(“srcview/index.html”);
addChild(view); 

      //add signature
Signature = Sprite(new SignatureSwf());
SignatureBitmap = new Bitmap(new BitmapData(Signature.width, Signature.height, true, 0));
stage.quality = StageQuality.HIGH;
SignatureBitmap.bitmapData.draw(Signature);
stage.quality = StageQuality.LOW;
addChild(SignatureBitmap); 
addChild(new AwayStats(view));
init();
  }


the last init() function instantiates all of the necessary event-listeners/lighitng/material/object loaders.

   

Avatar
theMightyAtom, Sr. Member
Posted: 22 April 2014 12:52 PM   Total Posts: 669   [ # 4 ]

As mentioned, you can only have one instance of Stage3D on iOS, so you should only call new View3D() ONCE in you application and re-use that same instance for each model.

Good Luck!

   

sjweekes, Newbie
Posted: 22 April 2014 01:00 PM   Total Posts: 4   [ # 5 ]

In the snippet above is the only place in my code that i have called the new View3D()
I can’t see where I am using it multiple times

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X