Tuesday, February 17, 2009

Operators used in Adobe Flex

Symbolic operators are characters that specify how to combine, compare, or modify the values of an expression.


Arithmetic
+ addition Adds numeric expressions.
-- decrement Subtracts 1 from the operand.
/ division Divides expression1 by expression2.
++ increment Adds 1 to an expression.
% modulo Calculates the remainder of expression1 divided by expression2.
* multiplication Multiplies two numerical expressions.
- subtraction Used for negating or subtracting.
Arithmetic compound assignment
+= addition assignment Assigns expression1 the value of expression1 + expression2.
/= division assignment Assigns expression1 the value of expression1 / expression2.
%= modulo assignment Assigns expression1 the value of expression1 % expression2.
*= multiplication assignment Assigns expression1 the value of expression1 * expression2.
-= subtraction assignment Assigns expression1 the value of expression1 - expression2.
Assignment
= assignment Assigns the value of expression2 (the operand on the right) to the variable, array element, or property in expression1.
Bitwise
& bitwise AND Converts expression1 and expression2 to 32-bit unsigned integers, and performs a Boolean AND operation on each bit of the integer parameters.
<< bitwise left shift Converts expression1 and shiftCount to 32-bit integers, and shifts all the bits in expression1 to the left by the number of places specified by the integer resulting from the conversion of shiftCount.
~ bitwise NOT Converts expression to a 32-bit signed integer, and then applies a bitwise one's complement.
| bitwise OR Converts expression1 and expression2 to 32-bit unsigned integers, and places a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1.
>> bitwise right shift Converts expression and shiftCount to 32-bit integers, and shifts all the bits in expression to the right by the number of places specified by the integer that results from the conversion of shiftCount.
>>> bitwise unsigned right shift The same as the bitwise right shift (>>) operator except that it does not preserve the sign of the original expression because the bits on the left are always filled with 0.
^ bitwise XOR Converts expression1 and expression2 to 32-bit unsigned integers, and places a 1 in each bit position where the corresponding bits in expression1 or expression2, but not both, are 1.
Bitwise compound assignment
&= bitwise AND assignment Assigns expression1 the value of expression1 & expression2.
<<= bitwise left shift and assignment Performs a bitwise left shift (<<=) operation and stores the contents as a result in expression1.
|= bitwise OR assignment Assigns expression1 the value of expression1 | expression2.
>>= bitwise right shift and assignment Performs a bitwise right-shift operation and stores the result in expression.
>>>= bitwise unsigned right shift and assignment Performs an unsigned bitwise right-shift operation and stores the result in expression.
^= bitwise XOR assignment Assigns expression1 the value of expression1 ^ expression2.
Comment
/*..*/ block comment delimiter Delimits one or more lines of script comments.
// line comment delimiter Indicates the beginning of a script comment.
Comparison
== equality Tests two expressions for equality.
> greater than Compares two expressions and determines whether expression1 is greater than expression2; if it is, the result is true.
>= greater than or equal to Compares two expressions and determines whether expression1 is greater than or equal to expression2 (true) or expression1 is less than expression2 (false).
!= inequality Tests for the exact opposite of the equality (==) operator.
< less than Compares two expressions and determines whether expression1 is less than expression2; if so, the result is true.
<= less than or equal to Compares two expressions and determines whether expression1 is less than or equal to expression2; if it is, the result is true.
=== strict equality Tests two expressions for equality, but does not perform automatic data conversion.
!== strict inequality Tests for the exact opposite of the strict equality (===) operator.
Logical
&& logical AND Returns expression1 if it is false or can be converted to false, and expression2 otherwise.
! logical NOT Inverts the Boolean value of a variable or expression.
|| logical OR Returns expression1 if it is true or can be converted to true, and expression2 otherwise.
Other
[] array access Initializes a new array or multidimensional array with the specified elements (a0, and so on), or accesses elements in an array.
as Evaluates whether an expression specified by the first operand is a member of the data type specified by the second operand.
, comma Evaluates expression1, then expression2, and so on.
?: conditional Evaluates expression1, and if the value of expression1 is true, the result is the value of expression2; otherwise the result is the value of expression3.
delete Destroys the object property specified by reference; the result is true if the property does not exist after the operation completes, and false otherwise.
. dot Accesses class variables and methods, gets and sets object properties, and delimits imported packages or classes.
in Evaluates whether a property is part of a specific object.
instanceof Evaluates whether an expression's prototype chain includes the prototype object for function.
is Evaluates whether an object is compatible with a specific data type, class, or interface.
:: name qualifier Identifies the namespace of a property, a method, an XML property, or an XML attribute.
new Instantiates a class instance.
{} object initializer Creates a new object and initializes it with the specified name and value property pairs.
() parentheses Performs a grouping operation on one or more parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as arguments to a function that precedes the parentheses.
/ RegExp delimiter When used before and after characters, indicates that the characters have a literal value and are considered a regular expression (RegExp), not a variable, string, or other ActionScript element.
: type Used for assigning a data type; this operator specifies the variable type, function return type, or function parameter type.
typeof Evaluates expression and returns a string specifying the expression's data type.
void Evaluates an expression and then discards its value, returning undefined.
String
+ concatenation Concatenates (combines) strings.
+= concatenation assignment Assigns expression1 the value of expression1 + expression2.
" string delimiter When used before and after characters, indicates that the characters have a literal value and are considered a string, not a variable, numerical value, or other ActionScript element.
XML
@ attribute identifier Identifies attributes of an XML or XMLList object.
{ } braces (XML) Evaluates an expression that is used in an XML or XMLList initializer.
[ ] brackets (XML) Accesses a property or attribute of an XML or XMLList object.
+ concatenation (XMLList) Concatenates (combines) XML or XMLList values into an XMLList object.
+= concatenation assignment (XMLList) Assigns expression1, which is an XMLList object, the value of expression1 + expression2.
delete (XML) Deletes the XML elements or attributes specified by reference.
.. descendant accessor Navigates to descendant elements of an XML or XMLList object, or (combined with the @ operator) finds matching attributes of descendants.
. dot (XML) Navigates to child elements of an XML or XMLList object, or (combined with the @ operator) returns attributes of an XML or XMLList object.
( ) parentheses (XML) Evaluates an expression in an E4X XML construct.
< > XML literal tag delimiter Defines an XML tag in an XML literal.

Delete a node from XML / XMLListCollection

source

PROBLEM SUMMARY

simply using the Delete key work in Flex does not work most of the time and if you have a Tree that's bound to the XMLListCollection Flex will mess up the Tree Selection after deleting an XML element.
SOLUTION SUMMARY

Use a custom method to for loop and delete proper child and reset tree selection
EXPLANATION
__________________________________________________________________________________
Use this method:
private function xmlDeleteNode(xmlToDelete:XML):Boolean
{
var cn:XMLList = XMLList(xmlToDelete.parent()).children();

for ( var i:Number = 0 ; i < cn.length() ; i++ )
{
if ( cn[i] == xmlToDelete )
{
delete cn[i];
return true;
}
}

return false;

}

Also, remember to do on an XML Bound Tree Control:
myTree.selectedItem = null;
_______________________________________________________________________________

i have extended this logic
myTree.selectedItem = null;
after delete ... instead setting the selectedItem to null, it wud b gud
if you select the deleted node's parent
before calling the xmlDeleteNode method

save the xmlToDelete's parent
**************************************
var tmp:XML = xmlToDelete.parent();
xmlDeleteNode(xmlToDelete);
myTree.selectedItem = tmp

**************************************

Freelance