List paddingTop/paddingBottom controls the vertical distance between the itemRenderers ???

Another one of the Flex gotchas…I spent way too much time on this only to have an adobe engineer himself answer this on the flexcoders mailing list:
I had created custom renderers for my list and it looked great. But there was a 2 pixel gap between the renderers that was driving me insane. After my own efforts went nowhere I asked the question on the flexcoders mailing list. The answer, use paddingTop and paddingBottom = 0 in your style. The Flex documentation on the 2 styles says “Number of pixels between the container’s {…} border and the {…} edge of its content area”. This is definitely not something I would read and use that property to manage my item renderers in a list. Ah well, now I know better :).

This tip is going straight to flextips.corank.com, a site dedicated to these weird gotchas and helpful hints. Do check it out and post your own tips there.

New site for flex developers: Flextips

One thing that amazes me is that there isnt a site that aggregates tips on flex that developers find in the course of developing applications. With that in mind, I have just completed some work on my new site: flextips.corank.com. Running on the corank platform, the site essentially works like Digg (actually corank is a platform for creating Digg type sites). The idea is, if you find a good tip, link to it on flextips. I typically find a lot of value in people posting really simple tips that save me hours of investigative work.

Anyway so here is the model for the site:

If you find a cool tip on a website or post a cool tip on your blog, link to it on flextips.corank.com. Put it under one of the categories mentioned there (if anyone feels we need more categories, let me know). Tag it appropriately as well. For tags, use the name of the flex component or class this will affect.

When you come to flextips at other times (usually more than once a day 😉 ), give various tips a thumbs up or down. That way, the more important tips start surfacing above the trivial ones.

Please leave me some feedback on the project.

Cheers.

Philadelphia Flash Users Group: Thanks for coming…

I just wanted to thank everyone who showed up for the Philadelphia Flash Platform Adobe User Group session this Thursday. It was a lot of fun for me and meeting so many Flash/Flex developers in the area was really cool. I was hoping to show a lot more code but the session seemed packed enough with just the overview of the Flex internals. CIM did record the whole session though and I’ll post a link to the video once we have it online. In the meanwhile, feel free to download the presentation here (pdf)

Special thanks to Rob for making this thing happen.

I am really excited about the new Flex User Group. I hope we can meet more often as a group. I am sure that we all have a truckload of questions about Flex and Apollo that we can help each other through.

Keep your eyes on CimLabs as we get ready to release Fan 4 beta and for more Flash and Flex goodness in the coming months.

Undocumented Flex goodness

When using Drag-and-Drop enabled controls, you can use a public function called calculateDropIndex(event:DragEvent) to figure out where Flex will drop the element being dragged. This method is part of the ListBase class and is overridden for TileBase (which extends Listbase but is the superclass for containers that layout stuff horizontally).

Flex Tip: Changing the source of an ArrayCollection

Here is a quick tip for Flex newbies although I imagine this is something thats fairly obvious. If you want to change the complete dataset of an ArrayCollection, do not create a new ArrayCollection object pointing to the same variable(well you can, but it will kill all the databound controls that are listening to events on the ArrayCollection instance). Instead use arraycollection.source = [ … ] to repopulate the source value with a new Array. This will broadcast a CollectionEvent with the ‘kind’ property of the event set to ‘RESET’ and keep all the controls in sync. CollectionEvents are broadcasted everytime the values in an ListCollectionView instance are changed (ArrayCollections extend ListCollectionView).

I just saw this bug on an application I was working on where the controls kept getting out of sync with the core data in the ArrayCollection and this was the culprit ! The code looked something like this:

[AS]

[Bindable]
public var dataAC:ArrayCollection;

private function onDataLoaded(evt:Event){
dataAC = new ArrayCollection(parseIntoArray(evt.data));
}

[/AS]

So everytime the new data came in, databinding was destroyed. The correct solution should have looked like:

[AS]

[Bindable]
public var dataAC:ArrayCollection = new ArrayCollection;

private function onDataLoaded(evt:Event){
dataAC.source = parseIntoArray(evt.data);
}

[/AS]

Hope this saves some time for someone 🙂

Woohoo…DiggGraphr is a finalist at the Digg API contest and is featured on TechCrunch !!!

This is amazing. My apollo application is one of the 10 finalists in the Digg API contest. But it gets even better: Techcrunch did an overview of the 4 apollo based entries and only mine has a screenshot up there 🙂 (yay! I am special). I am not going to win the contest itself but I never imagined I would ever be on Techcrunch!!! This rocks !

Check out the DiggGraphr application here and digg it if you like it.
The TechCrunch article can be found here
For more info on DiggGraphr, check the info page here

And here is a screenshot saved for posterity

DiggGraphr on Techcrunch

My entry for the Digg API contest: DiggGraphr Desktop

I just submitted by entry for the Digg API contest. Building on my earlier DiggGraphr tool, I was fairly easily able to port it to Apollo. I even added some customization features, like refresh interval and stuff. For more details on the application, check out the application page here. Feedback is always welcome 🙂

PS, it took me a while understanding some file metaphors that apollo has. So this is just the first version of the application. Hopefully, I will add more features to it soon :).

My first useful Apollo app…

This is for a project I am working on and it works pretty sweet. There were a few lessons learnt during the development of the app so I thought I would write a post on it in the spirit of the rest of the world learning from my mistakes ;). The project (that I cant tell you about yet) required a bunch of songs represented by their spectral-waveforms. I tried to find an application that would generate them for me easily but I couldnt really find a simple one. There are some applications that do it but they have so many controls that I couldnt figure out how to do it really quick. I still had source code from my FlexAmp application lying around so I figured, what the heck, I’ll just write a small application to do it. The result was the SpectrumGrapher application.

The concept is pretty simple:
1) Browse to a song on your filesystem.
2) Select it and it begins playing as well as using the computeSpectrum method to draw the graph (using a function that uses the drawing api thats called by a timer)
3) Click on the ‘Snapshot’ button to take a snapshot of the drawing (using the bitmap information of the UIComponent and the Bitmap to png class in the Adobe corelib)
4) Write the png file to the filesystem with a name like [song]_waveform.png

Screen shots (click for larger image)

Choose File
Choose File


Drawing Spectrum

Drawing the Spectrum

Final Waveform png
The output waveform (as saved to the desktop)

The problem I faced was after about 6-10 seconds of playback, my cpu would start spiking since I had too many vectors on the stage. The solution was a modified version of Grant Skinner’s ‘copy vector into bitmap and clear the vector’ approach. I put another timer that fired an event every 5 seconds to do that. The result: I tried a song that lasted almost 8 minutes and no issues (yeah Dream Theater songs are loooooong…but cool 😉 ). The other thing I just discovered was that using a filetype filter to control enabling/disabling the select button on the browse window doesnt seem to work on the mac ( I am a mac newbie and did this development on my PC). The more interesting output of this project was the file chooser dialog box which I had to write since the apollo alpha release doesnt give access to the native file chooser control (although I have seen it on the beta build demo). Maybe I’ll release that part of the code sometime soon.

Let me know what you think 🙂

Talking Flex with the Philadelphia Flash Platform Adobe User Group

Comcast Interactive Media (CIM) is hosting the next PFPAUG meetup and I will be talking on how we use Flex here in applications that immediately appear in front of millions of people. My recent blog entry on how we used Flex to develop the next version of the square view of the Fan got quite a bit of attention in the blogosphere and I think we did a fairly good job of developing a Flex application the way adobe has envisioned. I am thinking this will be a mid to advanced level talk on Flex and we will cover things like skinning, debugging and our build system using Ant. If you are in or around Philadelphia around May 31st, come on down to 1500 Market Street. There will be food and we will also be giving away some goodies.

If anyone has anything they would specifically like to be covered, drop me a comment below and I will try to include that in the talk. More details on the event can be found at the PFPAUG page.

New top reason to work at CIM: See Spiderman 3 before it opens ;)

Woohoo. We (the entire Comcast Interactive Media group) just got back from a private screening of the new Spiderman movie. The whole theater was rented out for us and food and soda were aplenty.

We are still looking for developers across the board, so if you have coding skill in any domain, c’mon over.

Mail me at mathur.arpit [at] gmail dot com