tags:

views:

487

answers:

1

I'm working on a Flex application that includes a crawl component -- a block of text that moves across a portion of the screen from right to left, implemented as a Label object being moved by a Move effect across a containing Canvas object. (Okay, technically, at the moment it's an Image object being moved, but as it's an all-text crawl, I'm working to phase-out the image and just present it as text.) As a bit of visual eye candy, I'm trying to fade the text in when it appears and fade it out when it disappears, rather than have obvious sharp edges at either end of the Canvas.

I've largely accomplished this by placing small rectangles at the left and right sides of the Canvas, setting them to the background color, and giving them an alpha gradiant. This works for the majority of situations, and if I don't come up with anything better, I'll gladly roll it into production.

However, when there's a background image/pattern instead of a solid background color, this won't work; there will be two very conspicuous monochromatic blocks on either end of the text crawl. (Note that the background image/pattern applies to the entire application, of which the crawl Canvas is only a single part; when there is an app-wide background image, the crawl's background is transparent.)

The only general solution I can see is to somehow apply the alpha gradiant to the crawl itself -- fade it in and out at the edges. But I have no idea how you'd do that for something like this. Putting the gradiant on the Canvas seems quite pointless, and if it were on the Label, it would need to slide along the Label from left to right at precisely the same speed the Label is moving across the Canvas from right to left.

Is there some solution I'm missing, or should I toss this in the More Trouble Than It's Worth pile?

A: 

You could try adding a fade effect in parallel.

CookieOfFortune
Wouldn't that apply to the entire Label object, though? I just want to fade in or out at the edges that are visible on the screen.
BlairHippo
Hmmm... You could create a gradient mask around your entire canvas, then set it as the mask for the label.
CookieOfFortune
Hmm. Now this sounds promising. Would I need to explicitly move the mask from left to right as the Label moves across the Canvas (if such a thing is even possible), or could the Label use it while it's anchored in place by the Canvas?(Please forgive me if this is a silly question, I'm still learning Flex.)
BlairHippo
I think the mask can be the size of the Canvas and sit there. The Label will move across the Canvas and use the mask that has lower alpha at the edges.
CookieOfFortune