[flexcoders] Flex 3 piechart legend label
I have a pie chart that is bound to XML data and corresponding legend. I am using data Tips to format the display value for Project Number. The data that is returned is numeric, but I want to add a 2 character string prefix before that number. For example, when I hover over a pie slice I want to see PR140, instead of the underlying plain data 140. I am able to achieve this with the label functions but cannot figure out how to format the actual legend data. How do I format the legend label - there does not seem to be a labelfunction for that? Here is my code: mx:PieChart id=pieChart1 x=20 y=0 showDataTips=true dataTipFunction=pieChart_dataTipFunction selectionMode=single height=200 width=300 mx:series mx:PieSeries id=pieSeries nameField=ProjectNumber labelPosition=callout field=ApprovedBudget labelFunction=pieSeriesLabelFunction explodeRadius=0.05/ /mx:series /mx:PieChart mx:Legend id=pieLegend labelPlacement=right x=335 y=110 /
[flexcoders] Trapping keydown event when focus is on an AccordionHeader
I am trying to trap the keyDown event when the focus is on an accordion header. My accordion control has a keyDown event that fires when the focus is inside the accordion, but it will not fire if the focus selector is around the actual Accordion header. You can use tab/Shift-tab/up and down arrow keys to set the focus on an AccordionHeader and then navigate up and down to the various headers. But I need to trap these keydown events. Any suggestions?
[flexcoders] Flex datagrid with Excel-like behaviour
In my application I am trying to create an Excel-type spreadsheet using a DataGrid. I need the ability to lock certain cells so that they are not editable. I need to be able to tab between editable cells (this is the default behaviour) when navigating between cells, but be able to skip over locked (non-editable) cells. This should work both with Tab and alt-Tab to go backwards. As with a spreadsheet too - I need to be able to total columns. I am particularly having trouble getting the tab key functionality working. Has anyone else attempted something like this or can they point me in the direction of an existing component that may have this functionality? Thanks
[flexcoders] Re: Flex datagrid with Excel-like behaviour
Hi Alex, Yes, I am using that to block particular cells from being edited. When I click on a cell, this event fires and I can check the dataProvider to determine if this is a cell that should be non-editable and successfully prevent the cell from being editable by calling event.preventDefault. The problem is if I am in an editable cell and then hit tab. If the next cell should be non-editable, this event fires, and I call event.preventDefault but the cell still becomes editable and the itemEditor displays. This only happens when tabbing to a cell that should be non-editable. It doesn't happen when you click on the cell. --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: ITEM_EDIT_BEGINNING event can be used to block editing of a cell. I have a DataGrid Footer example on my blog. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Friday, December 18, 2009 9:44 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Flex datagrid with Excel-like behaviour In my application I am trying to create an Excel-type spreadsheet using a DataGrid. I need the ability to lock certain cells so that they are not editable. I need to be able to tab between editable cells (this is the default behaviour) when navigating between cells, but be able to skip over locked (non-editable) cells. This should work both with Tab and alt-Tab to go backwards. As with a spreadsheet too - I need to be able to total columns. I am particularly having trouble getting the tab key functionality working. Has anyone else attempted something like this or can they point me in the direction of an existing component that may have this functionality? Thanks
[flexcoders] Re: Flex datagrid with Excel-like behaviour
I have version 3.0 Thanks Alex, I was able to fix the problem, it was something to do with the way I was checking row values - is working now. --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: Which version of Flex are you using? That might be fixed in more recent versions. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Friday, December 18, 2009 11:02 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Flex datagrid with Excel-like behaviour Hi Alex, Yes, I am using that to block particular cells from being edited. When I click on a cell, this event fires and I can check the dataProvider to determine if this is a cell that should be non-editable and successfully prevent the cell from being editable by calling event.preventDefault. The problem is if I am in an editable cell and then hit tab. If the next cell should be non-editable, this event fires, and I call event.preventDefault but the cell still becomes editable and the itemEditor displays. This only happens when tabbing to a cell that should be non-editable. It doesn't happen when you click on the cell. --- In flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com, Alex Harui aharui@ wrote: ITEM_EDIT_BEGINNING event can be used to block editing of a cell. I have a DataGrid Footer example on my blog. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com] On Behalf Of flexcoder2008 Sent: Friday, December 18, 2009 9:44 AM To: flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Flex datagrid with Excel-like behaviour In my application I am trying to create an Excel-type spreadsheet using a DataGrid. I need the ability to lock certain cells so that they are not editable. I need to be able to tab between editable cells (this is the default behaviour) when navigating between cells, but be able to skip over locked (non-editable) cells. This should work both with Tab and alt-Tab to go backwards. As with a spreadsheet too - I need to be able to total columns. I am particularly having trouble getting the tab key functionality working. Has anyone else attempted something like this or can they point me in the direction of an existing component that may have this functionality? Thanks
[flexcoders] capturing SHIFT+TAB on keyDown event
Trying to capture the SHIFT+TAB key event on my DataGrid. It seems the Keydown handler can only handle 1 key at a time. What is the best way to handle this?
[flexcoders] Re: capturing SHIFT+TAB on keyDown event
Thanks for the replies - I got this working using this logic in the keydown handler: if(event.shiftKey){ if(event.keyCode == Keyboard.TAB){ // SHIFT-TAB // logic goes here } } --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: The actual work of tabbing is done in a FocusEvent.KEY_FOCUS_CHANGE which has a property that tells you if the shift key was down. Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of invertedspear Sent: Friday, December 18, 2009 3:59 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: capturing SHIFT+TAB on keyDown event I don't have time to look it up right now, but I'm pretty sure you catch the Tab key down, then check if the shift key was down at the same time. Hopefully this gets you going in the right direction. --- In flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com, flexcoder2008 djohnson29@ wrote: Trying to capture the SHIFT+TAB key event on my DataGrid. It seems the Keydown handler can only handle 1 key at a time. What is the best way to handle this?
[SPAM] RE: [SPAM] [flexcoders] Re: e4x Filtering with a variable?
Thanks! --- In flexcoders@yahoogroups.com, Tracy Spratt tr...@... wrote: Aha, it is child(); So it would be: myXML.RootNode.child(Item + i); Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Tracy Spratt Sent: Friday, December 04, 2009 12:39 AM To: flexcoders@yahoogroups.com Subject: [SPAM] RE: [SPAM] [flexcoders] Re: e4x Filtering with a variable? One way is bracket notation: myXML.RootNode[Item + i] There is another way, using a real xml method, but I don't recall it right now. Maybe elements()? Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of invertedspear Sent: Thursday, December 03, 2009 1:50 PM To: flexcoders@yahoogroups.com Subject: [SPAM] [flexcoders] Re: e4x Filtering with a variable? I was just doing something similar and found help here: http://livedocs. http://livedocs.adobe.com/flex/3/html/help.html?content=13_Working_with_XML _08.html adobe.com/flex/3/html/help.html?content=13_Working_with_XML_08.html probably best you read through there and find the solution that is specific for you. Let us know if you still need help after reviewing that. ~Mike --- In flexcod...@yahoogro mailto:flexcoders%40yahoogroups.com ups.com, flexcoder2008 djohnson29@ wrote: I have an XML structure that gets built dynamically. Nodes are constructed with a number appending the node name and the number of these nodes depends on values in a database. The structure looks like this: RootNode Item1 / Item2 / Item3 / etc... Now I want to access a particular node using a variable. For example: var i:int = 2; myXML.RootNode.Item{i} but this is not working. How can I create an E4x expression that appends a variable value onto a node name in the filter expression?
[flexcoders] e4x Filtering with a variable?
I have an XML structure that gets built dynamically. Nodes are constructed with a number appending the node name and the number of these nodes depends on values in a database. The structure looks like this: RootNode Item1 / Item2 / Item3 / etc... Now I want to access a particular node using a variable. For example: var i:int = 2; myXML.RootNode.Item{i} but this is not working. How can I create an E4x expression that appends a variable value onto a node name in the filter expression?
[flexcoders] e4x Filtering with a variable?
I have an XML structure that gets built dynamically. Nodes are constructed with a number appending the node name and the number of these nodes depends on values in a database. The structure looks like this: RootNode Item1 / Item2 / Item3 / etc... Now I want to access a particular node using a variable. For example: var i:int = 2; myXML.RootNode.Item{i} but this is not working. How can I create an E4x expression that appends a variable value onto a node name in the filter expression?
[flexcoders] Re: DateField - minYear and maxYear - don't work if they contain calculated valu
Thanks valdhor, I tried your example and yes it works...very strange. I noticed another person had a similar issue to me at this post: http://forums.adobe.com/message/1052372; The thing is, I was working with 2 datefields trying to do some date math to ensure restricted values for a start and end date. After removing this date math and trying your example everything worked. I think there is a built in bug with the datefield though. The issue seems to be when you set the minYear and maxYear to the same value. In this case the maxYear value works but the minYear doesn't. Try it with your example, make both values {year} and you will see that you can keep navigating back before the minimum year. --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote: I am using SDK 3.3 and this works for me: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=vertical mx:Script ![CDATA[ [Bindable] private var year:int = new Date().getFullYear(); ]] /mx:Script mx:DateField maxYear={year} minYear={year - 9}/ /mx:Application I can only select a date between Jan 2000 and Dec 2009. --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@ wrote: I have a DateField and if I set the minYear or the maxYear property to a value directly, everything works great. eg. mx:Datefield maxYear=2009 minYear=2000/ But if I want to use a calculated value in there, it doesn't work. I can navigate past this value. eg. [Bindable] var year:int = new Date().getFullYear(); mx:DateField maxYear = {year} minYear={year - 10}/ Why is this? Does anybody have a workaround for this?
[flexcoders] DateField - minYear and maxYear - don't work if they contain calculated value?
I have a DateField and if I set the minYear or the maxYear property to a value directly, everything works great. eg. mx:Datefield maxYear=2009 minYear=2000/ But if I want to use a calculated value in there, it doesn't work. I can navigate past this value. eg. [Bindable] var year:int = new Date().getFullYear(); mx:DateField maxYear = {year} minYear={year - 10}/ Why is this? Does anybody have a workaround for this?
[flexcoders] Datagrid won't let me select row
What would cause a datagrid to keep it's current selection locked. In my application, I have a datagrid that is bound to an XMLListCollection. I can navigate away to another another module which shares the same data using Cairngorm, and then when I come back to the original module, I re-select the row I need in the datagrid programmatically by looping through the XMLListCollection and looking for the item with the same ID. This all works fine. However, sometimes...but not all the time, if I click on another datagrid row, I can see the higlight of the row I want but when I release the mouse, the original row is still selected. It also seems to only happen when I have a top or bottom row selected and then try to select a row above or below this one. Just curious if anyone else has had similar datagrid woes and if there is something I should be looking for. It seems that the databinding perhaps is locking in this selection but I am not sure where to look or what is causing this.
[flexcoders] Re: List ScrollToIndex does not work for last item in List
bump --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: How do you make scrollToIndex work on a List where the last item in the List is currently not visible? When I use List.scrollToIndex it works for any item above my current selection, but will never scroll to the end of the List.
[flexcoders] List ScrollToIndex does not work for last item in List
How do you make scrollToIndex work on a List where the last item in the List is currently not visible? When I use List.scrollToIndex it works for any item above my current selection, but will never scroll to the end of the List.
[flexcoders] Re: Creating a new ListEvent - how to specify ItemRenderer?
Thanks Tim, That's not quite the behavior I was looking for though - my List can not be in edit mode. I figured out exactly what I needed - I had to use the indexToItemRenderer method of the List - hopefully this will help someone else... Here's my List KeyDown handler: private function myListKeyDownHandler(event:KeyboardEvent):void{ var le:ListEvent = new ListEvent(ListEvent.ITEM_CLICK); var ir:IListItemRenderer = myList.indexToItemRenderer(myList.selectedIndex); le.itemRenderer = ir; myListClickEvent(le); } --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: I have a List that handles a Click event - the ClickEvent takes a ListEvent, and inside that handler I have access to the ListEvent's itemRenderer property. This allows me to align a button next to the row that I have clicked on. I also want to trigger this click event when the user uses the keyboard up and down arrow keys to navigate the list. Inside my KeyDown handler I want to call my List click handler. The trick is, how do I specify the itemRenderer for the new ListClick event or get access to it? eg. var le:ListEvent = new ListEvent(ListEvent.CLICK,.. .. .., myItemRenderer);
[flexcoders] Creating a new ListEvent - how to specify ItemRenderer?
I have a List that handles a Click event - the ClickEvent takes a ListEvent, and inside that handler I have access to the ListEvent's itemRenderer property. This allows me to align a button next to the row that I have clicked on. I also want to trigger this click event when the user uses the keyboard up and down arrow keys to navigate the list. Inside my KeyDown handler I want to call my List click handler. The trick is, how do I specify the itemRenderer for the new ListClick event or get access to it? eg. var le:ListEvent = new ListEvent(ListEvent.CLICK,.. .. .., myItemRenderer);
[flexcoders] Re: Datagrid non-editable but want to tab between columns
Thanks Alex, Tried the advanced datagrid but that didn't work. As far as overriding the keyFocusChange - it is private so can't override. --- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote: That would be highly difficult. Requires overriding keyFocusChange event and doing a bunch of work. ADG does have per-cell selection I think. Did you try that? Alex Harui Flex SDK Developer Adobe Systems Inc.http://www.adobe.com/ Blog: http://blogs.adobe.com/aharui From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Monday, June 15, 2009 10:34 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Datagrid non-editable but want to tab between columns bump --- In flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com, flexcoder2008 djohnson29@ wrote: I have a datagrid that has some columns formatted using item renderers. I want to enable keyboard navigation so the user can tab across the columns. I know that this behaviour is built in to the datagrid if the editable property is set to true, but how do I accomplish this if I want the grid to be read only? I just want to be able to tab to a particular column and capture keyboard events from there.
[flexcoders] Re: Datagrid non-editable but want to tab between columns
bump --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: I have a datagrid that has some columns formatted using item renderers. I want to enable keyboard navigation so the user can tab across the columns. I know that this behaviour is built in to the datagrid if the editable property is set to true, but how do I accomplish this if I want the grid to be read only? I just want to be able to tab to a particular column and capture keyboard events from there.
[flexcoders] Datagrid non-editable but want to tab between columns
I have a datagrid that has some columns formatted using item renderers. I want to enable keyboard navigation so the user can tab across the columns. I know that this behaviour is built in to the datagrid if the editable property is set to true, but how do I accomplish this if I want the grid to be read only? I just want to be able to tab to a particular column and capture keyboard events from there.
[flexcoders] Re: getting currency symbol to display when loading locale from resource module
Yes, that's correct - for my purposes that's what I needed - I was using the non-breaking space to put an extra character before the currency symbol (for right-aligned currency symbol and also a blank space as the thousands seperator character). Thanks again --- In flexcoders@yahoogroups.com, Paul Hastings paul.hasti...@... wrote: flexcoder2008 wrote: Figured it out. To get the blank space to work in the .properties file you have to enter it as ALT+0160 just so you know, that's a non-breaking space (not sure how the player renders that sort of thing).
[flexcoders] Re: getting currency symbol to display when loading locale from resource module
Thanks! Saving the .properties file with UTF-8 encoding fixed the problem with the pound symbol. I still am unable to get an empty space character to display though. How do I specify a blank space for the thousands seperator? I tried putting nbsp; in the .properties file but that doesn't work either. --- In flexcoders@yahoogroups.com, Paul Hastings paul.hasti...@... wrote: flexcoder2008 wrote: # locale/en_GB/FormattingValues.properties THEMECOLOR=0xFF DATE_FORMAT=DD/MM/YY TIME_FORMAT=L:NN A CURRENCY_PRECISION=0 CURRENCY_SYMBOL=� THOUSANDS_SEPARATOR=, DECIMAL_SEPARATOR=. As you can see, I have the pound symbol for the CURRENCY_SYMBOL. I typed this with ALT-156 no i can't see, its garbaged. is that properties file utf-8 encoded? and in unicode the codepoint for the pound sign is 163 (0x00A3). When I load this resource module and try to display currency values that have been formatted with the british locale, the pound symbol will not display. Instead I get a square box symbol. It's like the Flash player doesn't a box means the whatever can't render that symbol using the given font (except in buzzword which wandered off the reservation all by it's lonesome). either a minor encoding issue or wrong font. a major encoding issue results in questions marks being displayed.
[flexcoders] Re: getting currency symbol to display when loading locale from resource module
Figured it out - to get a blank space to display in your .properties file you have to type ALT+0160 --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: Thanks! Saving the .properties file with UTF-8 encoding fixed the problem with the pound symbol. I still am unable to get an empty space character to display though. How do I specify a blank space for the thousands seperator? I tried putting nbsp; in the .properties file but that doesn't work either. --- In flexcoders@yahoogroups.com, Paul Hastings paul.hastings@ wrote: flexcoder2008 wrote: # locale/en_GB/FormattingValues.properties THEMECOLOR=0xFF DATE_FORMAT=DD/MM/YY TIME_FORMAT=L:NN A CURRENCY_PRECISION=0 CURRENCY_SYMBOL=� THOUSANDS_SEPARATOR=, DECIMAL_SEPARATOR=. As you can see, I have the pound symbol for the CURRENCY_SYMBOL. I typed this with ALT-156 no i can't see, its garbaged. is that properties file utf-8 encoded? and in unicode the codepoint for the pound sign is 163 (0x00A3). When I load this resource module and try to display currency values that have been formatted with the british locale, the pound symbol will not display. Instead I get a square box symbol. It's like the Flash player doesn't a box means the whatever can't render that symbol using the given font (except in buzzword which wandered off the reservation all by it's lonesome). either a minor encoding issue or wrong font. a major encoding issue results in questions marks being displayed.
[flexcoders] Re: getting currency symbol to display when loading locale from resource module
Figured it out. To get the blank space to work in the .properties file you have to enter it as ALT+0160 --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: Thanks! Saving the .properties file with UTF-8 encoding fixed the problem with the pound symbol. I still am unable to get an empty space character to display though. How do I specify a blank space for the thousands seperator? I tried putting nbsp; in the .properties file but that doesn't work either. --- In flexcoders@yahoogroups.com, Paul Hastings paul.hastings@ wrote: flexcoder2008 wrote: # locale/en_GB/FormattingValues.properties THEMECOLOR=0xFF DATE_FORMAT=DD/MM/YY TIME_FORMAT=L:NN A CURRENCY_PRECISION=0 CURRENCY_SYMBOL=� THOUSANDS_SEPARATOR=, DECIMAL_SEPARATOR=. As you can see, I have the pound symbol for the CURRENCY_SYMBOL. I typed this with ALT-156 no i can't see, its garbaged. is that properties file utf-8 encoded? and in unicode the codepoint for the pound sign is 163 (0x00A3). When I load this resource module and try to display currency values that have been formatted with the british locale, the pound symbol will not display. Instead I get a square box symbol. It's like the Flash player doesn't a box means the whatever can't render that symbol using the given font (except in buzzword which wandered off the reservation all by it's lonesome). either a minor encoding issue or wrong font. a major encoding issue results in questions marks being displayed.
[flexcoders] getting currency symbol to display when loading locale from resource module
For my application, I load a specific locale resource module based on the logged in user's locale. I am trying to configure the en_GB (British) and fr_CA (French Canadian) locales. In order to build my resource module from the command line, I need a properties file. The content of my properties file for the British locale looks like this: # locale/en_GB/FormattingValues.properties THEMECOLOR=0xFF DATE_FORMAT=DD/MM/YY TIME_FORMAT=L:NN A CURRENCY_PRECISION=0 CURRENCY_SYMBOL=£ THOUSANDS_SEPARATOR=, DECIMAL_SEPARATOR=. As you can see, I have the pound symbol for the CURRENCY_SYMBOL. I typed this with ALT-156 When I load this resource module and try to display currency values that have been formatted with the british locale, the pound symbol will not display. Instead I get a square box symbol. It's like the Flash player doesn't recognize the pound symbol. Also, I have a Canadian French locale - I wish to display a blank space as the thousands seperator. So for my fr_CA locale .properties file I have this: # locale/fr_CA/FormattingValues.properties THEMECOLOR=0xFF DATE_FORMAT=DD/MM/YY TIME_FORMAT=L:NN A CURRENCY_PRECISION=0 CURRENCY_SYMBOL=$ THOUSANDS_SEPARATOR= DECIMAL_SEPARATOR=, There is an actual blank space after the '=' sign. When I select the french locale, no space displays. How do I specify these characters in my .properties file? I have tried using HTML entities but every character then displays when my text input or datagrid column is formatted.
[flexcoders] Building an ant script and starting/stopping server - how to automate
Does anybody know if there is a way to record a macro in FlexBuilder for a sequence of tasks? My Flex project has a Java backend and I use an Ant script to build everything and deploy it to Tomcat. I regularly have to stop my Tomcat server, right click on my Ant build file and build it, then restart the Tomcat server. This is a tedious process to do repeatedly throughout the day - just wondering if anyone else has a similar scenario and if they have found a way to do this all in 1 step. It would be great to just push a button, and have those 3 steps execute.
[flexcoders] Weird XMLListCollection behaviour - items won't remove
I am having all sorts of problems with removing items from an XMLListCollection. Not sure if this is because the dataBinding is preventing the items from being removed or not - I'm hoping someone who has run into this issue as well can give me some insight. I have 2 XMLListCollections, each 1 is bound to a seperate DataGrid. There is an approvedItemList bound to dgApproved, and an unApprovedList bound to dgUnApproved. Sometimes, I want to remove an object from the 1 list, and then add it to the other list. (I am using Cairngorm by the way) For example, I want to take an item in the unApprovedList and add it to the ApprovedList. So first I would add the object to the ApprovedList, and then get the Index of the object in the UnApprovedList and use RemoveAt like so: approvedList.addItem(myObject); var index:int = unApprovedItemList.getItemIndex(myObject); unApprovedList.removeAt(index); I am looking at the collections in the watch window, and I can see that when the .removeAt fires, the object is still left in the unApprovedList! Why is this happening? I then attempted to remove the item this way as a workaround: approvedList.addItem(myObject); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.Id == myObject.Id.toString()){ delete o[index]; break; } else index++; } Here again, when the delete command gets hit, the line executes, but the object is left in the collection. I am left with 2 copies, the newly added one in the approvedList, and the leftover copy that I've tried to delete in the unApprovedList. Is the databinding somehow making a copy or locking that object?
[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove
I should make a correction...the 2nd example doesn't workwhere I am using the delete with an index. That just removes one of the nodes of the object itself. So I am still stuck as to how to successfully remove a shared object between 1 list and another and have the item removed from 1 datagrid and added to another. --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: I am having all sorts of problems with removing items from an XMLListCollection. Not sure if this is because the dataBinding is preventing the items from being removed or not - I'm hoping someone who has run into this issue as well can give me some insight. I have 2 XMLListCollections, each 1 is bound to a seperate DataGrid. There is an approvedItemList bound to dgApproved, and an unApprovedList bound to dgUnApproved. Sometimes, I want to remove an object from the 1 list, and then add it to the other list. (I am using Cairngorm by the way) For example, I want to take an item in the unApprovedList and add it to the ApprovedList. So first I would add the object to the ApprovedList, and then get the Index of the object in the UnApprovedList and use RemoveAt like so: approvedList.addItem(myObject); var index:int = unApprovedItemList.getItemIndex(myObject); unApprovedList.removeAt(index); I am looking at the collections in the watch window, and I can see that when the .removeAt fires, the object is still left in the unApprovedList! Why is this happening? I then attempted to remove the item this way as a workaround: approvedList.addItem(myObject); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.Id == myObject.Id.toString()){ delete o[index]; break; } else index++; } Here again, when the delete command gets hit, the line executes, but the object is left in the collection. I am left with 2 copies, the newly added one in the approvedList, and the leftover copy that I've tried to delete in the unApprovedList. Is the databinding somehow making a copy or locking that object?
[flexcoders] Re: Forcing an Image to redraw when the source filename is the same
Thanks for that suggestion, but I don't think that's an approach I can take. Any other suggestions? Is this just a browser cache issue?
[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove
The collections are independent. When my app starts up I have an XML variable that gets split into 2 seperate lists. So for example: var myList:XML I then split the lists into 2 like so: for each(var x:XML in myList){ if(x.Status == UnApproved) unApproved.addItem(x.copy()); else if(x.Status == Approved) approvedList.addItem(x.copy()); } I used the .copy() method to ensure that this isn't tied back to the original XML by reference. --- In flexcoders@yahoogroups.com, Tracy Spratt tspr...@... wrote: First, are you sure your collections are independent? If you use the same XMLList for both, they are not. Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:27 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove I should make a correction...the 2nd example doesn't workwhere I am using the delete with an index. That just removes one of the nodes of the object itself. So I am still stuck as to how to successfully remove a shared object between 1 list and another and have the item removed from 1 datagrid and added to another. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , flexcoder2008 djohnson29@ wrote: I am having all sorts of problems with removing items from an XMLListCollection. Not sure if this is because the dataBinding is preventing the items from being removed or not - I'm hoping someone who has run into this issue as well can give me some insight. I have 2 XMLListCollections, each 1 is bound to a seperate DataGrid. There is an approvedItemList bound to dgApproved, and an unApprovedList bound to dgUnApproved. Sometimes, I want to remove an object from the 1 list, and then add it to the other list. (I am using Cairngorm by the way) For example, I want to take an item in the unApprovedList and add it to the ApprovedList. So first I would add the object to the ApprovedList, and then get the Index of the object in the UnApprovedList and use RemoveAt like so: approvedList.addItem(myObject); var index:int = unApprovedItemList.getItemIndex(myObject); unApprovedList.removeAt(index); I am looking at the collections in the watch window, and I can see that when the .removeAt fires, the object is still left in the unApprovedList! Why is this happening? I then attempted to remove the item this way as a workaround: approvedList.addItem(myObject); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.Id == myObject.Id.toString()){ delete o[index]; break; } else index++; } Here again, when the delete command gets hit, the line executes, but the object is left in the collection. I am left with 2 copies, the newly added one in the approvedList, and the leftover copy that I've tried to delete in the unApprovedList. Is the databinding somehow making a copy or locking that object?
[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove
Thanks Tracey - yes I am doing that as well. I'm trying a new approach now - the problem now is that when I try to retrieve the item index, even though I can see that the object is there, I am getting an index of -1. Is there something wrong with this code block? approvedList.addItem(myObject.copy()); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.id == o.id.toString()){ break; } else index++; } var x:XML = unApprovedList[index]; // x should refer to the same object in unApprovedList! var index:int = unApprovedList.getItemIndex(x); // is returning -1 unApprovedList.removeItemAt(index); --- In flexcoders@yahoogroups.com, Tracy Spratt tspr...@... wrote: Good. Are you using copy() when you addItem() to the approvedList? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:49 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove The collections are independent. When my app starts up I have an XML variable that gets split into 2 seperate lists. So for example: var myList:XML I then split the lists into 2 like so: for each(var x:XML in myList){ if(x.Status == UnApproved) unApproved.addItem(x.copy()); else if(x.Status == Approved) approvedList.addItem(x.copy()); } I used the .copy() method to ensure that this isn't tied back to the original XML by reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: First, are you sure your collections are independent? If you use the same XMLList for both, they are not. Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:27 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove I should make a correction...the 2nd example doesn't workwhere I am using the delete with an index. That just removes one of the nodes of the object itself. So I am still stuck as to how to successfully remove a shared object between 1 list and another and have the item removed from 1 datagrid and added to another. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , flexcoder2008 djohnson29@ wrote: I am having all sorts of problems with removing items from an XMLListCollection. Not sure if this is because the dataBinding is preventing the items from being removed or not - I'm hoping someone who has run into this issue as well can give me some insight. I have 2 XMLListCollections, each 1 is bound to a seperate DataGrid. There is an approvedItemList bound to dgApproved, and an unApprovedList bound to dgUnApproved. Sometimes, I want to remove an object from the 1 list, and then add it to the other list. (I am using Cairngorm by the way) For example, I want to take an item in the unApprovedList and add it to the ApprovedList. So first I would add the object to the ApprovedList, and then get the Index of the object in the UnApprovedList and use RemoveAt like so: approvedList.addItem(myObject); var index:int = unApprovedItemList.getItemIndex(myObject); unApprovedList.removeAt(index); I am looking at the collections in the watch window, and I can see that when the .removeAt fires, the object is still left in the unApprovedList! Why is this happening? I then attempted to remove the item this way as a workaround: approvedList.addItem(myObject); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.Id == myObject.Id.toString()){ delete o[index]; break; } else index++; } Here again, when the delete command gets hit, the line executes, but the object is left in the collection. I am left with 2 copies, the newly added one in the approvedList, and the leftover copy that I've tried to delete in the unApprovedList. Is the databinding somehow making a copy or locking that object?
[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove
What is the best way to do this? I tried this line and it returned true so it should be a good reference right? var x:XML = unApprovedList[index]; trace(x == unApprovedList[index]); --- In flexcoders@yahoogroups.com, Tracy Spratt tspr...@... wrote: Did you verify that var x:XML = unApprovedList[index]; is returning a good reference? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 3:57 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove Thanks Tracey - yes I am doing that as well. I'm trying a new approach now - the problem now is that when I try to retrieve the item index, even though I can see that the object is there, I am getting an index of -1. Is there something wrong with this code block? approvedList.addItem(myObject.copy()); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.id == o.id.toString()){ break; } else index++; } var x:XML = unApprovedList[index]; // x should refer to the same object in unApprovedList! var index:int = unApprovedList.getItemIndex(x); // is returning -1 unApprovedList.removeItemAt(index); --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: Good. Are you using copy() when you addItem() to the approvedList? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:49 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove The collections are independent. When my app starts up I have an XML variable that gets split into 2 seperate lists. So for example: var myList:XML I then split the lists into 2 like so: for each(var x:XML in myList){ if(x.Status == UnApproved) unApproved.addItem(x.copy()); else if(x.Status == Approved) approvedList.addItem(x.copy()); } I used the .copy() method to ensure that this isn't tied back to the original XML by reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: First, are you sure your collections are independent? If you use the same XMLList for both, they are not. Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:27 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove I should make a correction...the 2nd example doesn't workwhere I am using the delete with an index. That just removes one of the nodes of the object itself. So I am still stuck as to how to successfully remove a shared object between 1 list and another and have the item removed from 1 datagrid and added to another. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , flexcoder2008 djohnson29@ wrote: I am having all sorts of problems with removing items from an XMLListCollection. Not sure if this is because the dataBinding is preventing the items from being removed or not - I'm hoping someone who has run into this issue as well can give me some insight. I have 2 XMLListCollections, each 1 is bound to a seperate DataGrid. There is an approvedItemList bound to dgApproved, and an unApprovedList bound to dgUnApproved. Sometimes, I want to remove an object from the 1 list, and then add it to the other list. (I am using Cairngorm by the way) For example, I want to take an item in the unApprovedList and add it to the ApprovedList. So first I would add the object to the ApprovedList, and then get the Index of the object in the UnApprovedList and use RemoveAt like so: approvedList.addItem(myObject); var index:int = unApprovedItemList.getItemIndex(myObject); unApprovedList.removeAt(index); I
[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove
Yes, I tried that and it is the correct node. --- In flexcoders@yahoogroups.com, Tracy Spratt tspr...@... wrote: trace(x.toXMLString()); //is that the node you expect? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 4:15 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove What is the best way to do this? I tried this line and it returned true so it should be a good reference right? var x:XML = unApprovedList[index]; trace(x == unApprovedList[index]); --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: Did you verify that var x:XML = unApprovedList[index]; is returning a good reference? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 3:57 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove Thanks Tracey - yes I am doing that as well. I'm trying a new approach now - the problem now is that when I try to retrieve the item index, even though I can see that the object is there, I am getting an index of -1. Is there something wrong with this code block? approvedList.addItem(myObject.copy()); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.id == o.id.toString()){ break; } else index++; } var x:XML = unApprovedList[index]; // x should refer to the same object in unApprovedList! var index:int = unApprovedList.getItemIndex(x); // is returning -1 unApprovedList.removeItemAt(index); --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: Good. Are you using copy() when you addItem() to the approvedList? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:49 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove The collections are independent. When my app starts up I have an XML variable that gets split into 2 seperate lists. So for example: var myList:XML I then split the lists into 2 like so: for each(var x:XML in myList){ if(x.Status == UnApproved) unApproved.addItem(x.copy()); else if(x.Status == Approved) approvedList.addItem(x.copy()); } I used the .copy() method to ensure that this isn't tied back to the original XML by reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: First, are you sure your collections are independent? If you use the same XMLList for both, they are not. Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:27 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove I should make a correction...the 2nd example doesn't workwhere I am using the delete with an index. That just removes one of the nodes of the object itself. So I am still stuck as to how to successfully remove a shared object between 1 list and another and have the item removed from 1 datagrid and added to another. --- In flexcoders@yahoogroups.com
[flexcoders] Re: Weird XMLListCollection behaviour - items won't remove
Got it working!! I stepped through the code and could see that an index of -1 was being thrown from Sort.as. I had applied a Sort to these XMLListCollections at an earlier point in the application's lifecycle. I had to call .refresh() on the collection before I remove the item and somehow this gets the collection all in nice shape and then returns the correct index. So now my code looks like this: approvedList.addItem(myObject); unApprovedList.refresh(); var index:int = unApprovedList.getItemIndex(myObject); unApprovedList.removeItemAt(index); Not sure why I had to explicitly call .refresh here. I have other XMLListCollections in my application that are sorted and I am able to call .removeAt without always calling .refresh() first. This brings me to another related question. When you have a Sort applied to an XMLListCollection, is there a way to turn off or reset that Sort to some sort of default value? --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: Yes, I tried that and it is the correct node. --- In flexcoders@yahoogroups.com, Tracy Spratt tspratt@ wrote: trace(x.toXMLString()); //is that the node you expect? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 4:15 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove What is the best way to do this? I tried this line and it returned true so it should be a good reference right? var x:XML = unApprovedList[index]; trace(x == unApprovedList[index]); --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: Did you verify that var x:XML = unApprovedList[index]; is returning a good reference? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 3:57 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove Thanks Tracey - yes I am doing that as well. I'm trying a new approach now - the problem now is that when I try to retrieve the item index, even though I can see that the object is there, I am getting an index of -1. Is there something wrong with this code block? approvedList.addItem(myObject.copy()); var index:int = 0; for each(var o:Object in unApprovedList){ if(o.id == o.id.toString()){ break; } else index++; } var x:XML = unApprovedList[index]; // x should refer to the same object in unApprovedList! var index:int = unApprovedList.getItemIndex(x); // is returning -1 unApprovedList.removeItemAt(index); --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: Good. Are you using copy() when you addItem() to the approvedList? Tracy Spratt Lariat Services Flex development bandwidth available From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of flexcoder2008 Sent: Thursday, February 19, 2009 2:49 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Weird XMLListCollection behaviour - items won't remove The collections are independent. When my app starts up I have an XML variable that gets split into 2 seperate lists. So for example: var myList:XML I then split the lists into 2 like so: for each(var x:XML in myList){ if(x.Status == UnApproved) unApproved.addItem(x.copy()); else if(x.Status == Approved) approvedList.addItem(x.copy()); } I used the .copy() method to ensure that this isn't tied back to the original XML by reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: First, are you sure your collections are independent? If you use the same XMLList for both, they are not. Tracy Spratt
[flexcoders] Forcing an Image to redraw when the source filename is the same
In my application, I have an Image control that I am using for an application-wide image. Then user is allowed to upload this image to the server and it is saved with a set filename, for example ApplicationImage.png I was having trouble getting the Image to update when a new image is selected and uploaded to the server. This is because the source property is set to the same filename and the image was not reloading. I have seen posts elsewhere that explain that the browser caches the response it got from the first call you make when the image source property is set. To prevent this caching, you append a unique value to the end of the source path. For example, myImage.source = 'myPath/ApplicationImage.png?param=+(new Date()).getTime); This works for the most part but there appears to be a timing issue. If I select an image to upload, it uploads fine to the server, then in my complete handler where I get the response back from the server I reset the image .source property to the filename again and append the date value to trigger a refresh and the image loads with the selected value. But if I initiate this process over again, then image just stays to the old value. The source actually has been reassigned (because if I refresh the new image will be there) but the image has not been reloaded or refreshed. If I wait a good 5 seconds between each attempt to upload a new image, then the image will always be correctly updated to the newly selected one. How do I force the image to refresh every time? What is this strange timing issue that caches the old image value even though I am setting the source property to a unique value? Is there a way to prevent the image from caching or is there some timout value that can be set?
[flexcoders] Re: Datagrid bound to XMLListCollection not updating properly - ItemRenderer issue?
To put it more simply, how do I force an itemRenderer bound to an image to refresh itself? --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: I am having trouble getting a datagrid that is bound to an XMLListCollection to update properly. The datagrid uses item renderers for a couple of the columns which display a simple colored image. mx:itemRenderer mx:Component mx:Canvas mx:Image source={data.MyImage} / /mx:Canvas /mx:Component /mx:itemRenderer This datagrid's dataProvider is set to bind to an XMLListCollection variable which contains XML with one of the nodes being MyImage This datagrid is a part of a module that gets loaded into a TabNavigator control. When the module initializes I loop through each row in the datagrid and check the values of the XML, and depending on certain values, I update the content of the MyImage node, which in turn will change the image source property. When the module first loads, everything works fine and the grid displays correctly. The problem happens when I load a different module into the tabNavigator. In a seperate module I do an update to this same XMLListCollection. (I am using the Cairngorm framework and all my shared data is stored in the model. ) When I reload the first module, and the initialization logic fires, as I am looping through to do the calculations to update the MyImage node I can see that everything is updating in the XMLListCollection correctly. However, when the dataGrid displays, the row that corresponds to the updated XML in the XMLListCollection is displaying a blank row, even though the underlying values are correct. I believe this is a problem with the ItemRenderer not updating itself. How do I force it to invalidate? I have tried doing a dataGrid.dataProvider.refresh() and calling invalidateDisplayList() etc. but cannot figure this one out. One workaround I discovered is that when I reload the first module after updating the underlying XMLListCollection, if I append a new empty node to the XML like so: myXML.* += empty /Then the updated row displays correctly! Has anybody else out there ran into this problem?
[flexcoders] Datagrid bound to XMLListCollection not updating properly - ItemRenderer issue?
I am having trouble getting a datagrid that is bound to an XMLListCollection to update properly. The datagrid uses item renderers for a couple of the columns which display a simple colored image. mx:itemRenderer mx:Component mx:Canvas mx:Image source={data.MyImage} / /mx:Canvas /mx:Component /mx:itemRenderer This datagrid's dataProvider is set to bind to an XMLListCollection variable which contains XML with one of the nodes being MyImage This datagrid is a part of a module that gets loaded into a TabNavigator control. When the module initializes I loop through each row in the datagrid and check the values of the XML, and depending on certain values, I update the content of the MyImage node, which in turn will change the image source property. When the module first loads, everything works fine and the grid displays correctly. The problem happens when I load a different module into the tabNavigator. In a seperate module I do an update to this same XMLListCollection. (I am using the Cairngorm framework and all my shared data is stored in the model. ) When I reload the first module, and the initialization logic fires, as I am looping through to do the calculations to update the MyImage node I can see that everything is updating in the XMLListCollection correctly. However, when the dataGrid displays, the row that corresponds to the updated XML in the XMLListCollection is displaying a blank row, even though the underlying values are correct. I believe this is a problem with the ItemRenderer not updating itself. How do I force it to invalidate? I have tried doing a dataGrid.dataProvider.refresh() and calling invalidateDisplayList() etc. but cannot figure this one out. One workaround I discovered is that when I reload the first module after updating the underlying XMLListCollection, if I append a new empty node to the XML like so: myXML.* += empty /Then the updated row displays correctly! Has anybody else out there ran into this problem?
[flexcoders] How to register a dynamicEvent in an Actionscript class
I have seen numerous examples of registering a dynamicEvent in a component's mxml such as: [Event (name=rowSelected, type=mx.events.DynamicEvent)] If I have an actionscript class that dispatches a dynamicEvent, what is the syntax for this? I want to dispatch a dynamicEvent from an actionscript class, and I want my module to listen for that event.
[flexcoders] Re: How to register a dynamicEvent in an Actionscript class
Hmmm, this is the way I have done it - but my event handler is not firing. I am dispatching my DynamicEvent from a Cairngorm command - in the execute method I have: var evt:DynamicEvent = new DynamicEvent(initCompleted); dispatchEvent(evt); in my module's creationComplete handler I have this code: this.addEventListener(initCompleted,initCompletedHandler); Then in the module's script block I have the event handler private function initCompletedHandler(event:DynamicEvent):void{ } This handler never gets hit. --- In flexcoders@yahoogroups.com, Nate Beck n...@... wrote: It's exactly the same as a standard Event. As you can see in the Language Reference ( http://livedocs.adobe.com/flex/3/langref/mx/events/DynamicEvent.html): var event:DynamicEvent = new DynamicEvent(credentialsChanged); event.name = name; event.passsword = password; // misspelling won't be caught! dispatchEvent(event); then.. module.addEventListener(credentialsChanged, myHandler); The DynamicEvent class works exactly like and Event... it just gives you the ability to add properties to it at runtime. If you're going to be using the same event over and over again. You're better off just creating a custom event (http://livedocs.adobe.com/flex/3/html/help.html?content=createevents_1.html#110674). If you do not identify an event in the class file with the [Event] metadata tag, the MXML compiler generates an error if you try to use the event name in MXML. Any component can register an event listener for the event in ActionScript by using the addEventListener()method, even if you omit the [Event] metadata tag. HTH, Nate On Mon, Jan 12, 2009 at 11:07 AM, flexcoder2008 djohnso...@...wrote: I have seen numerous examples of registering a dynamicEvent in a component's mxml such as: [Event (name=rowSelected, type=mx.events.DynamicEvent)] If I have an actionscript class that dispatches a dynamicEvent, what is the syntax for this? I want to dispatch a dynamicEvent from an actionscript class, and I want my module to listen for that event. -- Cheers, Nate http://blog.natebeck.net
[flexcoders] Re: How to register a dynamicEvent in an Actionscript class
Well, I want to dispatch the dynamicEvent from the actionscript class (which is a Cairngorm command) and I want my module to listen for that event. Since the module event handler code is not being hit, I thought I might need to register this event with the compiler (perhaps my terminology is wrong - sorry). I know that when using a component, you use the [Event] metadata tag to announce that the component dispatches a particular event. I thought that I might have to do the same thing with an actionscript class. --- In flexcoders@yahoogroups.com, kylewburke monk...@... wrote: What do you mean by register? Do you want to listen for that event or dispatch one? --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@ wrote: I have seen numerous examples of registering a dynamicEvent in a component's mxml such as: [Event (name=rowSelected, type=mx.events.DynamicEvent)] If I have an actionscript class that dispatches a dynamicEvent, what is the syntax for this? I want to dispatch a dynamicEvent from an actionscript class, and I want my module to listen for that event.
[flexcoders] Re: How to register a dynamicEvent in an Actionscript class
Thanks Nate, Tried that but it still doesn't work. I'm basically trying to dispatch a dynamicEvent from a Cairngorm event and then trying to get a module to listen for that event. I don't want this event to be a CiarngormEvent to be handled by the FrontController and the Command object. In other words, I want the module that originally dispatched the CairngormEvent to handle the DynamicEvent that gets raised by the CairngormCommand. I just can't seem to get this to work. --- In flexcoders@yahoogroups.com, Nate Beck n...@... wrote: Events don't bubble by default. So if you're depending on the Cairngorm Front Controller to pick them up, and the object dispatching the event isn't directly below the Application, you need to enable event bubbling. new DynamicEvent(myType, true); Cheers, Nate On Mon, Jan 12, 2009 at 11:48 AM, flexcoder2008 djohnso...@...wrote: Well, I want to dispatch the dynamicEvent from the actionscript class (which is a Cairngorm command) and I want my module to listen for that event. Since the module event handler code is not being hit, I thought I might need to register this event with the compiler (perhaps my terminology is wrong - sorry). I know that when using a component, you use the [Event] metadata tag to announce that the component dispatches a particular event. I thought that I might have to do the same thing with an actionscript class. --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, kylewburke monkeys@ wrote: What do you mean by register? Do you want to listen for that event or dispatch one? --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, flexcoder2008 djohnson29@ wrote: I have seen numerous examples of registering a dynamicEvent in a component's mxml such as: [Event (name=rowSelected, type=mx.events.DynamicEvent)] If I have an actionscript class that dispatches a dynamicEvent, what is the syntax for this? I want to dispatch a dynamicEvent from an actionscript class, and I want my module to listen for that event. -- Cheers, Nate http://blog.natebeck.net
[flexcoders] Re: How to register a dynamicEvent in an Actionscript class
In case this helps anyone else - I got this to work. Had to reference the moduleLoader through the application - so when I dispatch the dynamicEvent from inside the CairgormCommand's execute method it looks like this: initCompleteEvent = new DynamicEvent(initCompleted,true); Application.application.myModuleLoader.child.dispatchEvent(initCompleteEvent); --- In flexcoders@yahoogroups.com, flexcoder2008 djohnso...@... wrote: Well, I want to dispatch the dynamicEvent from the actionscript class (which is a Cairngorm command) and I want my module to listen for that event. Since the module event handler code is not being hit, I thought I might need to register this event with the compiler (perhaps my terminology is wrong - sorry). I know that when using a component, you use the [Event] metadata tag to announce that the component dispatches a particular event. I thought that I might have to do the same thing with an actionscript class. --- In flexcoders@yahoogroups.com, kylewburke monkeys@ wrote: What do you mean by register? Do you want to listen for that event or dispatch one? --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@ wrote: I have seen numerous examples of registering a dynamicEvent in a component's mxml such as: [Event (name=rowSelected, type=mx.events.DynamicEvent)] If I have an actionscript class that dispatches a dynamicEvent, what is the syntax for this? I want to dispatch a dynamicEvent from an actionscript class, and I want my module to listen for that event.
[flexcoders] Re: Unformatting currency values - best practice?
Thanks very much for those suggestions. The RegExUtil class is almost perfect, except that it will strip out decimal places since they are non-numeric characters. In the focus in/out events I am trying to assign the numeric value of the TextInput's text property to the data property minus the currency symbol and thousands separator. The tricky part is the decimal place. The RegExUtil strip function will remove the decimal place since it is a non-numeric character and so the value saved to the .data property is wrong. The other thing to consider is that for some locales, a comma is used for a decimal point. So if we want to save this back to the database, the comma has to be replaced with a period. This shouldn't be too hard though - I'll just use string functions to find the decimal character, then split the number into 2 parts, strip the extra characters with the RegExUtil function and then concatenate them back with a . character to save to the db. Thanks again.
[flexcoders] Re: Unformatting currency values - best practice?
I'm not quite clear on what you're trying to do formatting wise, however. Are you saying that you try to detect when a user has finished entering a currency amount, and then add currency symbols, thousands separator symbols, decimal point symbol, etc.? I guess it is a high road approach. I'm reapplying formatting when they have finished entering a currency amount but also allowing them to enter amounts with or without the currency characters for their locale. The underlying .data property stores the plain numeric value with all the extra formatting characters removed. When the control is first displayed, the currency formatting shows the value in the TextInput for example as: $1,000.34 When the focus enters the text control, the entry is selected, allowing the user to type over and replace the amount. They can enter just numbers, or also enter the currency formatting characters. On the FocusOut event, the formatting is reapplied, and the numeric value is stored in the TextInput's .data property for saving to the db. I'm pleased to say I've finally got this working thanks to the suggestions posted. When I get some time I might try to post this at Flex examples. Cheers --- In flexcoders@yahoogroups.com, jim.abbott45 [EMAIL PROTECTED] wrote: It sounds like you're taking the 'high road' approach to this (i.e., letting users enter arbitrary currency strings and then trying to figure out the currency type after the fact and then checking the thousands separators and decimal point characters to see if they match that). That's a best practice usability-wise (at least if you agree with Alan Cooper...), but it can also take a lot of code to implement it robustly and it requires thorough testing. If you're willing to trade off some usability, you could have user's pick the currency type (i.e., USD, Euro, Yen), _separately_, say in a drop-down list; and then have them enter the actual value (in a separate text field). If you implement it that way, then your (currency) string parsing problem becomes much simpler. If you put the currency type selector _before_ the amount field (in the workflow/tab order), then you can also do things like dynamically changing the validator for the amount field, based on the selected currency. You could even have a 'no currency type selected' default for the currency type selector and disable the amount field until the user selected a particular currency. I don't know if I would consider the latter approaches as 'best practices' (especially from a usability perspective), but they are reasonable trade-offs. YMMV. I'm not quite clear on what you're trying to do formatting wise, however. Are you saying that you try to detect when a user has finished entering a currency amount, and then add currency symbols, thousands separator symbols, decimal point symbol, etc.? Regards, Jim --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@ wrote: What is the best practice or a good recommendation for formatting currency values and then removing the currency formatting for saving to the database? Here's what I have attempted to do so far. It works - but only if the user enters plain old numbers - if they add any currency symbol or thousand separator, it fails. I have a form which has some textInput's that are formatted with currencyFormatters. I initialize each textInput's .data property to 0. The textInput displays formatted currency amounts from xml data retrieved from the database. On the focusIn event, the text property is assigned to the textInput's .data property, so the value stays the same but the formatting is gone. And when a change event fires, the unformatted text in the textInput gets updated to the data property as well. On the FocusOut event, the currency formatting is re-applied. When I save to the db, I use the textInput's .data property. So for the most part this works, but fails if the user enters any currency symbols. Is there a good class or function someone could recommend to take a currency value in a textInput and strip out all the extra formatting characters? I am also trying to implement localization, so the various currency symbols will be different depending on the locale. Thanks
[flexcoders] Unformatting currency values - best practice?
What is the best practice or a good recommendation for formatting currency values and then removing the currency formatting for saving to the database? Here's what I have attempted to do so far. It works - but only if the user enters plain old numbers - if they add any currency symbol or thousand separator, it fails. I have a form which has some textInput's that are formatted with currencyFormatters. I initialize each textInput's .data property to 0. The textInput displays formatted currency amounts from xml data retrieved from the database. On the focusIn event, the text property is assigned to the textInput's .data property, so the value stays the same but the formatting is gone. And when a change event fires, the unformatted text in the textInput gets updated to the data property as well. On the FocusOut event, the currency formatting is re-applied. When I save to the db, I use the textInput's .data property. So for the most part this works, but fails if the user enters any currency symbols. Is there a good class or function someone could recommend to take a currency value in a textInput and strip out all the extra formatting characters? I am also trying to implement localization, so the various currency symbols will be different depending on the locale. Thanks
[flexcoders] Re: Sorting XMLListCollection based on node value
Thanks! --- In flexcoders@yahoogroups.com, valdhor [EMAIL PROTECTED] wrote: You have to apply the sort to the ListCollection: var s:Sort = new Sort(); s.fields = [new SortField(DisplayName)]; myXMLListCollection.sort = s; myXMLListCollection.refresh(); --- In flexcoders@yahoogroups.com, flexcoder2008 djohnson29@ wrote: I have an XMLListCollection that I want to sort based on a particular node value. All of the examples I have seen show sorting by XML attribute. My xml is in the following format: Employee FirstNameWilliam/FirstName LastNameJackson/LastName DisplayNameBob Jackson/DisplayName /Employee I want to sort items by the DisplayName node, which will show up in a List control. Here's the code I've attempted (not working) var s:Sort = new Sort(); s.fields = [new SortField(DisplayName)]; myXMLListCollection.refresh(); How do I sort based on a particular XML node?
[flexcoders] Sorting XMLListCollection based on node value
I have an XMLListCollection that I want to sort based on a particular node value. All of the examples I have seen show sorting by XML attribute. My xml is in the following format: Employee FirstNameWilliam/FirstName LastNameJackson/LastName DisplayNameBob Jackson/DisplayName /Employee I want to sort items by the DisplayName node, which will show up in a List control. Here's the code I've attempted (not working) var s:Sort = new Sort(); s.fields = [new SortField(DisplayName)]; myXMLListCollection.refresh(); How do I sort based on a particular XML node?