Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-22-2012, 04:07 PM   #1
joeyg479
Registered User
 
Join Date: May 2012
Posts: 5
Default mc not changing color

Hi,

Can anyone tell me why a movie clip i have on stage is not changing color? The movieClip - box1 is being called from the library through linkage and within this movie clip there is a movie clip called boxBG which is the movie clips color I'm trying to change.

I'm getting back "A term is undefined and has no properties" looks like a simple enough problem but can't figure it out - I've already checked that boxBG has the correct instance name, the error is being called when the MouseOverHandler and MouseOutHandler functions run:

ActionScript Code:
import flash.display.MovieClip; import flash.display.Loader; import flash.events.MouseEvent; import flash.geom.ColorTransform; var colorTransformBG:ColorTransform; var myBox:box1; myBox = new box1(); addChild(myBox); myBox.y = 200// positions droppables on y axis myBox.x = 200; myBox.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); myBox.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); function mouseOverHandler(e:Event):void {         colorTransformBG = e.target.boxBG.transform.colorTransform;     colorTransformBG.color = 0x6e2685;     e.target.boxBG.transform.colorTransform = colorTransformBG;         } function mouseOutHandler(e:Event):void {         colorTransformBG = e.target.boxBG.transform.colorTransform;     colorTransformBG.color = 0x6effff;     e.target.boxBG.transform.colorTransform = colorTransformBG;         }

here is the error:

TypeError: Error #1010: A term is undefined and has no properties.
at Untitled_fla::MainTimeline/mouseOverHandler()[Untitled_fla.MainTimeline::frame1:23]

Last edited by joeyg479; 05-22-2012 at 06:57 PM.
joeyg479 is offline   Reply With Quote
Old 05-22-2012, 04:11 PM   #2
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,796
Send a message via AIM to abeall
Default

Hi and welcome. First things first:

1. When posting code on this forum, put it inside [as][/as] bb tags so that it's formatted properly.
2. When you run into errors in Flash, turn on line numbers by going to publish settings and selecting "permit debugging"
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 05-22-2012, 06:14 PM   #3
joeyg479
Registered User
 
Join Date: May 2012
Posts: 5
Default

anyone?
joeyg479 is offline   Reply With Quote
Old 05-22-2012, 06:39 PM   #4
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,796
Send a message via AIM to abeall
Default

Thanks for fixing point 1, fix point 2 please and post the error with line number
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 05-22-2012, 06:53 PM   #5
joeyg479
Registered User
 
Join Date: May 2012
Posts: 5
Default

hi abeall, not sure what exactly is supposed to happen after i select 'permit debugging' but i am getting the following message in the output window...

TypeError: Error #1010: A term is undefined and has no properties.
at Untitled_fla::MainTimeline/mouseOverHandler()[Untitled_fla.MainTimeline::frame1:23]
joeyg479 is offline   Reply With Quote
Old 05-22-2012, 07:03 PM   #6
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,796
Send a message via AIM to abeall
Default

Now it tells you the line number, which is 23. Line 23 has "e.target.boxBG.transform.colorTransform" and something in there is undefined. Try tracing values like e.target and e.target.boxBG to see what they are -- something is not as you expect it to be.

I'm guessing that e.target is not what you want. e.currentTarget probably is. Read about the difference here:
http://www.wastedpotential.com/flash...currenttarget/
(This is an important read which also explains mouseOver/Out vs rollOver/Out -- don't skip it!)
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter

Last edited by abeall; 05-22-2012 at 07:05 PM.
abeall is offline   Reply With Quote
Old 05-22-2012, 07:10 PM   #7
joeyg479
Registered User
 
Join Date: May 2012
Posts: 5
Smile

abeall, my heart is literally soaring with happiness, pulling my hair out all day with this, thank you a hundred times!
joeyg479 is offline   Reply With Quote
Old 05-22-2012, 07:14 PM   #8
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,796
Send a message via AIM to abeall
Default

Cheers
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Old 05-22-2012, 07:15 PM   #9
samestreet
Registered User
 
Join Date: May 2012
Posts: 3
Default To change Mc color

Here's a basic example on how to do it:

var c:Color = new Color;
c.setTint(0xFF0000,1.0);
mc.transform.colorTransform = c;


Notes:
The first parameter of "setTint" is the color (uint format), so, to declare a new color you can use:

var clr:uint = 0xFFFFFF;
var c:Color = new Color;
c.setTint(clr,1.0);

The second parameter (float) is the amount of the color. You can play with it to understand it better. Here's a tip: To get a half transparent color transformation I use 0.3 in that value.

Hope to help you

My regards
samestreet is offline   Reply With Quote
Old 05-23-2012, 03:19 PM   #10
joeyg479
Registered User
 
Join Date: May 2012
Posts: 5
Default

just one more question, if i wanted to add another function that would be called when the movie clip is clicked and change the color to green and stay green how would i do that? in the code below it is working when its clicked but it changes again when my mouse moves off the movie clip?

ActionScript Code:
import flash.display.MovieClip; import flash.display.Loader; import flash.events.MouseEvent; import flash.geom.ColorTransform; var colorTransformBG:ColorTransform; var myBox:box1; myBox = new box1(); addChild(myBox); myBox.y = 200// positions droppables on y axis myBox.x = 200; myBox.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); myBox.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); myBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); function mouseOverHandler(e:Event):void {         colorTransformBG = e.currentTarget.boxBG.transform.colorTransform;     colorTransformBG.color = 0x6e2685;     e.currentTarget.boxBG.transform.colorTransform = colorTransformBG;         } function mouseOutHandler(e:Event):void {         colorTransformBG = e.currentTarget.boxBG.transform.colorTransform;     colorTransformBG.color = 0x6effff;     e.currentTarget.boxBG.transform.colorTransform = colorTransformBG;         } function mouseDownHandler(e:Event):void {         colorTransformBG = e.currentTarget.boxBG.transform.colorTransform;     colorTransformBG.color = 0x2BD73A;     e.currentTarget.boxBG.transform.colorTransform = colorTransformBG;         }
joeyg479 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 07:23 AM.

///
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.