Copy Fully Qualified Classname Plugin for Flash Builder 4 (CFQCN)
I created a little add-on for Flash Builder 4 which gives you a "Copy Fully Qualified Name" entry to the context menu in the MXML/AS3-Editors of Flash Builder. This is especially useful if you're creating new skin classes in Flex 4 and need to know the FQCN of the skin class to reference it in the CSS file for example (oh - and for item renderers, also very useful, and for a few other things it's useful, too btw)
I was a bit lazy concerning the name for this plugin so I just called it CFQCN
To get proper result you have to point the cursor into the editor (i.e. click on an element), then right-click and choose the "Copy Fully Qualified Name" menu entry. This will try to get the FQCN of the element (in case it's an element in MXML) or the name of the topmost class (in case of AS3 file or top-level MXML elements).
Some notes:
Members, properties and imports in AS3 (AS3 class files and Script blocks in MXML) are currently not supported
You really need a selection on the element you want tp copy the name from, i.e. the cursor needs to be placed on the element by mouse or by keyboard
This is really the first version of the plugin and I will add more functionality over time.
To install, download the ZIP file from here, unzip it and copy the JAR file to the /plugins directory of your Flash Builder 4 / Eclipse installation and restart. That's all. Oh, and yes it's free to use. Enjoy!
Nathan Mische'sAMF Explorer is a nice add-on for Firefox which allows to seamlessly debug AMF traffic from within Firefox. Looks very promising, especially as the capturing of the AMF packets seems to be written in JS (not sure, though).
In case you missed this year's W-JAX conference, here are the slides for my session "Flex and Spring integration". I'll post the demo files later. Enjoy!
Pass CF Array as serialized ArrayCollection from CF to Flex
UPDATE: Sorry, my assumption was plain wrong. See my comment in the Comments section.
By default, a CF Array is serialized to a native Flash Array when when using AMF3/Remoting between Flex and CF. If you want to pass a CF Array directly as an ArrayCollection to Flex instead of wrapping in into an ArrayCollection on the Flex client side, then just wrap the CF Array into a java.util.ArrayList in your CFC:
Distinguish between Flex Remoting and "normal" HTTP requests in ColdFusion
After a lot of Flex and Java coding I'm currently doing a CF/Flex project again. I haven't really touched CF for quite some time and decided to use ColdSpring in this project just for getting an idea of it. I've used Spring in my past Java projects and wanted to get a feeling for ColdSpring - and it really rocks! Make sure to check it out!
One thing I remembered from my past Flex/CF projects was that it always was not that easy to build a CF backend that can both serve Flex clients with AMF over HTTP (i.e. Remoting) and "normal" HTTP clients (standard-browser-HTML-you-know-what-I-mean). For example, the error handling is a bit difficult as you want CF runtime exceptions to get transported back to Flex clients as FaultEvents but for HTML clients you want a nice HTML output with error information. I never found a decent solution for this... until now :) Sometimes it is good to change perspectives (or to switch languages).
In the past Java projects we either used BlazeDS or LC on the backend side. The server side API offers a broad set of ways to access the incoming HTTP requests and the AMF payload. A main class in the BlazeDS and LCDS API to access all that information is the flex.messaging.FlexContext class. The idea is quite simle: in your server side Java code you can use the FlexContext class to get the current client (wrapped in a FlexClient object), the sessions (wrappers around the HTTPSession) and so on. So to check if a method was called from a Flex client you just have to check if FlexContext.getFlexClient() is != null.
Thanks to the fact that CF8 uses the same (or parts of) server side Flex API to implement the Flex <-> CF Remoting infrastructure you can also use the same method in your CFCs making it *much* easier to distinguish between Flex and HTML-client requests. A simple example goes like this - it could be used inside your Application.cfc's onError method:
<cfset var ctx = createObject("java", "flex.messaging.FlexContext")> <cfif ctx.getFlexClient() neq ""> <!--- this is a request from a Flex cliet ---> ... <cfelse> <!--- this is a standard http request ---> ... </cfif>
Some of the interesting new features are the option to export Remoting Destinations by using Java 5 Annotations instead of classic XML-wiring and full support for custom JavaAdapters like those provided by dpHibernate or Gilead.
German Java Magazin publishes my article on Spring BlazeDS Integration
In the recent issue 05/09 of the German Java Magazin you'll find my article "Spring trifft Flex" (translation: "Spring meets Flex") where I show how to use Flex, BlazeDS and Spring together by using Spring BlazeDS Integration.
Btw, it is a print magazine so you'll have to buy it - and no, I don't get money if you buy it :)
HP releases tool to find security vulnerabilities in Flash/Flex applications
HP’s Web Security Research Group has released a tool called SWFScan. The application aims at helping developers finding and fixing security issues in compiled SWF files.
The tool first decompiles the SWF file (ActionScript 2 and 3 is supported) and then scans the generated sourcecode for a range of several security vulnerabilities like hard-coded passwords, XSS and cross-domain issues. Also, the tool checks the code against Adobe's security best practices. So in contrast to other decompiler tools this one really adds value for the developer. Worth checking out!
IMPORTANT: you'll have to update your Debug-Players as well as the default update will only update the Release version of the installed Players! The Debug-Player downloads can be found here.
Anyone else experiencing that certain features of opensource.adobe.com are not working? Most notably, all the top menu links like Projects, Source are not working or give an error page here...
BlazeDS Gotcha: default Cookie handling in proxy service only accepts RFC 2109 cookies
I found a very subtle behaviour in BlazeDS yesterday. I assume that this also applies to LCDS, haven't tested it though.
BlazeDS comes with a proxy service that allows you to solve the crossdomain data loading restrictions of Flash Player (i.e. a SWF on server A may not load data from a different domain B, unless domain B allows the SWF explicitely). To proxy the requests, BlazeDS uses the famous HTTPClient library. I used the proxy in several projects so far and never had any issues with it - until yesterday...
In a current project BlazeDS is used to proxy between a Flex client application and a hosted Adobe Connect account that lives on the admin.emea.acrobat.com sub-domain. When a user logs in to the Connect system, the Connect server sends back a Cookie with the domain set to .acrobat.com (notice the leading dot). However, this Cookie is ignored by the BlazeDS proxy service and you'll get a warning message in the server logs similar to: "Cookie rejected: "$Version=0; BREEZESESSION=Sbreez8chuv13an7trwkon; $Path=/; $Domain=.acrobat.com". Domain attribute ".acrobat.com" violates RFC 2109: host minus domain may not contain any dots" - this means subsequent calls made by BlazeDS will not send any Cookies with the request which mixes up things badly as you can imagine.
So - the Cookie returned by acrobat.com is not RFC 2109 compliant because the RFC does not allow compliant clients to accept Cookies which domain attribute is set to value starting with a dot (i.e. .acrobat.com) when the Cookie itself was set by a domain with a subdomain that contains a dot (i.e. admin.emea is the subdomain)... everyone got that?
The underlying HTTPClient library used by BlazeDS by default uses a Cookie policy that only accepts RFC 2109 compliant Cookies (which is a rather strict setting). In contrast, all modern browsers use a somewhat lax Cookie interpretation to maximize compability with existing web sites. So while everything works nicely in a browser it does not with BlazeDS' proxy service.
I was able to solve this issue by extending the default HTTPProxyAdapter that comes with BlazeDS. This custom Adapter sets the CookiePolicy used by the HTTPClient to BROWSER_COMPATIBILITY and this actually ensures that the Cookie returned by admin.emea.acrobat.com is accepted - puh :)
I also logged a bug for this in the BlazeDS bugbase and attached my workaround for it. So if you want to see this fixed in BlazeDS feel free to vote for it.
"Stratus" Public Beta - UDP-based P2P with RTMFP and FP10 /AIR 1.5
Wow - this was just announced by Kevin Towes:
Adobe Stratus - Developer Keys Now Available! Adobe is excited to announce that Stratus is now publicly available for use by developers as a beta service. This is the long awaited missing link that will allow developers to take advantage of the new RTMFP protocol in Flash Player 10 and AIR 1.5. Why is this important? Well with RTMFP and Stratus, data can now be sent directly client to client allowing for highly cost-effective real-time communication. We can't wait to see what our developers build! REF: http://blogs.adobe.com/ktowes/
Sönke Rohde just posted a very nice example on how easy it is to use mocked-up business delegates when using the Swiz framework - check it out here.
In case you do not know Swiz: no problem, neither did I until the FlexCamp "triangle" in Hamburg, Wien and Bukarest in early November where Sönke accidentally mentioned Swiz (well, meanwhile I think this was not by accident - he really wanted me to try it out :)
Swiz claims to be a "Brutally simple micro-architecture for Rich Internet Application development with Adobe Flex" and, hey - it really is! After I did a lot of Java developing using Spring I really liked Swiz' approach as it also uses Inversion of Control (IoC) in a... well... brutally simple and intutive way. If you want to try something "different" than the standard MVC frameworks then I urge you to try it yourself.
The idea is pretty simple: people in the audience will ask technical/coding questions concerning Flex, AIR and related technology (like BlazeDS, LC, CD etc) and we will try our best to answer them live on stage - no props, no tricks. So there's no real agenda but we promise to show a lot of insider tips and tricks and do some seeeerious hacking there.
Of course, everything depends on the amount (and quality) of the questions you ask - to allow for a good start, Sven and I ask you to send us some questions YOU would like to ask, no matter if you make it to MAX Europe or not. We just need some input to get started during the session so the audience then knows what type of questions we're looking for (of course, we'll give credits for every submission we'll pick!).
So, please feel free to add comments here - and make sure to join our Freestyle Hacking session :)
Combining runtime CSS and runtime ResourceBundle loading into one single SWF file
In a current AIR project we need to ship customized versions of the same code base for different customers. Of course we don't want to compile a new AIR file for every new customized application as this would make maintenance and deployment pretty hard - so we looked for other options.
The customization we need to apply for each customer consists of two things: a new CSS stylesheet with styles and skins and customized ResourceBundles for certain UI elements (error messages, HTTP links, label text etc.). The CSS requirement be easily solved by using runtime CSS styles, i.e. SWF files that get loaded into the application dynamically - so for every customer we create a new CSS-SWF file. Loading ResourceBundles at runtime is also possible since Flex 3 when you compile down the resources to SWF files as well.
The process of creating these two SWF files per customer is not that hard but it just seemed too much work when actually all the application should need to is to load ONE single SWF file containing bith the customized ResourceBundles AND the customized CSS style.
So in the end I created a simple prototype that is actually capable of loading a single SWF file at runtime that hosts the customized CSS and ResourceBundle data. The thing is that Flex 3 under the hood uses the same mechanism to load ResourceBundle SWFs and CSS SWFs - they are actually plain Modules. So I created a new Module, put the ResourceBundle Metadata and a Style block into it, compiled it to a SWF (using the -load-externs switch on the compiler) and loaded it into the main AIR application After the SWF was loaded the new CSS Stylesheet and the ResourceBundles were applied correctly! Look Ma, only one SWF :)
Reminder: always set ByteArray.position = 0 before trying do process the ByteArray...
When working with ByteArrays in AS3 always remember that writing to the ByteArray instance increases the position property - which has impacts on the next read / write operations of course! Today, I forgot that again and had a hard time figuring out why things did not work as expected - so here's a reminder for myself (and a hint for other people).
In my case I created a SHA-256 message digest from a String value using the SHA256 class in Flex 3. The static computeDigest() method takes a ByteArray instance and returns a message digest ("hash") of that message. Then, I sent this digest over the wire to BlazeDS and on the backend side I compared it with another dynamically created digest (using Java's MessageDigest class). Simple story - however, the digests never matched!
Finally, I realized that the ByteArray's position was still on the same position that was set after writing to the ByteArray, thus the digest was not created for the fully populated String but only for the last character... oh dear! Setting the position to 0 before passing the ByteArray to the computeDigest() method did the trick and both digests matched afterwards.
The application was developed by Digital Primites and hosts "over 30 examples of streaming and multiway communication solutions, including basic server connection examples, complex video streaming, and authentication routines. You can also learn to build video messaging and VoIP solutions.
AS3 inner classes not working properly under Mac OS X Leopard?
Now this one is strange: in a current project I created a volume button / slider control similar to the volume control in the Youtube player. I based this VolumeButton control on the mx.controls.Button class and used inner / internal classes for the sliding part which consists of a Canvas container and a VSlider subclass (again this one is an internal class). The slider itself is skinned programmatically to give it an unique look. All in all, the final VolumeButton class defines 3 internal classes.
This works perfectly well on all Windows machines (running Flash Player 9,0,124 and also 9,0,115 on Firefox and IE) but does not work as expected on Mac OS X 10.5.4 (FP 9,0,124, Firefox and Safari). On the Mac, the VSlider's thumb button is not drawn at all making it impossible to use the slider.
After hours of debugging I extracted the internal slider class, making it a "normal" public class sitting in its own AS file, compiled it - and it works on PC and Mac!
So the question is: why? Is there a limit on how many internal classes can be handled in the Mac FP VM? That would rather be strange, right? Any ideas?
I'll try to isolate the issue and log a bug for it but for now I just wanted to see if someone else experiences something similar - maybe some Adobe folks have some ideas on this as well?
Just in case you never used the profiling tools in Flex Builder 3: make sure you give it a try. It was yesterday when the Profiler helped me in finding and fixing a severe memory leak in a deployed application. It was a subtle issue that only happened when the application was running for several hours (it's a kiosk system actually) and I only had some vague ideas what the issue could be but no concrete evidence.
But finally, the Profiler helped me a lot to nail it down: I memory profiled the application and quickly found the cause of the leak (some IResponder references not being cleared caused the trouble) and after fixing it and running another memory profile session the peak memory was not increasing over time but on a stable level. Mission accomplished.
So: kudos to the Profiler - and the great people behind it :-)
Flash Player 9,0,124 security update and Flex WebService calls
Yesterday, Adobe released Flash Player 9,0,124 (Release and Debug versions) which fixes some critical security issues concerning DNS rebinding and cross-site scripting vulnerabilities, more info here. To allow more control over the permissions a remote site can grant SWF files, the cross-domain data loading concept has changed - as well as the crossdomain.xml file syntax.
One important change in the way Flash Player 9,0,124 works is that it no longer allows you to send custom HTTP headers to a remote host. Example: a SWF from domain A wants to send custom HTTP headers in a GET/POST request to domain B. By default, starting with Flash Player 9,0,124 this won't work anymore!.
This has impact for your Flex 2/3 applications (and also 1.5 if you have one flying around still), especially if you're using the WebService classes in Flex as all SOAP messages sent by the Flex client contain custom SOAP HTTP headers (custom here really means anything that gets added to the requests HTTP header).
So if your Flex application sits on domain A and connects to a WebService endpoint on domain B and you (or your customer) uses Flash Player 9,0,124 the Flex application wil fail to load the data due to the new restrictions. Even if you already have a crossdomain.xml file in place on domain B (of course, otherwise it wouldn't have worked before), the syntax is not valid any more. Or to be more specific: domain B does not explicitely allow custom headers to be send - so you'll need to update the crossdomain.xml file on domain B.
Here are two URLs that should give you a jump start:
In summary: with the new cross-domain data loading restrictions in place you now have fine grained control over custom HTTP headers on the receiving side (i.e. the remote server that hosts the service) including who may send which headers - which is good. On the other hand, it breaks your exsiting applications (ok, the fix is pretty easy to implement). The only thing I'm wondering is why there's no single word in the official Adobe article that mentions Flex and the implications of the update to Flex applications...
Sidenote: I'm referring to Flex and the default Flex framework classes here but actually any network API in the Flash Player (URLLoader, URLStream etc.) is restricted in the same way of course - and Flex uses those classes for networking calls anyway.
Wow! That's a real gem! Metal Hurlant has released an early version of a true AS3 eval library - if you don't have a clue what that means: it's an AS3 compiler written in AS3! The Core bits are a port of the Tamarin project "esc" compiler.
Although it's still in an early stage it allows quite funny stuff, even dynamic class creation and instantiation is possible!
LiveCycle Data Services becomes Open Source - and AMF3 specs are out!!!
Wow! Adobe just announced to bring out an Open Source (LGPL) version of the LiveCycle Data Services ES product, codenamed "BlazeDS", a first beta version is available at labs.adobe.com! According to the FAQ, BlazeDS will contain the HTTP and AMF3 over HTTP based messaging features known from the full LCDS product, i.e. Remoting, Messaging and Data Management. RTMP is not mentioned, so obviously the protocol/transport will not be open sourced and probably there will no be RTMP endpoints in the BlazeDS J2EE component - still, this is great stuff of course :)
Also, has released the complete AMF3 specification - and this is a great move IMHO. There were rumours about this for quite a while now and I'm sure the community will love to see that!
A simple(r) workaround for the "Multiple sets of visual children" runtime error
One limitation (or feature?) of Flex 2/3 is that you cannot extend custom MXML components in MXML if you want to add additional chld elements in the subclass, e.g. if you have a MXML component BaseBox deriving from VBox which includes a Label (all written in MXML) and have a subclass of BaseBox called BaseBoxWithButtn also built in MXML you cannot just put new MXML child elements into this second MXML subclass. The code compiles fine but at runtime you'll get an "Error: Multiple sets of visual children have been specified for this component (base component definition and derived component definition)." error
However, sometimes you don't want to take the extra effort of using templates, especially not if you don't have the time to do so - exactly the situation we were confronted with last week. One option was to remove the MXML base classes and rebuild everything in ActionScript (again: too time consuming) - and the second one was to "fix" the framework and make it allow sublcassing and adding child elements through MXML. So we debugged the framework and found the corresponding line in the LayoutContainer class that that throws the mentioned runtime error.
In the end we created a subclass of the framework's LayoutContainer class and overrode the corresponding method. To use it, simply have your MXML components extend this class and specify the layout to use (absolute, horizontal, vertical). Beware, this worked just fine for our needs but it may not work for you at all. Also, it will probably also need some hacking to make this work with more complex / composite Container classes like Form, Panel etc. so don't complain :)
Demo (view Source enabled) available here. You can download the class here.
Speaking at Flex Best Practices Panel in Barcelona
FYI, I was asked to join the Flex Best Practices Panel discussion at MAX Europe as a speaker - and of course I accepted. This session will be an open session with no static agenda, instead it is more a diloag between the audience and the speakers. Together with Joe Berkovitz (Allurent), Sascha Wolter (Flashforum.de) and Steven Webster (Adobe Consulting) we will share ideas, best-practices and in-depth tips & tricks you cannot afford to miss! The session is scheduled for Monday, 10am in room 123.
TODO/FIXME extension works fine with Flex Builder 3 Beta 2
Just FYI, the TODO/FIXME extension also works in Flex Builder 3 Beta 2. If it does not work for you, then make sure to start Flex Builder / Eclipse with the -clean command line option. This should fix it.
For some reason, the session description for my session "Building a CRM system using ColdFusion, Flex and LiveCycle Data Services" is not online anymore so I had to enter it again. In case it does not show up at the MAX site here it is:
Learn how to combine the power of Flex, ColdFusion and LiveCycle Data Services to create a feature-rich, innovative CRM system. This session talks about the lessons learned during the development cycle of a feature-rich, innovative CRM system and gives you in-depth information on how to tackle CRM specific requirements.
So - if you want to know how to successfully combine Flex, ColdFusion and LCDS (and what problems occured during development) be my guest on Tuesday from 4-5pm!
Building monolithic Flex SWFs that still startup quickly
Monolithic Flex SWFs that still startup quickly? Doesn't that sound weird? Of course it does, but actually it works just fine. Thanks to the way the Flash Player downloads multi-frame SWF files it's possible to defer the loading of "heavy" parts of your Flex application making the startup time pretty fast - under the hood the Flash Player still streams in the remaining data (BWT, with "streaming" I'm not referring to live video streaming or anything video releated, there's an ongoing discussion about this somewhere else)
Sven and I will be speaking at MAX Europe in Barcelona - I'm sure this will be great fun!
Sven's session is "Introduction to LiveCycle Data Services for Flex Developers" and will show the great fetaures the LiveCycle Data Services have to offer. Sven did a similar session last year at MAX Las Vegas.
My session is "Building a CRM system using ColdFusion, Flex and LiveCycle Data Services" where I'll give in-depth tips and tricks on how to marry Flex 2, ColdFusion 8 and LCDS.
Sending messages from CF8 to Flex 2 and vice versa
A very cool new feature in ColdFusion 8 is the ability to send messages from a Flex 2 client to a CFC and vice versa by using the new DataServicesMessaging Event Gateway in CF8 over the real time RTMP protocol. This is possible because CF8 adds a Service Adapter to LiveCycle Data Services 2.5 (which you can now install as an integrated web application inside CF8).
Sending a message from Flex 2 to a CFC is as simple as creating a new DataServicesMessaging Gateway instance and assign it a CFC that handles the message. The CFC (in its simplest form) just needs to implement a onIncomingMessage method. In your Flex 2 client you then create a new Producer instance and set the destination to ColdFusionGateway (the default name as configured in LCDS' messaging-config.xml file). Finally, you create a new AsyncMessage instance in Flex, add the Gateway's ID to the header and send it away. This will invoke the CFC's onIncomingMessage
To send a message from any CFC or CFML page to Flex clients you just send a Struct (including a DESTINATION and BODY field) to the Adpater using the SendGatewayMessage() method including the Gateway's ID - that's it! A great feature and super-easy to use!
The best thing is that Event Gateways are now also available in CF8 Standard - you do not need an Enterprise license for it anymore!
Finally... it turned out that it was neither an issue with Flash Player 9 nor with ColdFusion MX 7.02 but with the firewall configuration (*ouch*). The firewall's integrated intrusion protection system filetered out the potential security risk - although an XDP file itself will never be harmful the IPS just found the <script/> sequence and stopped the HTTP request. So sorry for the noise - File uploads work fine in FP 9 and of course also in CF7 :)
After some more testing it turns out as if not Flash Player is causing the upload problems but ColdFusion MX 7.02 - we found this as we tested the application with the new ColdFusion 8 version and there the upload works just fine. In ColdFusion 7 neither an upload with Flash Player nor with a simple HTML upload form works as soon as a <script>...</script> sequence is present in the file.
Using CF 8 is not an option in our project however as we need to deploy on Solaris 8 which is not a supported platform for CF8. Any ideas on how to workaround this bug in CF 7 are highly appreciated!
FileReference.upload() fails silently in FP 9 if the file to upload contains a script tag
This is a weird bug in the current Flash Player 9 - it took us quite some hours to isolate it (and I wonder why it's there anyway).
When you try to upload a file in FP 9 by using FileReference.upload() the upload will fail if the file contains a <script></script> sequence anywhere in the file! No matter what fileextension (does not necessarily has to be .xml it could be anything) and no matter how large the file is. Just try to upload it - it won't work.
We came across this when we tried to upload an LiveCycle XDP file from a Flex 2 application and it did not worked whereas other XDPs could be uploaded with no problems. After hours of searching we found that the script tag was causing the problem.
I reported this subtle bug already to Adobe so let's hope it gets fixed quickly.
The Web Tools Platform (WTP) is a great enhancement for Eclipse - especially since Peter Martin of Adobe Consulting released a new version of the FDS Plugin that adds support for Eclipse 3.2.x and Flex 2.0.1 (for those people who don't know what it is: Peter's plugin allows you to develop and debug your Flex and Java code in a single Dynamic Web project)
One thing that is currently missing in WTP (or to be more specific missing in JST which is part of it) is built-in support for JRun. Based on this excellent article by Alex Kazakov I created and packaged a plugin for Eclipse 3.2.1 that adds JRun 4 support to WTP / JST so you can now also develop and debug your Flex applications on JRun using Peter's plugin :)
I've only tested in on my Windows XP box and didn't even tested it completely - so just take it as is and drop me an email if something does not work. To install it just download the ZIP file below, extract it and copy the plugin to your Eclipse installation.
We did some internal testing with Flex Data Services (FDS) and the Flex Stress Testing Framework recently and are now pleased to provide the results to the community. We tested the three main features provided by FDS: Remoting, Messaging and Data Management. The main focus of our tests was to get a rough idea of how many data / messages FDS can handle and the results are pretty interesting. So - enjoy :)
TODO/FIXME extension works fine with Flex Builder 2.0.1
I just tested my TODO/FIXME extension with Flex Builder 2.0.1 (Windows) and it just works fine - so do yourself a favour and throw it into the plugins folder of your 2.0.1 install :)
Btw, I'd be very happy if someone on a Mac could test it also - I don't have a Mac at my disposal and I'm curious if it runs on the Mac version as well (should work but you never know).
Flex 2.0.1 will be available... soon :) I'm just pointing to a flexcoders message here sent on Wedneday, Jan 3 so you have to make your own assumptions:
Long time no message... again. In case you're wondering why, here's the reason for it: We're currently quite busy developing some sweet Flex 2 applications and do a lot of Flex consulting and Flex training all across Europe. We've done custom on-site trainings, official Flex courses and hosted some Adobe partner "deep dive" trainings to help Adobe partners quickly learn about Flex and where it fits in the Adobe portfolio.
What we see in general is that a broader mass of people is really starting to evaluate Flex and consider adding Flex to their IT systems. This has shifted a lot compared to e.g. a year ago (or even half a year ago).
Also, a while ago we started a German-speaking community platform called Flexforum to help and support the somewhat "invisible" German Flex community. After roughly haly a year we now have about 230 users and and 450 Threads and it's up-and-coming.
In conclusion: more work to do, less time to blog and plenty of time (and a lot of fun) to do Flex coding :) 2007 will be very exciting, with Flex 2.0.1 and Apollo just around the corner.
With kuler you can create color themes and color harmonies and store them for later reference. I'm not a designer - but this tool allows me to grab a nice set of matching colors the next time I need to build a Flex portotype that uses charting for example. Not sure if this is a Flex 2 application or not but anyway - it's kule :)
EDIT: Sean Corfield has a bit more info on the technology behind it
ActionScript core goes Open Source: Adobe gives AS3 to Mozilla
For a good overview on everything about the now Open Sourced AS3 Engine check JD's posts here and here. Also, for a better understanding of what this means (and what not) I'd (again) like to quote Gordon Smith (Adobe):
This is a major contribution from Adobe to the open-source community, but let me try to clarify what it is and what is isn't. The code being open-sourced is for the core AS3 language, not for anything specific to Flash. The contributed engine is able to execute a program that uses core classes of the language like Array, Date, RegExp, and XML. It is not be able to execute a program that use Flash-specific classes like Sprite, TextField, SharedObject, or URLLoader. In particular it supports no Flash graphics. Mozilla will use this engine by adding browser-DOM classes such as Window, Document, Form, Anchor, etc., which are the "domain objects" that a browser manipulates, in the same way that Flash uses this engine by adding classes for its domain objects such as Sprites. Once this is done, webapp developers will be able to use AS3/ES4 as a fast, type-checked, object-oriented "JavaScript" if they want to. So this has nothing to do with putting Flash into Firefox. Firefox users will still require the Flash plugin to run SWFs. But contributing a high-performance virtual machine for a type-checked, object-oriented language is still a big deal!
Applying background gradients to VBox, HBox, Canvas etc.
Here's a little custom border class I created called SimpleGradientBorder which allows you to use non-solid fills with Flex 2 containers. Here's how it looks (the Container shown here is actually a Canvas):
By setting the border-skin style of a Container to the SimpleGradientBorder class, it's possible to fill Box/Canvas containers with a background gradient. This is just a basic example which only supports two fill colors and always draws a vertical gradient but it is actually pretty easy to modify this example if you need more advanced drawing routines. Note that you must set the border-style style attribute to "solid" on the Container, otherwise the background will not be drawn!
Gordon Smith (Flex Framework Engineer) hits the nail on the head. A very good post on flexcoders on the topic of deferred instantiation and the use of creationPolicy.
While browsing flex.org I just found this article by Christophe Coenraets called "30 Minutes Flex Test-Drive for Java Developers". Nothing more to say about the article than this: IMHO the article covers everything a Java Developer needs to know to jump start into Flex 2. Great reading.
Finished Flex 2 Training in Milan, Barcelona next week
I just returned from the Adobe office in Milan where I trained the new Flex 2.0 courseware ("Developing Rich Client Applications" and "Data and Communications") to an excited group of 16 people from Italy, Austria and France (I hope I did not miss anything here)Next week I'll gonna do the same class in Barcelona..
This was the second time I did this course and the overall feedback has been great so far. I especially like the "ohhs" and "ahhs" in the audience when it comes to those magic features like the Data Management Services :)
The former MCI (Macromedia Certified Instructor) program has become part of the Adobe Solutions Network and a few days ago I received my new ACI (Adobe Certified Instructor) certificates (printed on heavy paper with some golden letters - very neat). So, goodbye old MM certs, hello to the new ones :) In addition, I proudly present "my" new ACI logo:
*Tada*
I'm also pretty excited about the fact that I'm going to do three Flex 2.0 trainings during the next three months for Adobe Solution Partners in Milan, Barcelona and Stockholm.
While coding in Flex Builder 2 I found an interesting code hint for a enterDebugger():void method. This seemed to be another undocumented goodie so I gave it a try - and it really works. By using the enterDebugger() method in your code you can invoke the Debugger without setting any breakpoints in your code. Just place the method call where you want to enter the Debugger and it will stop at that very line :)
Here's a quick example:
var n:Number = Math.random(); if (n > 0.9) { enterDebugger(); }
This allows you to write pretty nice dynamic debug code - of course you need to have the Debug version of Flash Player 9 to get this working. I haven't tested yet what happens if the enterDebugger() gets called in the Release version but I suspect it is just ignored silently.
FDS: How to delete an item with unresolved lazy references
In a current Flex 2 project which uses the FDS Data Management Services I stumbled across an issue where deleting a managed item that has a not resolved lazy reference to another item, fails.
In my case I tried to delete a Person object that holds a lazy loaded reference to an Organization object. Calling deleteItem() on the Person destination throws an ItemPendingError (this seems to be a bug which I already reported to the Flex team). By adding an ItemResponder to the error it is possible to process the incoming results of the resolved object (i.e. the freshly fetched Organization object) and then try to delete the object again. Here's a snippet of the workaround:
private function deletePerson(item:Person):void { var ds:new DataService("person"); try { ds.deleteItem(item); } catch (ipe:ItemPendingError) { var token:Object = {caller: arguments.callee, args: [item]}; var responder:ItemResponder = new ItemResponder(pendingResult, pendingFault, token); ipe.addResponder(responder); return; } catch (e:Error) { handleError(e); } if (ds.commitRequired) { ds.commit(); } }
private function pendingResult(result:Object, token:Object=null):void { token.caller.apply(this, token.args as Array); }
This is not the complete code but it shows the main idea: if ds.deleteItem(item) throws an ItemPendingError a responder gets added. When creating the responder, a custom token gets passed in. This token is just a plain Object but the nice thing about it is, that it will be passed over to the result/fault handling functions. This allows for some very neat dynamic callback setup. E.g. inside the pendingResult() function the token is used to call the function that originally setup the responder (which is deletePerson() again). Now, ds.deleteItem(item) gets called for a second time, but this time with the lazy reference completely filled so (hopefully) no error is thrown and finally the changes get committed.
I finally found some time to finish work on an extension plugin for Flex Builder 2 which adds TODO/FIXME Task support similar to Eclipse's Java Development Tool JDT. This is the nice thing about Flex Builder 2: it's based on Eclipse so you're able to contribute to the product by adding your own extensions.
How it works: the plugin parses every MXML/AS file when opened and searches comments (both MXML and AS comments) for TODO and FIXME tokens (this search is case insensitive, so it also finds todo). The same action takes place after a file has been saved. If a token is found, a new Task gets generated with its message set to the comment and displayed in the Task View (To open Task View choose Window-->Other Views...-->Basic-->Tasks in Flex Builder 2 standalone and Window-->Show View-->Other-->Basic-->Tasks when running Flex Builder 2 as a plugin in Eclipse). Note: to really delete a Task you have to delete the comment - deleting a Task from the Task View does not kill the comment, so after you save the file the Task will reappear.
Installation: unzip the ZIP file and move the content of the plugins folder to the plugins folder of Flex Builder 2 / Eclipse. Then, close Flex Builder 2 / Eclipse and restart. The ZIP also contains a Test.mxml file which can be used to test the functionality.
Currently, the plugin only processes single-line comments but it ignores whitespaces between the start of a comment line and the TODO/FIXME token. I'm open for comments and enhancement requests, so please post them here.
Version 2.5 of MDM's Zinc (a tool to turn SWFs into standalone applications for Windows and Mac OS X while adding access to a lot of low-level system through wrapper functions) is now available. The update adds support for Flex 2 / AS3 so you can now run your Flex 2 apps on your desktop. There's also a quickstart article on how to use Flex with Zinc.
Modifying channel definitions dynamically in Flex 2
Yummy... I just found that using a bit of E4X it's possible to adjust the channel definitions that are defined in the services-config.xml file dynamically after your SWF has been compiled. This way you can easily switch endpoints on the fly during development :)
What happens behind the scenes when you compile your SWF using the compiler flag -services=services-config.xml is that parts of the service-config.xml (and the linked *.xml files e.g. data-management-config.xml) get compiled into the application SWF as native XML. This chunk of data is stored in the static xml property of the (undocumented) mx.messaging.config.ServerConfig class. Modifying the data before any service call is made ensures that your modifications will be respected :)
Here's a little snippet how to modify the endpoint URI of the channel "my-rtmp" for example:
Tada! Flex 2 has been released! Adobe has released the complete Flex 2 product line (Flex 2 SDK, Flex Builder 2, Flex 2 Charting and the Flex Data Services) and also the ColdFusion updater 7.02 which includes Flex 2 connectivity (i.e. integrating with Flex 2 RPC and Data Services). They also launched flex.org, a new community platform hosted by Adobe.
We've worked very closely with the Flex and ColdFusion teams during the development cycle of Flex 2 and CF 7.02 and are very happy with what the products have become in the end.
We also wanted to contribute a bit more to the community and launched flexforum.de, a German discussion board focused on Flex 2 - so if you want to share your Flex knowledge or need some help or simply want to be a part of a surely emerging community then please sign in!
Tech Talk: Jeff Vroom on Flex 2 and Flex 2 Data Services
The Serverside hosts a very interesting interview with Jeff Vroom (I dare to say "The Brain behind Flex 2 Data Management Services" - please correct me if I'm wrong) on Building Rich Internet Applications with Adobe Flex. Quote:
In this interview, Jeff Vroom previews the new features in Adobe Flex 2.0 and Flash Player 9. He discusses the benefits of using ActionScript for rich client programming, compares Flex and Ajax, and outlines how Flex integrates with existing Java EE architectures, including Spring, Hibernate and JMS.
Btw, this is *not* a Flash Video but a RealPlayer stream - I don't know when I last had to start-up RealPlayer, it's been quite a while :)
Now that Flex 2 is around the corner (according to some sources) we're pleased to announce our new blog Flexperten.
This blog is especially targeted towards our German readership and so we'll blog in German only there. We'll focus on Flex and CF on the new blog and will bring you tips & tricks, tutorials and other useful information.
Btw: this does not mean that richinternet.blog will be discontinued - we just want to add some momentum to the German Flex community and hope that you'll like it :)
There's not too much content there yet and still only default styling etc. but we'll add new stiff within the next days so stay tuned!
Nice. The Kiwi Project blog, a blog dedicated on "creating read/write web components for Flex" now offers some very interesting articles. Most notably, NoteTag - a Flex 2 application for task tracking - gets introduced and dissected. There's also an article at labs dealing with it in more details.
CF/FlexBuilder 2 Application Generation Wizard Available
The CF/FlexBuilder 2 Application Generation Wizard is available at labs.adobe.com, it's included in the latest drop of the CF Extensions for Flex Builder. To get an overview of the great feature set check out this 11 minute demo Damon Cooper put on his blog. Pretty neat stuff.
Cool: Damon Cooper has some news about the Rapid Application Development Wizard the ColdFusion team is currently working on:
We're currently putting the final touches on the ColdFusion / Flex 2 DB Application Generation Wizard, and we hope to refresh the CF / FlexBuilder 2 plugins soon to add this exciting functionality that will bring hyper-RAD productivity to ColdFusion customers using FlexBuilder 2, to dramatically jump-start Flex 2 /CF DB application RIA construction.
Flex 2 Beta 3 provides an easy way to use the improved FlashType font rendering for embedded fonts inside your Flex 2 application.
Currently, the Flex 2 compiler is not capable of creating FlashType fonts for you - instead, you'll have to create a Flash 8 SWF file that embeds the according font. Then, inside your Flex 2 CSS definition, you embed the font as you did before, but refer to the SWF file instead a TTF file. Here's a little demo that shows the difference between the default font embedding and a FlashType font (Flash Player 9 beta 3 required). While the upper Labels appear very blurry, the Labels on the bottom appear very crisp and clear.
David Zuckerman, one of the Flex Builder 2 engineers, has released an update for Flex Builder 2. This (unofficial) update adds a very useful functionality called "quick fix" (automatic error fixing for untyped variables, missing imports etc.)
This update is not official supported by Adobe and uses two extension points David added to the product - let's hope these stay there.
Running Flex Builder's incremental compiler from ANT
If you're using ANT inside Flex Builder 2 to compile your Flex 2/AS3 application you've probably noticed that invoking mxmlc from inside ANT is not as fast as running the integrated compiler - even if incremental is set to true. This is because mxmlc gets loaded and initialized every time you build whereas the internal builder stays in the VM.
Fortunately, the builder used in Flex Builder 2 extends the core IncrementalProjectBuilder class and Eclipse contributes its own ANT task to invoke it. So if you're using ANT inside Eclipse simply use the <eclipse.incrementalBuild /> task to invoke the internal Flex 2 compiler. You should see same compilation times as running it by hand. The only thing you have to do is to tell ANT to run in the same VM as Eclipse, otherwise it won't now about the Workspace (Run --> External Tools... --> Ant build --> your build file --> JRE --> check "Run in the same VM as the Workspace")
A basic ANT file to invoke the incremental build process in the current workspace is:
If you're running Windows XP SP2 with IE 6 and you've installed update 912945 then IE won't automatically activate ActiveX controls when using the OBJECT tag (so they're InActiveX controls). Instead, only a "still image" of the control is drawn - hovering over the control with the mouse or TAB-bing to it displays a localized message which informs the user how to activate it. This also applies to Flash content embedded with the classic OBJECT/EMBED combo.
According to MS this only applies if the control is embedded directly. If the control is created through an external script, then this limittaion does not apply (of course, this requires active scripting is turned on on the client).
We found that the easiest way to react to this new behaviour was to replace all of our "classic" OBJECT/EMBED combos with the excellent FlashObject by Geoff Stearns. It is a very easy to use JS wrapper with a huge load of configuration options. The clever thing is that if no JS is enabled it will fallback to a custom default behaviour - which could be the OBJECT/EMBED combo again.
More info about FlashObject and the IE update is available here.
Artur wasn't idle and has released three new "Pimp my Flash Form" articles. The coolest bit is a CustomTags that allow you to use the Slider control inside a CF Flash Form :)
Ben Watson of Adobe kindly provided two diagrams that give a pretty good overview over the Flex/Flash Ajax Bridge and the (not yet released) Ajax Client for Flex Data Services architecture:
The extra benefit comes from integrating the Flex Data Services into the web layer (blue):
This will allow to create hybrid web applications that can also work offline (by transparently interacting with the local data store instead of a server side backend)
Another mind blowing gem from the labs: ACFDS (Ajax Client for Flex Data Services) is a library that will allow Ajax applications to access the free (free as in beer) version of the Flex Enterprise Data Services (FES). This way it's possible to create Ajax web applications that are synched with backend data stores (i.e. data gets pushed to the client by taking advantage of the FES messaging capabilities and is not pulled in via XML).
ACFDS will be available later this year but to get a first impression make sure to watch the video on this page.
The weirdest and most impressive part is where a Flex 2 application, an Ajax page and a XLS sheet (!!!) are synched and a change in one application causes the other applications to update their view - w00t!
... I could not get enough (pun intended). Wow, the first version of "The Bridge" (FABridge - Flex Ajax Bridge), a code library to access Flex 2 objects directly from JavaScript/Ajax powered web applications, has been posted at the labs. Kudos to Ely Greenfield who developed this beast!
With the FABridge it is possible to easily integrate Ajax and Flex 2 applications to get the best of both parts. To get an first impression what this is all about make sure to check out this sample (Flash Player 8.5 required). The FABridge functionality is built on top of the ExternalInterface API while maintaining a solid API on both the JS and the AS3 side of things.
More information is available at Ely's blog (yeah, he finally has one up and running)
Very nice: Artur has just released his first "Pimp my Flash Form" article. He really got down to the guts of ColdFusion's CFForm tag and explains how to use the Flex 1.5 RemoteObject tag inside CFForm :)
ActiveX update for IE won't automatically activate OBJECT/EMBED content
According to this MS support article"Microsoft is releasing a software update to Microsoft Internet Explorer 6 for Microsoft Windows XP Service Pack 2 and for Microsoft Windows Server 2003 Service Pack 1. This update changes the way in which Internet Explorer handles some Web pages that use ActiveX controls"
Now, what does this mean? In short, this means that ActiveX controls (such as the Flash Player Control) won't be automatically activated by default if they are embedded with the OBJECT tag. End-users have to explicitely click on the control to activate it. However, if the control is instantiated by an external script file, the control will be active automatically.
One consequence is that the "traditional" approach of embedding ActiveX controls with the OBJECT/EMBED combo won't work as before once the IE update is out in the field. The other one is that now ultimately active scripting has to be enabled in the client's IE because otherwise the external script won't be pulled in. Very annoying.
Adobe is already working on a solution, probably some sort of JavaScript library or HTML wrapper files. More info available here:
I've often been asked how to best pass complex objects to Flex 1.5 while enforcing automatic type mapping between the CF and the Flex side. Due to the typeless nature of CF there isn't a built-in way to get this working in CF 6/7 and Flex 1.5 (of course, the next CF updater codenamed "Mystic" introduces a better way to map CFCs to AS classes but targets CF 7 and Flex 2). I've already posted a working approach here - however, the _remoteClass field usage is deprecated in Flex 1.5 and introduces several drawbacks during deserialization.
We've used the following approach in several projects and it worked out quite well:
To return a typed object from CF to Flex:
inside a CFC method create a new instance of flashgateway.io.ASObject
set the type of the object (see below)
fill the object with data
for nested objects, repeat the above
return the object
in Flex, create a mapping between the type set above and the AS class
Ok, here's a simple example - first, the CFC method "getPerson" which should return a Person value object:
class foo.bar.Person { public var firstName:String; public var lastName:String;
private static var rc:Boolean = Object.registerClass("Person", foo.bar.Person);
public function toString():String { return "My name is " + firstName + " " + lastName"; }
}
This also mimics the way Flex 1.5 interacts with Java POJOs quite well - in theory you shouldn't have to bother if your Flex client is working against a CF or a generic Java backend
Nice: the Flex team added a credits/easteregg SWF to Flex 1.5. To watch it: point your browser to the following URL on your Flex server http://{contextroot}/flex-internal/about/aboutFlex.mxml (e.g. http://localhost:8080/flex/flex-internal/about/aboutFlex.mxml). After the MXML is loaded press and hold the "F" key (yeah - F as in Flex) - shortly after the Flex logo fades out the Flex 1.5 credits are shown (I only got it to work with IE, seems as if the key press isn't received when running in Firefox)
Very cool: Joe Berkovitz contributed an ActionScript code generation plugin to the XDoclet2 project. The plugin creates ActionScript value objects from JavaBeans and supports both AS 2 and AS 3. See also his post on flexcoders here.
Using the Flex 2 Logging API with the Flex Trace Panel
Flex 2 comes with a great new Logging API. I've created an AS 3.0 class that allows you to route logging messages to the Flex Trace Panel.
To use the class, create the folder structure de/richinternet/logging inside your Flex 2 project and copy the TracePanelTarget class to this location. Inside your Flex 2 application you add a new instance of the TracePanelTarget as a target to the Log class, e.g.
private function initApp():Void { var target:TracePanelTarget = new TracePanelTarget(); target.level = LogEventLevel.DEBUG; Log.addTarget(target); }
Later, you acquire an ILogger instance from the Log class and invoke a logging method on it. The parameter passed is the category you want a logger for (by convention the category maps to the fully qualified class name in which the logger is used):
Log.getLogger("foo").info("this is an info message!"); Log.getLogger("foo").warn("this is a warn message!");
Please note that as of now the Flex Trace Panel is not fully compatible to Flex 2 - trying to trace complex objects will fail because some techniques used in the Dumper class no longer work in Flex 2. Also, I haven't adjusted the Flex Trace Panel log levels to the Flex 2 log levels yet. I will create an updated version of the Flex Trace Panel that fully supports Flex 2 in the future - so, just take it as a preview :)
Very nice: the fact that ColdFusion Flash Forms are generated by an embedded Flex 1.5 instance allows you to add your own ActionScript 2.0 classes to your CFForms project. Artur and I found this out while doing some CFForm stuff.
You simply need to modify the flex-config.xml file inside the [CFROOT]/WEB-INF/cfform directory (this file gets used by the embedded Flex server and is a stripped down version of the original Flex config file). To add your own code and class libraries simply define additional AS class paths. E.g. to add the directory D:\dev\asclasses open the config file and look out for the actionscript-classpath node:
<-- path locations of actionscript class files --> <actionscript-classpath> <path-element>D:\dev\asclasses</path-element> </actionscript-classpath>
The best thing: classes linked in this way aren't restricted - you can happily create new instances by using new inside external AS 2.0 classes :)
Mapping SOAP results to ActionScript classes - the easy way
Have you ever found yourself mapping those plain AS objects returned from webservice calls to typed AS 2.0 class instances by hand in your Flex 1.5 application? I've done this but it never felt right.
For example: you know that the Webservice function getPersonList returns an ArrayList of Person POJOs but the Flex 1.5 XMLDecoder creates an Array of Objects from the SOAP result body - you're loosing type information here. So, to get typed Person VOs on the Flex side you normally create a temporary Array, then you loop over the result Array. For every entry in the result Array create a new instance of the AS class (e.g. Person), copy the properties from the untyped result object to the class instance, add this instance to the temporary Array and finally return the temp Array for further use in the Flex client...
To optimize this process you can benefit from the fact that AS 2.0 is just some addon on the AS 1.0 language and you have full access to all this famous "hacking the prototype chain" stuff - this means you can dynamically change the type of an object by pointing the __proto__ property of an object to the (static) prototype property of a class (well, actually not a class but a Function but you get the idea). For the above example (change Array of Objects to Array of Persons):
// Webservice result handler private function handleResult(event:Object):Void { var arr:Array = mx.utils.ArrayUtil.toArray(event.result); for (var i:Number = 0; i < arr.length; i++) { // apply some magic here arr[i].__proto__ = Person.prototype; } return arr; }
And you're done! Please note that the above code will not work in AS 3.0! it's a AS 2.0 specific solution and I've tested it with Flex 1.5 only. Also, some care has to be taken when designing your client side VO classes. Ideally, just use plain VO classes with public members. Implicit getters/setters seem to work but I haven't tested it thoroughly.
MBS5Online - our large Flex App is online since 4 Week with more than 150 Users
MBS5Online is an ASP-Service for contract caterers for planing meals. 4 Weeks ago it went into production with over 150 Users. The frondend application is 100% Flex 1.5 which connects via SOAP to .NET based Webservices. The application was made by the Flex Team of Herrlich & Ramuschkat.
Ok, here are some questions for you: Are you a Flex developer? Are you also a ColdFusion developer? Are you calling CFCs from Flex as RemoteObjects? Are you using the Flex Trace Panel? Have you ever thought about how cool it would be to have something like the Flex Trace Panel for ColdFusion? Something that works like cfdump but displays the dump in a standalone window? Especially when trying to debug Flex-->CFC calls and there's no way to cfdump because there's simply no browser window to display the dump...?
If you're still reading this post then you probably answered every question with "YES!!!" - which is good. I'm currently creating a tool that does all this and I hope to put it online by the end of the week. So stay tuned!
Wow! Colin Moock just announced Essential ActionScript 3.0 which is really great news! It's predecessor Essential ActionScript 2.0 is my all time favourite AS 2.0 book because it really gets down to the guts of AS 2.0 in a very thoroughly way. Colin doesn't mention a release date for the new book but nevertheless it's good to know he's already down with a new one!
In case you're not subscribed to the Edge newsletter, you may have missed this informative article by David Mendels on Flex 2. He points out some interesting details on Flex 2 and the Public Alpha.
I finally found some time to update the Flex Trace Panel. Actually, I've rewritten it completely and added some more functionality. All messages are now held within a message buffer which allows to filter the messages after they are received. Also, the object introspection mechanism has been improved and cyclical references are no longer causing the Trace Panel to freeze.
The core functionality of the Flex Trace Panel is still implemented within a SWF file but I've decided to embed it into a Zinc shell as this will enable me to add more features in the future.
Please go ahead and test it and let me know if this works for you.
via cflex.net: Sun has silently open-sourced Java Server Faces - see this eWeek.com article for more information. By adding some AJAX to JSF this may be Sun's effort to get a piece of the rich client cake.
via mike chambers: "you will be able to use Zorn to develop and deploy applications based on MXML, ActionScript and the next generation of the Flex framework (all without requiring a server)"
This is great news! It means that Zorn will allow to compile Flex applications that don't need to be deployed on a Flex server! Flex applications could be deployed anywhere - just like a classic Flash application. More info here:
After the very smooth installation experience Flash Player reported a version number of 8,0,0,434
The Player team did a great job to get things right: FP8 uses far less memory and comes with a better garbage collection. Also, the overall playback experience has improved - in general, almost every content you've ever created will perform better on FP8. We tested one of our bigger Flex applications with FP8 and it consumes about 30% less memory and significantly performs better in terms of screen redrawing and initialization times when using deferred instantiation.
BTW, a great tool to easily install and uninstall several versions of Flash Player is the kewbee Flash Plugin Switcher
Macromedia joins Eclipse Foundation, new Eclipse-based Flex IDE underway
Macromedia today announced that they're joining the Eclipse Foundation as an Add-In Provider. The official press release is available here. With this move, Macromedia makes a big step towards the Open Source community and also shows their intention to influence the future direction of the Eclipse platform. Among others, the member list of the Eclipse Foundation include companies like BEA, Borland, IBM, SAP and Sybase.
Macromedia also mentions that they're currently developing a new Eclipse-based IDE for Flex code-named "Zorn". To quote from the Flash Platform PDF:
To further support Flex development, Macromedia has joined the Eclipse Foundation and is building a new development tool code-named Zorn, based on Eclipse. Zorn will unify the design, development, and debugging of RIAs and provide a more robust, extensible environment that supports the full range of Flex development needs. news.com also provides some good information about this story.
Flash Platform and new features of Flash based products
Macromedia launched a new company site introducing the Flash Platform. The new term Flash Platform is meant as a genus for the different tools and technologies evolving around the core Flash technology. MM also provides a very interesting PDF that explains the present and the future of the Flash Platform.
When reading through this document, you'll find some great information about upcoming software:
Upcoming Flash Player capabilities (Maelstrom) include a new image API for dynamic custom effects, runtime support of PNG, GIF and progressive JPG files, improved performance (graphics rendering, text scrolling, component rendering, ActionScript execution, and memory management) and finally file up- and download.
Next version of Flash Lite, code-named Deuce: based on Flash Player 7 with ActionScript 2 support.
Next major release of Flex, code-named Mistral, will introduce new data services to support transparent data persistence across tiers, occasionally connected clients, data synchronization, a robust data push infrastructure, and paging large datasets. The new data services will also support offline data access.
Upcoming Flash Communication Server release, code-named Edison, will support new hi-fidelity video capability in Maelstrom, and provide integration with the Flex programming model.
Microsoft announces the Avalon Beta 1 RC. Very interesting about the new release: contrary to former announcements, it will be able to run Avalon applications as "Express Applications" inside a browser:
The Avalon application model now supports two distinct modes of execution: standalone executables and "Express" applications. Standalone applications can derive from NavigationApplication or Application, have access to all privileges granted to the current user context, and are installed to a user's machine. Express applications must derive from NavigationApplication, are hosted in a browser window, run in a security-constrained partial trust sandbox, and offer a zero-footprint install model.
Obviously MS still believes in the browser and browser based applications - do they feel the impact of RIAs?
Handle double clicks with the DoubleClickDispatcher
As there's no built-in way in the Flash Player to register for double clicks, we've recently built a little helper class called DoubleClickDispatcher which acts as a listener for double clicks on any component. If a double click is detected, the DoubleClickDispatcher dispatches a doubleClick event on the component itself. This allows to register for doubleClick events on every component (mx.core.UIObject subclass)
To use it, you'll have to register the component with the DoubleClickDispatcher. After that, you can add an event listener for the doubleClick event just as you would with any event.
Some details about the upcoming Flash Player 8 unintentionally left the building and were posted on flexcoders some hours ago. As expected by many, Flash Player 8 will support E4X (ECMAScript for XML), resulting in less code to write (no more firstChild.childNodes[i].firstChild.nodeValue) and better performance. E4X comes with its own path and filtering notation - the samples shown in the posting look very nice.
Although the post refers to Flex 2.0 I believe the whole E4X feature will also apply to "normal" Flash content as it's going to be integrated into the player itself.
Using Remoting with Flex and ColdFusion CFCs - Part 1
Finally, here's the first part of a series of articles about Flex/CF interconnectivity. This first part explains how to use CFCs as named and unnamed RemoteObjects.
via Kai: very cool! The next version of NetWeaver Visual Composer will include Flex! Here's a snippet from the press release:
SAP (NYSE: SAP) and Macromedia (NASDAQ: MACR) today announced they are extending SAP NetWeaver™ with the Macromedia Flex application framework to give organizations the ability to create rich interfaces for SAP® solutions, including customer-facing SAP® Enterprise Portal-based applications. As a result, employees and customers will have an enhanced experience using SAP solutions, yielding higher employee productivity and greater satisfaction among customers. The announcement was made at SAPPHIRE® ’05, SAP’s international customer conference being held in Copenhagen, Denmark, April 26-28, 2005.
This will add some more momentum to Flex - that's for sure. IMHO it's also a good indicator that Flex won't be dropped from the Adobe/Macromedia product portfolio any time soon :)
Very interesting: I just found that Object.__resolve also fires when accessing an instance via brackets, i.e. by calling foo[42] on a class instance. This allows to build proxy objects for Arrays - for example to delay "expensive" object creation operation until they are really needed.
class TestProxy { function __resolve(num) { if (num == 0) { return "Hello"; } else { return "World!"; } } }
If we create now create an instance of this TestProxy class and access it by using brackets, the __resolve function fires:
var foo:TestProxy = new TestProxy(); trace(foo[0]); // traces "Hello" trace(foo[1]); // traces "World!" trace(foo[42]); // also traces "World!"
Ok, lame example, but you get the idea. The __resolve function can take control what to do. To the outside it still looks like an Array.
Ok, here's a little anecdote concerning the Adobe/Macromedia acquisition:
Back in the late 80s, a small company in Richardson, Texas called Altsys developed an illustration program called FreeHand. Freehand was licensed to another company called Aldus and Aldus published and sold FreeHand for quite some time.
In September 1994 Aldus was taken over by Adobe. Altsys was afraid that Adobe would drop Freehand in favour of their own Illustrator product so Altsys filed suit against Aldus to take FreeHand back. Finally, marketing rights to FreeHand got back to Altsys. Shortly after (in 1995), Macromedia bought Altsys - and FreeHand.
Adobe aquires Macromedia! I'd never thought of that before - and still I can't see how this fits together. Ok, Adobe and Macromedia have been competitors for years in the graphics/tools market but how do the mobile and server solutions fit in here?
So I'm gonna use Adobe ColdFusion and Adobe Flex 2.0 in a couple of months... strange. Also, what will this mean to the competing technologies FlashPaper/PDF, Flash/SVG, Dreamweaver/GoLive?
Here's some more information I found quite useful:
Wow! These guys have successfully used their Flex with a Apple G4!
Ok, if you haven't laughed out loud now then apparently because you didn't know that here in Germany the term Flex is a synonym for an angle grinder tool :)
Btw, no Apple computer got harmed - they only had a slotted screwdriver so they created the according screw by using brute force :)
Brightcove, Inc., a young startup lead by former Macromedia CTO Jeremy Allaire is looking for experienced Flash developers seasoned at building Flex applications to join its engineering team. As a member of this team, you will contribute to the development, release and maintenance of a service that aims to touch millions of people around the world and revolutionize the consumer television experience. The ideal candidate has 3-8 years of experience building dynamic, interactive websites with a solid background in good development practices. All positions are based in Cambridge, MA.
Using Remoting with Flex and ColdFusion CFCs (introduction)
I've decided to write a series of articles on how to use the Flex RemoteObject servicetag to invoke ColdFusion CFCs and to exchange data between both systems. Every few days a Flex/CFC related question pops up on the flexcoders list so I thought it's time to do something about it :)
I haven't created an outline for this series of articles yet but the topics I'd like to include are:
setting up the RemoteObject tag to call CFCs
building and calling a facade.cfc that delegates calls
The Flex Profiler application focuses on measuring the client side performance of your Flex application and helps you finding bottlenecks inside your AS code. Information on how to use the Profiler can be found on the DevNet and inside the Flex documentation.
Another great tool for doing stress test is Apache JMeter - a very powerful tool that's fully scriptable. It also support SOAP/XML-RPC calls so you can test the overall performance of your web services with it easily.
The only available tool that is able to record and display the proprietary AMF format that is used when doing RemoteObject calls is Silk Performer - again, there's an in-depth article about it on the DevNet.
Undocumented autoRepeat feature of mx.controls.SimpleButton
While playing around with the mx.controls.SimpleButton class, I found that there's an undocumented property called autoRepeat of type Boolean. Setting this to true fires constantly buttonDown events as long as the mouse button is pressed - and as mx.controls.Button is a subclass of Simplebutton it's available there, too :)
Just play around with the sample below to see the effect - pretty useful for custom steppers etc.
The defaut cell editor that's created when using an editable DataGrid is a plain TextInput control that's neither restricted nor limited to a maximum amount of characters - but when dealing with editable DataGrid's you'll usually want exacatly this kind of control.
According to the docs, the DataGrid's cellEditor property is a reference to the current cell editor so it's possible to access and manipulate it. For ease of use I subclassed mx.controls.gridclasses.DataGridColumn and created a RestrictedDataGridColumn class. The class provides two extra attributes: maxChars and restrict. When a cell is clicked or foucused in, the properties restrict and maxChars of the grid's cellEditor are getting set accordingly:
Info: according to Sven Claar, it's still possible to type characters into a restricted TextInput field. If you hammer on your keyboard and then switch focus to another cell, it's possible to insert characters into the cell :(
I updated the DelayedCall utility class a bit to get rid of some scoping issues. The constructor now takes three mandatory arguments, an interval, the target object and the function to call on the target object (very much like mx.utils.Delegate). As usual, all additional arguments passed to the constructor will be the input arguments for the target function.
Restrict NumericStepper to only numeric characters
The mx.controls.NumericStepper control is very neat. Unfortunately, it doesn't provide a way to restrict the embedded TextInput control to a range of valid input characters.
By default, when clicking into the TextInput of the NumericStepper it's possible to type numeric charecters, dashes, commas and colons - I don't know why, because ususally you'll only want integers inside the NumericStepper.
So here's a little workaround how to setup the control's TextInput field to only accept positive integer values:
Dreamweaver extensions for CFMX 7 support breaks Flex Builder 1.5 code hinting
Beware if you're planning to download and install the updated Dreamwever MX 2004 extension that adds code hinting support for ColdFusion MX 7 when you've got Flex Builder 1.5 installed. For some reason, the extension also gets added to Flex Builder (at least on my machine) and breaks some of the MXML/AS 2.0 code hinting.
Make sure to backup your FB configuration before you're applying this update so you can roll it back if it gets corrupted, too.
We'll exhibiting at this year's CeBIT fair in Hannover, Germany. Together with the folks from eggs unimedia, msg at.NET and the team of Macromedia Germany, we'll be your host at the "Macromedia Center of Excellence" booth in Hall 3, Stand A 14.
The main focus will be on presenting the MM server technologies Flex, Breeze, and ColdFusion and custom enterprise solutions based on these products (nope, we won't show regular products like Flash or Dreamweaver).
Last year's CeBIT was quite exciting and I hope this year it will even be better. The fair takes place from March 10-16.
Don't know if this documented, but it's possible to disable the headers of an Accordion control - by doing this, clicking on a header doesn't switch the view. This is pretty useful if you're for example splitting a form into multiple Accordion views and only want to activate the next view if all form items of the current view are valid.
The mx.containers.Accordion class provides a getHeaderAt(i:Number) method that returns a reference to the UIComponent that is used as a header for this view (by default, calling getHeaderAt() returns an instance of the mx.containers.accordionclasses.AccordionHeader class). As the header is a subclass of UIComponent, you simply have to set its enabled property to false.
Here's a little class that can be used to postpone the invokation of a function or object method by a given amount of time. In a current project we needed some kind of timeout functionality that can be used to control application flow and came up with this class.
Basically, it's a wrapper around the setInterval() function that automatically removes the interval after it fired. This way we needn't to clear all intervals by hand.
Usage is pretty straightforward. The constructor of DelayedCall takes two arguments: the number of milliseconds to wait and the function/method to call after that amount of time. Any additional parameter will be passed to the function that gets called.
DateChooser extension now compatible with Flex 1.5
Because of popular demand I fixed my DateChooser extension to be compatible with Flex 1.5 (original description of the extension is available here)
I changed two things: first, instead of calling setStyle() on the TextFields that make up the calendar's date labels I now set the textColor directly - simply because setStlye() didn't worked any more. Second, I added a bit of delay to the highlightDays() method. Sometimes the method wasn't called correctly and this should do the trick (the setInterval() setup may look a bit weird but that's because doLater() didn't worked at all...)
The complete example is available for download here. I haven't tested it with Flex 1.0 but it should run fine with 1.5
Using mx.managers.HistoryManager for undo functionality
I just played around a bit with the mx.managers.HistoryManager package and found that it's pretty useful for building generic undo mechanisms. The HistoryManager provides a register(obj:Object) method which allows you to register any object with it - it doesn't have to be a visual element. By registering with the Historymanager you "agree" to implement two methods into your object's code:
function saveState():Object
function loadState(state:Object)
(Unfortunately, there's no real interface to implement here, although the documentation mentions a mx.managers.StateInterface interface). Everytime the state of the application changes, the Historymanager calls the saveState() method on all registered objects. It's up to you to return any object that describes the current state of your object (like a snapshot). If this state is going to be restored, then all registered objects receive their state back via the loadState() method. Again, it's up to you to rebuild the state by investigating the snapshot.
You can also inform the HistoryManager to save the current state of the whole application by calling its static save() method - this is what you have to do by hand if a performed action has to result in building a "snapshot" of your application.
Here is an example that shows how two popUps play nicely with the HistoryManager.
Flex Builder 1.5 is available for download - performance has improved noticeable (less CPU cooking and crashes) and it now fully supports Flex 1.5 including charting and RSL. If needed, die-hard coders can deactivate the Design View completely to gain even more performance. Flex Builder really matured - good job!
Flex compiler decorates every class with a className identifier
When compiling a Flex application, the compiler automatically adds a public instance variable called className of type String to every AS 2.0 class which contains the name of the class itself (this is of course also true for every mxml file that gets compiled as every mxml file gets translated into a AS 2.0 class prior compilation). While this is obviously intended to be used internally, it may come in handy if you want to create class instances at runtime but you only have the name of the class but not its constructor function - e.g. you could have read in an external configuration file that contains the name of the class to use and now you want to create an instance of it.
Two things to look out for: the className identifier only contains the class name, not the fully qualified class name - this might lead to unexpected results. Also, the above allows not to dynamically load classes á la Java, you'll have to make sure that the classes that should be created later on get compiled into the app.
Here's something for your pleasure: it is possible to invoke a CFC as a RemoteObject and to take advantage of the built-in mechanism in Flex that creates instances of a custom AS 2.0 class during deserialization. This way you can pass over structs from your CF application and have them automatically mapped to your client side AS 2.0 classes
I've put together a little example that shows this technique. Basically, you only have to make sure that the struct you're passing over the wire contains a "field" (i.e. a key) called _remoteClass - pretty much the same as when you're invoking POJO's with Flex. The example invokes a CFC that returns an array of structs. Every struct contains a key called _remoteClass that contains the name of the AS 2.0 class to use for deserialization on the client side.
Adjust the number of objects to create by using the NumericStepper and hit the "invoke" button. The result is rendered in the List control (by taking advantage of a implicit getter function called "label" that's defined in the custom AS 2.0 class). Selecting an item in the List calls the toString method of the current item and renders the text in the Label control.
Edit: if you want to return CFC instances rather than structs then you'll have to change the static property FLEX_CLASS_FIELD of the mx.utils.ClassUtil class to "_REMOTECLASS". Additionally, all members of the AS 2.0 class should be written in uppercase.
I wasn't aware of this but the Central SDK for Flex is already available at macromedia.com. Just browse over to the default download page for the Central SDK and click on the topmost link "Macromedia Central 1.5 SDK".
After agreeing to the license agreement you'll see the different downloads of the SDK - and now there also is the Flex SDK for Central.
After CNet already wrote about it yesterday, Macromedia now officially announced Flex 1.5. It will be available in November and comes with new functionality and optimizations, including charting components, runtime shared libraries, Central 1.5 support and other neat features. More information below:
IBM article on developing webservice clients with Flex
I just found this interesting article over at IBM's developerWorks site. The two authors show very thoroughly "how sometimes confusing WSDL constructs map to Flex declarations". They also show how to use WSDL declarations that define more than one service and how to do Document and RPC oriented invokation.
If you want data integrity you usually use message digest algorithms like MD5 or SHA1. Flex does not provide built-in message digest functionality so I throw this one in: an ActionScript 2.0 implementation of the Secure Hash Algorithm SHA1 based on the JavaScript implementation by Paul Johnston distributed under the BSD License. Basically, I just wrapped the functionality into static methods and added implicit getters/setters for property access (btw, the class also works in plain Flash MX 2004 projects). Usage is quite straightforward: just add the class package to the [flexcontext]/WEB-INF/flex/user_classes directory and you're set.
The most useful methods are
static de.richinternet.crypto.SHA1.encode(message:String):String - returns a 40 byte hexadecimal message digest (lower case hex chars by default)
static de.richinternet.crypto.SHA1.test(Void):Boolean - return true if the VM (i.e. the Flash Player) works ok
To change the default setting for the output format of the hexadecimal message digest use
static de.richinternet.crypto.SHA1.upperCaseHex:Boolean - set to true to force upper case output, default is false
There are some additional methods and properties (e.g. base64 output) which I'll document if time permits. Otherwise: Just check the source code for further information :)
Wow, that's really an interesting article: if you ever wanted to know how Flex really bakes internally the make sure you don't miss this fine piece by Roger Gonzalez. It's a very in-depth article on the internal workings of the SWF compiler and linker with lots of information in it that may not be relevant for your daily Flex work (actually, I think they are confusing if you haven't done Flash before) - nevertheless, it may be helpful when you want to tweak your applications.
When looking behind the mxml scenes a RemoteObject basically is a nice wrapper around the mx.remoting.Services class which in turns is very similar (if not same) to the same named class that is included with the Flash Remoting Kit for ActionScript 2. For that reason it is possible to assign an instance of the mx.services.Log class to a RemoteObject which provides useful debug information.
The constructor of mx.services.Log takes two parameters, bot optional. The first parameter is a numeric value and sets the debug level. The Log class provides 4 static variables to set this up: Log.DEBUG, Log.BRIEF, Log.VERBOSE and Log.NONE - the default value is Log.BREF. The second parameter is of type String and comes handy when you have more than one Log instance that all display in the same output channel.
After assigning the Log instance to the RemoteObject instance's log property, the RemoteObject instance reports all lifecycle information to the Log instance and the Log instance can respond. The default eventhandler for these logging events is Log.onLog(message:String):Void which of course can be overwritten or reassigned to another function.
Now here's a quick example that uses the Flex Trace Panel to trace the Log's information:
The application is very-well designed and consists of four mxml files that build up the UI and an additional non-visual mxml component that encapsulates the remote object calls. The remote object invokes a server-side Java class called Database that in turns connects to the MySQL server and returns Value Objects to the frontend.
BLDoc beta announced - autogenerated JavaDoc style docs from AS classes
This just popped up on flexcoders: B-Line Express (www.blinex.com) has just opened a public beta for their BLDoc tool that (like JavaDoc) generates HTML documentation by doing introspection on your source code and special meta tags buried in comments. I be it's worth checking out!
Here's a little helper if you are building custom Flex components with ActionScript 2.0: if you make your properties bindable you can add another (undocumented?) meta tag called [CollapseWhiteSpace] to the property. This directive automagically collapses all whitespaces from the value passed in. Here's an example:
// AS component snippet code
// a private member that stores the text privatevar _text:String; // make the property _text available via getter/setters // and make it Inspectable and Bindable in Flex BUilder [Inspectable(defaultValue="Your Text")] [Bindable] // collapse all white space characters [CollapseWhiteSpace] publicfunctiongettext():String { return _text; } publicfunctionsettext(txt:String):Void { _text = txt; }
Flex Builder is not a standalone product but comes bundled together with Flex (and with the Flex Trial of course). If you already have your Flex Trial CD then according to this statement from Lucian Beebe (Flex Builder product manager) you'll also get a Flex Builder trial: "Flex Builder comes bundled with your eval and full copies of Flex. For those of you who already have the Flex eval CD, you'll receive an e-mail in about 12 - 18 hours telling you how to download your trial of Flex Builder. That will last 60 days and if you need more time, there are instructions for how to contact our Customer Service."
Java2AS: create ActionScript classes from Java VOs
Christophe Coenrats released a nifty java tool that automagically creates ActionScript 2.0 classes based on your Java Value Objects. That's a real timesaver as you don't need to write the client side AS classes by hand any more. 2 Thumbs!
This one is tasty! Christophe Coenraets posted an example on how to push data from the server to a Flex application by using XMLSocket connections. Looks as if he's also working on a second example that uses Flash Communication Server to push the data to the client.
Another fresh item from the coding laboratories: the Flex Team just released Updater 2 for Flex 1.0. It contains about 20 50 product bug fixes and also introduces some changes that will affect your Flex applications built under Updater 1. A updated documentation is also available as a seperate download.
Kai just asked me if it's possible to let the Flex Trace Panel always stay on top (i.e. in front of all other windows). I hacked together a litte starter application (win only, sorry folks) that starts the Flex Trace Panel as a always-on-top application. This starter is not very smart, so please follow the instructions below:
extract the starter.exe to the directory where the panel.exe resides
make sure the Flex Trace Panel is not running
start the starter.exe
The Flex Panel now should be a frontmost window. Again, this all depends on the execution of the starter.exe - the panel.exe is not patched in anyway, you'll always have to use starter.exe
Macromedia Germany offers Flex DevTalk via Breeze live
This one is from Sven Claar: Macromedia Germany is starting a "Flex DevTalk" event series. The events will be served as Breeze Live meetings, starting Tuesday, June 29 at 11:30 (GMT+1). German Flex developers will give overviews on Flex, MXML and Flex best practices.
You may have heard rumours about "Brady" before, finally here is some in-depth information right from the source: Heidi Bauer-Williams talks in this article about the Brady feature set and the benefits for Flex developers.
Unfortunately, she makes no statement on availability, pricing and distribution model - Brady is based on the Dreamweaver MX 2004 codebase so it may be possible that it will be selled as a add-on (that's what I could think of, not sure though). Brady is in final beta right now - if you're interested in becoming a Brady beta tester check the email at the end of the article.
I'll be speaking at this year's MAX on debugging Flex :-)
It's official: I'll be speaking at this year's MAX conference in New Orleans (November 1-4). I will do a 90 minutes hands-on session on debugging Flex applications. Different debugging techniques and approaches will be introduced, profiling of ActionScript code is also a topic - this is my first MAX and I am really really looking forward to this one :-)
The session is workshop alike, meaning that the audience is invited to do hands-on practices. Coding allowed ;-)
When I wrote a Flex application that communicates with Java classes deployed on my local J2EE server I wondered how data and their type is mapped. Although ActionScript 2.0 may remind you of Java at the first look it is not based on it (e.g. ActionScript comes with only one primitive type for all numeric values).
Remote Java objects can be accessed with the mx.servicetags.RemoteObject tag. RemoteObject does a very nice job serializing and deserializing data - an ActionScript String (passed to RemoteObject as a parameter for example) gets serialized into a Java String argument to the remote method. A custom Java class MyClass with private members and getters/setters for those members gets serialized into an ActionScript Object with property names based on the Java getters/setters. If you want the Java object to be serialized into a custom ActionScript class instance instead then you have to add a public String variable called _remoteClass to the Java class. Flex then creates the according ActionScript class and fills its members with the data from the Java object.
Here's an overview of the AS to Java data type mappings (may not be complete, compiled from this article):
ActionScript data type
Java data type
Number (primitive data type)
java.lang.Double
Boolean (primitive data type)
java.lang.Boolean
String
java.lang.String
Object
flashgateway.io.ASObject
null
null
undefined
null
Ordered array
java.util.ArrayList
Named array
flashgateway.util.CaseInsensitiveMap
Date object
java.util.Date
XML object
org.w3c.dom.Document
This table shows the Java to ActionScript mappings:
Sometimes it is worth to look at the MM Site ... there is a brandnew Flex Performance Brief. The study details the server-side performance of a Flex application by comparing it to a similar application implemented in JSP.
UPDATE: Version 1.5b2 of the Trace Panel is available here!
I have updated the Flex Trace Panel to version 1.1 and added a Dumper class that makes tracing easier. The class provides several convenience methods to trace/dump messages out of your app into the panel.The download is available here.
UPDATE: I also coded a little helper app, that starts the Trace Panel "always-on-top" - more info here.
The archive consists of the updated panel as a standalone exe and the Dumper class file (inside the "src" folder). To make the Dumper class available to all your MXML applications extract it into the [YourInstallDir]\Flex\WEB-INF\flex\user_classes directory and leave the folder structure intact.
The Dumper class is a static class and provides five methods (four of them are just shortcuts actually) and three different log levels. The levels are 2 (or Dumper.INFO), 4 (Dumper.WARN) and 8 (Dumper.ERROR).
de.richinternet.utils.Dumper.dump(message:Object, level:Number):Void takes the passed Object (any type) and routes it to the Flex Trace Panel, the 2nd paramter is optional and refers to the different log levels of the Dumper class (the default is Dumper.INFO)
de.richinternet.utils.Dumper.trace(message:Object):Void takes the passed Object (any type) calls the Dump.dump() method with log level Dumper.INFO (2).
de.richinternet.utils.Dumper.info(message:Object):Void takes the passed Object (any type) calls the Dump.dump() method with log level Dumper.INFO (2).
de.richinternet.utils.Dumper.warn(message:Object):Void takes the passed Object (any type) calls the Dump.dump() method with log level Dumper.WARN (4).
de.richinternet.utils.Dumper.error(message:Object):Void takes the passed Object (any type) calls the Dump.dump() method with log level Dumper.ERROR (8).
Here is a simple example on how use the Dumper class:
import de.richinternet.utils.Dumper;
function traceTest() { Dumper.dump("a normal message"); Dumper.info("also a normal message"); Dumper.warn("oops, a warning message"); Dumper.error("Houston we have a problem!"); Dumper.dump("this is also an error!", Dumper.ERROR); }
Together with the updated Flex Trace Panel you are now able to filter the messages, if you select the "ERROR" radiobutton control for example only messages with a level of Dumper.WARN will be displayed. This is what it looks like if you run the above example with a filter setting of "ALL":
BTW: The filter does not work on the already displayes messages in the Panel but only on all future messages.
I also put an experimental method into the Dumper class called Dumper.setHook() that adds shortcut functions to the Application.application scope. After you called Dumper.setHook() the dump(), warn(), and error() functions are available directly in the application's main scope - the only thing you have to do is declaring the functions, otherwise the compiler will throw a warning.
Important: this version only works with Flex 1.0 - please use this version for Flex 1.5
Alright, here's a little goodie for you: I extended the mx.controls.DateChooser control so that it is able to highlight (or emphasize) given days of the displayed month. Very similar to those HTML calendar controls you find in almost every blog (even we have one ;)
It was quite a hack to get the functionality implemented. First, I had to check how the DateChooser control works internally. I you look at the files from which you installed Flex, you'll find a flexforflash directory and a flexforflash.zip file. Even if you are no Flash developer these archive is a real treasure as a lot of (yet not all) source code is included. The files are mainly targeted for developing advanced Flex conponents with the help of Flash and Flash needs the files for proper compilation. But if you are curious (you always should be) then extract those files and have a look at it!
So basically, here's what I did: I extracted the flexforflash.zip archive and browsed inside the [YourDir]\Flex Classes\mx\controls directory. In this directory you find almost all the code for the visual components. Don't hesitate to open a file, you can even edit or delete them - Flex does not care about it. The source code class files are not used by Flex, they are just a copy of the files the Flex controls are built upon and are only important if you're doing Flash --> Flex stuff. Anyway, having a look at the class files is a great way if you what to learn about the architecture and how things work under the hood.
First, I created a new MXML component called DateChooserEx.mxml that extends mx.controls.DateChooser. The additonal functionality is implemented by inline ActionScript. To be honest: that's awkward to me, I would like it better if there would be a way to let Flex package the component as a SWC so you get it as an encapsulated building-block (maybe in Flex 2.0?).
Then I added the method highlightDays() to my control that processes a given Array of Numbers and emphasizes the given days. For example: if you call highlightDays([1,14]) on the control then the 1st and the 14th day is highlighted. This is done by calling the setStyle() method of the according Labels that resemble the current's month view. The references to the Labels are stored inside the DateChooser property dateGrid which is of type mx.controls.CalendarLayout. Here's the full code of the method:
public function highlightDays(dayArray:Array, highColor:Number):Void { // check the input params if (dayArray == undefined) return; if (!dayArray instanceof Array) return; if (highColor == undefined || isNaN(highColor)) highColor = 0xff9900; // row 0 of the dateGrid is used for the display of day names var startRow = 1; // calculate the column where the first day of the month is placed var startCol = this.dateGrid.getOffsetOfMonth(this.displayedYear, this.displayedMonth); // how many days do we have this month? var lastDay = this.dateGrid.getNumberOfDaysInMonth(this.displayedYear, this.displayedMonth); // now process the array for (var i = 0; i < dayArray.length; i++) { var day = dayArray[i]; // only numbers allowed if (isNaN(day)) continue; if (day < 1) continue; if (day > lastDay) continue; // calculate row and column of the day var row = Math.floor((day-1 + startCol) / 7) + 1; var col = (day-1 + startCol) % 7; // adjust the text-color style of the dateGrid this.dateGrid["dayBlock" + col + "label" + row].setStyle("textColor", highColor); } }
You can download a zip file containing the DateChooserEx control and a simple example here. Just extract the files to your Flex application directory. Please note that you have to select a day on the control do call the method. I wanted to use the controls initialize event to trigger the method but somehow this does not work. Maybe in the next release. Enjoy!
Important: this version only works with Flex 1.0 - please use this version for Flex 1.5
Etwas kurzfristig, aber bestimmt interessant: Macromedia veranstaltet heute um 18:00 Uhr (Westeuropäischer Sommerzeit) ein Breeze Live Meeting zum Thema "Flex for Java Users". Link zum einloggen:
Nachtrag: wer die Live-Meetings verpasst hat, oder sich nicht um Mittenacht vor den Rechner begeben möchte, hat ab morgen die Möglichkeit, sich die Präsentation "aus der Konserve" anzusehen. Das Archiv gibt es hier.
Macromedia hat den Flex 1.0 Updater 1 zur Verfügung gestellt. Das bemerkenswerte and diesem Update ist, dass viele der Änderungen und Anpassungen auf Anregungen und Diskussionen in den Anwenderforen und -Listen zurückgehen. Man hat wirklich den Eindruck, Macromedia hört zu und bemüht sich ernsthaft um Produkt und Community. Gut so!
Neben wichtigen Bugfixes wie z.B. die Behebung des UIObject Memory Leaks gibt es zwei Änderungen, die mich besonders erfreuen: zum einen unterstützten MXML Komponenten jetzt Interfaces(!)
<local:ConcreteBox implements="BoxInterface" />
zum Anderen wurde die MXML API Referenz umfassend aktualisiert und kommt jetzt in ganzen Sätzen, statt nur in Stichwörtern daher (und einige Änderungen kommen mir seeeehr bekannt vor ;)
Am Montag habe ich den ersten Flex At A Glance Workshop gehalten. Einen Tag lang habe ich den Teilnehmern einen Überblick über Flex, die zugrundeliegende Technologie, die Architektur und das Framework gegeben. Im Praxisteil ging es dann Schritt für Schritt von einer einfachen Anwendung zu einer kompletten Applikation mit Login, Remote-Datenzugriff, Form-Validierung und einer Vielzahl von verschiedenen UI Elementen.
Alles in allem war es eine erfolgreiche Veranstaltung, die auch bei den Teilnehmern Begeisterung für die Anwendungsentwicklung mit Flex erzeugt hat.
Da ich meinen Flex-Code in Ermangelung eines anderen unterstützen Editors derzeit in TextPad verfasse, bin ich auf folgendes gestoßen: externe ActionScript Dateien sollten unbedingt als UTF-8 (ist ja klar) und zusammen mit einem BOM (Byte Order Mark) gespeichert werden. Ich vermute mal andere Tools wie z.B. Dreamweaver tun dies von Haus aus, TextPad allerdings nicht. So wurden z.B. Strings, die Umlaute enthalten, nicht korrekt gespeichert und zur Laufzeit falsch ausgegeben.
Kennt sonst jemand evtl. einen (verfügbaren) Editor mit Syntax-Highlighting und sogar Codehinting? Ich habe Syntaxdefinitionen für TextPad, das hilft ungemein, Codehinting ist allerdings nicht dabei.
Inspired by my last post I built my own standalone Flex Trace Panel. It enables you to display debug messages "in real-time" rather than letting Flex write debug info to the flashlog.txt file (which is not a very intuitive way methinks). Here's what it looks like if you use it together with a Flex app:
I have further plans for this tool, so stay tuned - and if you have ideas or feature requests please drop a comment.
Usage is quite simple: first, you'll have to include the debugUtils.as file into your mxml file:
"dumpUtil.as">
Second, compile your app and display it in a browser, then open up the Flex Trace Panel. All calls inside your Flex app to the dump() function will be routed to the Flex Trace Panel. For example you could output the content of a TextInput when a Button is clicked:
"OK">
Of course the data to be dumped can be more complex than this - you can pass any data type to the dump() function. If you do not see any output in the Panel (especially if the Panel is open prior the Flex application is loaded or you reloaded the mxml in the browser), click the 'reconnect' button to rebuild the connection.
You may download a zip archive containing the Panel, the dumpUtils.as and a mxml sample file here.
Using the Central Debug Panel for tracing from a Flex app
Debugging a Flex app can be tricky - especially if you are a Flash developer and are used to use trace() statements all over your code.
The first thing I did was using mx.controls.Alert.show() to display debug messages - but hey, that isn't cool ;)
I also developed some Central applications and fell in love with the Standalone Central Debug Panel supplied by Mike Chambers. Central uses a nice debug feature: if you issue a trace() command, the Central application "sends" the data to be traced over a so called LocalConnection to the Central Debug Panel. The Panel embeds a swf file "listening" for messages, parses the sent data and finallay dumps it into a TextArea component - easy and effective.
So what should stop us from doing this with Flex, too? Nothing at all. I built a simple ActionScript file that can be included into your MXML app. If you have the Standalone Central Debug Panel installed all calls to the dump() function will be output in the Central Pabel. Nifty, ehh?. And this is what it looks like:
You may download the zip archive containing the dumpUtil.as file and a MXML sample application here. Be sure to download and install the Central Debug Panel first - and start it of course.
Tipp: man kann die Reaktionszeit von "Multi-View Components" wie z.B. mx.containers.Accordion massiv beschleunigen, wenn man die creationPolicy (geerbt von mx.containers.Container) auf "all" setzt: