|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ActionScript 3 - Access submovieclip from actionscript
I have a movieclip called Hair_Male_001 in my library.
This movieclip is a combined Movieclip from 3 other movieclips. Thru actionscript i create an instance of this Hair_Male_001 movieclip but i want to access one of the sub movieclips and adjusts its tint. The submovieclip's name is Hair_Male_Color_001 but i'm wondering how i can change its properties without changing it for all the instances that are created for Hair_Male_001. I hope you understand what i'm trying to do. Otherwise I'll put the example online. Thanks in advance. Ontani |
|
#2
|
|||
|
|||
|
Did you use addChild to make Hair_Male_Color_001 a child or have you just created an instance of it on the timeline at design time? If you did the former then you can access it like:
Code:
import flash.geom.ColorTransform; var new_color:ColorTransform = new ColorTransform(); new_color.color = 0xff0000; // Assuming the parent has the instance name "hair" hair.getChildAt(0).transform.colorTransform = new_color; Each sub movieclip is accessable via getChildAt(index), you just have to work out the correct index to use. If you created it via the timeline then you have to give it an instance name on stage, let's say "hair_color_001" and then inside your class you have to declare a public var with the same name. Then you can access it like: Code:
import flash.geom.ColorTransform; var new_color:ColorTransform = new ColorTransform(); new_color.color = 0xff0000; // Assuming the parent has the instance name "hair" hair.hair_color_001.transform.colorTransform = new_color; Declaring it would look like: Code:
package
{
import flash.display.MovieClip;
public class Hair_Mail_001 extends MovieClip
{
// Has to be public
public var hair_color_001:MovieClip;
public function Hair_Mail_001()
{
}
}
}
|
|
#3
|
|||
|
|||
|
Ah great! Didn't know it could be that easy.
Code:
var new_color:ColorTransform = new ColorTransform(); new_color.color = HairColor; this._hair.getChildAt(0).transform.colorTransform = new_color; worked like a charm |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > ActionScript 3 - Access submovieclip from actionscript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|