They add the graphics object to the BasicShapes component You then need to add that component to MoveShapes. And if you instantiate Moveshapes in an Application, you will need to use addChild() to add that to the application container.
Tracy Spratt, Lariat Services, development services available _____ From: [email protected] [mailto:[email protected]] On Behalf Of Brad Bueche Sent: Saturday, April 11, 2009 11:49 PM To: [email protected] Subject: Re: [flexcoders] ActionScript package/class wont produce output (or error) Thanks! You made my saturday night! (Yea, I'm THAT boring). If the class had not had all those addChilds in it I would have normally thought to do this. What are all those addChild's in the class adding TO then? Its the same stage, same display list ??? brad On Sat, Apr 11, 2009 at 6:14 PM, Alex Harui <aha...@adobe. <mailto:[email protected]> com> wrote: Call addChild() Alex Harui Flex SDK Developer Adobe Systems Inc. <http://www.adobe.com/> Blog: http://blogs. <http://blogs.adobe.com/aharui> adobe.com/aharui From: flexcod...@yahoogro <mailto:[email protected]> ups.com [mailto:flexcod...@yahoogro <mailto:[email protected]> ups.com] On Behalf Of Brad Bueche Sent: Saturday, April 11, 2009 1:15 PM To: flexcod...@yahoogro <mailto:[email protected]> ups.com Subject: [flexcoders] ActionScript package/class wont produce output (or error) I'll probably get this working by just changing things until it runs, however, I'd like to really understand what is going wrong. ;) My packaged class is below (at the bottom). IF I run it as the only file in an actionscript project (in the Flex 3 ide). It works and draws 3 shapes onto the screen. However, if I try to call it from the default application class like this (immediately below) I get nothing on the screen and I dont get any errors (I didnt know wether I was supposed to use MovieClip or Sprite either). ---------------- package{ import flash.display.MovieClip; import flash.display.Sprite; import com.bueche.flex.graphics.BasicShapes; public class MoveShapes extends Sprite{ public function MoveShapes (){ var testItem:BasicShapes = new BasicShapes(); } } //end of class MoveShapes } // end of package ----------------------------- *********packaged class source**************************** package com.bueche.flex.graphics { import flash.display.DisplayObject; import flash.display.Graphics; import flash.display.JointStyle; import flash.display.LineScaleMode; import flash.display.Shape; import flash.display.Sprite; public class BasicShapes extends Sprite { private var size:uint = 80; private var bgColor:uint = 0xFFCC00; private var borderColor:uint = 0x666666; private var borderSize:uint = 0; private var cornerRadius:uint = 9; private var gutter:uint = 5; public function BasicShapes() { doDrawCircle(); doDrawRoundRect(); doDrawRect(); refreshLayout(); } private function refreshLayout():void { var ln:uint = numChildren; var child:DisplayObject; var lastChild:DisplayObject = getChildAt(0); lastChild.x = gutter; lastChild.y = gutter; for (var i:uint = 1; i < ln; i++) { child = getChildAt(i); child.x = gutter + lastChild.x + lastChild.width; child.y = gutter; lastChild = child; }//end of for }//end of function private function doDrawCircle():void { var child:Shape = new Shape(); var halfSize:uint = Math.round(size/2); child.graphics.beginFill(bgColor); child.graphics.lineStyle(borderSize, borderColor); child.graphics.drawCircle(halfSize, halfSize, halfSize); child.graphics.endFill(); addChild(child); } private function doDrawRoundRect():void { var child:Shape = new Shape(); child.graphics.beginFill(bgColor); child.graphics.lineStyle(borderSize, borderColor); child.graphics.drawRoundRect(0, 0, size, size, cornerRadius); child.graphics.endFill(); addChild(child); } private function doDrawRect():void { var child:Shape = new Shape(); child.graphics.beginFill(bgColor); child.graphics.lineStyle(borderSize, borderColor); child.graphics.drawRect(0, 0, size, size); child.graphics.endFill(); addChild(child); } }//end of class BasicShapes }//end of package

