Re: [flexcoders] Re: Getting parent information from AdvancedDataGrid
Amy, You can't put the same object in your dataProvider twice. This is an error for DataGrid and AdvancedDataGrid. They use the UID to create Object-based hashes for various purposes. If you put the same object in there twice, the grid won't function properly. Here are two articles, one for each grid, that explain this (although, I think you've figured this out, I thought I'd post anyway for others): AdvancedDataGrid highlights wrong row with duplicate data: http://jonathanbranam.net/solutions/advanceddatagrid-highlights-wrong-row http://tinyurl.com/5kzjge DataGrid highlights wrong row with duplicate data: http://jonathanbranam.net/solutions/datagrid-highlights-wrong-row http://tinyurl.com/55hzhu Also, the UIDUtil class will only add an mx_internal_uid property to your data if you are using dynamic classes (like Object, Array, or a custom dynamic class). If you're using a strongly typed VO or XML, the method of storing the UID is different. You can read about it in the UIDUtil article here: http://jonathanbranam.net/flex3anatomy/class/UIDUtil http://tinyurl.com/6crwey -Jonathan http://jonathanbranam.net - Flex 3 Anatomy Solutions On Sat, Jun 28, 2008 at 3:59 PM, Amy [EMAIL PROTECTED] wrote: --- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote: Sorry, this thread is one of the ones I am following for my own education. It is beyond my current experience. I found that my code wasn't adding the UID where I thought it was. When the HierarchicalCollection called the UIDUtil class, the UIDUtil class saw that my component was an IUID but had a null UID and set a UID on it. This suggests that it should have also been adding a mx_internal_uid to my old class that did not implement IUID, but I could never get at it. In retrospect, I'm not really sure how much good it would have done for it to do that, since it was always the _same_ instance that it would have been added to. Somewhere in the asdoc comments of one of the classes I stepped through to find this was a comment to the effect that two references to the identical object shouldn't have worked in the first place. So, in summary, I think that the HierarchicalCollection _can't_ handle this situation, because to do so it would have to make the same instance different, which is why I needed to do something to wrap the same instance in different instances of another class. Live and learn. At this rate my head will explode by mid July. -Amy -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
Re: [flexcoders] Setting up custom component listener
Jason, applicationComplete is dispatched as soon as the SWF has finished preloading, just after it has put the application on the display list, and nothing else. I would use creationComplete for something like this. I don't think there is any concern that the user will be able to interact with the component before creationComplete fires. -Jonathan http://jonathanbranam.net - Flex Anatomy Solutions On Mon, Jun 30, 2008 at 9:14 PM, Merrill, Jason [EMAIL PROTECTED] wrote: Such a stupid question. I am trying to assign a listener to a custom component. It broadcasts a simple event. Here is a dumbed-down version of the code I am using: mx:Application applicationComplete=init() xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:c=com.project.components.* mx:Script ![CDATA[ private function init():void { myComponent.addEventListner(myEvent, onMyEvent); } private function onMyEvent():void { trace(onMyEvent heard.) } ]] /mx:Script c:MyComponent id=myComponent/ /mx:Application !--Here is a simplified version of the component: -- !--com/project/components/MyComponent.mxml: -- mx:Canvas xmlns:mx=http://www.adobe.com/2006/mxml; mx:Script ![CDATA[ import flash.events.EventDispatcher; import flash.events.Event; private function broadcastClicked():void { dispatchEvent(new Event(myEvent)) } ]] /mx:Script mx:Checkbox click=broadcastClicked()/ /mx:Canvas However, I get a runtime error for the init() event that myComponent is null. I would have thought that calling it on applicationComplete would ensure that the instance of my component was there. Why not and how instead do I add the listener for it? Thankya Jason Merrill ***Bank of America * Global Technology Operations Global Risk LLD eTools Multimedia *Join the Bank of America Flash Platform Developer Community* *Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal * *GTO Innovative Learning Blog** * * subscribe*.
Re: [flexcoders] RadioButton change event not firing in Flex 3 when button in group is deselected
You should use svn diff. I usually do it from within Eclipse. It has a command called Create a Patch or something. But I think just: svn diff patch.txt will work. On Fri, Jun 27, 2008 at 1:22 AM, Josh McDonald [EMAIL PROTECTED] wrote: The problem's in RadioButtonGroup, I've posted the details to the bug. Alex, I've got Contrib permission, but the submit a patch document just talks about TortoiseSVN. Is the patch file I need to submit simply: diff /path/to/checkout/foo.as /path/to/new/foo.as mypatch.diff Just using standard BSD Diff (OS X)? Or have I got the operands in the wrong order, or is it not standard diff at all? -Josh RadioButton.click simply calls out to group.selection On Fri, Jun 27, 2008 at 2:31 PM, Alex Harui [EMAIL PROTECTED] wrote: It looks like it was done to prevent events for programmatic changes to .selected which would be correct, but the RBG programmatically unselects an RB and this code now prevents an event which probably should fire. -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Josh McDonald *Sent:* Thursday, June 26, 2008 3:44 PM *To:* flexcoders@yahoogroups.com *Subject:* Re: [flexcoders] RadioButton change event not firing in Flex 3 when button in group is deselected It makes more sense to me to be for Radiobutton than Checkbox. Why on earth would you not want to get a change event when a checkbox is unchecked? -Josh On Fri, Jun 27, 2008 at 2:48 AM, Samuel Neff [EMAIL PROTECTED] wrote: Thanks for confirming. Bug filed. https://bugs.adobe.com/jira/browse/SDK-15918 Best regards, Sam - We're Hiring! Seeking passionate Flex, C#, or C++ (RTSP, H264) developer in the Washington D.C. Contact [EMAIL PROTECTED] On Thu, Jun 26, 2008 at 11:51 AM, Alex Harui [EMAIL PROTECTED] wrote: That's what I figured, just wanted to confirm. I still think the change (which was for CheckBox) had unintended consequences in RadioButton, so file a bug. __._,_ -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]
Re: [flexcoders] Which event is dispatched when the view is shown by a stage change?
Hey João, Posted online with SWF and View Source: http://jonathanbranam.net/node/56 http://jonathanbranam.net/solutions/detect-state-addchild There are two solutions that I've found to work in this case. This first is to add a new public method to the component called activate() and then call it from a handler on the enterStatehttp://jonathanbranam.net/flex3anatomy/event/enterStateEvent. The second is to listen to the addedToStage http://jonathanbranam.net/flashphysiology/event/addedToStageand updateComplete http://jonathanbranam.net/flex3anatomy/event/updateCompleteevents, set a flag in addedToStage http://jonathanbranam.net/flashphysiology/event/addedToStagethat you check in updateComplete http://jonathanbranam.net/flex3anatomy/event/updateCompleteto run your initialization. Here is the code, example app, and more detailed explanation. You can view the example on a separate pagehttp://jonathanbranam.net/files/src/detect-state-addchild/DetectStateAddChild.htmland view the source (View Source doesn't work in the embedded SWF below due to a bug in Flex Builder). Explanation: The first solution is easy and should be solid. The enterStatehttp://jonathanbranam.net/flex3anatomy/event/enterStateEvent fires after the component has been added to the stage (not during the operation), so it is safer to access subcomponents. The method, however, does not guarantee that the component has been fully updated yet. The downside to this is adding more coupling between the Statehttp://jonathanbranam.net/flex3anatomy/class/Stateand the component. 1. mx:State name=solution1 2. mx:enterState 3. sol1.activate(); 4. /mx:enterState 5. mx:RemoveChild target={noState}/ 6. mx:AddChild 7. local:Solution1VBox id=sol1/ 8. /mx:AddChild 9. /mx:State The code in the component is equally obvious: 1. public function activate():void 2. { 3. ti.setFocus(); 4. } 1. mx:Label text=Solution 1/ 2. mx:TextInput text=No focus here!/ 3. mx:TextInput id=ti text=Focus here!/ The second solution relies on the behavior of the Statehttp://jonathanbranam.net/flex3anatomy/class/StateAddChild operation. AddChild is true to its name, it will add and remove the component from the display list. This means that the addedhttp://jonathanbranam.net/flashphysiology/event/added, addedToStage http://jonathanbranam.net/flashphysiology/event/addedToStage, removed http://jonathanbranam.net/flashphysiology/event/removed, and removedFromStagehttp://jonathanbranam.net/flashphysiology/event/removedFromStagemethods will fire when the state is entered and exited. The trouble is that the component has not been fully created when these events fire. The solution I present here is to set a flag when the component has been added to the stage so that the component knows that it needs to run its activation code again: 1. protected var addedToStage:Boolean = false; 2. protected function addedToStageHandler(event:Event):void 3. { 4. if (event.target == this) { 5. addedToStage = true; 6. } 7. } The next part of the solution uses the updateCompletehttp://jonathanbranam.net/flex3anatomy/event/updateCompleteevent to trigger the activation code. If the addedToStage code has run since the most recent update, then we run the activation code. 1. protected var addedToStage:Boolean = false; 2. protected function addedToStageHandler(event:Event):void 3. { 4. if (event.target == this) { 5. addedToStage = true; 6. } 7. } Note that updateCompletehttp://jonathanbranam.net/flex3anatomy/event/updateCompletefires every time the component is invalidated through something like invalidateDisplayList(). I put a button in the component so you can trigger updateComplete http://jonathanbranam.net/flex3anatomy/event/updateComplete. If you remove the check for addedToStage, then invalidating the component will run the activation code again, which is not the desired behavior. See the article on updateCompletehttp://jonathanbranam.net/flex3anatomy/event/updateCompletefor more information about this event. 1. mx:Label text=Solution 2/ 2. mx:TextInput text=No focus here!/ 3. mx:TextInput id=ti text=Focus here!/ 4. mx:Button label=Invalidate Component click= invalidateDisplayList()/ I'm not sure which solution I like better. The first is more direct and should be more resistant to changes in implementation or functionality. If you move from using AddChild to toggling visibility, then you can still call the activate() method from the enterStatehttp://jonathanbranam.net/flex3anatomy/event/enterStateEvent. However, this type of change will break the second solution. Ultimately, there isn't a single, reliable event that will tell your component it has now become viewable so you have to code up
Re: [flexcoders] Repeater not repeating
How would you do that, exactly? How could your extended ArrayCollection know the Array had changed? It's just not possible. On Fri, Jun 27, 2008 at 1:05 PM, Joseph Balderson [EMAIL PROTECTED] wrote: You could always extend ArrayCollection so that the extended-AC notifies its bound objects when its Array source changes. It depends whether you want the code change made to the 'source' of the data (in which case you'd update the AC, not the Array, as Tom mentioned), or the 'destination' (change the source Array on extended-AC). ___ Joseph Balderson, Flash Platform Developer | http://joeflash.ca Tom McNeer wrote: Jonathan, Thanks very much for your clear and thorough explanation. One of the major difficulties of discussing matters like this, of course, is semantics. Many common words we might use to describe apparent actions - like update or refresh -- have such specific meanings within the context of Flex -- often naming specific methods, in fact -- that someone like me, who is relatively new to Flex and ActionScript, may misspeak (and mislead) by referring to things incorrectly. I understand that the key concept is whether an object knows that something has happened. I mistakenly thought that the AC knew that its source had changed, but the Repeater didn't know that the AC had changed. You've straightened me out: the AC didn't know its source had changed, and therefore didn't communicate to any other object. The easiest solution is to use the AC directly to change the data. Thanks. I understand. I'll have to think about whether that's appropriate in this case, since a change in the source array would actually be generated by the addition of an object from a wholly different area of the app. But you've given me more understanding, and a good rule of thumb: when something doesn't appear to be updating, it probably hasn't been told to. -- Thanks, Tom Tom McNeer MediumCool http://www.mediumcool.com 1735 Johnson Road NE Atlanta, GA 30306 404.589.0560 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
Re: [flexcoders] RadioButton change event not firing in Flex 3 when button in group is deselected
I found the command line tools to compile the Flex SDK to be very speedy for the amount of code it's working with. I just use eclipse for editing and SVN. It really doesn't take much time at all. Its FB3 that's apparently so slow. Either that or the framework code is easier to compile than my app, because it certainly has more code in it. I would recommend getting familiar with building the Flex SDK from source if you're planning to submit patches. On Fri, Jun 27, 2008 at 10:15 AM, Josh McDonald [EMAIL PROTECTED] wrote: Not using eclipse' SVN, I hate it :) I went with regular old diff. I can always re-submit it again some time, but I'm not recompiling the whole source since that'd take weeks (exaggerating only a little), Flex's compiler ain't quick. I'm just monkey-patching changes into my test-project source tree. On Sat, Jun 28, 2008 at 12:07 AM, Jonathan Branam [EMAIL PROTECTED] wrote: You should use svn diff. I usually do it from within Eclipse. It has a command called Create a Patch or something. But I think just: svn diff patch.txt will work. On Fri, Jun 27, 2008 at 1:22 AM, Josh McDonald [EMAIL PROTECTED] wrote: The problem's in RadioButtonGroup, I've posted the details to the bug. Alex, I've got Contrib permission, but the submit a patch document just talks about TortoiseSVN. Is the patch file I need to submit simply: diff /path/to/checkout/foo.as /path/to/new/foo.as mypatch.diff Just using standard BSD Diff (OS X)? Or have I got the operands in the wrong order, or is it not standard diff at all? -Josh RadioButton.click simply calls out to group.selection On Fri, Jun 27, 2008 at 2:31 PM, Alex Harui [EMAIL PROTECTED] wrote: It looks like it was done to prevent events for programmatic changes to .selected which would be correct, but the RBG programmatically unselects an RB and this code now prevents an event which probably should fire. -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Josh McDonald *Sent:* Thursday, June 26, 2008 3:44 PM *To:* flexcoders@yahoogroups.com *Subject:* Re: [flexcoders] RadioButton change event not firing in Flex 3 when button in group is deselected It makes more sense to me to be for Radiobutton than Checkbox. Why on earth would you not want to get a change event when a checkbox is unchecked? -Josh On Fri, Jun 27, 2008 at 2:48 AM, Samuel Neff [EMAIL PROTECTED] wrote: Thanks for confirming. Bug filed. https://bugs.adobe.com/jira/browse/SDK-15918 Best regards, Sam - We're Hiring! Seeking passionate Flex, C#, or C++ (RTSP, H264) developer in the Washington D.C. Contact [EMAIL PROTECTED] On Thu, Jun 26, 2008 at 11:51 AM, Alex Harui [EMAIL PROTECTED] wrote: That's what I figured, just wanted to confirm. I still think the change (which was for CheckBox) had unintended consequences in RadioButton, so file a bug. __._,_ -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]
Re: [flexcoders] Re: Repeater not repeating
And what would be the point of that? You can use an ArrayCollection as a substitute for Array in just about any situation and it will take care of the problem. If he could swap the original Array for a different class, just swap it for ArrayCollection and be done. That's what I would recommend anyway. If you extend Array to dispatch events on changes then you just wrote ArrayCollection again. It would support the methods on Array that aren't on ArrayCollection. This is assuming you can override the [] access using the flash_proxy methods, but I'm not sure if that works Array isn't a subclass of Proxy but it overrides their behavior. I'm not sure if you can do this or if its just magic (ie Flash internals)? On Fri, Jun 27, 2008 at 2:37 PM, Amy [EMAIL PROTECTED] wrote: --- In flexcoders@yahoogroups.com, Jonathan Branam [EMAIL PROTECTED] wrote: How would you do that, exactly? How could your extended ArrayCollection know the Array had changed? It's just not possible. Extend Array as well...? -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
Re: [flexcoders] Re: Styling AdvancedDataGridItemRenderer
Hi Amy, I'm trying to follow along, but you've asked several questions now! Setting the alpha property should work based on a simple test that I did. As I look at your code, though, I think you have some confusion between the alpha *property* and an alpha *style*. The alpha property is from Flash and indeed you cannot see the source to it. It does appear to apply correctly to Flex components and their skins. However, if you have a style called alpha that does not affect the alpha property (unless you have coded this connection). OK. I think I see the problem. ADGItemRenderer extends UITextField which is not a rendering component. The flexpearls post notes this, but doesn't really get into the implications. The inheritance tree is: UITextField FlexTextField TextField InteractiveObject DisplayObject. Therefore, a UITextField doesn't have a graphics property (only descendants of Shape and Sprite do), nor is it a DisplayObjectContainer. This means you cannot use the drawing API or addChild(). Looking at the livedocs for TextField, it doesn't appear to support alpha for background, so this is probably just not possible. If you set the Flash alpha property, it might fade the background, but it will also fade the text (if you have it embedded). The alpha property is almost never used in Flex components. Although I don't know why, I would steer away from it for that reason. I would recommend forgetting about ADGItemRenderer. It is a very optimized class that only displays text. Subclass something else and do your background manipulation there. You can make a fairly simple subclass of Label that is still pretty lightweight and supports rowColor and rowAlpha (if you add the drawing yourself). This is about as simple as I could get. You should keep all the nice code you have about initializing styles and all that, of course! [Style(name=rowColor)] [Style(name=rowAlpha)] public class ADGItemRendererBackgroundAlpha extends Label { override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); // Don't get styles this way in real code! graphics.beginFill(getStyle(rowColor), getStyle(rowAlpha)); graphics.drawRect(0,0,unscaledWidth, unscaledHeight); textField.setActualSize(unscaledWidth, unscaledHeight); } } On Thu, Jun 26, 2008 at 9:40 AM, Amy [EMAIL PROTECTED] wrote: --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Amy [EMAIL PROTECTED] wrote: I'm trying to extend AdvancedDataGridItemRenderer to allow the styleFunction to set both the backgroundColor and the alpha of the item in. I've used a combination of the custom style example in the docs and the example here http://flexpearls.blogspot.com/2008/02/row- background-color-in.html. The problem I'm having is that it doesn't matter what you set the alpha property to, it doesn't affect the visual appearance of the component. I tried using the graphics object to draw the box, but it seems like the base component doesn't support this. If anyone has any ideas, please share. I suppose I should feel flattered that I've asked a question that is so hard that no one here can answer it. Let me try again...maybe someone knows the answer to just this piece of it and if I know that I can perhaps find a fix: Why is it that setting the alpha property on the component does not modify the visual appearance of this class? I've really tried to figure this out myself, but the inheritance trail disappears into the Flash classes, and I haven't been able to find the source of those. Thanks! Amy
Re: [flexcoders] Repeater not repeating
Tom, It sounds like you are changing the contents of configArray? The ArrayCollection will not notice if you manipulate the underlying Array after the ArrayCollection has been created. You can either manipulate the ArrayCollection directly, or reset the source property on the ArrayCollection after you have changed the Array. Calling refresh() on the ArrayCollection does not fix the problem. For example, this works: mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ [Bindable] protected var a:Array = []; ]] /mx:Script mx:creationComplete ![CDATA[ a.push({a:one}); ac.source = ac.source; // reassign the source property to trigger a reset ]] /mx:creationComplete mx:ArrayCollection id=ac source={a}/ mx:DataGrid dataProvider={ac}/ /mx:Application -Jonathan http://jonathanbranam.net - Flex 3 Anatomy and Solutions On Thu, Jun 26, 2008 at 10:31 AM, Tom McNeer [EMAIL PROTECTED] wrote: I need to have a repeater iterate over an array, displaying an instance of a custom component for each iteration. However, for testing, I am simply attempting to output a button with a static label within the repeater. Here's the basic code on the repeater: mx:ArrayCollection id=configAC source={estimate.configArray}/ mx:VBox width=100% id=configDisplay mx:Repeater dataProvider={configAC} id=configRepeater mx:Button label=D'oh / /mx:Repeater /mx:VBox Setting a breakpoint after the array is populated, I can see that: a) the original array (estimate.configArray) is populated with a single member, a custom ActionScript object. Length is 1, there is an object of the correct type at position 0. b) the array collection with the original array as source (configAC) shows the same contents. c) the dataprovider on the repeater, which is the array collection, shows the correction contents, an AC with a length of 1. d) the currentItem in the repeater shows the correct object from the AC. Yet the contents of the repeater, which should just be a simple button, do not display. I'm mystified. So I must be missing something simple. -- Thanks, Tom Tom McNeer MediumCool http://www.mediumcool.com 1735 Johnson Road NE Atlanta, GA 30306 404.589.0560
Re: [flexcoders] Repeater not repeating
Right. The data is there, that's not exactly the problem. The problem is that, although the data is there, the Repeater wasn't told that new data was available. It already looped through the data once when it was empty and it needs to be told that the data has changed. It listens to CollectionEvents and updates itself. Reassigning the source property is maybe the most accurate way to get the result, but it looks like calling refresh() on the ArrayCollection will trigger the Repeater to recreate its contents (FYI: This would NOT work for DataGrid). Repeater treats all CollectionEvents as equivalent except update which it ignores. As for currentItem, when you access that property the getter method will actually seek into the Collection if it hasn't been initialized yet, so accessing currentItem effectively sets the currentItem (and currentIndex) but it doesn't trigger creation of subcomponents. On Thu, Jun 26, 2008 at 11:48 AM, Tom McNeer [EMAIL PROTECTED] wrote: Jonathan, Thanks for the reply. The ArrayCollection will not notice if you manipulate the underlying Array after the ArrayCollection has been created Thanks. I understand that. But in debugging, I have confirmed that the ArrayCollection does contain the correct contents of the Array -- that the DataProvider in the Repeater also contains those contents -- and that the CurrentItem in the Repeater contains the correct contents. Could it be that the Repeater itself is not detecting the change from an empty AC to a populated one and not refreshing itself, even though its DataProvider is refreshed, because it's bound? Do I need to do something like call invalidateLayout() on the Repeater? -- Thanks, Tom Tom McNeer MediumCool http://www.mediumcool.com 1735 Johnson Road NE Atlanta, GA 30306 404.589.0560
Re: [flexcoders] Repeater not repeating
Tom, Sure. It is confusing. I think the concept of the AC being updated and refreshed is the problem. I'd like to help you understand, because it will prevent future frustration! Your quote: I assumed (obviously incorrectly) that if the source of the AC was updated, and the contents of the AC refreshed (as was happening), the AC would dispatch some event that would alert bound objects (in this case, the Repeater) of the change. Specifically: contents of the AC refreshed (as was happening) The contents of the AC *is* the Array. So, when you change the Array, you are immediately changing the contents of the AC. There is no delay, no refresh, no update. It immediately changes and the AC immediately reflects those changes. If you do array.push(mydata) then ac.length it WILL be longer. And something like ac.getItemAt(ac.length-1) will immediately return mydata. Therefore, if you inspect the AC's source in the debugger it will always be up-to-date. The AC doesn't make a copy and it never has stale data. However, the AC itself does not know that its data has changed. If you call ac.addItem(mydate) then the AC knows that its data has changed. Only when the AC knows its data has changed does it dispatch any events. When you change the contents of the Array that the AC uses as source, it has no idea you've made any changes. Thus, any components using the AC are also not alerted to any changes. So, if a different event were to cause the component to loop through the AC again, it would see the new data. The trick is finding an event that does this reliably and repeatably. The easiest solution is to use the AC directly to change the data. Manipulating the AC will always update components that listen to events on the AC. On Thu, Jun 26, 2008 at 1:43 PM, Tom McNeer [EMAIL PROTECTED] wrote: First, Amy, thanks for your suggestion. I had already done this, although it wasn't clear from my note. Jonathan, Thanks for your explanation, and for the solution. Calling refresh() correctly alerts the Repeater. What I guess I don't understand is that the ArrayCollection was always correctly being updated -- I could see the values in the debugger. But even though the Collection was updated, it wasn't informing the Repeater. I assumed (obviously incorrectly) that if the source of the AC was updated, and the contents of the AC refreshed (as was happening), the AC would dispatch some event that would alert bound objects (in this case, the Repeater) of the change. Clearly, I have a lot to learn about the way events propagate from various changes. -- Thanks, Tom Tom McNeer MediumCool http://www.mediumcool.com 1735 Johnson Road NE Atlanta, GA 30306 404.589.0560
Re: [flexcoders] Re: Styling AdvancedDataGridItemRenderer
There are a bunch of comments below, but to sum up, it seems like extending AdvancedDataGridGroupItemRenderer and drawing a background with the graphics property will meet all of your needs. I missed the requirement to preserve leaf icons and such. Is there a reason this doesn't meet your needs, because you seem to have known this already? [Style(name=rowColor)] [Style(name=rowAlpha)] public class ADGGroupItemRendererBackgroundAlpha extends AdvancedDataGridGroupItemRenderer { override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); graphics.clear(); // Don't get styles this way in real code! //graphics.beginFill(getStyle(rowColor), getStyle(rowAlpha)); graphics.beginFill(0x5566FF, 0.3); graphics.drawRect(0,0,unscaledWidth, unscaledHeight); } } Which I did. Just to back up a bit, the goal was to allow the styleFunction to set the color and the amount that you could see the rollover or selection indicator when the row was colored. I guess I missed this. You can set the color already, from the flexpearls article. Adjusting the rollover or selection indicator is a different matter altogether. But nothing I tried actually affected the alpha, until finally I changed the blendMode, which allowed the change to be visible, but both the text and the background, which wasn't the effect I was looking for, especially since it didn't match the AdvancedDataGridGroupItemRenderer, which descends from UIComponent and behaves sensibly. Right. Changing the blendMode alters the way that Flash decides to render the component. You should find that setting cacheAsBitmap to true will have the same effect. When you apply a blend to a DisplayObject Flash renders it to a bitmap internally and then applies the blend to the bitmap. Because the component is now rendered as a bitmap it will honor the alpha property on its contents in a way that it would not previously. Actually, I couldn't get cacheAsBitmap or blendMode to do this to the AdvancedDataGridItemRenderer. I had to add a filter, which did it immediately. Maybe another feature of TextFields. It actually does, which is why it has an alpha property. The secret is that you either have to embed the font or change the blend mode, otherwise it stubbornly refuses to show any changes you make to the property. As explained above, when you cause the component to be rendered as a bitmap then it will begin to behave differently, such as honoring the alpha property when it normally would not, because it is using a non-embedded font. Of course, embedding the font also allows the alpha to be set. But, as I understood your question, you wanted to change the alpha of just the background. What I said was that the component does not appear to support that operation. All DisplayObjects have an alpha property, but text components don't honor its setting in the same way. I would recommend forgetting about ADGItemRenderer. It is a very optimized class that only displays text. And also icons... The problem is that I don't properly understand how it draws the leaf icon, so I am reluctant to mess with it too much. My explorations in the source code didn't leave me any the wiser about this. Right. It actually doesn't display icons so it isn't in the source code. For example, this does not display leaf icons nor does it indent the renderer: mx:AdvancedDataGrid id=adg dataProvider={hd} width=100% height=100% mx:columns mx:AdvancedDataGridColumn itemRenderer=mx.controls.advancedDataGridClasses.AdvancedDataGridItemRenderer dataField=title/ /mx:columns /mx:AdvancedDataGrid This only applies to the first column, however. Do you only have one column? If you want leaf icons and such (maybe I missed that), you need to subclass AdvancedDataGridGroupItemRenderer. That will draw the icons just fine for you and, as you mentioned, it is a subclass of UIComponent and you can draw a background on it just fine. Ultimately, I abandoned my attempts to gain control over the alpha of the background and opted for something that allowed me to see the rollover in a reasonably attractive manner--setting blendMode on both itemRenderer classes to DARKEN. I may have to change the mode on that once I get the real styleFunction working rather than just a placeholder that returns back yellow to everything. I'll probably just add a style that sets the blendMode, so I can adjust it based on the color needed. I wish the docs would point out these limitations so that people can estimate time needed to accomplish tasks better. If you read the docs, it sounds like this task should be a walk in the park. Well... it's tough for Adobe. They could use the richest classes everywhere so that customizing them is easier, but performance and memory would suffer. They usually seem to favor being very efficient in the
Re: [flexcoders] viewSourceURL is getting overridden ??
I'm having the same problem. The Export Release Build dialog always resets the value. This is breaking View Source when I embed into a page that doesn't have the flex source directly in it. As the value is encoded into the SWF (I think) there doesn't seem to be a way to fix this after the fact. Maybe it's a bug? There is probably a way to Export Release Build using the command line tools that probably doesn't have this feature of rewriting viewSourceURL. Can anyone give us a pointer on that command. Thanks, -Jonathan http://jonathanbranam.net On Sun, Jun 22, 2008 at 11:51 PM, luvfotography [EMAIL PROTECTED] wrote: How do I set viewSourceURL? Everytime that I edit the value, it gets overridden when I 'export release build' and select source files. it gets set to: viewSourceURL=srcview/index.html I would like to change this to: viewSourceURL=mydir/srcview/index.html thanks,
Re: [flexcoders] How to filter HierarchicalCollectionView????
moonrchand, (Also posted at http://jonathanbranam.net/solutions/filter-hierarchicalcollectionview-parent-child-datawith SWF and source code): Any function applied to the filterFunction of HierarchicalCollectionViewhttp://jonathanbranam.net/flex3anatomy/class/HierarchicalCollectionViewis applied to all of the elements in the collection. It can filter items at different levels of the hierarchy as long as the method itself understands the hierarchy. You can view the example on a separate pagehttp://jonathanbranam.net/files/src/filter-hierarchy/FilterHierarchicalCollectionView.htmland view the source (View Source doesn't work in the embedded SWF below due to a bug in Flex Builder). This is the definition of the AdvancedDataGridhttp://jonathanbranam.net/flex3anatomy/class/AdvancedDataGrid. Nothing special here: 1. mx:AdvancedDataGrid id=adg 2. dataProvider={hd} 3. width=100% height=100% 4. mx:columns 5. mx:AdvancedDataGridColumn 6. dataField=title/ 7. /mx:columns 8. /mx:AdvancedDataGrid The filter function is applied like this: 1. // Set the filter function and refresh the collection view. 2. adg.hierarchicalCollectionView.filterFunction = myFilter; 3. adg.hierarchicalCollectionView.refresh(); And it uses the CheckBoxes defined here to enable and disable its operation: 1. mx:CheckBox id=tParents label=Parents that start with 'T' change=criteriaChanged()/ 2. mx:CheckBox id=fourChildren label=Parents with at least four children change=criteriaChanged()/ 3. mx:CheckBox id=adChild label=Children named 'A' or 'D' change =criteriaChanged()/ Finally, here is the filter code. This would be simpler if you have a single filter you need to apply, but the example shows some dynamic behavior. The filter should return true for any item that is included in the display, and false otherwise. Notice that if you return false for a parent item, then it and all of its children will be filtered out. If you return true for a parent item, then you can still filter its children. 1. protected function myFilter(item:Object):Boolean 2. { 3. var title:String = item.title.toString(); 4. 5. // If the tParent filter is selected and this item it a parent 6. if (tParents.selected item.parent) { 7. // Then fail if the name doesn't start with a T. 8. if (title.substr(0,1).toUpperCase() != T) { 9. return false; 10. } 11. } 12. 13. // If the fourParent filter is selected and this item is a parent 14. if (fourChildren.selected item.parent) { 15. // Then fail if the parent doesn't have at least four children. 16. if (item.children.length 4) { 17. return false; 18. } 19. } 20. 21. // if the adChild filter is selected and this is a child (not a parent) 22. if (adChild.selected !item.parent) { 23. // Then fail if the child is not an A or a D 24. if (title.toUpperCase() != A title.toUpperCase() != D) { 25. return false; 26. } 27. } 28. 29. // Either all filters are disabled, or they all passed (or don't apply to this node) 30. return true; 31. } To filter a parent based on the data in its children, you simply have to process the children when the filter is asked about the parent. There must be some way for you to perform this operation on the parent. In this case, I have simply added a property to the parent object called parent and set it to true. There is nothing special about this property. You could also check the children property for null or check its length. In many cases, you will have a typed object that is the parent that is different than the type of the children. Explanation HierarchicalCollectionViewhttp://jonathanbranam.net/flex3anatomy/class/HierarchicalCollectionViewapplies the filterFunction to the main data source and also to all of the open nodes in the hierarchy. When you apply a filter function and then refresh the list (don't forget the filter isn't applied until you call refresh()), it loops through all the open nodes and sets the filterFunction property and calls refresh() on each of them. Closed nodes are not processed until they are open. When the HierarchicalCollectionViewhttp://jonathanbranam.net/flex3anatomy/class/HierarchicalCollectionViewopens a node, it applies the filterFunction set on itself to the node. This will wipe out any filters you may have tried to set yourself, which is one reason why you can only have a single filter on the entire hierarchy. I have an example SWF on the site as well as the source code for the example. This is my first attempt to post the copy-paste HTML, so I hope the formatting comes out OK.
Re: [flexcoders] Re: uint unset value
Amy, When you get the value of the style, you need to store it in an untyped variable. This will allow you to check for undefined. If you store the value in an int, uint or Boolean, for example, it will be converted from undefinedto the default value of that type (0, 0, or false, respectively). var myStyle:* = getStyle(myStyle); if (myStyle == undefined) { myStyle = 42; // appropriate default } var myStyleUntyped:* = getStyle(myStyle); var myStyle:int = 42; // appropriate default if (myStyle != undefined) { myStyle = myStyleUntyped; } You could also store the value in a variable typed Object. In my testing, I found that this stores null instead of undefined because an Object cannot be undefined. Only an untyped variable or an nonexistent property can be undefined. Actionscript has strict rules about what values can be assigned to variables of specific types. The undefined and null values, in particular, cannot be assigned to many of the basic types. Only an untyped variable can be undefined and only variables that represent classes which are descendants of Object can be null. Numeric variables such as int and uint always have a value. The Number type can be NaN, but is never null or undefined. The String type can be null, but not undefined. The Boolean type must always be true or false and is never null or undefined. These rules help limit the number of edge cases in the language and the impact of uninitialized variables, but can also be confusing. -Jonathan (Posted online at http://jonathanbranam.net/solutions/check-unset-styles) Short link: http://jonathanbranam.net/node/51 http://jonathanbranam.net - Flex 3 Anatomy and Solutions On Wed, Jun 25, 2008 at 4:13 PM, Amy [EMAIL PROTECTED] wrote: --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Hi, try using isNaN() if (isNaN(_myColor)){ //do something when NaN }else{ //do another thing when is a color } I actually wound up just comparing straight to the getStyle() result and comparing that to undefined, since that's what it is when it isn't set. I haven't been able to find any examples that show different ways of dealing with keywords, etc., so I figured that was the safest way. And thanks :-) -Amy
Re: [flexcoders] How do YOU do functional testing and automation package questions
Matt, is this actually the case today? Has anyone else been able to confirm this? I can't find the flex 2 automation packages in Flex Builder 3 Beta 2 or 3. At least, I can't find the automation_agent.swc. -- Forwarded message -- From: Matt Chotin [EMAIL PROTECTED] Date: Dec 10, 2007 11:26 AM Subject: RE: [flexcoders] How do YOU do functional testing and automation package questions To: flexcoders@yahoogroups.com Note that you can get the automation extensions for 2.0.1 by downloaded the Flex Builder 3 beta (they're included in the 2.0.1 SDK). From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Neil Curzon Sent: Monday, December 10, 2007 6:22 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] How do YOU do functional testing and automation package questions Hi all. I've been trying to add some automated functional testing to our flex app. I found FunFX, a functional test framework for flex built in ruby. This page ( http://peternic.blogspot.com/2007/11/funfx-getting-started.html) directed me to install the automation package, which claims that you can use it with LCDS or Express LCDS. However, it demands a license key to install, and the Express version of LCDS seems to just install by not entering a key. (ie if you have only Express LCDS, it seems you can't actually install the automation package). Any suggestions? We are in the process of upgrading to Flex 3, but in the short term this isn't an option. I'm curious as to what other people are using for functional testing their Flex apps. Some searching reveals that Selenium can be extended fairly easily for Flex testing, and google indicates that several people have in-house Selenium extensions, but none of these appear to have been contributed back yet. I'm partway through a proof of concept for selenium testing (I have JavaScript finding buttons in my Flex app), but this FunFX seems to have a lot of work done that I'd have to repeat. Any pointers would be appreciated! Thanks Neil
Re: [flexcoders] How do YOU do functional testing and automation package questions
And those will work with Flex 2 projects? That's the question. I see the files for Flex 3... I assumed they were incompatible. On Jan 18, 2008 2:11 PM, Matt Chotin [EMAIL PROTECTED] wrote: They're in sdks/3.0.0/frameworks/libs Matt *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Jonathan Branam *Sent:* Friday, January 18, 2008 9:01 AM *To:* flexcoders@yahoogroups.com *Subject:* Re: [flexcoders] How do YOU do functional testing and automation package questions Matt, is this actually the case today? Has anyone else been able to confirm this? I can't find the flex 2 automation packages in Flex Builder 3 Beta 2 or 3. At least, I can't find the automation_agent.swc. -- Forwarded message -- From: Matt Chotin [EMAIL PROTECTED] Date: Dec 10, 2007 11:26 AM Subject: RE: [flexcoders] How do YOU do functional testing and automation package questions To: flexcoders@yahoogroups.com Note that you can get the automation extensions for 2.0.1 by downloaded the Flex Builder 3 beta (they're included in the 2.0.1 SDK). From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Neil Curzon Sent: Monday, December 10, 2007 6:22 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] How do YOU do functional testing and automation package questions Hi all. I've been trying to add some automated functional testing to our flex app. I found FunFX, a functional test framework for flex built in ruby. This page ( http://peternic.blogspot.com/2007/11/funfx-getting-started.html ) directed me to install the automation package, which claims that you can use it with LCDS or Express LCDS. However, it demands a license key to install, and the Express version of LCDS seems to just install by not entering a key. (ie if you have only Express LCDS, it seems you can't actually install the automation package). Any suggestions? We are in the process of upgrading to Flex 3, but in the short term this isn't an option. I'm curious as to what other people are using for functional testing their Flex apps. Some searching reveals that Selenium can be extended fairly easily for Flex testing, and google indicates that several people have in-house Selenium extensions, but none of these appear to have been contributed back yet. I'm partway through a proof of concept for selenium testing (I have JavaScript finding buttons in my Flex app), but this FunFX seems to have a lot of work done that I'd have to repeat. Any pointers would be appreciated! Thanks Neil
Re: [flexcoders] Tabbing to an HBox
There is a special marker interface that a component must implement in order to receive focus from tabbing. Since those components don't extend that interface, they don't get into the tab order, I believe. The interface is mx.managers.IFocusManagerComponent. If you make a custom component that extends that interface, then setting focusEnabled and tabEnabled will have the desired effect. Of course, you won't be able to change the standard Flex components in this manner. -- Forwarded message -- From: Giles Roadnight [EMAIL PROTECTED] Date: Jan 18, 2008 7:15 AM Subject: Re: [flexcoders] Tabbing to an HBox To: flexcoders@yahoogroups.com And by the way, it doesn't work with a canvas either. On Jan 18, 2008 11:58 AM, Tom Chiverton [EMAIL PROTECTED] wrote: On Friday 18 Jan 2008, Giles Roadnight wrote: HBox set up as a button. This is unusual - why do this rather than use a (styled) Panel or other container ? -- Tom Chiverton Helping to continually industrialize attention-grabbing patterns on: http://thefalken.livejournal.com This email is sent for and on behalf of Halliwells LLP. Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A list of members is available for inspection at the registered office. Any reference to a partner in relation to Halliwells LLP means a member of Halliwells LLP. Regulated by The Solicitors Regulation Authority. CONFIDENTIALITY This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 2500. For more information about Halliwells LLP visit www.halliwells.com. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links http://groups.yahoo.com/group/flexcoders/ -- Giles Roadnight http://giles.roadnight.name
Re: [flexcoders] Re: setting effect to UI component
Well, it's not completely magic. It is just the [Effect] metadata tag. The Effect tag takes an event type and the framework will fire any effects specified when the corresponding event is fired from the component. It looks like this: [Effect(name=myCoolEffect, event=myCustomEvent)] So, you could add a new effect to an existing event as well, if there was some need for that: [Effect(name=clickEffect, event=click)] On Jan 18, 2008 11:47 AM, Jonathan Branam [EMAIL PROTECTED] wrote: -- Forwarded message -- From: Tom Chiverton [EMAIL PROTECTED] Date: Jan 18, 2008 9:48 AM Subject: Re: [flexcoders] Re: setting effect to UI component To: flexcoders@yahoogroups.com On Friday 18 Jan 2008, learner wrote: how the Flexbuilder understand resizeEffect as the one of the standered property of the UIcomponent or container, 'magic' :-) You can always read the source, along side the 'Developing' docs. -- Tom Chiverton Helping to dramatically build edge-of-your-seat markets on: http://thefalken.livejournal.com This email is sent for and on behalf of Halliwells LLP. Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A list of members is available for inspection at the registered office. Any reference to a partner in relation to Halliwells LLP means a member of Halliwells LLP. Regulated by The Solicitors Regulation Authority. CONFIDENTIALITY This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 2500. For more information about Halliwells LLP visit www.halliwells.com. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links
Re: [flexcoders] Drawn objects acting as children to components?
Instead of changing the height, which will not affect the size at all, you need to change the scaleX/scaleY properties: scaleX += .2; scaleY += .2; On Jan 18, 2008 3:03 PM, Merrill, Jason [EMAIL PROTECTED] wrote: Yeah, but for some reason when I do getBounds(this) and then re-size the panel, the drawn graphic can extend beyond the boundaries of the Panel. Also, zooming is tough because if I simply increase or decrease width and height, it seems to move the graphic instead of change it's size... public function zoomIn():void { height += 100; width += 100; updateDisplayList(unscaledWidth, unscaledHeight); } public function zoomOut():void { height -= 100; width -= 100; updateDisplayList(unscaledWidth, unscaledHeight); } Jason Merrill Bank of America GTO LLD Solutions Design Development eTools Multimedia Bank of America Flash Platform Developer Community -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Alex Harui *Sent:* Friday, January 18, 2008 1:42 PM *To:* flexcoders@yahoogroups.com *Subject:* RE: [flexcoders] Drawn objects acting as children to components? You want the bounds of what you drew, so getBounds(this) should be correct. If you set scaleX/Y to zoom, you shouldn't need to do anything. If you set scaleX/Y on an internal thing to zoom or in the case of the circle, multiply the radius by some zoom factor, then you have to report that new measuredWidth/Height in measure() and maybe call invalidateList if you have some property like zoomFactor that we're not already watching for changes -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Merrill, Jason *Sent:* Friday, January 18, 2008 10:36 AM *To:* flexcoders@yahoogroups.com *Subject:* RE: [flexcoders] Drawn objects acting as children to components? I thought the container reference was needed by the getBounds() method - it requires an argument of a UIComponent of some kind, I thought the custom component would need to know the new size of the container when it got re-sized. If I don't need the container reference, then maybe I could just say getBounds(this) instead and it would work. Also, I want to implement a method to scale the graphics up and down, I have that working, but I'm back to the graphic not being centered and not staying within the boundaries of the Panel container again when the zoom occurs. I tried calling updateDisplayList again when the zoom action happens, but that didn't work. Any thoughts there? Jason Merrill Bank of America GTO LLD Solutions Design Development eTools Multimedia Bank of America Flash Platform Developer Community -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Alex Harui *Sent:* Friday, January 18, 2008 12:10 PM *To:* flexcoders@yahoogroups.com *Subject:* RE: [flexcoders] Drawn objects acting as children to components? I think in the general case, you'll need to set minHeight/minWidth to zero or something small on the Panel or have fixed width/height on the Panel to get the Panel to consider putting up scrollbars. The graphics object should compute measuredMinWidth/measuredMinHeight to be the same as measuredWidht/Height so the Panel will not try to shrink it past its dimensions. If you can compute the measurements w/o drawing then you don't need commitProperties and just draw in updateDisplayList. I don't know why you need a container reference unless it is to get the bounds of the container to determine where to draw, but if you've set up % widht/height you'll be given those dimensions in updateDisplayList. -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Merrill, Jason *Sent:* Friday, January 18, 2008 7:02 AM *To:* flexcoders@yahoogroups.com *Subject:* RE: [flexcoders] Drawn objects acting as children to components? Hey Jim, passing minWidth and minHeight to the custom UI component worked perfectly for me - now the drawn graphic is contained in the Panel container - thank you! Jason Merrill Bank of America GTO LLD Solutions Design Development eTools Multimedia Bank of America Flash Platform Developer Community