noted a strange incompatibility today - the stage.mouseLeave event doesn't get triggered when you hold a mouse button down, and drag off stage on a flash object which has wmode set to transparent. in fact doing so takes the focus off the flash object so that regular stage events no longer get triggered until it receives focus again(say by the user clicking on the object).sounds obscure, but if someone's dragging a slider and somehow drags off the object, releases the mouse button and then returns to the object, the slider continues to move around with the mouse even though the mouseButton isn't down.
just got back from a six week holiday, so was wondering if i'd lost my mind while i was away...steps to recreate weird problem:1. set up two dynamic text boxes on the stage - one bold and one not bold - both with letter spacing of 1.(hint at solution) give them instance names - text1 and text22. set their text attributes in actionscript eg.text1.text="hello";
text2.text="there";3. run out - notice that neither text box is bold.for some bizarre reason, giving the text box a letter spacing value!=0 means that it loses its formatting when you set its text value.to resolve either set letter spacing to 0, or follow my earlier post in setting text with a letter spacing value.
What a laborious problem this was!
I had set up a DataGrid that resized with the browser, and the user could also resize the column widths. However one column contained a button, and needed to not be resizable by the user or by browser resizing. But in practice, the button was resizing smaller and smaller every time the browser was resized. After many forum postings a solution was suggested(thanks VarioPegged) that is not the most elegant but works:
To recap, three steps must be followed:
1. add a dummy datagridcolumn to the far right of the datagrid that is not resizable and has a width of 0.
2. give the column you don't want to resize a minWidth value.
3. set up an updateComplete event handler on the datagrid, which resizes the button column and then calls validateNow() on the datagrid.
you can follow the newsgroup post on this issue here.
This blog has moved.
Just discovered that flash resets the author-time letter spacing of a dynamic textfield when the textfield's text is set in ActionScript.
To maintain the authortime letter spacing settings of the textfield, you need to record the textfield's textformat, set the text, and then reset the textfield's textformat to what it was. For example, if your textfield's instance name is test:
var fmt:TextFormat = test.getTextFormat();
test.text="New text";
test.setTextFormat(fmt);
something to check is that if the textfield does not contain any text, the author-time TextFormat letter spacing property is not recorded. So if you don't want your textfield to contain any text, make sure the textfield contains at least one space to ensure it maintains its author-time TextFormat letter spacing property.
I'm currently working on a project that requires me to be using Flex 2 rather than Flex 3(I'm using an older version of Zinc, and avoiding upgrading if possible as we'll probably be moving to AIR after this project). But - issues in Flex 2 are no longer supported...
The problem i encountered was when changing the DataGridColumns and dataProvider of a DataGrid, it gave a #1010 error 'A term is undefined and has no properties.' when scrolling vertically.
After trawling the web for answers, I found a diamond here from Marc Sulinski, who suggested the hack of extending the DataGrid class and overriding updateDisplayList with the following:
override protected function updateDisplayList(w:Number, h:Number):void {
var b:Boolean = false;
if( rendererChanged ) b = true;
super.updateDisplayList(w, h);
if( b ) {
while( rowInfo.length > listItems.length ) rowInfo.pop();
}
}
i'd set up a repeater to display data returned from a ColdFusion call - which would either be a Y or N. I wanted to adjust how this appears to YES or NO, and thought a straightforward way of doing this would be set up an associative array:[Bindable]
public static var yesNoTranslator:Object={N: "No",Y: "Yes"};and my text component would look something like:<text="{Constants.yesNoTranslator[repeater.currentItem.rsvpStatus]}">Flex Builder produced warnings on this, however:
"Data binding will not be able to detect changes when using square bracket operator. For Array, please use ArrayCollection.getItemAt() instead."
Though in this case, i could ignore the warning and the app would work as desired, i could see that sometimes you may want your associative array to change and the binding wouldn't detect changes. Anyway, warnings are annoying to have hanging around, and for some strange reason they seem to propogate themselves in Flex Builder...
As the warning describes, if yesNoTranslator was an array, i could use ArrayCollection.getItemAt() instead. yesNoTranslator was an object and there is no equivalent with objects(for some reason), so i thought the simplest thing to do would be to create one, which i've called ObjectCollection:package
{
import mx.utils.ObjectProxy;
public class ObjectCollection extends ObjectProxy
{
public function ObjectCollection(item:Object=null, uid:String=null, proxyDepth:int=-1)
{
super(item, uid, proxyDepth);
}
[Bindable(event="propertyChange")]
public function getItemAt(index:String):Object {
return(this[index]);
}
}
}and modify my above code to:[Bindable]
public var yesNoTranslator:ObjectCollection=new ObjectCollection({Y:"Yes",N:"No"});
< text="{yesNoTranslator.getItemAt(repeater.currentItem.rsvpStatus)}">
public var interactionType:String=INTERACT_DRAG=INTERACT_FORM;This line of code just wasted 4 hours of my life.Flex didn't notice that there was a problem, and it was only in building that a problem arose with the line 'Classes must not be nested.' and then the more obscure 'An internal build error has occured' Location: UNKNOWN.So it was down to me looking through my thousands of lines of code to find the problem. I ended up restoring a backup of my code and comparing the two until i narrowed it down to the above line...