Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-06-2009, 04:22 AM   #1
froinds
Registered User
 
Join Date: Jul 2009
Posts: 26
Default Animating color of text with TweenMax

Hello,
Basically I have a menu with submenus. The submenu is a Sprite with two children, one is a square for the background and the text on top.
On mouse over, I can change the color of the first child, the background, but not the color of the text, the second child.
Here is the code.

ActionScript Code:
private function subMenuItemOver(evt:MouseEvent):void {      TweenLite.to(evt.target.getChildAt(0), 1, {tint:0x9ca26e}); // Works      TweenLite.to(evt.target.getChildAt(1), 1, {tint:0xffffff});    // Doesn't work }

The menus are created from an xml document and the color is assigned with TextFormat.

I have no idea why I can't animate the color of the text.

Thanks in advance.
froinds is offline   Reply With Quote
Old 10-06-2009, 04:47 AM   #2
despisedIcon
Senior Member
 
despisedIcon's Avatar
 
Join Date: Jul 2007
Location: australia
Posts: 167
Default

fonts embedded?
despisedIcon is offline   Reply With Quote
Old 10-06-2009, 04:22 PM   #3
mcmcom
Asleep At The Keyboard
 
mcmcom's Avatar
 
Join Date: Jun 2004
Location: Toronto, Canada
Posts: 2,528
Default

can you access the next item in the index? getChildAt(1) i mean? can you trace out somethign so you know it is infact being accessed. if evt.target is a menu item, the getChildAt may need to be on the parent.
just a thought.

hth,
mcm
__________________
www.mustcodemore.com
Adobe Certified Flash 8 Developer
mcmcom is offline   Reply With Quote
Old 10-06-2009, 04:40 PM   #4
froinds
Registered User
 
Join Date: Jul 2009
Posts: 26
Default

ActionScript Code:
trace("Menu Item is: " + evt.target + " - 1st Child: " + evt.target.getChildAt(0) + " - 2nd Child: " + evt.target.getChildAt(1) );

Output:
Menu Item is: [object MovieClip] - 1st Child: [object MovieClip] - 2nd Child: [object TextField]
froinds is offline   Reply With Quote
Old 10-07-2009, 04:07 AM   #5
greensock
Senior Member
 
greensock's Avatar
 
Join Date: Jan 2008
Location: Near Chicago
Posts: 343
Default

Without seeing your FLA, it's tough to say what's going on in there. You're positive that you embedded the font in the TextField and that the actual font is included in the swf, right?
greensock is offline   Reply With Quote
Old 10-07-2009, 04:20 AM   #6
froinds
Registered User
 
Join Date: Jul 2009
Posts: 26
Default

Quote:
Originally Posted by greensock View Post
You're positive that you embedded the font in the TextField and that the actual font is included in the swf, right?
Well, I hope the way I embed the font is the right way. I created a Font symbol in my library, selected the font, clicked export for as3 and then did the following for the textfield:
ActionScript Code:
var font:Font = new BoldFont();    var myFormat:TextFormat = new TextFormat();    myFormat.font = font.fontName;

I posted the code down below. I didn't post my whole AS file because it's big and I bet nobody would be patient enough to go through the whole thing, which I understand since it drives me nuts when I have to do it.
froinds is offline   Reply With Quote
Old 10-06-2009, 03:44 PM   #7
greensock
Senior Member
 
greensock's Avatar
 
Join Date: Jan 2008
Location: Near Chicago
Posts: 343
Default

despisedIcon makes a good point - make sure you embed the fonts.

Also, if you're using TweenLite v11 or later, make sure you activate the TintPlugin (not necessary in v10 or before). You only need to do this once in your swf. And it's not necessary if you use TweenMax.

import com.greensock.plugins.*;
TweenPlugin.activate([TintPlugin]);
greensock is offline   Reply With Quote
Old 10-06-2009, 04:19 PM   #8
froinds
Registered User
 
Join Date: Jul 2009
Posts: 26
Default

Ok, my fonts are embedded and I'm using TweenMax instead of TweenLite. Still nothing happens.

I'm setting the format for my text this way (maybe that's where the problem is):

ActionScript Code:
subMenuItemText.setTextFormat(setTextFormat()); // this is within a function

ActionScript Code:
private function setTextFormat():TextFormat {    var font:Font = new BoldFont();    var myFormat:TextFormat = new TextFormat();    myFormat.font = font.fontName;    myFormat.size = 10;    myFormat.color = 0x8b8b8b;    myFormat.align = TextFormatAlign.CENTER;    return myFormat; }

Mouse over and mouse out events:

ActionScript Code:
private function subMenuItemOver(evt:MouseEvent):void {    TweenMax.to(evt.target.getChildAt(0), 1, {tint:0x9ca26e});    TweenMax.to(evt.target.getChildAt(1), 1, {tint:0xffffff}); }         private function subMenuItemOut(evt:MouseEvent):void {    TweenMax.to(evt.target.getChildAt(0), 1, {removeTint:true});    TweenMax.to(evt.target.getChildAt(1), 1, {removeTint:true}); }

Like I said, the submenu is a Sprite with two children, one is the background and the other is a TextField.
froinds is offline   Reply With Quote
Reply


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:42 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.