I would like to use a movie clip (a box) to change the color of text as it passes over it like a mask would. The text is in a button which is in a separate movie clip as the box and is moving as well. All clips are moving via AS.
I’ll try to explain it better first. My fla is sort of a mess right now, and it is quite incomplete as I don’t know how to accomplish this effect. Whats the easiest way to discribe what I am trying to do?..
This is the basic setup:
I have a text button moving on the screen. The fact that it is text is meaningless I think, but that button is in a movieclip which moves it using actionscripting but for simplicity sake lets say its moving vertically.
There is a movieclip of a rectangular block also on the screen, also moving by action scripting but for simplicity lets say it is moving horizontally on the screen. (this is a bit simplified as the movement of the block is somewhat relative to the text but that shouldn’t matter to the result that I want).
I want it to work like this:
As the block movieclip passes over the text button movieclip i want the text that is covered by the block to change color (specifically the block is orange, the text is orange and I want the text covered by the block to be white)
Since these are separate movieclips I’m not sure how a mask would work. I haven’t used masks in a while so I’m sure forgetting something simple.
I will try to clean up my fla and post it for you but that may take a while
No it doesn’t, I’ll explain more as to the effect i want and almost have minus the color change.
the button starts out still but as i roll over the box moves over it. When i click the button the button moves off. but the motion of both the box and the button are not that fast so making a rollover or a hittest just looks bad. I want the passing of the rectangle to be the rollover, but in the fashion of a color changing mask passing over the text.
Hope this is a bit more helpful. I’m not very good at explaining it.
The box is a completely separate Movieclip which moves relative to the button only when the button is in rollover, on rollout it moves via other actionscripting.
basically all you have to do is make copies of both your box and your text. Your text should be in the movieclip which is moving, not the button itself. Once you have the duplicated text within the movieclip, make it a movieclip if its not already, make it orange. Then, place it directly over your existing text (in the button I assume) so it covers it completely and add to this new orange text movieclip
onClipEvent(load){
this.setMask(_root.boxCopy);
}
this assuming your moving box is in _root. The reason a copy is made is because when you make something a mask, its made invisible. This being the case, make sure your duplicate follows your original in its movement with an enterFrame event or whathaveyou.
Since the text is in the movieclip containing the button and the text isnt reactive to button events, it should remain completely in sync with the position of the original text, but since masked, only be seen when the box copy is over it
btw, if the text WAS reactive to button states or in a seperate position in each then you would have to do some workarounds to get the text mc to match the button text (which itself would be a mc). This is because movieclips in button clips dont retain their instance names and get re-initiated at each keyframe. So to identify them, a variable can be added within the movieclip itself, and checked for in a cycle through all the elements in the button object (one which will be the desired clip). If the variable exiists, or is as was assigned, then the correct clip is found and a position can be derived with the masked text set to match.
thanks, as I was taking a shower this morning I kindof came up with a similar solution but using layers rather than AS, as I am not familiar with setMask. Your solution should produce a better result. Thanks senocular.
Sniggins
P.S. Isn’t the morning shower a great place to think
I have run into another problem, probably due to my inexperience.
I have set a text movieclip to be masked by a box as discribed above, and it works fine. Now I add another text movieclip to be masked by the same box but, for some reason unknown to me, that one does not work. Can a mask box not be used twice or am I running into some a problem where code from one movieclip is being void by code from another (I run into the problem of conflicting code a lot it seems)
actually, thats right, you cant have more than one dynamic (setmask) masked clip per every mask. You’lll most likely just have to have individual mask copies for each clip you’ll want to mask