Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 13th, 2008, 08:29 AM
Ontani Ontani is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 20 Ontani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 13 m 41 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 13th, 2008, 08:58 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,714 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 10093 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 11 h 8 m 12 sec
Reputation Power: 580
Facebook MySpace
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()
               {
               }
         }
   }
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old July 13th, 2008, 09:45 AM
Ontani Ontani is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 20 Ontani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 13 m 41 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - Access submovieclip from actionscript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT