gree / lwf

LWF - Lightweight SWF
http://gree.github.com/lwf/
zlib License
627 stars 167 forks source link

Changing the ColorTransform of a LWF.Movie #148

Open DelSystem32 opened 9 years ago

DelSystem32 commented 9 years ago

I have a MovieClip in my flash that is tinted 100% blue. When I in Unity run the following code:

LWF.Movie m = lwf.SearchMovieInstance ("mymovieclipinstancename");

LWF.ColorTransform ct = m.colorTransform;
Debug.Log(ct.multi.red+","+ct.multi.green+","+ct.multi.blue+","+ct.multi.alpha);
Debug.Log(ct.add.red+","+ct.add.green+","+ct.add.blue+","+ct.add.alpha);

ct = new LWF.ColorTransform(0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f);
m.SetColorTransform(ct);
lwf.ForceExecWithoutProgress();

ct = m.colorTransform;
Debug.Log(ct.multi.red+","+ct.multi.green+","+ct.multi.blue+","+ct.multi.alpha);
Debug.Log(ct.add.red+","+ct.add.green+","+ct.add.blue+","+ct.add.alpha);

The MovieClip does indeed change color correctly. However, I'm not getting the correct console output:

0,0,0,1
0,0,0.9960938,0
1,1,1,1
0,0,0,0

Here is what the output should be like:

0,0,0,1
0,0,0.9960938,0
0.5,0.5,0.5,0.5
0.5,0.5,0.5,0.5

It looks like the SetColorTransform() method of LWF.Movie does not update its colorTransform field properly after it has reflected any changes (it just resets it). This is probably a bug, right?

DelSystem32 commented 9 years ago

There does also seem to be some problem between using SetAlpha() and then getting the colorTransform of a LWF.Movie. SetAlpha() doesn't update the alpha value of LWF.Movie's colorTransform so you may end up changing the alpha during the SetColorTransform().