Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-03-2008, 05:48 PM   #1
CPedrick
Senior Member
 
Join Date: Sep 2006
Posts: 123
Default testing for color transform

I want to be able to apply a color transformation to each of a number of movie clips each containing a single letter, and then remove the color transformation later based upon a mouse click event.
I have set up the various letters as individual movie clips, each of which listens for the click event, and can use the code shown below to readily apply the transformation to a randomly clicked letter.

Code:
public function clickLetter(event:MouseEvent) {
			
   var rOffset:Number;   //red offset
   var bOffset:Number;   //blue offset		 
   rOffset = transform.colorTransform.redOffset + 100;
   bOffset = transform.colorTransform.redOffset - 100;
   event.currentTarget.transform.colorTransform = new ColorTransform(1, 1, 1, 1, rOffset, 0, bOffset, 0);

} //end function clickLetter
The problem comes if I want to be able to remove the transformation when a particular letter is clicked again.

Is there some way I can test to see if a transformation has been applied?

TIA,
Carolyn
CPedrick is offline   Reply With Quote
Old 07-03-2008, 08:28 PM   #2
DiamondDog
Senior Member
 
DiamondDog's Avatar
 
Join Date: Jan 2008
Location: Exeter, UK
Posts: 263
Default

Maybe use a Boolean variable which is 'true' if the movie clip has been clicked, and 'false' if it hasn't been clicked?

ActionScript Code:
public function clickLetter(event:MouseEvent) {             if(event.currentTarget.clicked != true) {       var rOffset:Number;   //red offset    var bOffset:Number;   //blue offset        rOffset = transform.colorTransform.redOffset + 100;    bOffset = transform.colorTransform.redOffset - 100;    event.currentTarget.transform.colorTransform = new ColorTransform(1, 1, 1, 1, rOffset, 0, bOffset, 0);    event.currentTarget.clicked = true; // mark the clip as being clicked } else {   // it's been clicked already, so remove the color transformation    ....    ....    event.currentTarget.clicked = false; // reset the Boolean } } //end function clickLetter

The first time a movieclip is clicked, it's 'clicked' property will be undefined (so that first test will fail, and you'll apply the transformation).
After that, the above should mean that you can toggle the transformation on and off as many times as you wish.

Hope it works!
DiamondDog is offline   Reply With Quote
Old 07-03-2008, 08:37 PM   #3
CPedrick
Senior Member
 
Join Date: Sep 2006
Posts: 123
Default

That worked great!
I had created a workaround where I set the alpha to .9 or 1 to use it as a flag. This is much better.
I'm new to AS3, so I didn't know you could create properties like that on the fly, and I didn't want to have to set up some sort of array to track click state for all the letters.

Thanks very much!!
Carolyn
CPedrick is offline   Reply With Quote
Old 07-03-2008, 08:40 PM   #4
DiamondDog
Senior Member
 
DiamondDog's Avatar
 
Join Date: Jan 2008
Location: Exeter, UK
Posts: 263
Default

That's cool. I'm glad it worked.

I know what you mean. Not many days when AS3.0 doesn't surprise me with something.

Dynamic variables I think they're called.
DiamondDog 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing...123 bowljoman Site Check 0 01-17-2008 08:25 AM
local(desktop) testing works but not on the server lporiginalg Server-Side Scripting 0 07-01-2007 02:19 AM
Automation and QTP Testing curiousgeorge Flex 2 & 3 0 01-24-2007 10:36 AM
Automated UI Testing of Flash Applications testmann Other Flash General Questions 1 07-26-2005 10:00 AM
Unit Testing GUI code? confusednoise ActionScript 2.0 0 07-11-2005 10:55 PM


All times are GMT. The time now is 06:12 AM.


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