PDA

View Full Version : setRGB Halts my movie - WHY?



SnorkyFrog
August 28th, 2003, 08:03 PM
I have reduced this down to the simplest movie I can think of!

In my FLA I have a red circle that is a movieclip on frame 1 on the stage.

I am simply moving it across the stage.

It works just fine.

However, when I want to change its color in Actionscript using the following in frame 1,

var newColor = "0x00FF00";
var colorful = new Color("_root.myCircle");
colorful.setRGB(newColor);

my movie stops at frame 1 and will not continue.

Anyone know why this is behaving this way?

I swear someone could write a book three times as thick as Moock's by simply documenting all the weird behaviors of Flash!

lorcas
August 28th, 2003, 10:34 PM
i think your problem is in the var colorful... line
AS is thinking that the name of the object is actually "_root.myCircle" instead of _root.myCircle

there is a difference. try using this line instead:
var colorful = new Color(_root.myCircle);

SnorkyFrog
August 29th, 2003, 12:34 AM
Nope. Tried that earlier. It makes no difference.

No matter how you are moving a movieclip (tweening or setting it's location frame by frame) as soon as you call setRGB, that movieclip stops moving! (Haven't tried moving it using Actionscript yet but I assume that would work.)

watcher
December 1st, 2005, 01:17 PM
Nope. Tried that earlier. It makes no difference.

No matter how you are moving a movieclip (tweening or setting it's location frame by frame) as soon as you call setRGB, that movieclip stops moving! (Haven't tried moving it using Actionscript yet but I assume that would work.)

I just found this thread pointing to the same problem i have right now.

Otherwords: create movieClip e.g. mcBall, create motionTween from frame [let's say] 1 to frame 20. In frame 20 position mcBall elsewhere on Stage. Somewhere in the middle, [let's say at frame 10] of motiontween apply:

cColor = new Color(mcBall);
cColor.setRGB(0xFF0000);

When you view animation, ball goes to frame 10 where [in my case] it stops colored to "#ff0000". When i apply the code at frame 1, it stops at frame 1 [colored nicely..]

Anybody knows solution to this?

stringy
December 1st, 2005, 03:03 PM
I just found this thread pointing to the same problem i have right now.

Otherwords: create movieClip e.g. mcBall, create motionTween from frame [let's say] 1 to frame 20. In frame 20 position mcBall elsewhere on Stage. Somewhere in the middle, [let's say at frame 10] of motiontween apply:

cColor = new Color(mcBall);
cColor.setRGB(0xFF0000);

When you view animation, ball goes to frame 10 where [in my case] it stops colored to "#ff0000". When i apply the code at frame 1, it stops at frame 1 [colored nicely..]

Anybody knows solution to this?
I just checked Moock and according to him (MX)


Changing the color of a movie clip with a Color object will cause author-time tweens applied to the clip to stop functioning.

news to me.
I guess you will either have to fudge your tweens or use AS for movement.

Barn
December 1st, 2005, 03:23 PM
Actually ANY scripting attempting to manipulate a movieclip instance, such as changing it's rotation or alpha property, that is simultaneously being motion tweened, will cause the tween to halt.

stringy
December 1st, 2005, 03:33 PM
Actually ANY scripting attempting to manipulate a movieclip instance, such as changing it's rotation or alpha property, that is simultaneously being motion tweened, will cause the tween to halt.
I didn`t know that either.
I guess if you want to use motion tweens +script then the best way is to edit the mc in place & convert that to a mc,apply tweens to that and script to the _parent?
or maybe just shape tween

Barn
December 1st, 2005, 03:57 PM
Yeah, it depends on the desired effect. Sometimes it works best to script a clip and then nest it in a _parent that is then tweened. Sometimes it's better to create a movieclip out of the tween, and script the _parent.