|
-
Tweening color animations with setTransform
Hello all,
I just wanted to briefly thank all of the experinced AS coders who are willing to help out the newcomers to actionscript; without all of their posts I'd be utterly lost, instead of merely somewhat lost as I am now.
So here's my question: I'm trying to get a piece of code that increments the values for setTransform to make a more gradual transition to a color than the one frame jump that it usually does.
I've got a random image on my stage that I have named "pict" and converted into a movie clip. Attached to the movie clip is the following code:
code:
onClipEvent(load) {
var oNewColor:Object = new Object();
oNewColor.rb = cVarR;
oNewColor.gb = cVarG;
oNewColor.bb = cVarB;
cVarR = 0;
cVarG = 0;
cVarB = 0;
}
onClipEvent(enterFrame) {
newcVarR = -100;
newcVarG = 80;
newcVarB = 120;
if (newcVarR < cVarR) {
cVarR = cVarR - 20;
} else if (newcVarR > cVarR) {
cVarR = cVarR + 20;
}
if (newcVarG < cVarG) {
cVarG = cVarG - 20;
} else if (newcVarG > cVarG) {
cVarG = cVarG + 20;
}
if (newcVarB < cVarB) {
cVarB = cVarB - 20;
} else if (newcVarB > cVarB) {
cVarB = cVarB + 20;
}var cPict:Color = new Color(pict);
cPict.setTransform(oNewColor);
trace(cVarR+" , "+cVarG+" , "+cVarB);
}
The trace function returns that the values are incrementing as I want, but the image itself never changes. I suspect this is more of me not getting the AS logic yet, since that's what's been bedeviling me.
Currently, and for the forseeable future, I am using MX 04. Someday, when I win the lotto, I'll buy 8. :P
As always, any information is much appreciated.
Pacem!
--T
-
you are not updating oNewColor at enterFrame, so oNewColor is still 0,0,0 which is created when the movie was loaded.
var oNewColor:Object = new Object();
oNewColor.rb = cVarR;
oNewColor.gb = cVarG;
oNewColor.bb = cVarB;
should be included in the end of onEnterFrame instead of onload.
-The Dancin kidd

-
<smack forehead>
Yes. Thank you very much. I apprecciate it.
And eventually, when I've got the whole project that I'm working on finished, I'll post a link to it (in the proper forum, of course) to show you guys what all your help accomplished.
Pacem!
--T
-
Actually, that *doesn't* work.
I tried tacking the oNewColor object on the end of the onClipEvent(enterFrame) statement (and in various other places in the statement) and I still can't get the color to change in the MC that the code is placed in.
Any helpful information is appreciated. Thanks!
Pacem!
--T
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|