I have to do some research into figuring out how to use the flex components in all actionscript.. know of any good references or starter stuff??..
BTW, you originally said that you wanted to use Flex components, but via AS3 rather than via MXML. So why are you attempting to use low-level Flash classes like Sprite and TextField? If you're going to be using the Flex framework, I suggest that you use base classes in the framework such as UIComponent, UITextField. and Container or Canvas.
- Gordon
From: Gordon Smith
Sent: Friday, August 11, 2006 5:27 PM
To: '[email protected]'
Subject: RE: [flexcoders] AS3 Question
The warning is complaining that you haven't specified an access specifier like public, protected, private, or internal for var app.
You should also be getting an error that you haven't written the init() method which you are calling in your creationComplete event handler.
Also, you have to get your AppStarter instance onto the display list by using addChild() to attach it to the Application instance.
When I changed your MXML to the following, I saw "Hello World" appear.
<?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;
private function init():void
{
var app:AppStarter = new AppStarter();
rawChildren.addChild(app);
}
</mx:Script>
</mx:Application>
You have to use rawChildren.addChild() rather than addChild() when you add a plain Sprite to a Flex container like Application. If the child implemented the IUIComponent interface, you could just use addChild() to add it, but a plain Sprite doesn't have all the IUIComponent methods that the LayoutManager expects. By adding it as a "raw child", it won't undergo layout.
- Gordon
From: [EMAIL PROTECTED]ups.com [mailto: flexcoders@yahoogroups.com] On Behalf Of aaron smith
Sent: Friday, August 11, 2006 4:36 PM
To: [EMAIL PROTECTED]ups.com
Subject: Re: [flexcoders] AS3 Question
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]ups.com [mailto: flexcoders@ yahoogroups.com] On Behalf Of aaron smith
Sent: Friday, August 11, 2006 3:17 PM
To: [EMAIL PROTECTED]ups.com
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?
thanksOn 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:flexcoders@ yahoogroups.com] On Behalf Of aaron smith
Sent: Friday, August 11, 2006 11:31 AM
To: [EMAIL PROTECTED]ups.com
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.
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
![]()
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___
- Re: [flexcoders] AS3 Question aaron smith
- Re: [flexcoders] AS3 Question aaron smith
- Re: [flexcoders] AS3 Question Michael Schmalle
- Re: [flexcoders] AS3 Question Michael Schmalle
- [flexcoders] Re: AS3 Question Tim Hoff
- [flexcoders] Re: AS3 Question Geoffrey Williams
- RE: [flexcoders] AS3 Question Gordon Smith
- Re: [flexcoders] AS3 Question aaron smith
Reply via email to

