Skip to content

Movie color property for basic tinting#93

Open
kpatelPro wants to merge 2 commits intotconkling:masterfrom
kpatelPro:movie-color-property
Open

Movie color property for basic tinting#93
kpatelPro wants to merge 2 commits intotconkling:masterfrom
kpatelPro:movie-color-property

Conversation

@kpatelPro
Copy link
Contributor

Add a color property to flump.display.Movie basic tinting.
Implemented by propagating color value to leaf Image nodes in Movie display hierarchy.

@tconkling
Copy link
Owner

I'm not sure about this. Why not just use a generic setColor function, eg:

public static function setColor (disp :DisplayObject, color :uint) :void {
    if (disp is Quad) {
        Quad(disp).color = color;
    } else if (disp is DisplayObjectContainer) {
        var container :DisplayObjectContainer = DisplayObjectContainer(disp);
        var nn :int = container.numChildren;
        for (var ii :int = 0; ii < nn; ii++) {
            setColor(container.getChildAt(ii), color);
        }
    }
}

(Also, what happens when you have a Movie with a color that gets added as the child of another Movie with a different color?)

@kpatelPro
Copy link
Contributor Author

Using a generic setColor method would not account for display objects being removed and added to a Layer as the timeline advances.

The proposed implementation deep-dives all child layers and all layer-displays (including sub-movies) and sets their colors all at once. AFAICT this would only break if a child was added to a flump Movie programatically (i.e. from code external to flump.display) after set color was called. In this case the user would need to apply the tint manually (newChild.color = newParent.color;) when adding the new child. IMHO, that is an acceptable caveat.

An alternative implementation of 'set color' that would automatically account for this possibility would set the local _color field and all current children's color, and then also apply color whenever a child was added (i.e. overriding addChild). I opted away from this solution as it would be slightly less performant for Movies which did not have a tint applied and it would also complicate handling of child tinting (tinting child elements differently than parent tint).

--Ken

p.s.: Good call checking for Quad rather than Image in the setColor/colorDisplay method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants