[flexcoders] Handling results from multiple RemoteObject operations
Hi all, I've been wanting to learn Flex since 1.5 and finally got the chance to really dive in this weekend. I'm putting together an application that gets information from a ColdFusion application and was wondering if I'm handling the results properly. I want to bind the data from one of the methods of my RemoteObject, but I want to massage the data first (add a property that doesn't exist on the server) so this is what I'm doing: My RemoteObject looks like this: In my initApp() method, I've got this line: Jukebox.getFullList.addEventListener(ResultEvent.RESULT,handleResult); Which triggers this function: [Bindable] public var fullList:ArrayCollection = new ArrayCollection(); public function handleResult(e:ResultEvent):void { for (var i:Object in e.result) { e.result[i].inPlayList = "+"; fullList.addItem(e.result[i]); } } And then my DataGrid: It seems to be working, though I'm not sure how strong that binding is; I seem to recall in the reams and reams of docs and examples I read this weekend that binding a variable like that won't update the DataGrid if the contents of the variable change? Thanks! - Ken -- Suppose you were an idiot. And suppose you were a member of congress. But I repeat myself. -- Mark Twain
[flexcoders] Strange multiple select bug in List
I'm having a problem getting allowMultipleSelection to work properly. I have a form with a List control that's populated by an ArrayCollection. I cannot seem to get multiple selection or dataTips to work. The code for the list is: I've tried completely replacing the list with a DataGrid, and that doesn't work either. I've tried setting just the bare minimum attributes for the List control (and DG) without any luck. I've tried this using Flex 3 Beta 2 and 2.0.1 on Mac/Safari with player 9.0.47.0. I tried it on Mac/FF as well, and it sort of worked at first (clicking items didn't cause other items to deselect - so that's more like another bug really) but when I reloaded the app, it behaved the same way as Safari. I'm just building the UI at the moment, so there's no other functionality in the app. This has got me very confused, and I haven't been able to find any clues. I know about the Tree multiple select issue in Flex 2, is this related? I swear I've used a multi-select List control before. Any tips would be greatly appreciated. - Ken
Re: [flexcoders] Strange multiple select bug in List
Heh, I wish it were that simple :) Yeah, I know how it *should* work, but the problem is that isn't working. Oh, and you're right about the datatips - my mistake, should've read the docs closer. Any ideas why multi-select wouldn't function on a List or Tree? Is there something about it being inside a Form control? On Nov 30, 2007 2:05 PM, Alex Harui <[EMAIL PROTECTED]> wrote: >multi-select requires CTRL and SHIFT keys along with clicking or arrow > keys. Are you doing that? > > datatips don't show up unless the string can't be fully seen. > > -- > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Ken Dunnington > *Sent:* Thursday, November 29, 2007 10:10 AM > *To:* flexcoders@yahoogroups.com > *Subject:* [flexcoders] Strange multiple select bug in List > > I'm having a problem getting allowMultipleSelection to work properly. I > have a form with a List control that's populated by an ArrayCollection. I > cannot seem to get multiple selection or dataTips to work. The code for the > list is: > > > > > > > > > > > > > > > > > > > allowMultipleSelection="true" dataProvider="{pages }" > > dataTipField="url" showDataTips="true" /> > > > > > I've tried completely replacing the list with a DataGrid, and that doesn't > work either. I've tried setting just the bare minimum attributes for the > List control (and DG) without any luck. > > I've tried this using Flex 3 Beta 2 and 2.0.1 on Mac/Safari with player > 9.0.47.0. I tried it on Mac/FF as well, and it sort of worked at first > (clicking items didn't cause other items to deselect - so that's more like > another bug really) but when I reloaded the app, it behaved the same way as > Safari. I'm just building the UI at the moment, so there's no other > functionality in the app. This has got me very confused, and I haven't been > able to find any clues. I know about the Tree multiple select issue in Flex > 2, is this related? I swear I've used a multi-select List control before. > Any tips would be greatly appreciated. > > - Ken > > > -- Suppose you were an idiot. And suppose you were a member of congress. But I repeat myself. -- Mark Twain
Re: [flexcoders] Re: Subversion clients
SCPlugin is a contextual menu plugin for the Mac. Not as fancy as Tortoise, but I've had good luck with it. Otherwise, it's Subclipse and of course the command line tools. On Dec 1, 2007 11:52 AM, Kurt Wiersma <[EMAIL PROTECTED]> wrote: > I use SmartSVN on both my Mac and my Windows box. It works great and > they even have a free community version. Their SmartCVS client is great as > well. > > http://smartsvn.com > > --Kurt > > > On Nov 30, 2007 10:08 AM, eestes1 <[EMAIL PROTECTED]> wrote: > > > I use syncro client that is part of oxygen-it's really simple, > > straightforward and uncluttered > > gui to work with. i was trying scplugin as well but disabled it when i > > jumped to leopard. > > Again the simplicity of having it built in to the finder interface is > > very attractive with simple > > icons and options on the contextual menu. > > > > > > --- In flexcoders@yahoogroups.com , > > "Stephen Allison" <[EMAIL PROTECTED]> wrote: > > > > > > > > > >> What Subversion clients do you use, and what do you like or dislike > > about > > > >> them? I'm especially interested in opinions about GUI clients on > > the Mac. > > > > > > SVNX. Slightly odd multi-window interface, but beyond that no > > complaints so > > > far. > > > > > > > > > -- Suppose you were an idiot. And suppose you were a member of congress. But I repeat myself. -- Mark Twain
[flexcoders] Custom ItemEditor too big for container
I've built a custom Tree ItemEditor that consists of a VBox with a Form in it. It works just fine (besides the CheckBox which is too picky about "true" vs. true in the XML data...) except when I try to edit an item near the bottom of the container, the editor gets cut off. Because I wanted it to only occupy the smallest necessary space, I set the following properties on the Tree control: editorHeightOffset="150" editorWidthOffset="-650", and there is no width or height set for the ItemEditor. What's the best way to ensure that my custom editor won't occupy a huge amount of space, but will stay on-screen as well? I tried setting verticalScrollPolicy to "on" but it doesn't register as an increase in the control's height, so the bars don't activate when the editor is off the screen.
Re: [flexcoders] Datagrid ItemEditor - multiple data edits?
I'm doing exactly that, and it is pretty easy. Here's the LiveDoc link: http://livedocs.adobe.com/flex/201/html/celleditor_073_15.html#247667 and you also might want to read over this bit on making your custom editor respond to keyboard events (enter and escape, for example) http://livedocs.adobe.com/flex/201/html/celleditor_073_07.html#208069 On Dec 5, 2007 6:05 PM, Tracy Spratt <[EMAIL PROTECTED]> wrote: >Sure, this should not be difficult. Have your renderer do its own > updating of the dataProvider item, and don't attempt to use the > renderIsEditor or other built in item editor functionality. The renderer > gets a reference to the entire item, so it can manipulate that data however > you want. > > > > I also recall a document topic about returning multiple values from a > renderer, that might be useful. > > > > Tracy > > > -- > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Rick Schmitty > *Sent:* Wednesday, December 05, 2007 2:43 PM > *To:* flexcoders@yahoogroups.com > *Subject:* [flexcoders] Datagrid ItemEditor - multiple data edits? > > > > Is it possible for an ItemEditor in a datagrid (or some other way) to > allow you to edit 2 or more things at once? Like say instead of a > combo box dropdown for a cell in a datagrid, could you have an item > editor that is like a mini form update multiple data objects in that > row's data that may not be displayed in the datagrids view > > Or Flex3 advanced datagrid something I should look into? Or this will > have to be completely custom and kinda 'fake' this behavior > > > -- Suppose you were an idiot. And suppose you were a member of congress. But I repeat myself. -- Mark Twain
[flexcoders] Double click tree item editing
I needed my Tree control to only bring up the item editor when double clicked. I was going to post this as a question, but instead dug into it a bit more and came up with a solution, so I thought I'd share in case anyone else needs the same functionality (or has a better solution.) Basically, I'm listening for the itemEditBeginning event, canceling it, then manually setting the editedItemPosition on the itemDoubleClick event. Pretty simple, really, but if you're just getting into itemEditors (like me) hopefully this will be useful to you. Here's the relevant code:
Re: [flexcoders] Custom ItemEditor too big for container
I'm afraid that didn't do it. I'm going to try intercepting the itemEditBegin event and check the position of the item clicked and adjust the editorYOffset property on the Tree... does that sound right? Of course, I now need to learn how to figure out the item's position :) On Dec 6, 2007 1:03 PM, Alex Harui <[EMAIL PROTECTED]> wrote: >variableRowHeight? > > > -- > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Ken Dunnington > *Sent:* Wednesday, December 05, 2007 11:47 AM > *To:* flexcoders@yahoogroups.com > *Subject:* [flexcoders] Custom ItemEditor too big for container > > > > I've built a custom Tree ItemEditor that consists of a VBox with a Form in > it. It works just fine (besides the CheckBox which is too picky about "true" > vs. true in the XML data...) except when I try to edit an item near the > bottom of the container, the editor gets cut off. Because I wanted it to > only occupy the smallest necessary space, I set the following properties on > the Tree control: editorHeightOffset="150" editorWidthOffset="-650", and > there is no width or height set for the ItemEditor. > > What's the best way to ensure that my custom editor won't occupy a huge > amount of space, but will stay on-screen as well? I tried setting > verticalScrollPolicy to "on" but it doesn't register as an increase in the > control's height, so the bars don't activate when the editor is off the > screen. > > > -- Suppose you were an idiot. And suppose you were a member of congress. But I repeat myself. -- Mark Twain
Re: [flexcoders] Custom ItemEditor too big for container
Ok, got it! I had to use some hard-coded values, which I'm not fond of doing, but I can live with it :) Here's the function I used: private function adjustEditorOffset(e:ListEvent):void { var tree:Tree = Tree(e.currentTarget); var treeBottomY:int = tree.y + tree.height; tree.editorYOffset = (treeBottomY - tree.mouseY < 200) ? -155 : 5; } The 200 is the height of my item editor, and the -155 is just from trial and error as to what looked good :) This seems to do the trick just fine. On Dec 6, 2007 2:27 PM, Ken Dunnington <[EMAIL PROTECTED]> wrote: > I'm afraid that didn't do it. I'm going to try intercepting the > itemEditBegin event and check the position of the item clicked and adjust > the editorYOffset property on the Tree... does that sound right? Of course, > I now need to learn how to figure out the item's position :) > > > On Dec 6, 2007 1:03 PM, Alex Harui <[EMAIL PROTECTED]> wrote: > > >variableRowHeight? > > > > > > ------ > > > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of > > *Ken Dunnington > > *Sent:* Wednesday, December 05, 2007 11:47 AM > > *To:* flexcoders@yahoogroups.com > > *Subject:* [flexcoders] Custom ItemEditor too big for container > > > > > > > > I've built a custom Tree ItemEditor that consists of a VBox with a Form > > in it. It works just fine (besides the CheckBox which is too picky about > > "true" vs. true in the XML data...) except when I try to edit an item near > > the bottom of the container, the editor gets cut off. Because I wanted it to > > only occupy the smallest necessary space, I set the following properties on > > the Tree control: editorHeightOffset="150" editorWidthOffset="-650", and > > there is no width or height set for the ItemEditor. > > > > What's the best way to ensure that my custom editor won't occupy a huge > > amount of space, but will stay on-screen as well? I tried setting > > verticalScrollPolicy to "on" but it doesn't register as an increase in the > > control's height, so the bars don't activate when the editor is off the > > screen. > > > > > > > > > > -- > Suppose you were an idiot. And suppose you were a member of congress. But > I repeat myself. > -- Mark Twain -- Suppose you were an idiot. And suppose you were a member of congress. But I repeat myself. -- Mark Twain
Re: [flexcoders] IViewCursor.findAny on a typed object?
Considering I had to look that up, probably not. :) The docs say -optimize is true by default, or are you talking about something besides the compiler arg? I'll have to try again tonight, as for some reason the SWF isn't connecting to the debugger - my other projects connect without issue, so I'll try it on my home computer, where I'm doing active development on this project. On Tue, Mar 11, 2008 at 12:59 AM, Alex Harui <[EMAIL PROTECTED]> wrote: >Is your project set to optimize? We should be seeing line numbers for > the ListCollectionView classes as well, which is what I want to know. > > > -- > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Ken Dunnington > *Sent:* Monday, March 10, 2008 7:27 PM > *To:* flexcoders@yahoogroups.com > *Subject:* Re: [flexcoders] IViewCursor.findAny on a typed object? > > > > Sure thing: > > TypeError: Error #1009: Cannot access a property or method of a null > object reference. > at > mx.collections::ListCollectionView/http://www.adobe.com/2006/flex/mx/internal::findItem > () > at ListCollectionViewCursor/findAny() > at com.rpmchallenge.view.PlayerParts::Transport/updateSong > ()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/view/PlayerParts/Transport.mxml:211] > at mx.binding.utils::ChangeWatcher/wrapHandler() > at flash.events::EventDispatcher/dispatchEventFunction() > at flash.events::EventDispatcher/dispatchEvent() > at > com.rpmchallenge.model::ModelLocator/setselectedTrack()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/model/ModelLocator.as:25] > at com.rpmchallenge.view::Main/updateSelectedTrack > ()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/view/Main.mxml:68] > at flash.events::EventDispatcher/dispatchEventFunction() > at flash.events::EventDispatcher/dispatchEvent() > at mx.core::UIComponent/dispatchEvent() > at mx.controls.listClasses::ListBase/mouseDoubleClickHandler() > > As you can see, I'm using a ChangeWatcher to dispatch a > PropertyChangeEvent on my model. Currently, there is only 1 view from which > I'm creating my IViewCursor, but in the finished app, there will be many. > The object being watched on the model is an instance variable of the model, > so I'm not sure if it equals the same object in memory as the selected > object in the view. > > On Mon, Mar 10, 2008 at 2:33 AM, Alex Harui <[EMAIL PROTECTED]> wrote: > > Use a debug build and post the entire stack trace with line numbers. > > > -- > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Ken Dunnington > *Sent:* Sunday, March 09, 2008 8:28 PM > *To:* flexcoders@yahoogroups.com > > > *Subject:* [flexcoders] IViewCursor.findAny on a typed object? > > > > I'm having trouble getting the findAny() method to work on a simple typed > object. I've applied a single-field sort on my ListCollectionView, and the > object I'm trying to find is in the view, but findAny() always returns an > error of: TypeError: Error #1009: Cannot access a property or method of a > null object reference. This error is thrown by the > ListCollectionView.findItem() method. I haven't dug out the source yet, > but I'm hoping someone can shed some light on how this method is supposed to > work. Here is the code I'm trying: > > private function updateSong(e:PropertyChangeEvent):void { > var _track:PlaylistItem = e.newValue as PlaylistItem; > // Look for the track in the playlist > if (playlistCursor.findAny(_track)) { > track = playlistCursor.current as PlaylistItem; > play(); > } > } > > I've also tried looping over the view, using simple comparison (==) and I > can get the item's index, but I don't know how to update the cursor's > position without using the findxxx() methods! > > -- > The American Republic will endure until the day Congress discovers that it > can bribe the public with the public's money. > -- Alexis de Tocqueville > > > > > -- > The American Republic will endure until the day Congress discovers that it > can bribe the public with the public's money. > -- Alexis de Tocqueville > > -- The American Republic will endure until the day Congress discovers that it can bribe the public with the public's money. -- Alexis de Tocqueville
Re: [flexcoders] IViewCursor.findAny on a typed object?
Okay, when it rains it pours... I cannot get the source lookup to work in the debugging view. I've manually set the source lookup to the "Flex Builer 3 Plug-in/sdks/3.0.0/frameworks/projects/framework/src" directory with "search subfolders" turned on, but none of the framework classes are available for viewing through the debugger (and thus no line numbers show up in the stack trace.) I've reinstalled the FB3 plugin to no avail. This has worked in the past, but I can't recall when it stopped as I didn't use the feature much. I can't figure out why this is happening, but now it's making it difficult to debug my original issue. Any ideas how I can reconnect the framework source to Flex Builder? On Tue, Mar 11, 2008 at 10:21 AM, Ken Dunnington <[EMAIL PROTECTED]> wrote: > Considering I had to look that up, probably not. :) The docs say -optimize > is true by default, or are you talking about something besides the compiler > arg? > > I'll have to try again tonight, as for some reason the SWF isn't > connecting to the debugger - my other projects connect without issue, so > I'll try it on my home computer, where I'm doing active development on this > project. > > > On Tue, Mar 11, 2008 at 12:59 AM, Alex Harui <[EMAIL PROTECTED]> wrote: > > >Is your project set to optimize? We should be seeing line numbers > > for the ListCollectionView classes as well, which is what I want to know. > > > > > > -- > > > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > > Behalf Of *Ken Dunnington > > *Sent:* Monday, March 10, 2008 7:27 PM > > *To:* flexcoders@yahoogroups.com > > *Subject:* Re: [flexcoders] IViewCursor.findAny on a typed object? > > > > > > > > Sure thing: > > > > TypeError: Error #1009: Cannot access a property or method of a null > > object reference. > > at > > mx.collections::ListCollectionView/http://www.adobe.com/2006/flex/mx/internal::findItem > > () > > at ListCollectionViewCursor/findAny() > > at com.rpmchallenge.view.PlayerParts::Transport/updateSong > > ()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/view/PlayerParts/Transport.mxml:211] > > at mx.binding.utils::ChangeWatcher/wrapHandler() > > at flash.events::EventDispatcher/dispatchEventFunction() > > at flash.events::EventDispatcher/dispatchEvent() > > at > > com.rpmchallenge.model::ModelLocator/setselectedTrack()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/model/ModelLocator.as:25] > > at com.rpmchallenge.view::Main/updateSelectedTrack > > ()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/view/Main.mxml:68] > > at flash.events::EventDispatcher/dispatchEventFunction() > > at flash.events::EventDispatcher/dispatchEvent() > > at mx.core::UIComponent/dispatchEvent() > > at mx.controls.listClasses::ListBase/mouseDoubleClickHandler() > > > > As you can see, I'm using a ChangeWatcher to dispatch a > > PropertyChangeEvent on my model. Currently, there is only 1 view from which > > I'm creating my IViewCursor, but in the finished app, there will be many. > > The object being watched on the model is an instance variable of the model, > > so I'm not sure if it equals the same object in memory as the selected > > object in the view. > > > > On Mon, Mar 10, 2008 at 2:33 AM, Alex Harui <[EMAIL PROTECTED]> wrote: > > > > Use a debug build and post the entire stack trace with line numbers. > > > > > > -- > > > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > > Behalf Of *Ken Dunnington > > *Sent:* Sunday, March 09, 2008 8:28 PM > > *To:* flexcoders@yahoogroups.com > > > > > > *Subject:* [flexcoders] IViewCursor.findAny on a typed object? > > > > > > > > I'm having trouble getting the findAny() method to work on a simple > > typed object. I've applied a single-field sort on my ListCollectionView, and > > the object I'm trying to find is in the view, but findAny() always returns > > an error of: TypeError: Error #1009: Cannot access a property or method of a > > null object reference. This error is thrown by the > > ListCollectionView.findItem() method. I haven't dug out the source yet, > > but I'm hoping someone can shed some light on how this method is supposed to > > work. Here is the code I'm trying: > > > > private function updateSong(e:PropertyChangeEvent):void { > > var _track:PlaylistItem = e.newV
Re: [flexcoders] IViewCursor.findAny on a typed object?
Just wanted to follow this up with the solution. After chasing dead ends for awhile (and learning more about the inner workings of ListCollectionView,) I finally realized that (duh) I wasn't calling refresh() on the view after setting my sorts! I'm using Uday Shankar's excellent CGrid component, and I thought there was a sort applied inside that, but I was wrong. That's what I get for coding at night I guess :) Still having problems with seeing framework source in the debug view, but I'll post that in another topic. On Tue, Mar 11, 2008 at 11:55 PM, Ken Dunnington <[EMAIL PROTECTED]> wrote: > Okay, when it rains it pours... I cannot get the source lookup to work in > the debugging view. I've manually set the source lookup to the "Flex Builer > 3 Plug-in/sdks/3.0.0/frameworks/projects/framework/src" directory with > "search subfolders" turned on, but none of the framework classes are > available for viewing through the debugger (and thus no line numbers show up > in the stack trace.) I've reinstalled the FB3 plugin to no avail. This has > worked in the past, but I can't recall when it stopped as I didn't use the > feature much. > > I can't figure out why this is happening, but now it's making it difficult > to debug my original issue. Any ideas how I can reconnect the framework > source to Flex Builder? > > > On Tue, Mar 11, 2008 at 10:21 AM, Ken Dunnington <[EMAIL PROTECTED]> > wrote: > > > Considering I had to look that up, probably not. :) The docs say > > -optimize is true by default, or are you talking about something besides the > > compiler arg? > > > > I'll have to try again tonight, as for some reason the SWF isn't > > connecting to the debugger - my other projects connect without issue, so > > I'll try it on my home computer, where I'm doing active development on this > > project. > > > > > > On Tue, Mar 11, 2008 at 12:59 AM, Alex Harui <[EMAIL PROTECTED]> wrote: > > > > >Is your project set to optimize? We should be seeing line numbers > > > for the ListCollectionView classes as well, which is what I want to know. > > > > > > > > > -- > > > > > > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] > > > *On Behalf Of *Ken Dunnington > > > *Sent:* Monday, March 10, 2008 7:27 PM > > > *To:* flexcoders@yahoogroups.com > > > *Subject:* Re: [flexcoders] IViewCursor.findAny on a typed object? > > > > > > > > > > > > Sure thing: > > > > > > TypeError: Error #1009: Cannot access a property or method of a null > > > object reference. > > > at > > > mx.collections::ListCollectionView/http://www.adobe.com/2006/flex/mx/internal::findItem > > > () > > > at ListCollectionViewCursor/findAny() > > > at com.rpmchallenge.view.PlayerParts::Transport/updateSong > > > ()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/view/PlayerParts/Transport.mxml:211] > > > at mx.binding.utils::ChangeWatcher/wrapHandler() > > > at flash.events::EventDispatcher/dispatchEventFunction() > > > at flash.events::EventDispatcher/dispatchEvent() > > > at > > > com.rpmchallenge.model::ModelLocator/setselectedTrack()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/model/ModelLocator.as:25] > > > at com.rpmchallenge.view::Main/updateSelectedTrack > > > ()[/Users/ken/dev/Jukebox/src/com/rpmchallenge/view/Main.mxml:68] > > > at flash.events::EventDispatcher/dispatchEventFunction() > > > at flash.events::EventDispatcher/dispatchEvent() > > > at mx.core::UIComponent/dispatchEvent() > > > at mx.controls.listClasses::ListBase/mouseDoubleClickHandler() > > > > > > As you can see, I'm using a ChangeWatcher to dispatch a > > > PropertyChangeEvent on my model. Currently, there is only 1 view from > > > which > > > I'm creating my IViewCursor, but in the finished app, there will be many. > > > The object being watched on the model is an instance variable of the > > > model, > > > so I'm not sure if it equals the same object in memory as the selected > > > object in the view. > > > > > > On Mon, Mar 10, 2008 at 2:33 AM, Alex Harui <[EMAIL PROTECTED]> wrote: > > > > > > Use a debug build and post the entire stack trace with line numbers. > > > > > > > > > -- > > > > > > *From:* flexcoders@yahoogroups.com [mailto:[EMAI
[flexcoders] Binding Model to selectedItem property not updating
I'm currently refactoring a small application to be more MVC and am running into a few binding issues. In my Model, I store all my dataProviders, which are Arrays (because they will not change) and I also have a typed object that stores my form state as individual objects. In my View, which is mostly a bunch of ComboBoxes, I have set the dataProvider to bind to the arrays in the Model, and set the selectedItem to bind to the form state properties. I added a button which will update the form state for one of the properties when clicked, which works (the ComboBox updates to the expected value) the first time, but not on subsequent clicks. I've attached a listener to the valueCommit event on the ComboBox, and it does fire the first time. I've tried changing the Model to use ArrayCollections instead, and used the Collection API to try and update the selectedItem (by setting the form state model to the value of a getItem() call) but that isn't working either. Is there a better way to handle storing and binding form state in a well designed Flex app? I'm not using a framework, and don't really want to at this point in time (the app is fairly small, and the deadline is approaching quickly.) Any help or insight is greatly appreciated! - Ken Code snippets: The ComboBox: The function called to update the ComboBox (works on first click only): private function updateAge():void { model.quotingFormState.age = model.ageList[5]; }
Re: [flexcoders] Binding Model to selectedItem property not updating
Thanks Alex, I realized continuously setting the value to ageList[5] was pointless since it didn't change, and I made my form state model extend EventDispatcher, which made it possible to listen for propertyChange events being fired. But I am still trying to find information on the best way to handle binding a form's state in a more MVC style. Do I need to attach listeners to each of my form controls to manually update the state in my model each time the form changes? If my form control's selectedItem is bound to that same state model, will that cause an infinite loop of bindings firing one after the other? I've been unable to find examples of binding a form to a model beyond the very simple (and tightly coupled) examples in the Flex docs, or of two-way binding in general. On Fri, May 16, 2008 at 2:14 PM, Alex Harui <[EMAIL PROTECTED]> wrote: >If the value of model.ageList[5] does not change, no change event will > be fired, and if quotingFormState doesn't dispatch change events for changes > to the "age" property binding won't work then either. > > -- > *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On > Behalf Of *Ken Dunnington > *Sent:* Friday, May 16, 2008 8:19 AM > *To:* flexcoders@yahoogroups.com > *Subject:* [flexcoders] Binding Model to selectedItem property not > updating > > I'm currently refactoring a small application to be more MVC and am > running into a few binding issues. > > In my Model, I store all my dataProviders, which are Arrays (because they > will not change) and I also have a typed object that stores my form state as > individual objects. In my View, which is mostly a bunch of ComboBoxes, I > have set the dataProvider to bind to the arrays in the Model, and set the > selectedItem to bind to the form state properties. I added a button which > will update the form state for one of the properties when clicked, which > works (the ComboBox updates to the expected value) the first time, but not > on subsequent clicks. I've attached a listener to the valueCommit event on > the ComboBox, and it does fire the first time. > > I've tried changing the Model to use ArrayCollections instead, and used the > Collection API to try and update the selectedItem (by setting the form state > model to the value of a getItem() call) but that isn't working either. > > Is there a better way to handle storing and binding form state in a well > designed Flex app? I'm not using a framework, and don't really want to at > this point in time (the app is fairly small, and the deadline is approaching > quickly.) > > Any help or insight is greatly appreciated! > - Ken > > Code snippets: > > The ComboBox: > > > > > selectedItem="{model.quotingFormState.age}" /> > > > > > The function called to update the ComboBox (works on first click only): > > private function updateAge():void { > > model.quotingFormState.age = model.ageList[5]; > > } > > > -- The American Republic will endure until the day Congress discovers that it can bribe the public with the public's money. -- Alexis de Tocqueville
Re: [flexcoders] Binding Model to selectedItem property not updating
Thanks Pedro,I know of Cairngorm but unfortunately don't have time to factor it in on this project. I think I'll sort of fudge it with some BindingUtils calls for now, and start using a framework on the next app. :) I'm very interested in trying out Mate (http://mate.asfusion.com/) On Fri, May 16, 2008 at 3:11 PM, Pedro Sena <[EMAIL PROTECTED]> wrote: > Hi Ken, > > Do you know the Cairngorm framework ? > > It does what you want, and in this link you will find some intersting > tutorials: > > http://www.davidtucker.net/category/cairngorm/ > > C ya > > On Fri, May 16, 2008 at 3:54 PM, Ken Dunnington <[EMAIL PROTECTED]> > wrote: > >> Thanks Alex, I realized continuously setting the value to ageList[5] >> was pointless since it didn't change, and I made my form state model extend >> EventDispatcher, which made it possible to listen for propertyChange events >> being fired. >> >> But I am still trying to find information on the best way to handle >> binding a form's state in a more MVC style. Do I need to attach listeners to >> each of my form controls to manually update the state in my model each time >> the form changes? If my form control's selectedItem is bound to that same >> state model, will that cause an infinite loop of bindings firing one after >> the other? I've been unable to find examples of binding a form to a model >> beyond the very simple (and tightly coupled) examples in the Flex docs, or >> of two-way binding in general. >> >> On Fri, May 16, 2008 at 2:14 PM, Alex Harui <[EMAIL PROTECTED]> wrote: >> >>>If the value of model.ageList[5] does not change, no change event >>> will be fired, and if quotingFormState doesn't dispatch change events for >>> changes to the "age" property binding won't work then either. >>> >>> -- >>> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On >>> Behalf Of *Ken Dunnington >>> *Sent:* Friday, May 16, 2008 8:19 AM >>> *To:* flexcoders@yahoogroups.com >>> *Subject:* [flexcoders] Binding Model to selectedItem property not >>> updating >>> >>> I'm currently refactoring a small application to be more MVC and am >>> running into a few binding issues. >>> >>> In my Model, I store all my dataProviders, which are Arrays (because they >>> will not change) and I also have a typed object that stores my form state as >>> individual objects. In my View, which is mostly a bunch of ComboBoxes, I >>> have set the dataProvider to bind to the arrays in the Model, and set the >>> selectedItem to bind to the form state properties. I added a button which >>> will update the form state for one of the properties when clicked, which >>> works (the ComboBox updates to the expected value) the first time, but not >>> on subsequent clicks. I've attached a listener to the valueCommit event on >>> the ComboBox, and it does fire the first time. >>> >>> I've tried changing the Model to use ArrayCollections instead, and used >>> the Collection API to try and update the selectedItem (by setting the form >>> state model to the value of a getItem() call) but that isn't working either. >>> >>> Is there a better way to handle storing and binding form state in a well >>> designed Flex app? I'm not using a framework, and don't really want to at >>> this point in time (the app is fairly small, and the deadline is approaching >>> quickly.) >>> >>> Any help or insight is greatly appreciated! >>> - Ken >>> >>> Code snippets: >>> >>> The ComboBox: >>> >>> >>> >>> >> >>> selectedItem="{model.quotingFormState.age}" /> >>> >>> >>> >>> >>> The function called to update the ComboBox (works on first click only): >>> >>> private function updateAge():void { >>> >>> model.quotingFormState.age = model.ageList[5]; >>> >>> } >>> >>> >> >> >> -- >> The American Republic will endure until the day Congress discovers that it >> can bribe the public with the public's money. >> -- Alexis de Tocqueville >> > > > > -- > /** > * Pedro Sena > * System Architect > * Sun Certified Java Programmer > * Sun Certified Web Component Developer > */ > > > -- The American Republic will endure until the day Congress discovers that it can bribe the public with the public's money. -- Alexis de Tocqueville
[flexcoders] How to tell when background image is clicked?
I've got a custom component based on Canvas, and I'm programmatically setting its background-image style to a loaded SWF. I need to be able to differentiate between a click on the background, and a click on any of the other children. WIth no background set, I was using this code: private function clickHandler (evt:MouseEvent):void { if (evt.target == this) { setFocus(); dispatchEvent(new CanvasEvent(CanvasEvent.CLEAR_FOCUS)); } } WIth a background-image, however, this no longer works. I've also tried listening for the target phase, but the event never actually reaches the canvas object. I do have a separate ICollectionView instance containing all the other children, but I'd like to avoid having to use that for this handler, if possible.
Re: [flexcoders] Re: How to tell when background image is clicked?
Hi Tim, unfortunately, that's exactly what happens :) If you apply a backgroundImage, the target of the click event will be the FlexLoader instance for that image, or in the case of a SWF, it'll be the actual SWF instance. To make matters worse, the background image is (as far as I've been able to tell) indistinguishable from a regular child, in that it counts towards numChildren's value, returns true on contains() and owns() etc. I'm looking through the SDK source to try to find exactly where it's added and how it manages to stay behind everything, but this is certainly puzzling. - Ken On Tue, Mar 17, 2009 at 2:36 PM, Tim Hoff wrote: > Hi Ken, > > I'm pretty sure that the target will never be the background image itself; > but rather the Canvas. One hack is to check the type: > > if (evt.target is Canvas) > > -TH > > > --- In flexcoders@yahoogroups.com, Ken Dunnington > wrote: > > > > I've got a custom component based on Canvas, and I'm programmatically > > setting its background-image style to a loaded SWF. I need to be able to > > differentiate between a click on the background, and a click on any of > the > > other children. WIth no background set, I was using this code: > > > > private function clickHandler (evt:MouseEvent):void > > > > { > > > > if (evt.target == this) > > > > { > > > > setFocus(); > > > > dispatchEvent(new CanvasEvent(CanvasEvent.CLEAR_FOCUS)); > > > > } > > > > } > > > > > > WIth a background-image, however, this no longer works. I've also tried > > listening for the target phase, but the event never actually reaches the > > canvas object. I do have a separate ICollectionView instance containing > all > > the other children, but I'd like to avoid having to use that for this > > handler, if possible. > > > > >
Re: [flexcoders] Re: How to tell when background image is clicked?
I'm afraid that doesn't do it either - the problem is, a Canvas with a backgroundImage style set will never be the target of a click event, the backgroundImage will always get in the way. I think I'm going to have to refactor the whole thing at this point... On Tue, Mar 17, 2009 at 3:51 PM, Tim Hoff wrote: > Ok, maybe just check it's type: > > if (evt.target is FlexLoader) > > -TH > > --- In flexcoders@yahoogroups.com, Ken Dunnington > wrote: > > > > Hi Tim, unfortunately, that's exactly what happens :) > > If you apply a backgroundImage, the target of the click event will be the > > FlexLoader instance for that image, or in the case of a SWF, it'll be the > > actual SWF instance. To make matters worse, the background image is (as > far > > as I've been able to tell) indistinguishable from a regular child, in > that > > it counts towards numChildren's value, returns true on contains() and > owns() > > etc. I'm looking through the SDK source to try to find exactly where it's > > added and how it manages to stay behind everything, but this is certainly > > puzzling. > > - Ken > > > > On Tue, Mar 17, 2009 at 2:36 PM, Tim Hoff timh...@... wrote: > > > > > Hi Ken, > > > > > > I'm pretty sure that the target will never be the background image > itself; > > > but rather the Canvas. One hack is to check the type: > > > > > > if (evt.target is Canvas) > > > > > > -TH > > > > > > > > > --- In flexcoders@yahoogroups.com, Ken Dunnington ken.dunnington@ > > > wrote: > > > > > > > > I've got a custom component based on Canvas, and I'm programmatically > > > > setting its background-image style to a loaded SWF. I need to be able > to > > > > differentiate between a click on the background, and a click on any > of > > > the > > > > other children. WIth no background set, I was using this code: > > > > > > > > private function clickHandler (evt:MouseEvent):void > > > > > > > > { > > > > > > > > if (evt.target == this) > > > > > > > > { > > > > > > > > setFocus(); > > > > > > > > dispatchEvent(new CanvasEvent(CanvasEvent.CLEAR_FOCUS)); > > > > > > > > } > > > > > > > > } > > > > > > > > > > > > WIth a background-image, however, this no longer works. I've also > tried > > > > listening for the target phase, but the event never actually reaches > the > > > > canvas object. I do have a separate ICollectionView instance > containing > > > all > > > > the other children, but I'd like to avoid having to use that for this > > > > handler, if possible. > > > > > > > > > > > > > > > > > >
[flexcoders] NativeDragEvents require MouseEvent listener?
I've just come across a really strange bug (at least I hope it's a bug, as it seems like bad behavior to me.) - Subclass a Canvas in an ActionScript component - Add listeners for NativeDragEvent.NATIVE_DRAG_ENTER and NATIVE_DRAG_DROP (make the listeners simply trace a confirmation message) - Place the new component in an AIR app and see if the listeners fire. In my test, and in an app I'm working on, they don't. Now, add another listener for any MouseEvent (i.e. CLICK). This listener doesn't have to do anything, but relaunch the app and - suddenly - the NativeDragEvent listeners fire! It doesn't matter if you include flash.events.MouseEvent, or if you make a reference to a MouseEvent object (to ensure it's compiled in) - you have to have the listener registered or it won't work. Can anyone verify this so I know I'm not going crazy? :) Or even better, can anyone explain this behavior? I'm using Flex SDK 3.3. Thanks, - Ken
[flexcoders] ItemRenderer unscaledHeight = NaN?
I've got a fairly simple custom itemRenderer inside a TileList that's giving me problems. The renderer is simply an HBox with an Image and a few Label controls. The problem is the renderers all show up squished at the top of the list, piled on top of each other. I've overridden updateDisplayList() and can see that unscaledWidth is being set properly, but unscaledHeight is always NaN. I've set the width and height explicity in the renderer, as well as set columnWidth and rowHeight in the TileList. I've also set maxColumns, since I need it to be limited to 2 columns (side question: does columnCount do anything in a TileList?) I've tried converting the renderer to a Canvas, overriding measure(), tried every combination of width/height/columnWidth/rowHeight settings, but nothing seems to work. The highlights show up in the TileList where they should be, but none of the renderers display properly. I think the problem has to be in the TileList, as I've tried using the built in renderer, and that also screws up. Has anybody ever seen anything like this before? I've used TileLists in the past, and never had this problem. I'm using AIR 1.5, and the TileList is rendering itself properly (if I set a background color, I can see it occupies the proper space.) - Ken
Re: [flexcoders] Custom Classes and Custom Events
Take a look at some of the classes in the mx.events.* package. Generally, your custom events will have static constants to enumerate the possible values for 'type', i.e. public static const ADD_RECORD:String = "addRecordEvent"; public static const DELETE_RECORD:String = "deleteRecordEvent"; To attach data to an event, for example the record to delete, you would have a property on the event. public var record:RecordVO; Then, in your button's click handler, you would create a new instance of your custom event, attach the record you want to act on to it, and dispatch it. If you want to keep your components more loosely coupled (and you should) you would have your buttons announce an event simply stating "Delete the currently selected record" and have your business logic located elsewhere that would figure out what record to delete (ex. the currently selected item in the datagrid.) For a simple app, and since you're just getting started, you could place the listeners in your top-level Application MXML file. Have it subscribe to the DELETE_RECORD etc. events on the buttons, and act accordingly. Again, when you get further along, you'll want to move this business logic elsewhere, but I'll leave that up to you :) HTH, - Ken On Tue, Mar 24, 2009 at 9:23 AM, secrit.service wrote: > Hi all, > > The last couple of weeks I wrote my first application in Flex. Today I want > to refactor it, meaning : using custom classes and custom events. > > I have following : > > I created an application with a couple of buttons and with a custom > component (myCustomComp) in it. This custom component is based on a Vbox an > contains : > - an HBox (mySearchbar) with a textfield and button > - a datagrid which contains data from a database > - an HBox (myToolbar) with a button and a label > > The buttons are used for adding, modifying and deleteing records of > the database. SO I was thinking of creating a custom event (myCustomEvent). > > The code I have so far is following : > > *package events { > > import flash.events.Event; > > public class myCustomEvent extends Event { > > public function SpellEvent(type:String) { > super(type); > } > >override public function clone():Event{ > var evt:myCustomEvent = new myCustomEvent(type); > return evt; > } > > } > > } > * > I was thinking of adding event listners to my buttons. For example my > button to add a new record will have a addRecordEventListener. In this > listener I create a new instance of myCustEvent and pass my new record as a > parameter. > The same I will do with my button to delete a record. > > My question is where and how I should make the difference between the 2 > operations. > I suppose I have to create a new instance of my event and besides my new > record I also need to pass the type of operation : something like *new > myCustomEvent(newRecord, "addRecord") *or *new myCustomEvent(newRecord, > "deleteRecord")*. But in this case, how do I process the different > operations? > > I'm lost and hoping for a clear answer. > > Thanks > > >
[flexcoders] ShaderFilter drawing outside bounds
I'm applying some pixel bender shaders to photos in an app I'm building, and I'd like to keep them constrained to the original shape of my photo. However, when I rotate the photo, the filter draws outside the bounds. I've tried applying a mask, but the filter ignores it. Is there any way to keep pixel bender filters (or I suppose any bitmap filter) from drawing outside the bounds of the object they're being applied to?
Re: [flexcoders] Binding not executed
Bindings do a lot of checking to try and prevent getting stuck in infinite loops, perhaps that's causing your issue? You might instead try using a property on the parent component that your sub components bind to, i.e. [Bindable] private var someProperty:String; On Wed, Mar 25, 2009 at 10:19 PM, reflexactions wrote: > In a form I have component1/propertyA bound to component2/propertyA > which is bound to form1/propertyB. > > What I expcted to happen is I set propertyB which triggers to binding to > set propertyA on component2 which then triggers the binding to set property > A on component1. > > What actually happens is I set propertyB it triggers the binding to set > propertyA on component2 and it stops there. component1 never gets triggered. > > I have used default events simply marking the properties [Bindable], I have > also tried using custom events and whenI dispatch the change event in > component2 nothing happens, component1 never gets trigged. > > Any thoughts on why? > > Does binding ignore events whilst it is setting a property? > > >
[flexcoders] AIR: Security sandbox violation: PNG trying to access .swf?
Hi all, I'm getting some bizarre security errors in an AIR app, and I can't for the life of me make any sense of them. The most reproducible error looks like this: *** Security Sandbox Violation *** SecurityDomain 'file:///private/var/folders/8J/8J8HEVvxHMy7RVKw4iIqcE+++TI/TemporaryItems/FlashTmp0' tried to access incompatible context 'app:/Main.swf' What's happening in the app is I'm taking a snapshot of part of the screen, then saving it to a temporary file until needed. Thing is, I don't get this error actually writing or reading the file, I get it after the file has been written, and I start scrolling a HorizontalList component that is completely unrelated to the thumbnail snapshot. I get it every time I click the scrollbar, but not while dragging. The error doesn't trigger the debugger, it just shows up in the console. What the heck is going on? I don't even know how it would be possible for this error to be generated as 'FlashTemp0' is just a PNG, not a SWF! What's more, often after these errors occur, switching states in my app will fail, and the UI will vanish (and by 'fail', I of course mean that no errors are generated and remaining pieces of the UI still partially work, but the app is now in an unusable state.) Sorry if this post is vague on details, this app is near the end of development, so I don't even know where to begin in terms of pasting example code. - Ken
[flexcoders] Nested ADG height/scroll question
I'm building an app which utilizes nested ADGs to provide a drill down interface to my data. It works great in concept, but the problem I'm up against is trying to size the datagrids so they display all their rows, forcing any rows below them to move down (without creating any unnecessary space.) Basically, I just want to avoid scrollbars, except on the parent ADG. I'm just not quite sure where to start looking - is this a style thing, or should I be overriding measure/updateDisplaylist to handle this?