This content has been marked as final. Show 3 replies
One of the major differences between Flash 8 and Flash 9 is how drawing is done. In Flash 8 and earlier you could draw into a MovieClip, as you are trying to do. That doesn't work in Flash 9. You need to use the MovieClip's graphics property:
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill( 0xFF0000, 0.5 );
Check out the API reference for MovieClip. For what you want to do, a Sprite is actually better since it doesn't have the overhead of a timeline, which MovieClip does.
Secondly, you don't need to create a new class to give a layout container a gradient background. Let's say you like how VBox works, or Canvas. You can make your own class that extends either one of those, then override its updateDisplayList method and draw the gradient using the container's graphics property.
override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ) : void
super.updateDisplayList( unscaledWidth, unscaledHeight );
// then put what you were doing here, except use the graphics property and not the MovieClip
when you use your new layout container, it will have your gradient background.
Also check out the docs for custom styles as that's how you ought to programmatically change your container's gradient.
thank you for helping so quick and pointing out the main differences between flash and flex.
I got the idea working meanwhile. Though id like to know a little more about how to practically
seperate design and programming. Like, I have a lot of "custom styled" components, backgrounds,
frames and so on, which i like to design and style in flash8. It would be great if I could generate
some sort of library with symbols (mc's), which implement basic functionality like color settings,
hover/down/up button graphics ect., export those as .swf files, and get them to work
Is that a good approach? Would it be better to only generate plain graphics in flash8, and use
them as basis for custom components (.swc) in flex (and therefore do all "graphics logic", custom
components methods/events) inside flex?
I would really like to know more about this topic but cant seem to find in-depth information
in the online help.
I would love to hear from you again!
Very kind regards,
You can use Flash 8 to make things for Flex 2. The difficulty comes when you want Flex to communicate with the loaded SWF. Then you have to use LocalConnection.
On the other hand, if you use Flash to make static graphics (which is what I do) because you can have a single file with all of your icons in one place, it works fine. For example, if you create a symbol called HelpButtonIcon (that would be its exported name), you can include it: icon="@Embed(source='MyIcons.swf',symbol='HelpButtonIcon')". The drawback to this method is that only the first frame of a MovieClip is imported so no animation can run. For that you need to include an entire SWF.
Check out scale9grid, too. It is available in Flash 8 and Flex 2. It allows you to segment your graphic into a 3x3 grid so it scales properly. Very good for skinning buttons.
Your gradient is a good example of something that should be done in ActionScript within Flex 2. If you create a rectangle symbol with a gradient and it needs to scale to fill a Canvas, it can start looking bandy; the ActionScript code won't have that problem.