[flexcoders] Re: simple array?
Two good points. I used an Array, as I wrote, to try to show how Jason might have done what he had initially intended using arrays. I didn't mean to suggest that that's how it would be best done. Sorry for confusion. I guess I just like the similarity of arrays and objects - something that is not seen in all languages. As for efficiency, I would probably go with static const int's (in lieu of enums) and use an array. This would require to iterating - just simple offset into array. Something like, static const PAYMENT_TYPE_AC:int = 0; static const PAYMENT_TYPE_RN:int = 1; static const PAYMENT_TYPE_CP:int = 2; static const PAYMENT_TYPE_CR:int = 3; static const PAYMENT_MESSAGES:Array = [ Remember to reset the station address., Remember to reset the station expiration date., Remember to contact contractor to remove the certificates from this station., Remember to cancel the refund payment. ]; If there are better ways, I am always happy to hear them. I am still pretty new to this Flex thing. -eric --- In flexcoders@yahoogroups.com, Charles Parcell pokemonkil...@... wrote: Additionally, utilizing a loop to locate an item can eat up cycles if the list of codes gets to be large. Granted that in the case of this example looping 3 or even 10 items is likely not going to be an issue in anyway. Something to think about if the application of this example is used differently. Charles P. On Fri, May 22, 2009 at 10:50 AM, Charles Parcell pokemonkil...@...wrote: Why even have the Array aspect in the second example? It stands as a pointless container for what we are seeing it used for. Unless there will be some additional items added to it that we have not seen yet. I just feel the need to point that out. :) Charles P. On Thu, May 21, 2009 at 3:49 PM, Eric Cooper e...@... wrote: I just tried compiling what I wrote - and realized that it didn't... so here are two variants. The first is same as previous, but it compiles. The second may be more in the spirit of what you were attempting initially - and kind of highlights similarities between arrays and objects. First: var records:Array = new Array( { code:AC, text:Remember to reset the station address. }, { code:RN, text:Remember to reset the station expiration date. }, { code:CP, text:Remember to contact contractor to remove the certificates from this station. }, { code:CR, text:Remember to cancel the refund payment. } ); for each (var test:Object in records) { if (grid.selectedItem.PAYMENT_TYPE_CODE == test.code) Alert.show(test.text ); } Second: var PAYMENT_TYPE_CODE:String = CR; var records:Array = new Array( { AC: Remember to reset the station address. }, { RN: Remember to reset the station expiration date. }, { CP: Remember to contact contractor to remove the certificates from this station. }, { CR: Remember to cancel the refund payment. } ); for (var i:int = 0; i records.length; ++i) { if (records[i][grid.selectedItem.PAYMENT_TYPE_CODE]) Alert.show(records[i][PAYMENT_TYPE_CODE]); } --- In flexcoders@yahoogroups.com, Jason B nospam@ wrote: SWEET thanks --- In flexcoders@yahoogroups.com, Eric Cooper eric@ wrote: How about this: var records:Array = new Array( { code:AC, text:Remember to reset the station address. }, { code:RN, text:Remember to reset the station expiration date. }, { code:CP, text:Remember to contact contractor to remove the certificates from this station. }, { code:CR, text:Remember to cancel the refund payment. }, ); for each(test:Object in records){ if(grid.selectedItem.PAYMENT_TYPE_CODE == test[i].code) Alert.show(test[i].text
[flexcoders] Re: simple array?
Two good points. I used an Array, as I wrote, to try to show how Jason might have done what he had initially intended using arrays. I didn't mean to suggest that that's how it would be best done. Sorry for confusion. I guess I just like the similarity of arrays and objects - something that is not seen in all languages. As for efficiency, I would probably go with static const int's (in lieu of enums) and use an array. This would require no iterating - just simple offset into array. Something like, static const PAYMENT_TYPE_AC:int = 0; static const PAYMENT_TYPE_RN:int = 1; static const PAYMENT_TYPE_CP:int = 2; static const PAYMENT_TYPE_CR:int = 3; static const PAYMENT_MESSAGES:Array = [ Remember to reset the station address., Remember to reset the station expiration date., Remember to contact contractor to remove the certificates from this station., Remember to cancel the refund payment. ]; If there are better ways, I am always happy to hear them. I am still pretty new to this Flex thing. -eric --- In flexcoders@yahoogroups.com, Charles Parcell pokemonkil...@... wrote: Additionally, utilizing a loop to locate an item can eat up cycles if the list of codes gets to be large. Granted that in the case of this example looping 3 or even 10 items is likely not going to be an issue in anyway. Something to think about if the application of this example is used differently. Charles P. On Fri, May 22, 2009 at 10:50 AM, Charles Parcell pokemonkil...@...wrote: Why even have the Array aspect in the second example? It stands as a pointless container for what we are seeing it used for. Unless there will be some additional items added to it that we have not seen yet. I just feel the need to point that out. :) Charles P. On Thu, May 21, 2009 at 3:49 PM, Eric Cooper e...@... wrote: I just tried compiling what I wrote - and realized that it didn't... so here are two variants. The first is same as previous, but it compiles. The second may be more in the spirit of what you were attempting initially - and kind of highlights similarities between arrays and objects. First: var records:Array = new Array( { code:AC, text:Remember to reset the station address. }, { code:RN, text:Remember to reset the station expiration date. }, { code:CP, text:Remember to contact contractor to remove the certificates from this station. }, { code:CR, text:Remember to cancel the refund payment. } ); for each (var test:Object in records) { if (grid.selectedItem.PAYMENT_TYPE_CODE == test.code) Alert.show(test.text ); } Second: var PAYMENT_TYPE_CODE:String = CR; var records:Array = new Array( { AC: Remember to reset the station address. }, { RN: Remember to reset the station expiration date. }, { CP: Remember to contact contractor to remove the certificates from this station. }, { CR: Remember to cancel the refund payment. } ); for (var i:int = 0; i records.length; ++i) { if (records[i][grid.selectedItem.PAYMENT_TYPE_CODE]) Alert.show(records[i][PAYMENT_TYPE_CODE]); } --- In flexcoders@yahoogroups.com, Jason B nospam@ wrote: SWEET thanks --- In flexcoders@yahoogroups.com, Eric Cooper eric@ wrote: How about this: var records:Array = new Array( { code:AC, text:Remember to reset the station address. }, { code:RN, text:Remember to reset the station expiration date. }, { code:CP, text:Remember to contact contractor to remove the certificates from this station. }, { code:CR, text:Remember to cancel the refund payment. }, ); for each(test:Object in records){ if(grid.selectedItem.PAYMENT_TYPE_CODE == test[i].code) Alert.show(test[i].text ); } would that do it? -eric --- In flexcoders@yahoogroups.com, Jason B nospam@ wrote: var records:Array = new Array({ AC: Remember to reset the station address., RN: Remember
[flexcoders] Re: simple array?
How about this: var records:Array = new Array( { code:AC, text:Remember to reset the station address. }, { code:RN, text:Remember to reset the station expiration date. }, { code:CP, text:Remember to contact contractor to remove the certificates from this station. }, { code:CR, text:Remember to cancel the refund payment. }, ); for each(test:Object in records){ if(grid.selectedItem.PAYMENT_TYPE_CODE == test[i].code) Alert.show(test[i].text ); } would that do it? -eric --- In flexcoders@yahoogroups.com, Jason B nos...@... wrote: var records:Array = new Array({ AC: Remember to reset the station address., RN: Remember to reset the station expiration date., CP: Remember to contact contractor to remove the certificates from this station., CR: Remember to cancel the refund payment. }); for each(test:Object in records){ //HERE we match up PAYMENT TYPE CODE with AC RN CP if one is a match we show the value if(grid.selectedItem.PAYMENT_TYPE_CODE == test[i]) Alert.show(SHOW ME ---Remember to reset the station address ); } datagrid hidden column AC, RN, CP are in datagrid user selects RT item from grid and hits button system match's that row with what message should be displayed user never see's RT since its a hidden field in grid user now see's a message displayed as a reminder --- In flexcoders@yahoogroups.com, Paul Andrews paul@ wrote: Jason, I'm not sure I follow exactly what the problem is now. Paul - Original Message - From: Jason B nospam@ To: flexcoders@yahoogroups.com Sent: Thursday, May 21, 2009 4:02 PM Subject: [flexcoders] Re: simple array? i want to loop the records and compare the value addresschange to the PAYMENT Type Code if its the right one display it --- In flexcoders@yahoogroups.com, Paul Andrews paul@ wrote: - Original Message - From: Jason B nospam@ To: flexcoders@yahoogroups.com Sent: Thursday, May 21, 2009 3:46 PM Subject: [flexcoders] Re: simple array? Thanks but i dont know how to do a compare based on your example show? for(var i:uint = 0; i records.length; i++) { //If array matchs show text if(payment_grid.selectedItem.PAYMENT_TYPE_CODE == records[i].addresschange){ Alert.show(records[i].addresschange); } } for(var i:uint = 0; i records.length; i++) { //If array matchs show text if(payment_grid.selectedItem.PAYMENT_TYPE_CODE == records.valueof ){ Alert.show(records[0].addresschange); } --- In flexcoders@yahoogroups.com, Pedro Sena sena.pedro@ wrote: records[0].addresschange You are putting an object inside your array Using records[0] you retrieve your object using records[0].addresschange you access its property called addresschange On Thu, May 21, 2009 at 11:14 AM, Jason B nospam@ wrote: var records:Array = new Array({ addresschange: Remember to reset the station address., etc. }); Alert.show(records['addresschange']); Alert.show(records[0]); Alert.show(records.addresschange); how the heck can i access the item directly by index name? -- /** * Pedro Sena * Systems Architect * Sun Certified Java Programmer * Sun Certified Web Component Developer */ -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Alternative FAQ location: https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
[flexcoders] Re: simple array?
I just tried compiling what I wrote - and realized that it didn't... so here are two variants. The first is same as previous, but it compiles. The second may be more in the spirit of what you were attempting initially - and kind of highlights similarities between arrays and objects. First: var records:Array = new Array( { code:AC, text:Remember to reset the station address. }, { code:RN, text:Remember to reset the station expiration date. }, { code:CP, text:Remember to contact contractor to remove the certificates from this station. }, { code:CR, text:Remember to cancel the refund payment. } ); for each (var test:Object in records) { if (grid.selectedItem.PAYMENT_TYPE_CODE == test.code) Alert.show(test.text ); } Second: var PAYMENT_TYPE_CODE:String = CR; var records:Array = new Array( { AC: Remember to reset the station address. }, { RN: Remember to reset the station expiration date. }, { CP: Remember to contact contractor to remove the certificates from this station. }, { CR: Remember to cancel the refund payment. } ); for (var i:int = 0; i records.length; ++i) { if (records[i][grid.selectedItem.PAYMENT_TYPE_CODE]) Alert.show(records[i][PAYMENT_TYPE_CODE]); } --- In flexcoders@yahoogroups.com, Jason B nos...@... wrote: SWEET thanks --- In flexcoders@yahoogroups.com, Eric Cooper eric@ wrote: How about this: var records:Array = new Array( { code:AC, text:Remember to reset the station address. }, { code:RN, text:Remember to reset the station expiration date. }, { code:CP, text:Remember to contact contractor to remove the certificates from this station. }, { code:CR, text:Remember to cancel the refund payment. }, ); for each(test:Object in records){ if(grid.selectedItem.PAYMENT_TYPE_CODE == test[i].code) Alert.show(test[i].text ); } would that do it? -eric --- In flexcoders@yahoogroups.com, Jason B nospam@ wrote: var records:Array = new Array({ AC: Remember to reset the station address., RN: Remember to reset the station expiration date., CP: Remember to contact contractor to remove the certificates from this station., CR: Remember to cancel the refund payment. }); for each(test:Object in records){ //HERE we match up PAYMENT TYPE CODE with AC RN CP if one is a match we show the value if(grid.selectedItem.PAYMENT_TYPE_CODE == test[i]) Alert.show(SHOW ME ---Remember to reset the station address ); } datagrid hidden column AC, RN, CP are in datagrid user selects RT item from grid and hits button system match's that row with what message should be displayed user never see's RT since its a hidden field in grid user now see's a message displayed as a reminder --- In flexcoders@yahoogroups.com, Paul Andrews paul@ wrote: Jason, I'm not sure I follow exactly what the problem is now. Paul - Original Message - From: Jason B nospam@ To: flexcoders@yahoogroups.com Sent: Thursday, May 21, 2009 4:02 PM Subject: [flexcoders] Re: simple array? i want to loop the records and compare the value addresschange to the PAYMENT Type Code if its the right one display it --- In flexcoders@yahoogroups.com, Paul Andrews paul@ wrote: - Original Message - From: Jason B nospam@ To: flexcoders@yahoogroups.com Sent: Thursday, May 21, 2009 3:46 PM Subject: [flexcoders] Re: simple array? Thanks but i dont know how to do a compare based on your example show? for(var i:uint = 0; i records.length; i++) { //If array matchs show text if(payment_grid.selectedItem.PAYMENT_TYPE_CODE
[flexcoders] Slider question: click on track and drag?
I would like to have sliders whose 'track' could be clicked on to move thumb and whose thumb would then become receptive to thumbDrag. Is there some easy way to enabled this? What I see now, is that a mouse-down event on track will move thumb. But then the user has to release the mouse button and click again to get thumbDrag behavior. Is there some way to avoid this up-and-down? Thanks. -Eric
[flexcoders] Re: Load time, multiple redundant Embed() calls, etc.
Thanks, Nate and Alex, Your suggestions and information were very helpful. I think that simply eliminating redundant Embed() calls will save be close to 0.5MB. The third frame approach will be extremely helpful for end-user experience of load time. Ultimately, I could render most of the images as vector graphics - but I don't think that I'll have time to do that in the near term. Thanks again, -Eric --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: Basically, the entire SWF must be downloaded to show up. Flex SWFs default to 2 frame SWFs. The first frame should show the preloader, the second shows the app, and all embeds are in the second frame by default. Also see last paragraph of this post and its example. http://blogs.adobe.com/aharui/2008/09/using_the_flex_builder_3x_prof.html From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Nate Beck Sent: Tuesday, December 02, 2008 4:45 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Load time, multiple redundant Embed() calls, etc. Anytime you Embed anything, you're including it within your swf. It may get compressed a little bit, but you're still embedding it. That means your SWF file will contain all of the images that you used [Embed(source=foo.png)] on. Using Embed is not like HTML where you have your images in a directory and then your swf calls them at runtime. Also, use vector graphics as much as you possibly can. Cheers, Nate On Tue, Dec 2, 2008 at 12:55 PM, Eric Cooper [EMAIL PROTECTED]mailto:[EMAIL PROTECTED] wrote: Hi, I have inherited some code and it seems to build into a fairly large .swf and takes a very long time to download. Running locally, things go fairly quickly - but not so remotely. Part of this may be due to slow server and net connection - but I am not able to change those any time soon. So, I wonder two things: 1. Are there tools for highlighting cause of slowness of download (e.g., areas of bloat in code)? 2. If the code is rife with [Embed(source=foo.png)] - where same 'foo' is being embedded in multiple files - would cause bloat? And would it be better to have one managing singleton that embedded all images? Thanks! -Eric
[flexcoders] Load time, multiple redundant Embed() calls, etc.
Hi, I have inherited some code and it seems to build into a fairly large .swf and takes a very long time to download. Running locally, things go fairly quickly - but not so remotely. Part of this may be due to slow server and net connection - but I am not able to change those any time soon. So, I wonder two things: 1. Are there tools for highlighting cause of slowness of download (e.g., areas of bloat in code)? 2. If the code is rife with [Embed(source=foo.png)] - where same 'foo' is being embedded in multiple files - would cause bloat? And would it be better to have one managing singleton that embedded all images? Thanks! -Eric
[flexcoders] Re: UI component, a set function creationComplete
Mike, I am wondering if what I am experiencing with createChildren() is similar to what you've described below. I am subclassing UIComponent - and I read that it is best to create children in a createChildren() method. However, I am tying into someone else's existing code and she has done some nice work with loading state. Her code creates a new instance (of the class mentioned above that extends UIComponent - let's call it BTProcess). What I am finding is that after the instantiation, the new object is having properties set ON children that have not yet been instantiated and hooked up to BTProcess. I am guessing that I could have the state-loading code broken into two parts: one the instantiates and one that listens for CREATION_COMPLETE event before setting properties. But I am wondering if there is a faster way to do this. So, my question is does your approach address this by creating children in commitProperties() and does this provide a work-around to the problem that I am experiencing. Thanks! -Eric --- In flexcoders@yahoogroups.com, Michael Schmalle [EMAIL PROTECTED] wrote: Well, Basically, if you subclass a UIComponent or decendent, and you are making a component that uses setters that 'communicate' with composite children, I would always use this algorithm. As far as the randomness, might have to do with bindings, other timing issues. If you set a property in mxml it will always be called before children are created, you can count on that. Mike On Thu, Sep 18, 2008 at 6:57 AM, Manu Dhanda [EMAIL PROTECTED]wrote: Thanks for the answer Mik. But, Isn't it strange that this situation can occur randomly?? Or is there any particular case, when we always need to use the solution, like the one you provided. I am asking it because I had written other components in my code where everything is working seamlessly and I am worried now as if they are error prone?? Thanks, Manu. Michael Schmalle wrote: Hi Manu, This is a pretty simple answer. The reason is the mxml properties get looped into your component before createChildren() creates the child descriptors. This is why we need the invalidation system. You need the following. public function set data(value:ArrayCollection) { _data = value; dataChanged = true; invalidateProperties(); } ... in the same class override protected function commitProperties() { super.commitProperties() if (dataChanged) { // do things with child components IE myGrid.data = _data; dataChanged = false } } Setting your child properties in commitProperties() guarantees your children will be created. Peace, Mik On Thu, Sep 18, 2008 at 3:09 AM, Manu Dhanda [EMAIL PROTECTED] manuraj.dhanda%40gmail.comwrote: Hii Guyz, I am having some strange issue here. What I am doing is: comps:CustomUIComponent Data={_dataP}/ I am using this component in some abc.mxml as above. Data is something like: public function set Data(value:ArrayCollection){ //set ur data here. } But strangely, when I do it(pay attention to bold mxml code of line above now), I find one of flex components (say a Grid) in my CustomUIComponent as null, on which I want to set this Data. Now, I am worried like how a method, say set Data can be called before even creation complete of CustomUIComponent. Can someone please put some light here.. Thanks, Manu. -- View this message in context: http://www.nabble.com/UI-component%2C-a-set-function---creationComplete- tp19547254p19547254.html Sent from the FlexCoders mailing list archive at Nabble.com. -- Teoti Graphix, LLC http://www.teotigraphix.com Teoti Graphix Blog http://www.blog.teotigraphix.com You can find more by solving the problem then by 'asking the question'. -- View this message in context: http://www.nabble.com/UI-component%2C-a-set-function---creationComplete- tp19547254p19550295.html Sent from the FlexCoders mailing list archive at Nabble.com. -- Teoti Graphix, LLC http://www.teotigraphix.com Teoti Graphix Blog http://www.blog.teotigraphix.com You can find more by solving the problem then by 'asking the question'.
[flexcoders] Re: UI component, a set function creationComplete
Thanks, Amy. I have decided that my own model is more convoluted than is healthy. So, I have reworked things on my side and stuck with createChildren(). I was tempted to try Mike's suggestion - and, had I felt really good about my implementation, I might have. At this point, with more checks for null values than ideally there should be, things are working in various scenarios. Thanks again, -Eric --- In flexcoders@yahoogroups.com, Amy [EMAIL PROTECTED] wrote: --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Hi Eric, So, my question is does your approach address this by creating children in commitProperties() Yes, This is basically what I do with all renderers in my commercial components. I rarely use createChildren(). The only time I use createChilren() is when the composite is 100% owned by it's parent containing the creation code. commitProperties() will solve all timing issues if implemented correctly. I'm not quite sure I get what you are asking in the second half but, all item renderers use this algorithm which their state is entirely dependent on the data being pushed into the component either through data or public accessors. This means that children will not be instantiated until the data is present for their instantiation. If this doesn't make sense, try to clarify a bit more. It's probably better practice to create children in createChildren, then use commitProperties to do whatever setting of properties needs to be done, and then use updateDisplayList() to do any layout, and measure() to resolve any sizing issues. These functions are in place for very good reasons, and if you try to circumvent them you have a really good chance of running into problems. For instance, if you put child creation logic in commitProperties(), you are probably going to fail miserably unless you put that logic in _before_ the super.commitProperties(). That's because any children should be created prior to commitProperties. And that's the reason there's a commitProperties() function that's separate from createChildren(). Oh, and if you do anything that edits layout, etc., in commitProperties, you better do it _after_ the super. Guess why? You should try and catch her state changes and defer them until the appropriate moment in the invalidation process. If what's going on is that her logic is affecting public properties or styles that you've exposed on your class, then you just need to make sure that they set a flag and call the right invalidation method so that you can execute at the correct place in the invalidation process. HTH; Amy
Re: [flexcoders] Equivalent to Java's Class.isInstance(Object) instance method?
The question has been answered (yes, it is possible to use is as part of isInstanceOf() method. Here's an example of my use of this mechanism (for determining if geometric shapes share an instance of a particular class of constraint, e.g. are these two line segments perpendicular to each other?) public function sharesConstraintWith(that:MPShape, constraintClass:Class):MPConstraint { // Get those constraints that are shared between this and that, if there are any. for each (var c0:MPConstraint in this.constraints) { for each (var c1:MPConstraint in that.constraints) { if (c0 == c1 c0 is constraintClass) return c0; } } return null; } It works for me. -Eric --- In flexcoders@yahoogroups.com, Mark Carter [EMAIL PROTECTED] wrote: Hi Mike - sorry, you've lost me there... The few tests I've done show that obj is cls is what I need. Are you saying that does not work? Michael Schmalle wrote: Adding to the insight, if you wanted to use the 'is' operator with those two arguments, you need to create an instance of the Class and then use the 'is' operator. This would let you know if it is an instance of the object passed. public static function isObjectInstanceOfClass(obj:Object, cls:Class):Boolean { return obj is new cls(); } We have asked the player engineers about the performance hit on this is not as bad as describeType in some instances. Mike -- View this message in context: http://www.nabble.com/Equivalent-to-Java%27s-Class.isInstance%28Object%29-instance- method--tp20171501p20190188.html Sent from the FlexCoders mailing list archive at Nabble.com.
[flexcoders] Resizing width of TextArea to fit content width
Hi, I have searched through the archives and googled, but most related concerns seem to focus on text height. I am concerned solely with text width. I have a subclass of UIComponent (called BTVariable) that contains an HBox which, in turn, contains between two and four TextArea objects. I would like BTVariable to be as narrow as possible and to adjust its size as necessary (growing when needed and shrinking when prudent). I have tried implementing measure() on BTVariable, but I think that I have a cyclical relationship between various objects. The HBox needs to be given explicit width because its constituent TextAreas have no notion of their own width, apparently. I am thinking that this is probably something that has been dozens of times and that there is a fairly straightforward way to do it. But, having spent many hours pursuing seemingly promising approaches, I am starting to think that I am overlooking some obvious mechanism. Thanks in advance for any advice or pointers. -Eric
[flexcoders] Re: Accessing *other* browser plugins from Flash
Yes. A little further outside the box than my charter would allow at this point. Thanks, Tracy and Josh, for replies. I will read up on ExternalInterface. -eric --- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote: Now *that's* thinking outside the box! Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Josh McDonald Sent: Tuesday, October 14, 2008 6:02 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Accessing *other* browser plugins from Flash Why not embed Player inside your a C++ app and bypass the browser entirely? On Wed, Oct 15, 2008 at 5:39 AM, Tracy Spratt [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: You can explicitly allow swf scripting in the html wrapper. It might take bit to get the security side handled, but it is doable. You would actually control/communicate with the other objects by scripting them using javascript and ExternalInterface. Tracy From: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com ] On Behalf Of Eric Cooper Sent: Tuesday, October 14, 2008 3:05 PM To: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com Subject: [flexcoders] Accessing *other* browser plugins from Flash Hi, I have access to some powerful C++ functionality. Porting this to ActionScript is not an option. However, it looks like I could create a browser plugin that would wrap the C++ code. I am looking for pointers, caveats or advice on how to proceed. The obvious question is: can a .swf call out to another browser plugin or is this prevented by the security sandbox of all browsers? And the followup: if this is possible, how? Thanks in advance! -Eric -- Therefore, send not to know For whom the bell tolls. It tolls for thee. Like the cut of my jib? Check out my Flex blog! :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] :: http://flex.joshmcdonald.info/ http://flex.joshmcdonald.info/
[flexcoders] Accessing *other* browser plugins from Flash
Hi, I have access to some powerful C++ functionality. Porting this to ActionScript is not an option. However, it looks like I could create a browser plugin that would wrap the C++ code. I am looking for pointers, caveats or advice on how to proceed. The obvious question is: can a .swf call out to another browser plugin or is this prevented by the security sandbox of all browsers? And the followup: if this is possible, how? Thanks in advance! -Eric
[flexcoders] Re: as3CoreLib
I think that I used http://as3corelib.googlecode.com/files/corelib-.90.zip which is now marked as deprecated... but still probably bette than nothing. I only use it for JSON. -eric --- In flexcoders@yahoogroups.com, Amy [EMAIL PROTECTED] wrote: --- In flexcoders@yahoogroups.com, Michael Schmalle teoti.graphix@ wrote: Hi, Have you tried http://actionscript3libraries.riaforge.org/ ? I see downloads 376 but I don't have a username so maybe you can get it there as a zip if you login. I don't see a way to download it. Thanks, though :-)
[flexcoders] Re: Trees, DataProviders and dynamic screen updates
Thanks, Tracy. What I meant was that I was adding Objects like { object:myObject } to ArrayCollection - where myObject was an instance of a proxy class - and whose properties were getting changed. I have now gone to a slightly different scheme, adding Objects like { object:mpObject, value:myObject.value } - and when 'value' property changes, I iterate through ArrayCollection, looking for match on 'object' - and, when I find that, I set 'value' to new myObject.value. This seems to trigger necessary dispatch and Tree's rendering updates. Thanks again for your help. =Eric --- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote: ...when the items referenced by the ArrayCollection change... How is that happening? The items... change? Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Eric Cooper Sent: Wednesday, July 23, 2008 6:24 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Trees, DataProviders and dynamic screen updates I am adding to and removing from ArrayCollection - and when I do that, the Tree items refresh and are current. But when the items referenced by the ArrayCollection change, I am doing nothing. Is there a way to touch the ArrayCollection so as to prompt Tree to reload (or reevaluate) its dataProvider and call labelFunction to generate updated rendering? Or is the preferred way to step walk through ArrayCollection and modify (in place) the changed objects? Thanks. =Eric --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Tracy Spratt tspratt@ wrote: If you use the ArrayCollection API to make the updates to the dataProvider, the changes should automatically reflect in the UI. How are you updating the ArrayCollection items? Tracy From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Eric Cooper Sent: Wednesday, July 23, 2008 3:53 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Trees, DataProviders and dynamic screen updates Hi, I am trying to display changes in state for proxy objects (where real state exists on a server). I have defined a Tree and set its dataProvider to be an ArrayCollection. I have tried having this be an array of references to actual proxy object and also as array of dynamically created Objects (of form {name:foo.toString(), object:foo} Server-side events result in client being notified that properties in proxy object have changed. I would like these changes in proxy object properties to propagate through the Tree's items. I have searched docs and this forum, but not found anything that addresses this issue. At the same time, I suspect that this is something that has been discussed - and may simply involve setting some flag on the Tree or the DataProvider... Thanks for any help! =Eric
[flexcoders] Trees, DataProviders and dynamic screen updates
Hi, I am trying to display changes in state for proxy objects (where real state exists on a server). I have defined a Tree and set its dataProvider to be an ArrayCollection. I have tried having this be an array of references to actual proxy object and also as array of dynamically created Objects (of form {name:foo.toString(), object:foo} Server-side events result in client being notified that properties in proxy object have changed. I would like these changes in proxy object properties to propagate through the Tree's items. I have searched docs and this forum, but not found anything that addresses this issue. At the same time, I suspect that this is something that has been discussed - and may simply involve setting some flag on the Tree or the DataProvider... Thanks for any help! =Eric
[flexcoders] Re: Trees, DataProviders and dynamic screen updates
I am adding to and removing from ArrayCollection - and when I do that, the Tree items refresh and are current. But when the items referenced by the ArrayCollection change, I am doing nothing. Is there a way to touch the ArrayCollection so as to prompt Tree to reload (or reevaluate) its dataProvider and call labelFunction to generate updated rendering? Or is the preferred way to step walk through ArrayCollection and modify (in place) the changed objects? Thanks. =Eric --- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote: If you use the ArrayCollection API to make the updates to the dataProvider, the changes should automatically reflect in the UI. How are you updating the ArrayCollection items? Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Eric Cooper Sent: Wednesday, July 23, 2008 3:53 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Trees, DataProviders and dynamic screen updates Hi, I am trying to display changes in state for proxy objects (where real state exists on a server). I have defined a Tree and set its dataProvider to be an ArrayCollection. I have tried having this be an array of references to actual proxy object and also as array of dynamically created Objects (of form {name:foo.toString(), object:foo} Server-side events result in client being notified that properties in proxy object have changed. I would like these changes in proxy object properties to propagate through the Tree's items. I have searched docs and this forum, but not found anything that addresses this issue. At the same time, I suspect that this is something that has been discussed - and may simply involve setting some flag on the Tree or the DataProvider... Thanks for any help! =Eric
[flexcoders] Re: Trees, DataProviders and dynamic screen updates
I am adding to and removing from ArrayCollection - and when I do that, the Tree items refresh and are current. But when the items referenced by the ArrayCollection change, I am doing nothing. Is there a way to touch the ArrayCollection so as to prompt Tree to reload (or reevaluate) its dataProvider and call labelFunction to generate updated rendering? Or is the preferred way to step walk through ArrayCollection and modify (in place) the changed objects? Thanks. =Eric --- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote: If you use the ArrayCollection API to make the updates to the dataProvider, the changes should automatically reflect in the UI. How are you updating the ArrayCollection items? Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Eric Cooper Sent: Wednesday, July 23, 2008 3:53 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Trees, DataProviders and dynamic screen updates Hi, I am trying to display changes in state for proxy objects (where real state exists on a server). I have defined a Tree and set its dataProvider to be an ArrayCollection. I have tried having this be an array of references to actual proxy object and also as array of dynamically created Objects (of form {name:foo.toString(), object:foo} Server-side events result in client being notified that properties in proxy object have changed. I would like these changes in proxy object properties to propagate through the Tree's items. I have searched docs and this forum, but not found anything that addresses this issue. At the same time, I suspect that this is something that has been discussed - and may simply involve setting some flag on the Tree or the DataProvider... Thanks for any help! =Eric
[flexcoders] Re: How to set the registration point for a UIComponent
How does one control (or even determine) the registration point? I am drawing a circle and it seems like the center of the circle is being used as the registration point - which means that when I display the center point and radius point (having subtracted topLeft from their real positions) I am seeing these points displayed outside the circle. Thanks, -Eric --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: There isn't really a registration point. All that is is magic to reposition the graphical content to some other place. IOW, instead of drawing a rectangle from 0,0 to 100, 100, you can effectively set the reg point at 50,50 by drawing from -50, -50 to 50,50 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of flexawesome Sent: Tuesday, June 17, 2008 7:11 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How to set the registration point for a UIComponent is it possible? --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , flexawesome flexawesome@ wrote: I was working on the scale for my application, I could set scaleX and scaleY to change the size of my UIcomponent. ( it extends to the right and bottom ) I had one problem is how to set the registration point in the middle of my UI ( black box ). http://www.privatepaste.com/e10vnP2DX1 http://www.privatepaste.com/e10vnP2DX1 Thank you
[flexcoders] Re: Writing text directly to Graphics object.
In retrospect, it seems reasonable that one would need to use a drawXxx() command to have beginBitmapFill() affect the graphics port. Anyway, in case this useful to anyone else, here's a method that draws a string to a graphics object: public function drawString(g:Graphics, str:String, x:Number, y:Number):void { var tf:TextField = new TextField(); tf.text = str; var bmd:BitmapData = new BitmapData(tf.textWidth + 6, tf.textHeight, true, 0xFF); bmd.draw(tf); var matrix:Matrix = new Matrix(); matrix.createBox(1, 1, 0, x, y); g.beginBitmapFill(bmd, matrix); g.drawRect(x, y, bmd.width, bmd.height); g.endFill(); } Of course, in actual use, one would probably want to set fonts, colors, etc. --- In flexcoders@yahoogroups.com, Eric Cooper [EMAIL PROTECTED] wrote: I have tried this, but it doesn't seem to be working. Here's what I am doing: override public function renderShape(graphics:Graphics):void { var matrix:Matrix = new Matrix() matrix.createBox(1, 1, 0, this.center.x, this.center.y ); // center is the vertex of an angle graphics.beginBitmapFill(this.bitmapData, matrix); graphics.endFill(); } // use bright colors for debugging. private function generateBitmapData():void { this._textField.text = this.angle + º; this._textField.textColor = 0xFF; this._textField.background = true; this._textField.backgroundColor = 0xFF; _bitmapData = new BitmapData(this._textField.textWidth, this._textField.textHeight, false, 0x00FF00); _bitmapData.draw(this._textField); } private function get bitmapData():BitmapData { if (_bitmapData == null) this.generateBitmapData(); return _bitmapData; } Note that the real renderShape() also draws a pie wedge to the canvas - and the wedge is visible. As an aside, though, I am also having trouble with drawing the pie wedge - the wedge works fine, but if I try to draw just the arc of the wedge, then I find that the arc deforms into a closed shape: the two end points are connected by a line. If I omit beginFill() and endFill() calls, relying only on lineStyle(), then connecting line goes away, but I start seeing strange flood fills. Reading about Graphics, I see that endFill() plays a role in getting draw commands pushed onto draw stack. I also see that the fill specified by beginFill() et al. persists until another beginFill() call. Is there some mantra for turning off fill? Thanks! -Eric --- In flexcoders@yahoogroups.com, Doug McCune doug@ wrote: You can draw a TextField to a BitmapData object (using the draw() method) and then use graphics.beginBitmapFill and pass in that BitmapData (make sure to specify the right matrix for where to start the fill). But no, as far as I know there is not way to do it directly, I often use BitmapData as an intermediary to do stuff like that. Doug On Fri, Apr 11, 2008 at 3:50 PM, Eric Cooper eric@ wrote: Is there any way to write/draw text directly to a Graphics object? For that matter is there anyway to draw text (single line of static text) into a Canvas? I suspect that the answer is no, having searched and searched... but maybe there's some obscure utility class that I've overlooked. Thanks in advance. -Eric
[flexcoders] newbie design question
I have been working in Flex for about 3 months now. I am writing a geometry tool that allows user to create points, line segments, circle and polygons, as well as constraints between these objects (e.g., distance, angle, perpendicular, etc.). Initially, I created a (subclass of) ApplicationControlBar and (a subclass) of Canvas. Tools in the app control bar and objects (by which I mean geometric shapes) in the canvas. My canvas listeners for Event.RENDER and then, provided it's been told that something has changed, calls its draw() method - which, essentially, loops through objects, drawing them to the graphics object - after having cleared the graphics object. Similarly, the canvas listeners for various MouseEvents and KeyboardEvents, and traverses the list of objects doing hit tests. This was okay until I needed to render text (for distances and angles). Apparently there are ways around that - by rendering text to a bitmap and adding bitmap to graphics command stack (though I have yet to actually get this working). There are other concerns that I have about my approach thus far. But switching over to a model where each geometric object is a Sprite or a Shape raises some questions, too. Currently, I can highlight points, edges and angles of polygons are the mouse moves over them. I have no idea how I would accomplish this with Sprite or Shape, as neither appears to have a draw() or paint() method... Would I need to add Shapes for selected look for each point, line segment, etc. and toggle visible property appropriately? Is this something that skins might be used for? If so, how? I realize that this is a somewhat open-ended question, and I am hesitant asking it. I have done a fair amount of reading (books, blogs, docs), but I think that I am missing something here. If you have pointers or advice, I would be most grateful. Thanks. -Eric
[flexcoders] Re: How do I repaint?
I am not sure if this is best practice - but have you tried calling stage.invalidate() ? -eric --- In flexcoders@yahoogroups.com, Matt [EMAIL PROTECTED] wrote: I am dynamically setting the 'icon' to a LinkButton using Ben Stucki's IconUtility and it works great when the link first gets loaded, but if I want to dynamically change the icon after it is displayed it doesn't refresh properly. If I add a line to displayLoader that calls component.styleChanged('icon') that seems to help a little...when I move my mouse over the link the icon will change to the correct one. I'm still missing a step I think. What else do I need to do in order to get it to completely redraw the LinkButton to display the new icon? Is there some way I can replicate the mouseover validation that occurs (since there is obviously something in there that's doing what I need)?
[flexcoders] problems with ArrayCollections, Trees and PopUpButtons
I have spent the day trying to understand how to get a dynamically-backed hierarchical popup menu to work (within a ControlBar). I have gone from a fairly complex starting point to a minimal test case - and things are still not working. I am seeing three failures, depending on how I attempt this feat. I have an ArrayCollection which is static (thanks to posting by Peter Ent): public var componentsAC:ArrayCollection = new ArrayCollection( [ { name: Polygon_1, data: top, children: new ArrayCollection( [ { name: Line_sement_2 }, { name: Line_sement_3 }, { name: Line_sement_4 }, { name: Line_sement_5 } ]) } ]); a Tree and a PopUpButton: private var popbComponents:PopUpButton = new PopUpButton(); private var treeComponents:Tree = new Tree(); and I have a utility method with a couple of boolean arguments for testing purposes. private function makeComponentsUI(usePopUpButton:Boolean, validateProps:Boolean=false):void { treeComponents.showRoot = true; treeComponents.labelFunction = treeLabel; treeComponents.dataProvider = componentsAC; if (usePopUpButton) { popbComponents.popUp = treeComponents; popbComponents.label = Components; if (validateProps) popbComponents.validateProperties(); addChild(popbComponents); return; } // else addChild(treeComponents); } and I have three cases: 1. Call this.makeComponents(false, false) Tree shows up but seems to, somehow, remove all the other buttons and sliders that precede it in my subclass of ControlBar. This is lacking the popup aspect and would take much more real estate than it merits, but otherwise is okay. 2. Call this.makeComponents(true, false) I get this: TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.controls::PopUpButton/commitProperties()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\controls\PopUpButton.as:469] at mx.core::UIComponent/validateProperties()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:5670] at mx.managers::LayoutManager/validateProperties()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:519] at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:669] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8460] at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8403] which seems related to another topic that was discussed - except that I do not think that I am removing anything from the stage (at least not knowingly). 3. Call this.makeComponents(true, true) It doesn't crash, so that's good, I guess ;-) But all I get is a popup button labeled Components - but which lacks any popup-ness. I would prefer to find a solution that works with ArrayCollection instead of with XMLListCollection. And, fwiw, I was able to get things working with a Menu and ComboBox, but that lacked the hierarchical aspect. Thanks for any help with this. -eric
[flexcoders] Re: problems with ArrayCollections, Trees and PopUpButtons
Okay, a combination of factors and I got something working. I did need to resort to listening for Event.ADDED_TO_STAGE and re-setting popUp value. And I agree with others that that seems sub-optimal. I also needed to set the labelField property for my Tree. And I needed to set the width for my PopUpButton. Ironically, it seems that the much easier and friendly solution of wrapping an HBox around the Tree looks and behaves much better for my purposes... Now I need to figure out what it take to create some sort of floating windoid... oh joy. -eric --- In flexcoders@yahoogroups.com, Eric Cooper [EMAIL PROTECTED] wrote: I have spent the day trying to understand how to get a dynamically-backed hierarchical popup menu to work (within a ControlBar). I have gone from a fairly complex starting point to a minimal test case - and things are still not working. I am seeing three failures, depending on how I attempt this feat. I have an ArrayCollection which is static (thanks to posting by Peter Ent): public var componentsAC:ArrayCollection = new ArrayCollection( [ { name: Polygon_1, data: top, children: new ArrayCollection( [ { name: Line_sement_2 }, { name: Line_sement_3 }, { name: Line_sement_4 }, { name: Line_sement_5 } ]) } ]); a Tree and a PopUpButton: private var popbComponents:PopUpButton = new PopUpButton(); private var treeComponents:Tree = new Tree(); and I have a utility method with a couple of boolean arguments for testing purposes. private function makeComponentsUI(usePopUpButton:Boolean, validateProps:Boolean=false):void { treeComponents.showRoot = true; treeComponents.labelFunction = treeLabel; treeComponents.dataProvider = componentsAC; if (usePopUpButton) { popbComponents.popUp = treeComponents; popbComponents.label = Components; if (validateProps) popbComponents.validateProperties(); addChild(popbComponents); return; } // else addChild(treeComponents); } and I have three cases: 1. Call this.makeComponents(false, false) Tree shows up but seems to, somehow, remove all the other buttons and sliders that precede it in my subclass of ControlBar. This is lacking the popup aspect and would take much more real estate than it merits, but otherwise is okay. 2. Call this.makeComponents(true, false) I get this: TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.controls::PopUpButton/commitProperties()[E:\dev\3.0.x\frameworks\projects\framew ork\src\mx\controls\PopUpButton.as:469] at mx.core::UIComponent/validateProperties()[E:\dev\3.0.x\frameworks\projects\framework \src\mx\core\UIComponent.as:5670] at mx.managers::LayoutManager/validateProperties()[E:\dev\3.0.x\frameworks\projects\fra mework\src\mx\managers\LayoutManager.as:519] at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\ framework\src\mx\managers\LayoutManager.as:669] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framewo rk\src\mx\core\UIComponent.as:8460] at mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framewor k\src\mx\core\UIComponent.as:8403] which seems related to another topic that was discussed - except that I do not think that I am removing anything from the stage (at least not knowingly). 3. Call this.makeComponents(true, true) It doesn't crash, so that's good, I guess ;-) But all I get is a popup button labeled Components - but which lacks any popup-ness. I would prefer to find a solution that works with ArrayCollection instead of with XMLListCollection. And, fwiw, I was able to get things working with a Menu and ComboBox, but that lacked the hierarchical aspect. Thanks for any help with this. -eric
[flexcoders] Re: Writing text directly to Graphics object.
I have tried this, but it doesn't seem to be working. Here's what I am doing: override public function renderShape(graphics:Graphics):void { var matrix:Matrix = new Matrix() matrix.createBox(1, 1, 0, this.center.x, this.center.y ); // center is the vertex of an angle graphics.beginBitmapFill(this.bitmapData, matrix); graphics.endFill(); } // use bright colors for debugging. private function generateBitmapData():void { this._textField.text = this.angle + º; this._textField.textColor = 0xFF; this._textField.background = true; this._textField.backgroundColor = 0xFF; _bitmapData = new BitmapData(this._textField.textWidth, this._textField.textHeight, false, 0x00FF00); _bitmapData.draw(this._textField); } private function get bitmapData():BitmapData { if (_bitmapData == null) this.generateBitmapData(); return _bitmapData; } Note that the real renderShape() also draws a pie wedge to the canvas - and the wedge is visible. As an aside, though, I am also having trouble with drawing the pie wedge - the wedge works fine, but if I try to draw just the arc of the wedge, then I find that the arc deforms into a closed shape: the two end points are connected by a line. If I omit beginFill() and endFill() calls, relying only on lineStyle(), then connecting line goes away, but I start seeing strange flood fills. Reading about Graphics, I see that endFill() plays a role in getting draw commands pushed onto draw stack. I also see that the fill specified by beginFill() et al. persists until another beginFill() call. Is there some mantra for turning off fill? Thanks! -Eric --- In flexcoders@yahoogroups.com, Doug McCune [EMAIL PROTECTED] wrote: You can draw a TextField to a BitmapData object (using the draw() method) and then use graphics.beginBitmapFill and pass in that BitmapData (make sure to specify the right matrix for where to start the fill). But no, as far as I know there is not way to do it directly, I often use BitmapData as an intermediary to do stuff like that. Doug On Fri, Apr 11, 2008 at 3:50 PM, Eric Cooper [EMAIL PROTECTED] wrote: Is there any way to write/draw text directly to a Graphics object? For that matter is there anyway to draw text (single line of static text) into a Canvas? I suspect that the answer is no, having searched and searched... but maybe there's some obscure utility class that I've overlooked. Thanks in advance. -Eric
[flexcoders] Re: Writing text directly to Graphics object.
Yes, this is what I was hoping for. And even though it is not now available, I wonder, Gordon, if you are at liberty to tell us about the future? Is Graphics.drawText() be something that might get added? -eric --- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote: I think the original poster was looking for something like graphics.drawText(Hello, format); But there are (alas!) no APIs in the Graphics class that know how to render a text string. Only TextField knows how to do that. Gordon Smith Adobe Flex SDK Team
[flexcoders] Re: graphics object seems to degrade performance
Is there a way to clock exactly how long the actual drawing to the screen was taking? I know that profiling tools will show time spent within [pre-render] and [render], but I wonder if there is some thing that could be done inside my own code. In particular, I am trying to figure out where time is being spent. I suspect that it is not in rendering - but I would like to confirm that. Thanks. -Eric --- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote: Btw, is there any way to inspect the graphics object to see the drawing commands that it has? Unfortunately, no. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Eric Cooper Sent: Tuesday, April 15, 2008 1:47 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: graphics object seems to degrade performance Thanks. Yes, that one got me when I first started -- and took me a few days to realize what was happening. Btw, is there any way to inspect the graphics object to see the drawing commands that it has? --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: Also make sure you are calling graphics.clear() before re-drawing all of your graphic commands.
[flexcoders] Re: graphics object seems to degrade performance
I am experiencing performance issues similar to those described in this thread. By way of background, I am working on a geometry tool that allows the user to create points, line segments, circles and polygons, to move then about and to create constraints between them. I am new to ActionScript/Flex/Flash and, perhaps, tainted by other languages/frameworks. So, I have subclasses Canvas and it is responsible of rendering all the geometric shapes. In other words, my geometric shapes do extend DisplayObject and are *not* in the display list. As I add more and more shapes (i.e., more than 10), I see that drag performance degrades rapidly. I am considering adopting Alex's suggestion: generating a bitmap at the start of a drag (such that the bitmap contains all shapes that are not about to be dragged), clearing the graphics object, blitting the bitmap and then drawing the object(s) being dragged. I am wondering, though, if I would get this for free if I used DisplayObject and the built- in drag events. I am also wondering, if I am saving that much in terms of memory and speed, by rolling my own as it were. Thanks, -Eric --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: It will help some, but you'll still end up with 500,000 vectors spread thorough 1000 overlaid shapes. In order to handle undo, you would track the vectors in your own array of points and take snapshots as I suggested. I wouldn't even encode as png, all you need is one extra bitmapdata.
[flexcoders] Re: graphics object seems to degrade performance
Thanks. Yes, that one got me when I first started -- and took me a few days to realize what was happening. Btw, is there any way to inspect the graphics object to see the drawing commands that it has? --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: Also make sure you are calling graphics.clear() before re-drawing all of your graphic commands.
[flexcoders] Re: graphics object seems to degrade performance
Thank, Tom. Perhaps I should have started by extending DisplayObject. At this point, that would be a bit of a slog. I may end up resorting to that, but would like to try other avenues first. --- In flexcoders@yahoogroups.com, Tom Chiverton [EMAIL PROTECTED] wrote: On Tuesday 15 Apr 2008, Eric Cooper wrote: I am wondering, though, if I would get this for free if I used DisplayObject and the built- in drag events. I am also wondering, if I am saving that much in terms of memory and speed, by rolling my own as it were. I would definetaly use Adobe's to start with, then until or unless some problem actually appeared. -- Tom Chiverton Helping to continually aggregate leading-edge infrastructures on: http://thefalken.livejournal.com
[flexcoders] Re: graphics object seems to degrade performance
Thanks, Troy. I am using alpha currently, and think that I will be able to use various matrix manipulations when I get there. I am drawing to a Canvas. I think that I will be exploring bitmap caching shortly. But if it starts looking like I will need to manage my own dirty rectangles then I will spend some time extending DisplayObject. -Eric --- In flexcoders@yahoogroups.com, Troy Gilbert [EMAIL PROTECTED] wrote: I am wondering, though, if I would get this for free if I used DisplayObject and the built- in drag events. I am also wondering, if I am saving that much in terms of memory and speed, by rolling my own as it were. If you make each draggable item (each shape) its own DisplayObject then yes, you'll get some optimizations for free, such as bitmap caching. You'll also get the benefit of the fact that the drawing loop is at least written in native code (the display list), and may even have some additional optimizations helping you depending on your specific dataset (dirty rectangle lists, etc.). Finally, by making each object a DisplayObject instead of managing the shapes yourself, you get a huge amount of features for free, such as alpha, filters, sort order, scaling, rotation... all those nice, native things DisplayObjects do. Troy.
[flexcoders] Re: graphics object seems to degrade performance
John, This is helpful. I am not dealing with complex polygons. Rather, I am dealing with triangles and quadrilaterals. I am calling out to a C++ server that includes code that helps maintain constraints within and between my polygons (e.g., perpendicular, concentric, congruence, etc.). This means that every moveBy call on a polygon gets sent to the server and the server sends back a list of points that have changed position. I suspect that much of my slowness is a result of the drawing taking a bit longer than the network roundtrip - with the result that a backlog of point updates builds up. I wonder, though, if caching bitmaps for each polygon would speed things up. I don't think that I can get away with creating a single bitmap of non-dragged polygons because there is a potential for interaction between dragged and non- dragged objects (that's one way that constraints can be made, albeit with modifier key). Thanks. -Eric --- In flexcoders@yahoogroups.com, Jon Bradley [EMAIL PROTECTED] wrote: On Apr 15, 2008, at 12:23 AM, Eric Cooper wrote: I am wondering, though, if I would get this for free if I used DisplayObject and the built- in drag events. I am also wondering, if I am saving that much in terms of memory and speed, by rolling my own as it were. My personal choice was not to use any of the built-in drag event stuff for this. I created my own handler for clicking and 'selecting' or initiating a drag or other transform on a display object using transformation matrices. Objects extend some base classes that implement an interface containing a setTransformation method. Each object can then override the capabilities of the transformation that is being applied (as a matrix parameter). I find it pretty weird you run into issues with more than 10 display objects. I would imaging you'd have issues with a few hundred or thousand, but not low single digits. If you get to really complex vector shapes dragging can slow down quickly because the renderer has to deal with visibility and compositing of that complex shape. Bitmap representations here are much more efficient, using cacheAsBitmap=true (gotta extend movieclip) and have your class that contains the graphics automatically handle the drawing of the bitmap into itself. I do this with text because animating or moving type in a layered 'canvas' has performance and display issues. My 0.02. cheers, jon
[flexcoders] Writing text directly to Graphics object.
Is there any way to write/draw text directly to a Graphics object? For that matter is there anyway to draw text (single line of static text) into a Canvas? I suspect that the answer is no, having searched and searched... but maybe there's some obscure utility class that I've overlooked. Thanks in advance. -Eric
[flexcoders] Re: Question about DisplayObject.hitTestPoint() and the shapeFlag
jon, thanks! my polygons are only triangles and quadrilaterals at this point, but your method works beautifully for concave quads. I did have to change one line (which appears a few times) in order to compile: w += 2 * ( p[ip].y p[i].y ) - 1; became: w += 2 * (( p[ip].y p[i].y ) ? 1 : 0) - 1; I am new to AS, so this may have been unnecessary or they may have been a more elegant way to do this. thanks again. -eric --- In flexcoders@yahoogroups.com, Jon Bradley [EMAIL PROTECTED] wrote: On Apr 7, 2008, at 8:46 AM, Jon Bradley wrote: /** * Point inside polygon using winding number method * q Point2d A point 2d structure with x,y properties * p Polygon A polygon as an array of points in clockwise order * returns Boolean Point is inside polygon if winding (w) number is != 0 */ Forgot to add that the parameter p for the polygon is a closed loop where p[0] == p[n]. cheers, jon
[flexcoders] Re: Question about DisplayObject.hitTestPoint() and the shapeFlag
FWIW, I decided to write my own hit test using dot products for concave polygons. I will need to do something a bit more involved for convex polygons, but I don't need that immediately. I would still be interested to answer to my original question, if anyone knows the answer. Alternatively, a pointer to some discussion of this issue would be most helpful. (I googled for several hours before posting original question - without any good hits.) --- In flexcoders@yahoogroups.com, Eric Cooper [EMAIL PROTECTED] wrote: I am writing a simple geometry editor (i.e., user can create, move and deform circles and polygons). I am *not* adding geometric shapes to display list. Instead, I am managing them myself. (This may be a bad idea, but doesn't really affect my overall question.) Here is a method that is defined on my Polygon class. I would like to know why it returns true when (x, y) is on top of a polygon and shapeFlag is false -- but returns false when (x, y) is on top of a polygon and shapeFlag is true. override public function containsPoint(x:Number, y:Number):Boolean { var shapeFlag:Boolean = false; var testShape:Shape = new Shape(); testShape.graphics.beginFill(0xFF, 1.0); testShape.graphics.lineStyle(1.0, 0xFF, 1.0); this.renderInteractionShape(testShape.graphics); testShape.graphics.endFill(); return ((testShape == null) ? false : testShape.hitTestPoint(x, y, shapeFlag)); } With shapeFlag = false, any points in the polygon's bounding rectangle will cuse containsPoint() to return true. I need to deal with non-rectangular shapes and rotated rectangles. Performance is important, so generating and regenerating bitmaps would be suboptimal. Then again, if that is part of the solution, then I could cache bitmaps of unmoved shapes. Here's Polygon.renderInteractionShape() for completeness. The MPPoint class wraps a point and provides some UI. override public function renderInteractionShape(graphics:Graphics):void { var scale:Number = drawing.getScale(); var pt:MPPoint = _vertices[0]; graphics.moveTo(pt.x * scale, pt.y * scale); for (var i:int = 1; i _numSides; i++) { pt = _vertices[i]; graphics.lineTo(pt.x * scale, pt.y * scale); } // close up the polygon. pt = _vertices[0]; graphics.lineTo(pt.x * scale, pt.y * scale); } Thanks in advance, -ec
[flexcoders] Question about DisplayObject.hitTestPoint() and the shapeFlag
I am writing a simple geometry editor (i.e., user can create, move and deform circles and polygons). I am *not* adding geometric shapes to display list. Instead, I am managing them myself. (This may be a bad idea, but doesn't really affect my overall question.) Here is a method that is defined on my Polygon class. I would like to know why it returns true when (x, y) is on top of a polygon and shapeFlag is false -- but returns false when (x, y) is on top of a polygon and shapeFlag is true. override public function containsPoint(x:Number, y:Number):Boolean { var shapeFlag:Boolean = false; var testShape:Shape = new Shape(); testShape.graphics.beginFill(0xFF, 1.0); testShape.graphics.lineStyle(1.0, 0xFF, 1.0); this.renderInteractionShape(testShape.graphics); testShape.graphics.endFill(); return ((testShape == null) ? false : testShape.hitTestPoint(x, y, shapeFlag)); } With shapeFlag = false, any points in the polygon's bounding rectangle will cuse containsPoint() to return true. I need to deal with non-rectangular shapes and rotated rectangles. Performance is important, so generating and regenerating bitmaps would be suboptimal. Then again, if that is part of the solution, then I could cache bitmaps of unmoved shapes. Here's Polygon.renderInteractionShape() for completeness. The MPPoint class wraps a point and provides some UI. override public function renderInteractionShape(graphics:Graphics):void { var scale:Number = drawing.getScale(); var pt:MPPoint = _vertices[0]; graphics.moveTo(pt.x * scale, pt.y * scale); for (var i:int = 1; i _numSides; i++) { pt = _vertices[i]; graphics.lineTo(pt.x * scale, pt.y * scale); } // close up the polygon. pt = _vertices[0]; graphics.lineTo(pt.x * scale, pt.y * scale); } Thanks in advance, -ec