# Manual event dispatch to a 3d object...coersion error! Gah!

**URL:** <https://forum.kirupa.com/t/manual-event-dispatch-to-a-3d-object-coersion-error-gah/260215>\
**Category:** Uncategorized\
**Created:** [May 13, 2008, 3:32pm UTC](https://forum.kirupa.com/t/manual-event-dispatch-to-a-3d-object-coersion-error-gah/260215 "2008-05-13T15:32:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![plasnid](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@plasnid](https://forum.kirupa.com/u/plasnid)\
**Post date:** [May 13, 2008, 3:32pm UTC](https://forum.kirupa.com/t/manual-event-dispatch-to-a-3d-object-coersion-error-gah/260215/1 "2008-05-13T15:32:12Z")

</div>

Good Day,

```
 I'm trying to use a dispatched event from a 2d element to control a similarly named 3d element. Unfortunately I've found that it is throwing a coersion error:( Am I doing something obviously wrong here? 

```

The Error:

TypeError: Error #1034: Type Coercion failed: cannot convert MC{com::Main@343f301 com::Main/sendName()}@3654c69 to org.papervision3d.objects.DisplayObject3D.  
at NavElmt/::clickEffect()

The Code:

package{  
import flash.display.MovieClip;  
import flash.text.TextField;  
import flash.events.\*;  
import org.papervision3d.scenes.Scene3D;  
import org.papervision3d.events.InteractiveScene3DEvent;  
import org.papervision3d.objects.primitives.Plane;  
import org.papervision3d.objects.DisplayObject3D;

```
    public class NavElmt extends MovieClip{ 
            private var stageRef:MovieClip; 
            private var sceneRef:Scene3D 
            public function NavElmt(stRef:MovieClip,scRef:Scene3D){ 
                    stageRef = stRef; 
                    sceneRef = scRef; 
                    trace("a nav element has been created"); 
                    trace("can we see the stage from the nav element? "+stageRef); 
            } 
            public function addListeners(){ 
                    trace("adding listeners to the bottom nav"); 
                    this.addEventListener(MouseEvent.MOUSE_OVER,overEffect); 
                    this.addEventListener(MouseEvent.MOUSE_OUT,outEffect); 
                    this.addEventListener(MouseEvent.MOUSE_UP,clickEffect); 
            } 
            private function overEffect(e:MouseEvent):void{ 
                    trace("you have rolled over this button: "+this.name); 
            } 
            private function outEffect(e:MouseEvent):void{ 
                    trace("you have rolled out of this button: "+this.name); 
            } 
            private function clickEffect(e:MouseEvent):void{ 
                    trace("you have clicked on this button: "+this.name); 
                    trace("can we see into the 3d stage: "+sceneRef); 
                    trace("can we see the axis point? "+sceneRef.getChildByName("axisPoint")); 
                    trace("entry object: "+sceneRef.getChildByName("axisPoint").getChildByName(this.name)); 
                    trace("rotation of the object: "+sceneRef.getChildByName("axisPoint").getChildByName(this.name).rotationY); 
                    trace("looking at side 1: "+sceneRef.getChildByName("axisPoint").getChildByName(this.name).getChildByName("side1").name); 
                    var planeRef:DisplayObject3D = sceneRef.getChildByName("axisPoint").getChildByName(this.name).getChildByName("side1") as DisplayObject3D; 
                    trace("planeRef: "+typeof(planeRef)); 
                    trace("stageRef.sendName:"+stageRef.sendName); 
                    //planeRef.rotationY = 80; 
                    planeRef.dispatchEvent(new InteractiveScene3DEvent(InteractiveScene3DEvent.OBJECT_PRESS,stageRef.sendName)); 
                    //sendName 
                    //sceneRef.getChildByName("axisPoint").getChildByName(this.name). 
            } 
            private function zaphod(e:Event){ 
                    trace("zaphod has been reached: "); 
            } 
    }	 

```

}
