Holomatix

Log In / Register


Purchase
MovieClip.attachSceneObject()
Usage

mc3d.attachSceneObject(newName:String, childSceneObject:SceneObject) : Void

Parameters

  • newName The name by which the child scene object will be known to its new parent.
  • childSceneObject The scene object which will become a child of mc3d.

Description

This method attaches a scene object as a child of this scene object. Until a scene object is attached to a movie clip or a previously attached scene object, it cannot be seen on the Stage.

If childSceneObject was already attached to another movie clip or scene object, it is automatically removed as a child from the existing parent before being attached to the new parent. Moving scene objects to new parents like this can result in unexpected behaviour. The property childSceneObject.matrix will be unchanged, and as this specifies the position of the scene object in realation to its parent, the chid object will move to a new location in 3D space.

Example

The following example creates two scene objects called octupus and helmet and attaches helmet as a child of octupus:

var octupus = new SceneObject(); 
 
var helmet = new SceneObject(); 
 
octupus.attachSceneObject("myHelmet", helmet);

The helmet can now be referred by either the variable helmet, or its new name as a child of the octupus:

trace(helmet == octupus.myHelmet); //displays true 
 
< Prev   Next >


© Copyright 2000-2011 Holomatix Ltd. All rights reserved.