Michael, good to see you back from the component exclusive world. Your input has been missed here. :)
-TH --- In [email protected], "Michael Schmalle" <[EMAIL PROTECTED]> wrote: > > Hi, > > <mx:Script> > import AppStarter; > var app:AppStarter = new AppStarter(); > </mx:Script> > > You can't do this. > > you need to put that call in > > private function init(event:FlexEvent):void > { > var app:AppStarter = new AppStarter(); > } > > Here again, you cannot add a Sprite to an Application becasue Application is > a Container. Children of containers have to be of type IUIComponent. > > You are going to have towrap your class in a UIComponent or implement the > WHOLE IUIComponent in your AppStarter component for it to be able to be > added to an app. > > There is a real 'mind perception' thing going on here. I think you are > trying to mix one older style say MTASC programming with the newer way of > Flex. > > Anymore questions, aim at me ;-) > > PS Also, somwhere you need to actually addChild(app) somwhere. > > PPS You error comes from defining a variable in the 'class' namespace. > > Imagine the following, this is where your property is being placed in the > quasi mxml class; > > package > { > import flash.text.TextField; > import flash.display.Sprite; > > var app:AppStarter = new AppStarter(); > > public class AppStarter extends Sprite > { > public function AppStarter() > { > > var t:TextField = new TextField(); > t.text = "Hello World"; > addChild( t ); > } > } > } > > Peace, Mike > > > On 8/11/06, aaron smith <[EMAIL PROTECTED]> wrote: > > > > hey.. another question... bare with me as i'm just figuring this stuff > > out. > > > > I am trying to do this: > > > > MXML:: > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" > > layout="absolute" creationComplete="init()"> > > > > <mx:Script> > > import AppStarter; > > var app:AppStarter = new AppStarter(); > > </mx:Script> > > > > </mx:Application> > > > > > > AS::: > > > > package > > { > > import flash.text.TextField; > > import flash.display.Sprite; > > > > public class AppStarter extends Sprite > > { > > public function AppStarter() > > { > > > > var t:TextField = new TextField(); > > t.text = "Hello World"; > > addChild( t ); > > } > > } > > } > > > > > > when I compile it the compiler spits this out: > > > > Warning: var 'app' will be scoped to the default namespace: Main: > > internal. It will not be visible outside of this package. > > var app:AppStarter = new AppStarter(); > > > > > > > > basically what I am going for is to create an entry point into AS. that > > being the AppStarter class.. it is not supposed to extend Application.. but > > this is just the starting point for the AS.. > > > > thanks for the help.. > > > > > > > > > > On 8/11/06, aaron smith <[EMAIL PROTECTED]> wrote: > > > > > > sweet. thanks man.. i'll give that a shot. is xmlns='...' a way of > > > saying everything? or were you just referencing the fact that I have to > > > import code... > > > > > > > > > thanks > > > > > > > > > > > > On 8/11/06, Gordon Smith <[EMAIL PROTECTED]> wrote: > > > > > > > > That's not really what I meant... if you use <mx:Application> the > > > > MXML compiler creates the application subclass and you can't replace it with > > > > a different one. But whatever you put in the Application's <mx:Script> goes > > > > into the body of the subclass (along with the useful autogenerated stuff),So > > > > instead of writing > > > > > > > > > > > > > > > > public class MyApplication extends Application > > > > > > > > { > > > > > > > > -- code -- > > > > > > > > } > > > > > > > > > > > > > > > > just write > > > > > > > > > > > > > > > > <mx:Application xmlnx:mx='...'> > > > > > > > > <mx:Script> > > > > > > > > -- code-- > > > > > > > > </mx:Script> > > > > > > > > </mx:Application> > > > > > > > > > > > > > > > > The only caveat I know of is that you can't write a constructor for > > > > your Application because the MXML compiler will generate one. > > > > > > > > > > > > > > > > For all your components, you can write them in AS: > > > > > > > > > > > > > > > > public class MyComponent extends VBox > > > > > > > > { > > > > > > > > -- code -- > > > > > > > > } > > > > > > > > > > > > > > > > - Gordon > > > > > > > > > > > > ------------------------------ > > > > > > > > *From:* [email protected] [mailto: [EMAIL PROTECTED] > > > > *On Behalf Of *aaron smith > > > > *Sent:* Friday, August 11, 2006 3:17 PM > > > > *To:* [email protected] > > > > *Subject:* Re: [flexcoders] AS3 Question > > > > > > > > > > > > > > > > I think I understand what you're saying. > > > > > > > > I could do something like: > > > > > > > > <mx:Application> > > > > <mx:Script> > > > > import someApplicationInstanceClass; > > > > var app = new someApplicationInstanceClass(); > > > > </mx:Script> > > > > </mx:Application> > > > > > > > > > > > > so when I would make an instance of the "someApplicationInstanceClass" > > > > that would start the app.. > > > > > > > > also, isn't there a variable called application? that references the > > > > Application isntance? I could pass that to the constructor of > > > > someApplicationInstanceClass? > > > > > > > > thanks > > > > > > > > On 8/11/06, *Gordon Smith* <[EMAIL PROTECTED]> wrote: > > > > > > > > Yes, it's possible. All MXML files simply get turned into AS3 classes > > > > and then compiled. If you turn on the <keep-generated- actionscript> option > > > > in flex-config.xml, you can see what these classes look like. > > > > > > > > > > > > > > > > If you do this, however, you'll see that the MXML compiler > > > > autogenerates a lot of non-obvious stuff, some of which is required for the > > > > components to run properly. For example, when you compile an > > > > <mx:Application> it generates setup code for a bunch of CSSStyelDeclaration > > > > instances that represent the CSS styles. If these CSSStyleDeclarations > > > > aren't properly set up, most Flex components will probably generate runtime > > > > errors when they try to call getStyle(). > > > > > > > > > > > > > > > > So my advice is to at least use <mx:Application>. But then it is quite > > > > easy to write only AS components instead of MXML components. > > > > > > > > > > > > > > > > - Gordon > > > > > > > > > > > > ------------------------------ > > > > > > > > * From:* [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] > > > > *On Behalf Of *aaron smith > > > > *Sent:* Friday, August 11, 2006 11:31 AM > > > > *To:* [email protected] > > > > *Subject:* [flexcoders] AS3 Question > > > > > > > > > > > > > > > > I have been dabbling lately with creating pure AS3 projects. ( http://www.senocular.com/flash/tutorials/as3withmxmlc/ > > > > ) > > > > > > > > Is it possible to use the components that are in Flex through just > > > > AS3. I would think you can, just a matter of figuring out how. > > > > > > > > Thanks. > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > What goes up, does come down. > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

