I can only guess that it's assumed that if you're doing a flex project, then you're going to be using either a standard component, an extension of one, or a completely custom one.
In that case, you'd be "inside" that component as it were (eg writing code in a component that extended UIComponent), whereupon it would work as in the docs. (again, check Jason's recent posts, it's a reasonable example of that sort of thing). It's a point of view thing really, but now I know flex a little I know that drawing stuff directly to the stage doesn't really fit in with the model all that well. You'd have to write a whole lot of routines to handle resizing of the app, or laying things around the drawing, dealing with z-orders etc. All of which is kind of the point of using the flex framework (e.g. it does all that for you, assuming you code to it's guidelines). I do understand where you're coming from though, I found much the same frustration/confusion when I first came from flash to flex, it took me a little while to get my head round it (and I still get a few nasty reminders that I don't know everything yet, by far ;)). But if you persevere with it, I hope you'll find that it pays of quite rapidly. It did for me. -----Original Message----- From: [email protected] on behalf of [EMAIL PROTECTED] Sent: Sun 20/01/2008 21:20 To: [email protected] Subject: Re: [flexcoders] Re: addchild Yes I know, but where is the documentation for a flex project ? Sherif Abdou wrote: > That is if you do an ActionScript Project instead of a FlexProject > > ----- Original Message ---- > From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > To: [email protected] > Sent: Sunday, January 20, 2008 1:05:32 PM > Subject: Re: [flexcoders] Re: addchild > > Thanks, that helps alot. > > Why isn't this in the documentation ? > http://livedocs. adobe.com/ labs/flex3/ html/help. html?content= > Drawing_Vector_ Graphics_ 6.html > <http://livedocs.adobe.com/labs/flex3/html/help.html?content=Drawing_Vector_Graphics_6.html> > > It uses import flash.display. Shape;, not import mx.core.UIComponent ; > > Or if it is somewhere else, where is it ? > > Here is the simplest version I could come up with. > import mx.core.UIComponent ; > public function makeSquare() :void > { > //make a new uicomponent > var uic:UIComponent = new UIComponent( ); > uic.graphics. beginFill( 0xFF0000, 0.5); > uic.graphics. drawRect( 0, 0, 100, 100); > uic.graphics. endFill() ; > > //add the uicomponent to the flex displaylist > this.addChild( uic); > } > > Jim Hayes wrote: > > > > What you need to do in flex is the following: (off top of head and not > > checked) > > > > //make a new uicomponent > > var uic:UIComponent = new UIComponent( ); > > > > var squareSize:uint = 100; > > var square:Shape = new Shape(); > > square.graphics. beginFill( 0xFF0000, 0.5); > > square.graphics. drawRect( 0, 0, squareSize, squareSize); > > square.graphics. beginFill( 0x00FF00, 0.5); > > square.graphics. drawRect( 200, 0, squareSize, squareSize); > > square.graphics. beginFill( 0x0000FF, 0.5); > > square.graphics. drawRect( 400, 0, squareSize, squareSize); > > square.graphics. endFill() ; > > > > // add the shape to the uicomponents displaylist > > uic.addChild( square); > > > > //add the uicomponent to the flex displaylist > > > > this.addChild( uic); > > > > It drove me a bit mad too, when I first used flex! > > > > If you wanted to, you could draw direct to the uicomponent' s graphics > > instead, we had a conversation on this list in the past few days > > covering that (Jason Merrill and Alex Harui mainly, with the odd post > > from myself). You may encounter rather a lot of "fun" with resizing > > though, as you'll see if you read those posts... > > (Drawn objects acting as children to components?) > > > > hope that helps, > > > > Jim. > > > > -----Original Message----- > > From: [EMAIL PROTECTED] ups.com > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups. com> > > on behalf of [EMAIL PROTECTED] org <mailto:info1%40reenie.org> > <mailto:info1% 40reenie. org> > > Sent: Sun 20/01/2008 15:56 > > To: [EMAIL PROTECTED] ups.com > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups. com> > > Subject: Re: [flexcoders] Re: addchild > > > > I'm still missing something very basic. Why would you think that a book > > called "actionscript 3 animation" > > uses only only flash.* classes throughout and avoids the mx.* classes > > completely ? Doesn't Flex use actionscript 3? Doesn't it do animation? > > > > I bought lots of other books too, thinking they would apply to flex., > > such as Colin Moock's Essential Actionscript 3.0. > > I would like to see an example of a ball that only uses mx classes. > > > > no kidding, I have looked and looked and looked and I don't see what you > > might be referring to. I thought I have found it when I got to > > > > http://livedocs. adobe.com/ labs/flex3/ langref/mx/ graphics/ > package-detail. html > <http://livedocs.adobe.com/labs/flex3/langref/mx/graphics/package-detail.html> > > > > <http://livedocs. adobe.com/ labs/flex3/ langref/mx/ graphics/ > package-detail. html > <http://livedocs.adobe.com/labs/flex3/langref/mx/graphics/package-detail.html>> > > > > but nothing from that page shows how to make a shape and apply the > > graphics to it. It just uses existing components. It should have a > > simple axample of making a shape and adding a stroke. > > > > http://livedocs. adobe.com/ labs/flex3/ langref/mx/ graphics/ > Stroke.html > <http://livedocs.adobe.com/labs/flex3/langref/mx/graphics/Stroke.html> > > <http://livedocs. adobe.com/ labs/flex3/ langref/mx/ graphics/ > Stroke.html > <http://livedocs.adobe.com/labs/flex3/langref/mx/graphics/Stroke.html>> > > talks about " The Graphics object to which the Stroke's styles are > > applied." but the link is to flash.display > > <http://livedocs. adobe.com/ labs/flex3/ langref/flash/ > display/package- detail.html > <http://livedocs.adobe.com/labs/flex3/langref/flash/display/package-detail.html> > > > > <http://livedocs. adobe.com/ labs/flex3/ langref/flash/ > display/package- detail.html > <http://livedocs.adobe.com/labs/flex3/langref/flash/display/package-detail.html>>> > > > > I did a search for mx.display, no results. > > > > I tried the example in > > http://livedocs. adobe.com/ labs/flex3/ html/help. html?content= > Drawing_Vector_ Graphics_ 5.html > <http://livedocs.adobe.com/labs/flex3/html/help.html?content=Drawing_Vector_Graphics_5.html> > > > > <http://livedocs. adobe.com/ labs/flex3/ html/help. html?content= > Drawing_Vector_ Graphics_ 5.html > <http://livedocs.adobe.com/labs/flex3/html/help.html?content=Drawing_Vector_Graphics_5.html>> > > > > var squareSize:uint = 100; > > var square:Shape = new Shape(); > > square.graphics. beginFill( 0xFF0000, 0.5); > > square.graphics. drawRect( 0, 0, squareSize, squareSize); > > square.graphics. beginFill( 0x00FF00, 0.5); > > square.graphics. drawRect( 200, 0, squareSize, squareSize); > > square.graphics. beginFill( 0x0000FF, 0.5); > > square.graphics. drawRect( 400, 0, squareSize, squareSize); > > square.graphics. endFill() ; > > this.addChild( square); > > > > And it turns out that these built in methods do not create a > > UIComponent either. > > TypeError: Error #1034: Type Coercion failed: cannot convert > > flash.display: :[EMAIL PROTECTED] to mx.core.IUIComponen t. > > > > What is going on here ? Is this because I'm using flex2 and not flex 3 ? > > > > Gordon Smith wrote: > > > > > > > The ball class is from the foundation action script 3 animation book > > > > and there is no import mx.core.UIComponent ; in thier example. > > > I'm not familiar with this book, but from the name I'd expect that > > > they use only flash.* classes throughout and avoid the mx.* classes > > > completely. You were trying to mix them by taking Ball and adding it > > > into VBox. If you added Ball to a Sprite-based app (rather than an > > > <mx:Application> -based app) you wouldn't have a problem. (You also > > > wouldn't get automatic layout, etc.) > > > > > > > Can you suggest a book ? > > > > > > I'm afraid that I haven't had time to investigate what's out there, > > > but I expect that others on the list will have suggestions. > > > > > > > It just blows my mind how bad the documentation is > > > > > > We've heard before that our examples are either too simple or too > > > complex. Do you have any suggestions for specific basic concepts that > > > aren't properly covered, or intermediate- level examples that would be > > > useful? If so, I'll pass them on to the doc team. > > > > > > Gordon Smith > > > Adobe Flex SDK Team > > > > > > ------------ --------- --------- --------- --------- --------- - > > > *From:* [EMAIL PROTECTED] ups.com > <mailto:flexcoders%40yahoogroups.com> > > <mailto:flexcoders% 40yahoogroups. com> > > [mailto:[EMAIL PROTECTED] ups.com > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups. com>] > > > *On Behalf Of [EMAIL PROTECTED] org <mailto:%2Ainfo1%40reenie.org> > <mailto:%2Ainfo1% 40reenie. org> > > > *Sent:* Thursday, January 17, 2008 11:37 PM > > > *To:* [EMAIL PROTECTED] ups.com > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% > 40yahoogroups. com> > > > *Subject:* Re: [flexcoders] Re: addchild > > > > > > I just use whatever I can get to work. I'm happy just using flex, and > > > when I use some old flash its only because I don't know any better. > > > The ball class is from the foundation action script 3 animation > book and > > > there is no import mx.core.UIComponent ; in thier example. > > > > > > When you say: If you're new to Flex, I suggest beginning with complete > > > Flex examples that use standard Flex components and postponing > trying to > > > use Sprites-based classes. > > > > > > I'd do that if I could figure out how. The "live docs" are not > good for > > > learning form because the examples are either not complete or are way > > > too complete with too many distracting bells and whistles. They > need to > > > start with basic building blocks but they don't seem to understand the > > > concept. It just blows my mind how bad the documentation is. . Can you > > > suggest a book ? > > > > > > Gordon Smith wrote: > > > > > > > > Built in to the Flash Player are low-level flash.* classes such as > > > > Sprite. The Flex framework libraries contains higher-level mx.* > > > > classes such as UIComponent, Button, Container, VBox, etc. which add > > > > many capabilities beyond those in the Player. > > > > > > > > The Flex framework was designed with the assumption that most > > > > developers would be delighted with the greater capabilities of > > > > the high-level classes and not have much interest in the low-level > > > > ones, which are primitive by comparison. In hindsight, this was > > > > wrongheaded. Many people like you want to mix the two -- generally > > > > because the low-level classes can have greater performance or > smaller > > > > code size, or because you're bringing over code from the > > > > Flash-not-Flex world -- and it isn't as easy as it should be to mix > > > > them. I hope we can do better in a future release. > > > > > > > > > > > You write AS3 code to use both flash.* and mx.* classes, and, > once you > > > > understand a few rules, you can use both sets of classes in a Flex > > > > application. But it isn't completely trivial, so it's dangerous to > > > > just take a simple Sprite-based class and expect it to "just > work" in > > > > Flex. > > > > > > > > The problem you're running into here is that Flex Containers such as > > > > VBox assume that their children are high-level UIComponents rather > > > > than just low-level Sprites. One reason is that containers do > > > > automatic layout management, which requires code in the children to > > > > report how big the child wants to be, etc. > > > > > > > > So currently you have to work around this assumption by doing things > > > > like creating an intermediate UIComponent to parent the Sprite or > > > > adding the Sprite to the Container as a "raw" child (see the > > > > rawChildren property). > > > > > > > > If you're new to Flex, I suggest beginning with complete Flex > examples > > > > that use standard Flex components and postponing trying to use > > > > Sprites-based classes. You'll make more progress, gain > confidence, and > > > > then be in a better position to understand how to take advantage of > > > > Sprites later. > > > > > > > > > > > > > > > > > ____________ _________ _________ _________ _________ _________ _ > > This communication is from Primal Pictures Ltd., a company registered > > in England and Wales with registration No. 02622298 and registered > > office: 4th Floor, Tennyson House, 159-165 Great Portland Street, > > London, W1W 5PA, UK. VAT registration No. 648874577. > > > > This e-mail is confidential and may be privileged. It may be read, > > copied and used only by the intended recipient. If you have received > > it in error, please contact the sender immediately by return e-mail or > > by telephoning +44(0)20 7637 1010. Please then delete the e-mail and > > do not disclose its contents to any person. > > This email has been scanned for Primal Pictures by the MessageLabs > > Email Security System. > > ____________ _________ _________ _________ _________ _________ _ > > > > > > ------------------------------------------------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > it now. > <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20> > > > ______________________________________________________________________ This communication is from Primal Pictures Ltd., a company registered in England and Wales with registration No. 02622298 and registered office: 4th Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT registration No. 648874577. This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 1010. Please then delete the e-mail and do not disclose its contents to any person. This email has been scanned for Primal Pictures by the MessageLabs Email Security System. ______________________________________________________________________
<<winmail.dat>>

