Here’s a quick tip to generate swc file using ant task with the Java tags.
There are plenty of example of using the compc tag like this one below:
<project name="ASDoc build" default="main" >
<!-- make sure that flexTasks.jar which is located in skd/ant/lib/flexTasks.jar otherwise you'll get an error message -->
<taskdef resource="flexTasks.tasks" classpath="Jars/flexTasks.jar" />
<!-- defines all values for the ASDoc compiler -->
<property file="build.properties" />
<target name="main" depends="clean-swc-directory, swc-generator" />
<!-- deletes and recreates the swc directory -->
<target name="clean-swc-directory" >
<delete dir="${workspace.dir}/build/swc" />
<mkdir dir="${workspace.dir}/build/swc" />
</target>
<!-- generate the swc -->
<target name="swc-generator" description="Compile the SWC file">
<compc output="${workspace.dir}/name.swc">
<include-libraries file="${workspace.dir}/libs" />
<include-sources dir="${workspace.dir}/src/com" includes="*" />
</compc>
<echo>SWC created successfully</echo>
</target>
</project>
Sometimes you want to generate the entire script using the Java tags. Here’s an example:
<java jar="${FLEX_HOME}/lib/compc.jar" maxmemory="512m" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg line="-source-path ${main.src.loc}"/>
<arg line="-output '${bin.loc}/Name.swc'"/>
<arg line="-include-libraries '${main.src.loc}/libs'"/>
<arg line="-include-sources '${main.src.loc}'"/>
</java>
Took me few hours to figure this out since there aren’t any examples online.
Cheers,
Elad Elrom
There are times where you need to convert a color from a uint to a string and back to uint, here’s a quick tip to convert between the two for Flex 4.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.events.ColorPickerEvent;
public static function convertUintToString( color:uint ):String
{
return color.toString(16);
}
public static function convertStringToUint(value:String, mask:String):uint
{
var colorString:String = "0x" + value;
var colorUint:uint = mx.core.Singleton.getInstance("mx.styles::IStyleManager2").getColorName( colorString );
return colorUint;
}
protected function changeHandler(event:ColorPickerEvent):void
{
var colorString:String = convertUintToString( event.color );
var colorUint:uint = convertStringToUint( colorString, '000000');
}
]]>
</fx:Script>
<mx:ColorPicker id="cp" change="changeHandler(event)" editable="true" />
</s:Application>
Wanted to add and manipulate a path during runtime. As we know we can wrap FXG code into a Graphic element using MXML:
<s:Graphic id="starGraphic">
<s:Path id="starPath" data="M 78.50 82.15 L 49.16 70.71 23.10 88.40 24.91 56.96 0.04 37.64 30.50 29.65 41.18 0.03 58.20 26.53 89.68 27.53 69.73 51.90 Z " height="47.947" width="48.039" x="1.075" y="1.117">
<s:stroke>
<s:SolidColorStroke caps="none" color="#000000" joints="miter" miterLimit="4" weight="1"/>
</s:stroke>
<s:fill>
<s:SolidColor color="#FF90CD"/>
</s:fill>
</s:Path>
</s:Graphic>
However what I wanted to do is create the path during runtime instead of compile time. Looked online and couldn’t figure it out so I dig into the MXMLC compiler guts to see what it’s doing and found out that it’s pretty simple, you just need to use the graphics.mxmlContent = [path]; and point to the array of elements that you will be adding.
See MXMLC code generated when using MXML tags:

And here’s the AS3 code to generate the same during runtime:
public static function drawStar(x:int, y:int, width:int, height:int, color:uint):Graphic
{
var graphics:Graphic = new Graphic();
var path:Path = new Path();
path.data = "M 78.50 82.15 L 49.16 70.71 23.10 88.40 24.91 56.96 0.04 37.64 30.50 29.65 41.18 0.03 58.20 26.53 89.68 27.53 69.73 51.90 Z ";
path.height = height;
path.width = width;
path.x = x;
path.y = y;
path.fill = new SolidColor(color);
graphics.mxmlContent = [path];
return graphics;
}
Cheers
In Flex 3 we had a RichTextEditor, however it was nothing like the WYSIWYG Text and HTML Editors .
Adobe released an open source to their advanced editor:
http://opensource.adobe.com/wiki/display/tlf/Text+Layout+Framework
That code is a good starting point, however I found it to be over complicated and laking some features. I am attaching here my implementation of the advanced editor based on Adobe’s source code. I am sure some of you will find it useful.
Implementation is simple, see here:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
xmlns:textEditor="view.textEditor.*">
<textEditor:TextLayoutEditorCanvas id="textLayoutEditorCanvas"
x="0" y="0"
width="150" height="20"/>
<textEditor:TextEditorTools id="textEditorTools" x="250"
activeFlow="{textLayoutEditorCanvas.activeFlow}"/>
</s:Application>

Source code click here.
Conferences attending this year
Last year It’s been an honor/privilege speaking at the following conferences:
- Flex Camp Wall Street – 11/15/2010 – My session: Essential Eclipse plug-ins and tools for Flash Builder developers
- Adobe MAX – 10/23/2010 – My session: Essential Eclipse plug-ins and tools for Flash Builder developers
- RIA Unleashed – 11/11/2010 – My session: AIR workshop
- 360|Flex DC – 8/19/2010 – Flex Data Binding Pitfalls: 10 Common Misuse Mistakes
- CFUnited – 7/28/2010 – My session: Security Threats in Flex Apps & Flex Data Binding Pitfalls 10 common misuse mistakes
- FlashAndTheCity event organizer & speaker – 5/14/2010
Additionally I attended Microsoft MIX 2010 thanks to an invite from @thedavedev
Conference season is just around the corner again and this year I am already confirmed to speak at four conferences as well as likely to attend/speak at three more conferences. This year I feel that it’s not as clear as in previous years who’s the “cool kid” on the block and where everything is heading. I believe that although Flash is still used heavily by many companies as the prefer technology when developing certain applications for the web/desktop such as video, charting and others, it did lost some of it’s “cool kid” status. I believe that this year more than ever it’s crucial to attend conferences in order to better understand which way the wind blows.
Flash Camp Israel

- When: Feb 22, 2011
- Where: Israel
- My topic: Developing & Deploying AIR Applications for TV
- Twitter hashtag: #flashisrael
- Website: http://flashisrael.com/
In Flash Israel 2010 they had a great turn around and completely sold out all tickets, this year it’s bigger and better — more international speakers including full 2 day event. One of the first events after AdobeMAX providing you the opportunity see everything that was announced at AdobeMAX and the great news is that a number of our speakers spoke at AdobeMAX. On a personal level I grew up in Israel I am super excited to be back and meet some fellow developers and talk technology. Almog Koran is doing a great job organizing and I am sure it will be an amazing event once again!
Flash Camp Brazil

Flash Camp Brazil 2010 which is organized by @Demianborba was considered by many as the best Flash Camp ever, unfortunately I missed the event last year. Luckily, I am stocked and lucky to be attending this year. This is one of the most exciting events this year and I am looking forward being part of it especially since I never been in Brazil and always wanted to go. Thanks for putting this event Don’t miss it!
D2WC

- When: 14th July, 2011
- Where: Kansas City
- My topic: Make your Flex application show some skin
- Website: http://lanyrd.com/2011/d2wc/
- Twitter hashtag: #D2WC
Kansas City’s become the home of Dee Sadler‘s annual Designer/Developer Workflow Conference called D2WC. Designer/Developer workflow has become very relevant especially in recent years and I am very excited to be part of this event. Amazing line-up and sessions and I am looking forward to learn and connect with talented designers and fellow developers.
FlashAndTheCity

- When: June 9, 2011
- Where: New York City
- My topic: 20 Tips on how to optimize your flash applications
- Website: http://flashandthecity.com/
- Twitter hashtag: #FATC
Flash and the City is a weeklong conference that showcases the most knowledgeable flash experts in the world in the greatest city in the world. By combining the hottest stars in the flash world in the most interesting venues in New York City, FATC completely sold out its first year and as the main organizer I am very excited about this year in term of venue, content and activities.
In addition to these conferences there is a good chance I will be attending AdobeMAX, RIAUnleashed and Flex Camp Wall Street.
I highly encourage you to check these conferences out and try to attend at least one in 2011. Cheers
I have a need to use a spell check on a TLF component.
I choose Squiggly since it seems a solid product, unfortunately it seems that currently Squiggly Prerelease 4 doesn’t support TLF as of today.
See here:
http://forums.adobe.com/message/2773334#2773334
I am pretty sure that in the near future Adobe will add support for TLF, meanwhile if you look for a quick way of using TLF without doing the entire spell check process manually, as shown in the forums by richardleggettmk — keep reading.
The idea is to have a TLF component, open a popup with only the copy pasted into a mx:TextArea component, which support Squiggly. Than allow the user to do a spell check and return the text back to the TLF component so you don’t lose formatting such as bold, indent or any other of the goodies coming with TLF.

Main MXML class:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import flashx.textLayout.conversion.ConversionType;
import flashx.textLayout.conversion.ITextExporter;
import flashx.textLayout.conversion.ITextImporter;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.TextFlow;
import mx.controls.Alert;
protected function button_clickHandler():void
{
var spellCheckPopup:SpellCheckerPopup = new SpellCheckerPopup();
spellCheckPopup.x = 50;
spellCheckPopup.y = 50;
spellCheckPopup.spellCheckText = ta.text;
spellCheckPopup.xmlExport = getXmlExportHTML(ta.textFlow);
spellCheckPopup.closeButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
popupPlaceHolder.removeAllElements();
});
spellCheckPopup.completeCheckSpelling.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
popupPlaceHolder.removeAllElements();
var textImporter:ITextImporter = TextConverter.getImporter(TextConverter.TEXT_FIELD_HTML_FORMAT);
var source:XML = spellCheckPopup.xmlExport;
var newFlow:TextFlow = textImporter.importToFlow(source);
if (textImporter.errors != null &&
textImporter.errors.length > 0)
Alert.show( textImporter.errors.toString() );
ta.textFlow = newFlow;
});
popupPlaceHolder.addElement( spellCheckPopup );
}
private function getXmlExportHTML(activeFlow:TextFlow):XML
{
var exporter:ITextExporter = TextConverter.getExporter(TextConverter.TEXT_FIELD_HTML_FORMAT);
var xmlExport:XML = exporter.export(activeFlow, ConversionType.XML_TYPE) as XML;
return xmlExport;
}
]]>
</fx:Script>
<s:Button label="Spell Check" y="220" click="button_clickHandler()"/>
<s:TextArea id="ta" width="300" height="200" />
<s:Group id="popupPlaceHolder" />
</s:Application>
SpellCheckerPopup.mxml:
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="344" height="236"
initialize="init();">
<fx:Script>
<![CDATA[
import com.adobe.linguistics.spelling.SpellUI;
[Bindable]
public var spellCheckText:String;
[Bindable]
public var xmlExport:XML;
private var preWords:Array = null;
public function init():void
{
SpellUI.enableSpelling(textArea, "en_US");
}
private function onUpdateComplete():void
{
preWords = getWords(spellCheckText);
var words:Array = getWords(textArea.text);
compareWordsAndChangeHTML(words, preWords);
}
private function compareWordsAndChangeHTML(words:Array, againstWords:Array):void
{
var len:int = words.length;
for (var i:int=0; i < len; i++)
{
if (words[i] != againstWords[i])
xmlExport = XML( xmlExport.toString().replace( againstWords[i], words[i]) );
}
}
private function getWords(text:String):Array
{
var wordPattern:RegExp =/\b\w+\b/; // match next word...
var inputValue:String = text;
var offset:int, curPos:int;
var words:Array = [];
for ( ; ; )
{
var res:Array = inputValue.match( wordPattern ); // lookup word by word....
if ( res == null ) break;
words.push( res[0] );
inputValue = inputValue.substr(inputValue.indexOf(res[0])+ res[0].length);
}
return words;
}
]]>
</fx:Script>
<s:Rect width="100%" height="100%">
<s:stroke>
<s:SolidColorStroke color="#000000" weight="1"/>
</s:stroke>
<s:fill>
<s:SolidColor color="#FFFFFF" />
</s:fill>
</s:Rect>
<s:Button id="closeButton" x="320" y="10"
width="13" height="13"
buttonMode="true"/>
<mx:TextArea id="textArea"
x="10"
y="16"
width="300"
height="173"
fontSize="16"
text="{spellCheckText}"
updateComplete="onUpdateComplete()"/>
<s:Button id="completeCheckSpelling" x="10" y="205" label="Done"/>
</s:Group>
Here’s a quick small utility class that you can use as a starting point to build a keyboard tracker to handle Copy, Paste, Cut, Undo, Redo etc operations from the user.
package utils
{
public final class KeyBoardCombination
{
public static const UNDO:int = 0;
public static const REDO:int = 1;
public static const CUT:int = 2;
public static const PASTE:int = 3;
public static const COPY:int = 4;
public static function get getCombinationCollection():Vector.<Array>
{
var combinationCollection:Vector.<Array> = new Vector.<Array>();
combinationCollection.push( new Array( 17, 90 ) );
combinationCollection.push( new Array( 17, 16, 90 ) );
combinationCollection.push( new Array( 17, 88 ) );
combinationCollection.push( new Array( 17, 86 ) );
combinationCollection.push( new Array(17, 67) );
return combinationCollection;
}
public static function checkKeyboardCombination(keyboardPressedCollection:Array):int
{
var retCombinationState:int = -1;
var combinationLength:int;
var confirmedKeys:int = 0;
var combinationCollection:Vector.<Array> = KeyBoardCombination.getCombinationCollection;
combinationCollection.forEach(function callback(combination:Array, selectedState:int, combinationCollection:Vector.<Array>):void{
confirmedKeys = 0;
combination.forEach( function callback(checkKey:int, index:int, array:Array):void {
combinationLength = combination.length+1;
keyboardPressedCollection.forEach(function callback(keyPressed:int, idx:int, arr:Array):void {
if (keyPressed == checkKey)
confirmedKeys++;
});
if (confirmedKeys == combinationLength-1)
retCombinationState = selectedState;
});
});
return retCombinationState;
}
}
}
Implementation looks like this:
private var keyboardCollectionPressed:Array = new Array();
mainView.stage.addEventListener(KeyboardEvent.KEY_DOWN, function(event:KeyboardEvent):void {
keyboardCollectionPressed.push( event.keyCode );
} );
mainView.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyboardUp);
private function onKeyboardUp(event:KeyboardEvent):void
{
var combination:int = KeyBoardCombination.checkKeyboardCombination( keyboardCollectionPressed );
switch (combination)
{
case KeyBoardCombination.UNDO:
trace("UNDO");
break;
case KeyBoardCombination.REDO:
trace("REDO");
break;
case KeyBoardCombination.CUT:
trace("CUT");
break;
case KeyBoardCombination.PASTE:
trace("PASTE");
break;
case KeyBoardCombination.COPY:
trace("COPY");
break;
}
keyboardCollectionPressed = new Array();
}

I can’t believe another year has passed and we are only few days away from the next edition of Flex Camp Wall Street.
Lots of great sessions and great speakers, including a good bit of AIR on Android,
new Flex 4.5 and AIR 2.5 features, reliable BlazeDS communication,
Flex and AIR application testing and performance tuning.
The prices are the same as last year: just $49 and lunch (Pizzas) is included within
the ticket price. We have a new and nicer venue as well! In addition, some nice giveaways to
be raffled at the event.
Go to www.flexcampwallstreet.com to register for the event and get more details.
Thanks for everyone that attended the 360 Unconference presentation for Hacking Android that James Ward ( jlward4th) and I gave during Adobe MAX, I was asked to provide the batch script to accomplished the hack to combine two projects (Native Java and AIR) into one projects in order to access additional APIs/services that are not avaliable such as messaging. I am not going to go into much detail since I am sure James Ward will write an extensive blog post about the hack.
In few words here are the steps to merge the two apk from native project and AIR project into one apk:
- Create an AIR App and use adt to create the AIR apk
- Explode the AIR apk with apktool to decompile the application
- Create a native Android App using app. as the package
- Create a AppEntry class that extends the service you need to extends
- Create a MainApp class that extends AppEntry
- Update the AndroidManifest file with MainApp Intent and AIR permissions & settings
- Export an unsigned apk
- Explode the apk with apktool
- Copy the AppEntry*.smali from the exploded AIR apk to the exploded native apk
- Copy the assets folder (SWF and AIR xml) from the exploded AIR apk to the exploded native apk
- Repackage the native apk with apktool
- Sign the new apk
- Run the zipalign tool on the new apk
- Install the new apk into the Android device
This process can take some time, so the easiest approach is to create a batch file that does all of that at once. Once you have the batch file you can tie it into an Ant or Maven task and have one script does everything easily and you can set it that in one click have the entire Java native and AIR project merge and placed on the Android device.
Here the Shell Script:
cd /Users/eelrom/Documents/Adobe\ Flash\ Builder\ Next/AIRApp/bin-debug
adt -package -target apk -storetype pkcs12 -keystore certificate.p12 -storepass PASSWORD out.apk AIRApp-app.xml AIRApp.swf
apktool d -r out.apk air_apk
apktool d -r AndroidNative.apk native_apk
mkdir native_apk/assets
cp -r air_apk/assets/* native_apk/assets
cp air_apk/smali/app/AIRApp/AppEntry*.smali native_apk/smali/app/AIRApp
apktool b native_apk
cd native_apk/dist
jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android out.apk androiddebugkey
zipalign -v 4 out.apk out-new.apk
cd ../../
cp native_apk/dist/out-new.apk AIRApp.apk
rm -r native_apk
rm -r air_apk
rm out.apk
adb uninstall app.AIRApp
adb install -r AIRApp.apk
Make sure to change the user name and other apps location such as Flash Builder to the location on your computer.
Create the file, than change the permission and move script to the bin folder, as done below:
$pico compileAndroidAIR (paste the shell script)
$chmod +x compileAndroidAIR
$mv compileAndroidAIR /usr/local/bin/
Next, map the path environment variable so adb and the Bash Script will work from everywhere:
$cd users/[YourUserName]
$cat >> .bash_profile
$export PATH=$PATH://[location of Android SDK]/android-sdk-mac_x86/tools
$export PATH=$PATH://usr/local/bin
Hit CTRL-SHIFT-D
Open new terminal &amp;amp; confirm the path is mapped to android SDK and bin folder:
$echo $PATH
Lastly,
- Ensure certificate.p12 is created in AIR bin-debug folder
- Create unsigned certificate for the AndroidNative.apk and place it under the Flash Builder bin-debug folder.
Hope you’ll find it useful..
Enjoy
Here are the presentation slides for the presentation I gave at MAX 2011 Los Angeles, CA. In this presentation I have covered “Essential Eclipse Plug-ins and Tools for Flash Builder Developers”
Exploring essential plug-ins and tools that every developer should add to their Adobe Flash Builder installation. In addition to covering configuration of the plug-ins, Exploring how to use them as part of a workflow for rapid development of Flex and ActionScript applications.
Download PDF