Flash Builder - How to design a UI with out MXML? - actionscript-3

Does anyone know of a decent guide to create a UI without MXML?
I royally dislike mxml for programming and would like to go any other way possible. (Pure Actionscript or Flash Professional for UI)

You can use Flex and never write any MXML. However, you may find that becomes counter productive. I create views/skins declaratively in MXML and do everything else in Actionscript.
Creating views, populating them with child objects, adding listeners, setting styles, all of this is done in a few simple lines of MXML. Doing the same tasks with Actionscript statements means a lot more typing. The MXML code is more concise, and that gives it a lot more clarity/maintainability in my opinion:
MXML:
<s:Group width="100%">
<s:Button label="button" click="onButtonClick()" paddingTop="0"/>
</s:Group>
AS3:
var g:Group = new Group();
g.percentWidth = 100;
var b:Button = new Buton();
b.label = "button";
b.addEventListener(MouseEvent.CLICK, onButtonClick);
b.setStyle("paddingTop", 0);
g.addChild(b);
I often create custom components (that I re-use in app views) in pure AS3. I implement the Flex life cycle methods, and then composite these components into an MXML view.
I do prefer to write everything in pure Actionscript. The one place I will not do it, however, is in creating views/skins for my applications. I think it's a fair trade off.

You can use Flash Builder to edit the Actionscript part of a Flash Pro project. There's a huge discussion about techniques with example files and everything here.

Related

How to use MXML mx.controls.Label in ActionScript

I have one AS3 application which was developed entirely in AS3 without using single line of code in MXML. Of late I am realizing that MXML has some rich controls which are not provided in open source Apache Flex SDK. One library which is of most interest to me in mx.controls, it includes Label, DataGrid etc.
Now, I want to extend my AS3 application to call mxml compiled into swf file. I tried to import mx.controls inside my AS3 programs but it does not sense that. Please tell me if I am doing anything wrong. If I am able to import mx.controls inside as3 class it would save me a lot of time. Can I do this?
Alternatively, I am trying to write a few applications in mxml and then call (.swf) in AS3. Is it possible?
I tried Googling but all examples are pointing to using ActionScript inside MXML with [CDATA[]]. But I want the inverse. Calling MXML from ActionScript.
Please explain me at nuts and bolts level as I am struggling with this a lot.
thanks in advace
You can't do that because Flex, that uses MXML, is framework built on top of the Actionscript. But you can do reverse. In Flex MXML you can use Actioscript code, and you can also use Flash components like Sprite, MovieClip... by using UIComponent or SpriteVisualElement as their parent container.

Flash Builder 4.6 Interface Programming

I'm having a very difficult time finding many resources available for Flash Builder 4.6 geared towards desktop application programming.
I'm trying to accomplish a simple (or at least I think simple) task. I have an application, and in the application is a button. When the user clicks the button, I want a new window to load, but not in the current window as a child; as a completely separate window.
I've managed to accomplish this once, but the code I was using gave a warning (from Adobe Flash Builder 4.6) that told me that it is best practice to use an "interface" as the new window is now a child of the window that opened it. (I have since lost this code as I've been trying other things, like ModuleLoader).
Basically my question is, can someone please provide an example of how to properly implement an interface in the way that 2 separate windowedapplications can be loaded and they can communicate with each other through events?
And as a bonus, if anyone can point me in the direction of a good resource, I'd appreciate that also (book or site). :) I have a Flex 4 book that I've read, and it has helped a lot with my understanding of the basic things, but is not geared towards AIR desktop programming (and had no mentions of interface).
Thank you for your time.
How I solved this problem. This article helped: Dual Monitor Support in Flex Application.
After you have created your project in Adobe Flash Builder 4.6, go to File > New > MXML Component. Type in the details as you see fit best for your application, but under "Based on" field, put "spark.components.Window". Click "Finish" when you are done with all the details.
In your main application, use the following code to pull up the new Window Component you just created into a separate Window. For the purpose of this code, I will assume that your new window is located under "assets.components" and is called CompNewWindow. Replace these details with your own.
<s:Button x="0" y="0" label="Button" click="_loadNewWindow(event)" />
<fx:Script>
<![CDATA[
import assets.components.CompNewWindow;
private var myNewWindow:CompNewWindow;
private function _loadNewWindow(event:MouseEvent):void
{
if (!myNewWindow) {
myNewWindow = new CompNewWindow();
myNewWindow.addEventListener(Event.CLOSE, _onNewWindowClose);
myNewWindow.open();
}
}
private function _onNewWindowClose(event:Event):void
{
myNewWindow.removeEventListener(Event.CLOSE, _onNewWindowClose);
myNewWindow = null;
}
]]>
</fx:Script>

How to add an Object to the stage with nested code in AS3.0

I'm busy developing my first application using the AS3.0 language.
I built the full application in Flash Professional, it worked, but it lacked performance.
Now, I'm rebuilding it in Flash builder, so it's more optimised, and it's running great.
Although I've hit a snag.
In Flash Pro, it was very easy for me to add movieclips to the stage, with code nested inside them, so when I added the object, all the code worked like a charm.
In Flash Builder, I have NO clue on how to achieve the same effect... I'm so close to being finished but have no idea how to achieve this.
I've tried making external classes, but with no programming background, it's very hard to find a solution when I don't know where to begin...
SO in short:
HOw to you add objects to your stage using pure AS3 code,
I need to add a graphic object to my stage
And add simple mouse interactivity to it.
Any responses, links, chuckles at me, would be greatly appreciated
Shane
The following code would add a movieclip to the stage, with a line drawn from 0,0 to 100,100 . Provided you are writing this code in the Main class.
var mc:MovieClip = new MovieClip();
addChild(mc) ;
mc.moveTo(0,0)
mc.lineTo(100,100) ;

learning flex 4 facing problem with namespaces

I am trying to learn flex4 from adobe document and I am very confused while using three namespaces.. there is no way i can keep track of when to use what often ending up using fx inside mx or s or similarly making some stupid goofed up combinations of {fx,mx,s}.
Adobe document is huge and i am looking for some good starting point for learning flex .
Your question is quite large; however, some basic explanation about the 3 namespaces you've cited:
<fx> tags are typically programmatic functionality and not visual display objects. You'd use it for declaring a script block in a MXML document or defining variables in a declarative way.
<fx:Script>
<![CDATA[
[Bindable]
public var myVariable:String = "Hello, World!";
]]>
</fx:Script>
<fx:Declarations>
<fx:Object id="variableName"
property1="myCustomProperty"
property2="anotherCustomProperty" />
</fx:Declarations>
When declaring visual elements and UIComponents on the display list, you'll typically want Spark architecture; therefore, you'd use the Spark namespace.
<s:Group />
MX architecture is important, but is generally deprecated by Spark. If a component is available as Spark, you should use that implementation.
<mx:Box />
All are just packages of the framework, and really no difference than importing packages in ActionScript. Your custom components will use their package name as a namespace, or you declare a namespace for your Flex MXML library.
If you're using an IDE like Flash Builder, you usually don't have to worry about the namespaces.
In an MXML file, enter the start tag (ie: <), skip the namespace and start typing the class you're after. In the above examples, I'd hit <s for "script" and the intellisense will show you completion options that will insert the namespace for you.
If the auto completion options do not appear, hit [ctrl]+[space-bar].
Let Flash Builder help with namespaces by completing them for you.
Probably doesn't go far to helping you out, but hopefully this helps a little.
Have you tried http://www.adobe.com/devnet/flex.html especially Getting Started part?

Best way to embed Flex-based swf into pure-AS3 project?

I'm working on a AS3 project that required a lot of UI, since Flex was used for time-saving for this part we ended up having a Flex Project (UI) and pure AS3 one (All BackEnd) or, in other words, two different .swf files.
Currently I can successfully comunicate both of them using a common interface and by loading the UI .swf into the AS3 .swf using a Loader class:
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest(“CustomUIModule.swf”);
The actual code contains listeners for SystemManagerHandler so Flex doesn't complain.
Since we are delivering two different files it is not really practical whenever we release a build of the project. For this case the meta tag [Embed] seems to be a better way to achieve this (With no satisfactory results to date).
With the above information (hopefully I made myself clear enough) what would be the best approach to ultimately generate a single swf? Or how should we properly implement the [Embed] tag for Flex swf?
Thanks in advance.
I try to avoid loading SWF into another SWF It just doesnt seem right to me, especially if I have control over all the SWFs. If it was me I would integrate everything into one fat flex project. After all isn't this what OOP is all about.