Skip to main content

Posts

Showing posts with the label Flex

Eclipse crashing and not starting

Problem: After restarting Eclipse, it crashes immediately and asks me to check C:\Users\username\Adobe Flash Builder 4.6\.metadata\.log In log it shows following error: !ENTRY org.eclipse.osgi 4 0 2013-02-13 11:53:46.760 !MESSAGE Application error !STACK 1 org.eclipse.swt.SWTError: Cannot initialize Drop     at org.eclipse.swt.dnd.DND.error(DND.java:266)     at org.eclipse.swt.dnd.DND.error(DND.java:227)     at org.eclipse.swt.dnd.DropTarget. (DropTarget.java:142)     at org.eclipse.ui.internal.EditorSashContainer.addDropSupport(EditorSashContainer.java:542)     at org.eclipse.ui.internal.EditorSashContainer.createControl(EditorSashContainer.java:534)     at org.eclipse.ui.internal.EditorAreaHelper. (EditorAreaHelper.java:41)     at org.eclipse.ui.internal.WorkbenchPage.init(WorkbenchPage.java:2507)     at org.eclipse.ui.internal.WorkbenchPage. (Workbench...

Preserving open nodes in AdvancedDataGrid with HierarchicalCollectionView

My dataProvider is an ArrayCollection, which is populated using XML. var initXML:XML = <items>    <item id="News" label="News" value_1="unchecked" value_2="unchecked" value_3="checked"/>    <item id="BBC" label="The Web" value_1="unchecked" value_2="unchecked" value_3="checked">        <item id="BBC1" label="BBC Homepage" value_1="unchecked" value_2="unchecked" value_3="checked">       <item id="YouTube" label="YouTube" value_1="unchecked" value_2="unchecked" value_3="checked"/>       <item id="GoogleMaps" label="Google Maps" value_1="unchecked" value_2="unchecked" value_3="checked"/>       <item id="MSN" label="MSN" value_1="unchecked" value_2="unchecked" valu...

Flash trace log file in Windows 7

In my recent project, I need to look at the Trace output from the Flex application outside Flash Builder. I have Windows 7 as my operating System. Following are the steps to setup trace log file: Download and install Flash player debug version. Check at www.flashplayerversion.com for the version details. Create a new file named mm.cfg in your home directory. To figure out home directory open a command wondow and type echo %HOMEDRIVE%     TraceOutputFileEnable=1     ErrorReportingEnable=1     MaxWarnings=500     TraceOutPutFileName=C:\Users\(username)\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt Last line is optional if you are fine with the output file location. Open web browser and your Flash application.4. Use a tool like baretail to check the log file.

Deploying swc library in repository and adding maven artifacts for that

We can either deploy the swc file on a web server or a local Maven repository. To deploy xyz.swc on a webserver, the command is (in the folder containing xyz.swc): mvn deploy:deploy-file -Dfile=xyz.swc -Durl=file:///path/to/repository -DgroupId=com.abc -DartifactId=xyz -Dversion=1.01 -Dpackaging=swc This deploys the xyz.swc file to /path/to/repository (using the groupId, artifactId, version). Users then can refer to this Web URL (by defining a repository in their Maven project) and use xyz as a dependency in their Maven projects. To deploy the swc in a local Maven repository, we can execute (in the folder containing xyz.swc): mvn install:install-file -Dfile=xyz.swc -DgroupId=com.abc -DartifactId=xyz -Dversion=1.01 -Dpackaging=swc -DgeneratePom=true -DcreateChecksum=true Users then can add the dependency in the pom.xml file under <project> tag as:     <dependencies>         <dependency>       ...

Spark TextInput for Currency values

In my project, I wanted to have an spark TextInput to show currency values. While formatting it should show unformatted number. The way I did it is by creating a new CurrencyTextInput class extending spark TextInput. Code for the component is (CurrencyTextInput.as): package com.abcd.component {     import flash.events.Event;     import flash.events.FocusEvent;     import spark.components.TextInput;     import spark.formatters.CurrencyFormatter;     public class CurrencyTextInput extends TextInput     {         public function CurrencyTextInput()         {             super();             formatter = new CurrencyFormatter();             formatter.currencySymbol ...

Check if a string converted to a number is actually a number in ActionScript (Flex) and setting scale of a number

An easy way to check if a String is actually a number of not is to actually convert the string to a Number and test if it's NaN. Flex API reference mentions that the top-level function Number(str) returns NaN if the string passed to the method cannot be converted to a Number. The problem with this approach is that if you take Number(null) or Number(undefined) or Number(""), all will return 0 and will evaluate to "is a number". The correct way to do this is shown in following code snippet. It also sets scale of the converted number to two decimal digits. public static function getNumberFromString(val:*, scale:uint = 2):* {     if ((val === null || StringUtil.trim(val) === "" || isNaN(val)) == false)         return setScale(Number(val)).toFixed(scale);     else         return ""; } public static function setScale(number:Number, scale:uint = 2):Number {      scale ...

MojoExecutionException: TargetPlayer and playerglobal dependency version doesn't match

If you get this error while compiling Flex modules using Maven, then you just need to exclude playerGlobal dependancy: <dependency> <groupId>com.adobe.flex.framework</groupId> <artifactId>flex-framework</artifactId> <version>${flex.version}</version> <type>pom</type> <exclusions> <exclusion> <groupId>com.adobe.flex.framework</groupId> <artifactId>playerglobal</artifactId> </exclusion> </exclusions> </dependency>

TeamCity fails running FlashUnit tests with "socket write error"

Error log: Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:3.9:test-run (default-test-run) on project Project1: Software caused connection abort: socket write errorC:\TeamCity\buildAgent\work\Project1\src\main\test\target\test-classes\TestRunner.swf This error is caused due to Flash Player's 9+ security configurations. Solution: The TeamCity agent should be installed as a domain user and not as SYSTEM user. Uninstall TeamCity agent and try reinstalling agent as domain user. If this does not work, then reinstall server also as domain user.

Download a file using FileReference in Flex

Following function gives an example of how to doanload a file in Flex. "file" object passed to the function is a simple object having following structure: file.fileName = "Abc.png" file.fileType = "image/png" file.url = "/documents/Abc.png" A pattern match-replacement is used to determine file extension, in case fileName does not have it. public function downloadFile(file:Object):void { if (file != null) { var fileName:String = (file.fileName != null && file.fileName.length > 0) ? file.fileName : (new Date()).time.toString(); var fileExtension:String = file.fileExtension; if (fileName.indexOf(".") = 0) fileExtension = fileExtension.slice(fileExtension.lastIndexOf("."), fileExtension.length); else if (fileExtension.lastIndexOf("/") >= 0) fileExtension = "." + fileExtension.slice(fileExtension.lastIndexOf("/...

Flex ByteArray to Java ByteArray

While trying to import XLS files from Flex front-end, we needed to pass the file contents to Java middle tier, where Apache POI library was used to parse the contents. The Java method expects a Java ByteArray containing the file contents, but when we pass a Flex ByteArray to it, it throws error. To overcome this instead of passing Flex ByteArray, we should pass an Array of bytes, as depicted in following code snippet: public static function byteArrayToArrayOfBytes(ba:ByteArray):Array {     var arrayOfBytes:Array = [];     ba.position = 0;     while(ba.bytesAvailable > 0)         arrayOfBytes.push(ba.readByte());     ba.position = 0;     return arrayOfBytes; } public function onFileSelectionComplete(fileReference:FileReference) {     var payload:Object = new Object();     payload.byteArray = byteArrayToArrayOfBytes(fileReference.data);  ...

Flex: ToolTip on Spark DataGrid Rows

We can use Spark DataGrid's showDataTips and dataTipFunction properties to show customized tool tips on the rows. An example showing this: <?xml version="1.0" encoding="utf-8"?> <s:Application initialize="onInitialize()" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.utils.StringUtil; private static function fnDataTip(item:Object, column:GridColumn):String { var toolTip:String = item[column.dataTipField != null ? column.dataTipField : column.dataField]; if (toolTip == null || StringUtil.trim(toolTip) == "") toolTip = ""; if (item.hasOwnProperty("toolTipComment") && item.toolTipComment != null && item.toolTipComment....

Unable to connect Adobe Flash Debugger in Google Chrome

The reason for it is that Google Chrome browser (32-bit) includes Adobe Flash Player built-in. To install and use an alternate version of Flash Player/Debugger: Download and install the appropriate system plug-in. Type "about:plugins" into the address bar at the top of a Chrome browser window. Click "Details" at the top right corner of the page. Find the "Flash" (or "Shockwave Flash") listing for the integrated plug-in on the page and click the corresponding "Disable" button. Find the "Flash" (or "Shockwave Flash") listing for the system plug-in on the page and click the corresponding "Enable" button. Close all Chrome windows and restart the browser.

Flex3 debugger gives error while evaluating E4X

Flex3 debugger does not support debugging E4X variables. User is shown error messages like "Errors during evaluation. No such variable." Wasted my half day because of this undocumented short-coming. Note: Flash Builder 4 does support it. Got another reason to push my company to buy Flash Builder 4 licenses :P

Install Flash player 10 debugger verion in Linux

Installing Flash player 10 debugger version in Linux, by running $sudo ./flashplayer-installer command, gives following error: [: 258: closing paren expected ERROR: Your glibc library is older than 2.3. Please update your glibc library. To fix the problem, make file flashplayer-installer writable and edit it. Comment the if-else condition in check_glibc() method, as follows: # if [ \( $GLIBCMAJOR -ge $MIN_GLIBCMAJOR \) -a \( $GLIBCMINOR -ge $MIN_GLIBCMINOR \) ]; then echo "valid-glibc" # else # echo "invalid-glibc" # fi Save the file and run it.

Error #1034: Type Coercion failed: DragManagerImpl to IDragManager

My Flex application is divided in modules, and I am having an advanced data grid in one of them. While clicking on the advanced data grid, I am getting following error: TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::DragManagerImpl@1ae729c1 to mx.managers.IDragManager.     at mx.managers::DragManager$/get impl()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\DragManager.as:202]     at mx.managers::DragManager$/get isDragging()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\DragManager.as:242]     at mx.controls.listClasses::AdvancedListBase/dragScroll()[E:\dev\4.y\frameworks\projects\advancedgrids\src\mx\controls\listClasses\AdvancedListBase.as:6821]     at Function/http://adobe.com/AS3/2006/builtin::apply()     at SetIntervalTimer/onTimer()     at flash.utils::Timer/_timerDispatch()     at flash.utils::Timer/tick() I fixed it by addin...