How to instantiate a Starling object (in his Starling layer) and use it with Away3D (in his Away3D layer)?

Software: Away3D 4.x

Avatar
miyijura, Newbie
Posted: 19 May 2014 04:54 PM   Total Posts: 6

This is the case:
I have a layer of Away3D under a Starling layer.
In my Away3D I have a mesh and in the Starling I have a colored Sprite square.

I want that the Starling sprite follows the mouse while I´m hovering over a specific mesh in the Away3D layer.

To achieve this, I followed the tutorial http://away3d.com/tutorials/Away3D_and_Starling_Interoperation and modified to work with an AWD object.

The mesh appears and the label appears, but I don´t know how to make an instance of the label to take over control. When I tried to instantiate like

private var myLabel:My_Slabel;

and then tried to create a new object I get an error.

In my initStarling() I have:

private function initStarling() : void{
  starlingLabel 
= new Starling(My_Slabelstagestage3DProxy.viewPortstage3DProxy.stage3D);

What is the best approach on this?
I really appreciate any help.
Regards!

   

Avatar
miyijura, Newbie
Posted: 19 May 2014 07:35 PM   Total Posts: 6   [ # 1 ]

Found the solution on the mere example, I just have to call a function that returns an instance of the object (in this case, a Starling Sprite).

private static var _instance My_Slabel;

  public static function 
getInstance():My_Slabel {
    
return _instance;
  

And in the constructor:

_instance this

And then, I can call it in my Starling/Away3D Main.as like:

var starlingStars:My_Slabel My_Slabel.getInstance(); 

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X