Alright then, updating to Actionscript 3 the example linked in the previous post which was Actionscript 2, we get something that works, like this...
If you have the free Flex 2 SDK you can compile and run it like this...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp(event)">
<mx:Script>
<![CDATA[
import flash.events.Event;
import flash.events.MouseEvent;
import mx.containers.Panel;
import mx.controls.Alert;
import mx.controls.Button;
import mx.controls.Label;
import mx.controls.TextInput;
public var submit_button:Button = null;
public var first_text:TextInput = null;
public function initApp(event:Event):void {
var panel:Panel = new Panel();
panel.title = "Hello World";
addChild(panel);
var label:Label = new Label();
label.text = "First Name";
panel.addChild(label);
first_text = new TextInput();
first_text.text = "Patrick";
panel.addChild(first_text);
submit_button = new Button();
submit_button.label = "Submit";
panel.addChild(submit_button);
submit_button.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
public function onMouseUp(event:MouseEvent):void {
Alert.show("Hello " + first_text.text + "!", "Message");
}
]]>
</mx:Script>
</mx:Application>
$ mxmlc something_else.mxml
Loading configuration file /home/patrick/flex2/frameworks/flex-config.xml
/home/patrick/dev/patrick.logan/flashstuff/formstuff/something_else.swf (143036 bytes)
$ flashplayer something_else.swf
"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.
Search This Blog
Thursday, April 19, 2007
And Now An Example That Works
Another Flex Tip
I got another promising tip from Garrett Hart here inside Liberty Mutual...
He sent along this Adobe documentation on "Dynamically Creating User Interface Components". Here we go...
Em, hold off on this one. The code as it is in the article seems to be for ActionScript 2 rather than ActionScript 3. There were substantial changes in the display object class hierarchy.
Back to the drawing board, but the Vista Smalltalk swf example is still a good indicator.
Update
The url Garrett refers to in the comments is this one. Blogger kind of mangled it.
Vista Smalltalk for Flash
A hat tip to Patrick Mueller in the comments of my most recent post on starting up with Flex.
I'd not been paying much attention to Vista Smalltalk. Very nice. And Peter Fisk seems to be using the controls from mx.controls that I had problems with. Now to dig into his code to figure out what if any magic lies behind his Lisp or if I was simply missing something.
Either way, good news. The blogs come through.
My RIA Is Dynamic -pause- Naught
Update: It's been a while but there are some corrections to this post.
- The Flex API *does* support drawing on pixmaps so a MacPaint-like capability using this would be efficient.
- All the controls can be created using the Flex 2 API fr ActionScript 3. There is just a minimal mxml wrapper required around the AS code. I can dig it out here if anyone wants to see it, but I'm too lazy at the moment.
I've been playing with Flex2 (I'd go all out with Apollo except it does not run on Linux yet and I don't have steady access to Windows XP or Mac OSX). I have some questions that I've posted to some lists, but maybe this blog can attract some feedback as well.
No Pixmaps?
First some general impressions: Flex could be so good, but I am not sure if it is. The basic display architecture is reasonably what I'd expect. I am kind of surprised there isn't a pixmap level drawing capability. (Or is there and I missed it?)I created a simple paint program that frequently cycles through colors, transparency, and line width. After a minute of "painting" the retained structured graphics system bogs down and mouse events are handled fewer and farther between.
No Intelligent Redisplay?
Which leads to my next question: even if all graphics have to be retained as heavyweight objects, does the repaint really have to slow down mouse handling so dramatically, so soon? If my program is adding a new line just a few pixels long, shouldn't the damage and repaint occur in a small rectangle around that line? I cannot tell what's going on in the slowdown to be sure.Since I have not found in the API any smart damage capability (e.g. "invalidate just this region for repainting") and only a display-wide "invalidate" then I might assume the entire display list is being repainted unnecessarily. Since the API does have a reasonable hit detection capability then I would expect that to be used to determine what to repaint, if the system had some understanding of where the damage is.
Controls Must Be Precompiled?
I would really like to generate some UI controls (e.g. labels and input controls) based on some data received from somewhere in the course of the application. I wrote a little app to try this out. Then I ran into an error at runtime when trying to add a label to a vbox... "TypeError: Error #1006: getInstance is not a function."
Apparently all the controls in mx.controls
can *only* be created through XML and the Flex mxmlc
compiler. Actually this is not strictly true since the -keep
switch will keep around the generated ActionScript files. Em, not the most beautiful or concise code considering the app consists of a window, a vbox to stack controls, and one static text control.
All kinds of craps are generated that have *nothing* to do with the app. This can also be seen in the runtime behavior of the XML version of this simple thing. While the few small Flex apps I have written to date come up and are ready very quickly, the XML generated app comes up slowly. Looking at the code it is apparently due to all kinds of initialization of things the app will never use.
Ugh - factories initializing craps - a very heavyweight stretch of code. Generated from XML input run through a compiler. (Apparently in spite of ActionScript having reasonable support for XML *in* the language, mxml code can only be generated from a compiler written in Java that runs at build-time. (Or on a "server" if you want to call out to one that can run the compiler for you!)
The result is "rich" but not very "interactive" -- especially given the heritage of ActionScript as a dynamic language. ActionScript, Flex, and such appear to be based in the developers Java heritage. The result is a Java-ization of what used to be a dynamic browser environment into a fairly static Java webstart/applet-like environment.
So given that mxml generates AS code and I can duplicate that, then to some degree this code could be hand-written and be data-driven at runtime (i.e. be done via a "gui interpreter" of data just like a browser interprets HTML). I am going to look into this some more. The code is readable if not concise. It only needs to be done once.
I'd love to find out Flex provides an easy-to-program, dynamic GUI/graphics capability. Almost the opposite appears to be case so far. Several companies are apparently building apps like word processors for Apollo. They have to be doing some fairly low-level and efficient stuff with the text layout and redisplay. I wonder what level of the API they are using and how much code they've had to write themselves.
I could be missing wide swaths of the API that just isn't covered in the typical documentation aimed at building static GUIs in an IDE via XML.
Tuesday, April 17, 2007
Gambit / Termite / Erlang
Dominique Boucher compares Erlang with Gambit Scheme, and in particular Termite, which is an Erlang-like system the runs on Gambit. His conclusion...
I would choose Erlang over Gambit-C+Termite for the development of a new scalable and robust distributed application. That being said, Gambit-C is a nice piece of software (in fact my preferred Scheme system), it has a great debugger, and the Scheme Now! project will certainly lead to a number of good portable libraries for Scheme. But from the perspective of an industrial developer, Erlang wins easily.I would have to go along with this conclusion for almost any system that might have to be "production-ready" in the next couple two, three years. On the other hand I think Gambit Scheme is the better investment for the long haul. Erlang is a great language, and OTP is a solid framework for distributed systems. But Scheme is the better "foundation" language and Gambit has all the qualities of Erlang to become a solid foundation for all kinds of distributed systems, even an Erlang system, as exhibited by ETOS (Erlang-to-Scheme).
Monday, April 16, 2007
And In The Darkness Bind Them
secretgeek is a bit more tongue in cheek about this than the Church would recommend...
Lisp is so simple that you can implement it in any language in just a few pages of code. This might never happen though, because once you've learnt lisp you'd never want to write anything in any language other than lisp, so you wouldn't bother implementing lisp in any language other than lisp.Lisp can be fully implemented in lisp in just a handful of lines. I just implemented lisp in lisp, fully, while i was hopping onto a bus and paying for my bus ticket all at the same time...
Only lispers have a true definition of fun.
Blog Archive
-
►
2011
(19)
- ► 12/04 - 12/11 (2)
- ► 08/21 - 08/28 (5)
- ► 07/17 - 07/24 (1)
- ► 04/03 - 04/10 (3)
- ► 03/27 - 04/03 (5)
- ► 03/20 - 03/27 (1)
- ► 03/13 - 03/20 (1)
- ► 03/06 - 03/13 (1)
-
►
2010
(2)
- ► 11/07 - 11/14 (2)
-
►
2009
(40)
- ► 06/07 - 06/14 (2)
- ► 05/31 - 06/07 (1)
- ► 05/17 - 05/24 (1)
- ► 04/05 - 04/12 (2)
- ► 03/22 - 03/29 (7)
- ► 03/15 - 03/22 (1)
- ► 03/08 - 03/15 (4)
- ► 03/01 - 03/08 (2)
- ► 02/22 - 03/01 (1)
- ► 02/15 - 02/22 (5)
- ► 02/08 - 02/15 (1)
- ► 02/01 - 02/08 (7)
- ► 01/25 - 02/01 (2)
- ► 01/04 - 01/11 (4)
-
►
2008
(402)
- ► 12/28 - 01/04 (12)
- ► 12/14 - 12/21 (3)
- ► 12/07 - 12/14 (10)
- ► 11/30 - 12/07 (14)
- ► 11/23 - 11/30 (7)
- ► 11/16 - 11/23 (14)
- ► 11/09 - 11/16 (7)
- ► 11/02 - 11/09 (11)
- ► 10/26 - 11/02 (14)
- ► 10/19 - 10/26 (10)
- ► 10/12 - 10/19 (11)
- ► 10/05 - 10/12 (16)
- ► 09/28 - 10/05 (26)
- ► 09/21 - 09/28 (16)
- ► 09/14 - 09/21 (3)
- ► 09/07 - 09/14 (9)
- ► 08/31 - 09/07 (8)
- ► 08/24 - 08/31 (10)
- ► 08/17 - 08/24 (12)
- ► 08/10 - 08/17 (4)
- ► 08/03 - 08/10 (5)
- ► 07/27 - 08/03 (10)
- ► 07/20 - 07/27 (6)
- ► 07/13 - 07/20 (7)
- ► 07/06 - 07/13 (3)
- ► 06/29 - 07/06 (8)
- ► 06/22 - 06/29 (6)
- ► 06/15 - 06/22 (5)
- ► 06/08 - 06/15 (10)
- ► 06/01 - 06/08 (4)
- ► 05/25 - 06/01 (5)
- ► 05/18 - 05/25 (6)
- ► 05/11 - 05/18 (3)
- ► 05/04 - 05/11 (7)
- ► 04/27 - 05/04 (7)
- ► 04/20 - 04/27 (7)
- ► 04/13 - 04/20 (6)
- ► 04/06 - 04/13 (9)
- ► 03/30 - 04/06 (7)
- ► 03/23 - 03/30 (5)
- ► 03/16 - 03/23 (15)
- ► 03/09 - 03/16 (7)
- ► 03/02 - 03/09 (5)
- ► 02/24 - 03/02 (4)
- ► 02/17 - 02/24 (2)
- ► 02/10 - 02/17 (3)
- ► 02/03 - 02/10 (1)
- ► 01/27 - 02/03 (8)
- ► 01/20 - 01/27 (4)
- ► 01/13 - 01/20 (3)
- ► 01/06 - 01/13 (7)
-
▼
2007
(388)
- ► 12/30 - 01/06 (11)
- ► 12/16 - 12/23 (5)
- ► 12/09 - 12/16 (3)
- ► 12/02 - 12/09 (5)
- ► 11/25 - 12/02 (5)
- ► 11/18 - 11/25 (4)
- ► 11/11 - 11/18 (4)
- ► 11/04 - 11/11 (11)
- ► 10/28 - 11/04 (11)
- ► 10/21 - 10/28 (3)
- ► 10/14 - 10/21 (6)
- ► 10/07 - 10/14 (5)
- ► 09/30 - 10/07 (18)
- ► 09/23 - 09/30 (13)
- ► 09/16 - 09/23 (9)
- ► 09/09 - 09/16 (12)
- ► 09/02 - 09/09 (15)
- ► 08/26 - 09/02 (2)
- ► 08/19 - 08/26 (8)
- ► 08/12 - 08/19 (25)
- ► 08/05 - 08/12 (7)
- ► 07/29 - 08/05 (8)
- ► 07/22 - 07/29 (2)
- ► 07/15 - 07/22 (4)
- ► 07/08 - 07/15 (11)
- ► 07/01 - 07/08 (3)
- ► 06/24 - 07/01 (8)
- ► 06/17 - 06/24 (4)
- ► 06/10 - 06/17 (17)
- ► 06/03 - 06/10 (6)
- ► 05/27 - 06/03 (12)
- ► 05/20 - 05/27 (5)
- ► 05/13 - 05/20 (15)
- ► 05/06 - 05/13 (10)
- ► 04/29 - 05/06 (14)
- ► 04/22 - 04/29 (5)
- ▼ 04/15 - 04/22 (6)
- ► 04/08 - 04/15 (16)
- ► 04/01 - 04/08 (8)
- ► 03/25 - 04/01 (5)
- ► 03/18 - 03/25 (3)
- ► 03/11 - 03/18 (3)
- ► 03/04 - 03/11 (5)
- ► 02/25 - 03/04 (1)
- ► 02/18 - 02/25 (4)
- ► 02/04 - 02/11 (10)
- ► 01/28 - 02/04 (11)
- ► 01/21 - 01/28 (2)
- ► 01/14 - 01/21 (1)
- ► 01/07 - 01/14 (7)
-
►
2006
(261)
- ► 12/31 - 01/07 (7)
- ► 12/24 - 12/31 (13)
- ► 12/17 - 12/24 (6)
- ► 12/10 - 12/17 (7)
- ► 12/03 - 12/10 (6)
- ► 11/26 - 12/03 (1)
- ► 11/19 - 11/26 (5)
- ► 11/05 - 11/12 (2)
- ► 10/29 - 11/05 (4)
- ► 10/22 - 10/29 (5)
- ► 10/15 - 10/22 (2)
- ► 10/08 - 10/15 (3)
- ► 10/01 - 10/08 (9)
- ► 09/24 - 10/01 (8)
- ► 09/17 - 09/24 (1)
- ► 09/10 - 09/17 (5)
- ► 09/03 - 09/10 (6)
- ► 08/27 - 09/03 (2)
- ► 08/13 - 08/20 (9)
- ► 08/06 - 08/13 (6)
- ► 07/30 - 08/06 (6)
- ► 07/23 - 07/30 (6)
- ► 07/16 - 07/23 (3)
- ► 07/09 - 07/16 (2)
- ► 07/02 - 07/09 (2)
- ► 06/25 - 07/02 (10)
- ► 06/18 - 06/25 (9)
- ► 06/11 - 06/18 (10)
- ► 06/04 - 06/11 (6)
- ► 05/28 - 06/04 (9)
- ► 05/21 - 05/28 (9)
- ► 05/14 - 05/21 (3)
- ► 05/07 - 05/14 (4)
- ► 04/30 - 05/07 (10)
- ► 04/23 - 04/30 (1)
- ► 04/16 - 04/23 (2)
- ► 04/09 - 04/16 (4)
- ► 04/02 - 04/09 (4)
- ► 03/19 - 03/26 (9)
- ► 03/12 - 03/19 (11)
- ► 03/05 - 03/12 (1)
- ► 02/26 - 03/05 (5)
- ► 02/19 - 02/26 (14)
- ► 02/12 - 02/19 (2)
- ► 02/05 - 02/12 (1)
- ► 01/29 - 02/05 (1)
- ► 01/22 - 01/29 (2)
- ► 01/01 - 01/08 (8)
-
►
2005
(335)
- ► 12/25 - 01/01 (9)
- ► 12/18 - 12/25 (4)
- ► 11/27 - 12/04 (1)
- ► 11/20 - 11/27 (1)
- ► 11/13 - 11/20 (1)
- ► 10/23 - 10/30 (1)
- ► 10/16 - 10/23 (2)
- ► 10/09 - 10/16 (3)
- ► 10/02 - 10/09 (11)
- ► 09/18 - 09/25 (4)
- ► 09/11 - 09/18 (4)
- ► 09/04 - 09/11 (1)
- ► 08/28 - 09/04 (7)
- ► 08/21 - 08/28 (10)
- ► 08/14 - 08/21 (6)
- ► 08/07 - 08/14 (2)
- ► 07/31 - 08/07 (16)
- ► 07/24 - 07/31 (5)
- ► 07/17 - 07/24 (6)
- ► 07/10 - 07/17 (5)
- ► 06/19 - 06/26 (1)
- ► 05/29 - 06/05 (7)
- ► 05/22 - 05/29 (7)
- ► 05/15 - 05/22 (16)
- ► 05/08 - 05/15 (10)
- ► 05/01 - 05/08 (8)
- ► 04/24 - 05/01 (6)
- ► 04/03 - 04/10 (7)
- ► 03/27 - 04/03 (19)
- ► 03/20 - 03/27 (15)
- ► 03/13 - 03/20 (27)
- ► 03/06 - 03/13 (7)
- ► 02/27 - 03/06 (16)
- ► 02/20 - 02/27 (7)
- ► 02/13 - 02/20 (10)
- ► 02/06 - 02/13 (23)
- ► 01/30 - 02/06 (4)
- ► 01/23 - 01/30 (12)
- ► 01/16 - 01/23 (15)
- ► 01/09 - 01/16 (2)
- ► 01/02 - 01/09 (17)
-
►
2004
(534)
- ► 12/26 - 01/02 (18)
- ► 12/19 - 12/26 (5)
- ► 12/12 - 12/19 (5)
- ► 12/05 - 12/12 (25)
- ► 11/28 - 12/05 (8)
- ► 11/21 - 11/28 (3)
- ► 11/14 - 11/21 (4)
- ► 11/07 - 11/14 (7)
- ► 10/31 - 11/07 (13)
- ► 10/24 - 10/31 (7)
- ► 10/17 - 10/24 (10)
- ► 10/10 - 10/17 (15)
- ► 10/03 - 10/10 (1)
- ► 09/19 - 09/26 (9)
- ► 09/12 - 09/19 (4)
- ► 09/05 - 09/12 (4)
- ► 08/29 - 09/05 (9)
- ► 08/08 - 08/15 (11)
- ► 08/01 - 08/08 (4)
- ► 07/11 - 07/18 (12)
- ► 07/04 - 07/11 (19)
- ► 06/27 - 07/04 (12)
- ► 06/20 - 06/27 (7)
- ► 06/13 - 06/20 (5)
- ► 06/06 - 06/13 (1)
- ► 05/30 - 06/06 (8)
- ► 05/23 - 05/30 (27)
- ► 05/16 - 05/23 (16)
- ► 05/09 - 05/16 (36)
- ► 05/02 - 05/09 (31)
- ► 04/25 - 05/02 (13)
- ► 04/18 - 04/25 (25)
- ► 04/11 - 04/18 (15)
- ► 03/28 - 04/04 (9)
- ► 03/21 - 03/28 (12)
- ► 03/14 - 03/21 (9)
- ► 03/07 - 03/14 (7)
- ► 02/29 - 03/07 (16)
- ► 02/22 - 02/29 (11)
- ► 02/15 - 02/22 (6)
- ► 02/08 - 02/15 (8)
- ► 02/01 - 02/08 (9)
- ► 01/25 - 02/01 (18)
- ► 01/18 - 01/25 (12)
- ► 01/11 - 01/18 (14)
- ► 01/04 - 01/11 (14)
-
►
2003
(286)
- ► 12/28 - 01/04 (7)
- ► 12/21 - 12/28 (10)
- ► 12/14 - 12/21 (5)
- ► 11/30 - 12/07 (5)
- ► 11/23 - 11/30 (5)
- ► 11/16 - 11/23 (2)
- ► 11/09 - 11/16 (3)
- ► 10/26 - 11/02 (6)
- ► 10/19 - 10/26 (9)
- ► 10/12 - 10/19 (8)
- ► 10/05 - 10/12 (5)
- ► 09/28 - 10/05 (3)
- ► 09/21 - 09/28 (3)
- ► 09/14 - 09/21 (4)
- ► 09/07 - 09/14 (3)
- ► 08/31 - 09/07 (6)
- ► 08/24 - 08/31 (12)
- ► 08/17 - 08/24 (3)
- ► 08/10 - 08/17 (6)
- ► 08/03 - 08/10 (8)
- ► 07/27 - 08/03 (9)
- ► 07/20 - 07/27 (5)
- ► 07/13 - 07/20 (8)
- ► 07/06 - 07/13 (15)
- ► 06/29 - 07/06 (12)
- ► 06/22 - 06/29 (5)
- ► 06/15 - 06/22 (6)
- ► 06/08 - 06/15 (1)
- ► 06/01 - 06/08 (5)
- ► 05/18 - 05/25 (7)
- ► 05/11 - 05/18 (9)
- ► 05/04 - 05/11 (13)
- ► 04/27 - 05/04 (9)
- ► 04/20 - 04/27 (4)
- ► 04/13 - 04/20 (10)
- ► 04/06 - 04/13 (15)
- ► 03/30 - 04/06 (7)
- ► 03/23 - 03/30 (13)
- ► 03/16 - 03/23 (9)
- ► 03/09 - 03/16 (3)
- ► 03/02 - 03/09 (8)
About Me
- Patrick Logan
- Portland, Oregon, United States
- I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.