I tired that and received this error. Copied from the command line:
C:\Program Files\Adobe\Flex Builder 2\Flex SDK 2\bin>compc -source-path C:\Documents and Settings\Judah\My Documents\Flex Builder 2\Components -output C:\Documents and Settings\Judah\My Documents\Flex Builder 2\Components\swc\MyComponent.swc -include-classes MyComponent Adobe Compc (Flex Component Compiler) Version 2.0 build 143452 Copyright (c) 2004-2006 Adobe Systems, Inc. All rights reserved. command line: Error: default arguments may not be interspersed with other options Use 'compc -help' for information about using the command line. C:\Program Files\Adobe\Flex Builder 2\Flex SDK 2\bin> On 12/6/06, Matt Horn <[EMAIL PROTECTED]> wrote:
Sounds like you might have missed a step or missed including a class somewhere during this process. I'll walk through it with a single application class (Main.mxml), a single MXML component (MyComp.mxml), and a single ActionScript class used by the component (MyClass.as). This ActionScript component is in a package, mypackage. This example is for the command line compiler, not Flex Builder, but you should be able to apply the ideas here to that environment. 1. Create the main application (c:\temp\Main.mxml): <?xml version="1.0"?> <mx:Application xmlns:local="*" xmlns:mx="http://www.adobe.com/2006/mxml"> <local:MyComp/> </mx:Application> Declare the generic namespace (*); this lets you access components in the same directory using the "local" prefix. 2. Create the MXML component in the same directory as the main app (c:\temp\MyComp.mxml): <mx:Label xmlns:mx="http://www.adobe.com/2006/mxml" text="test" creationComplete="init()"> <mx:Script> <![CDATA[ import mypackage.*; private var mc:MyClass = new MyClass(); private function init():void { trace(mc.getSomething()); } ]]> </mx:Script> </mx:Label> This component creates a new MyClass instance, which is the ActionScript helper class that will be created in teh next step. Be sure to declare the mx namespace here if you use MXML in your component. Also, since the AS class is in a package, you import the package. 3. Create the ActionScript helper class in the mypackage directory (c:\temp\mypackage\MyClass.as): package mypackage { public class MyClass { public function MyClass() { } public function getSomething():String { return "42"; } } } 4. Compile the main app to make sure it runs: mxmlc c:\temp\Main.mxml You should see a label that says "test" and the tracefile should show "42". 5. Now we want to create a SWC file so that the component and its helper file are more portable. Use compc to create the SWC file: compc -source-path c:\temp -output c:\temp\MySWC.swc -include-classes MyComp You add the location of the components with the source-path option, and then include the classes with the include-classes option. You only need to specify MyComp (and not MyComp.mxml) because you are adding the class that is in the source path, not the file name. Also, you do not need to include the mypackage.MyClass class, because the component does that for you with its import, and that import is relative to the source-path. 6. Now compile the Main.mxml file with the SWC file: mxmlc -library-path+=c:\temp\MySWC.swc -- c:\temp\Main.mxml You use the library-path option to add SWC files. hth, matt horn flex docs > -----Original Message----- > From: [email protected] <flexcomponents%40yahoogroups.com> > [mailto:[email protected]<flexcomponents%40yahoogroups.com>] On Behalf Of dorkie > dork from dorktown > Sent: Wednesday, December 06, 2006 6:28 AM > To: [email protected] <flexcomponents%40yahoogroups.com> > Subject: [flexcomponents] Example of creating a SWC > > I have two MXML components ready to go. I want to export them > to their own SWC. I have read the Using Flex Compilers > chapter in the Flex 2 Build and Deploy guide and read > Creating and Extending Flex 2 Components. I do not see an > example (or as i put it - a get out insanity free pass) of > how to do this for my situation. There are small snippets for > each feature but not an example like the RSL Example on page 225. > > * My MXML components are in the root directory of my regular > old standard plain jane Flex Project. I have them here rather > than in com.mynamespace.controls because I've read somewhere > that this is where it is supposed to be. > * My AS classes it imports are in com.mynamespace.utils. > There are three of them I need to include. > * It's not clear to me in my readings what I need to do to > make my components show the default name of the namespace in > my component. ie, <mynamespace:MyComponent /> or if Flex > Builder does this automatically for components added to a > project library path. > > I have had many undescribable times figuring undocumented > things out in the Flash component world (biting tongue). I do > not want to have so much "fun" again. > > dorkie jaded dork from dorktown > ps if i've missed the docs on this then great. tell me where it is. > > > >
