For Eclipse to regcognize projects with Flex nature you need to edit .project file and make sure that the flex natures are the first in the list:
<natures>
<nature>com.adobe.flexbuilder.project.flexnature</nature>
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
</natures>
Remove zeros function from left side of a number.
private function removeLeftZero(value:String):String {
var pattern:RegExp = /^0*/;
return value.replace(pattern,'');
}
Static variables of a class can be initialized automatically with a snip code within package between curly brackets as following:
package com.arcadio
{
[Bindable]
public class MyClass
{
public static var myText:String="Hello";
public function MyClass()
{
}
}
{
MyClass.myText="Bye";
}
}
¡Thanks Alfonso by your note!
Code to iterate over the properties of the objects of a collection:
[Bindable]
public var items:ArrayCollection = new ArrayCollection ([
{prop1:false, prop2:1, prop3:'One'},
{prop1:true, prop2:2, prop3:'Two'},
{prop1:false, prop2:3, prop3:'Three'}
]);
for each (var item:Object in items) {
trace("Object: "+ item);
for (var prop:Object in item) {
trace("Prop "+prop + " value: "+item[prop]);
}
}
Component to automatic adjust of LinkButton to resize the button to the container with reference ref or as parent.
<?xml version="1.0" encoding="utf-8"?>
<mx:LinkButton xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="onInitialize()"
creationComplete="onCreationComplete()"
resize="onResize()">
<mx:Script>
<![CDATA[
import mx.core.Container;
[Bindable]
public var ref:Container;
private function onInitialize():void {
width=0;
}
private function onCreationComplete():void {
if (ref!=null) {
ref.addEventListener('resize',function():void {onResize()});
} else {
parent.addEventListener('resize',function():void {onResize()});
}
}
private function onResize():void {
if (ref!=null) {
width=ref.width;
} else {
width=parent.width;
}
}
]]>
</mx:Script>
</mx:LinkButton>