Sorting Images with a Flex Tile Component
This is a test for an image manager component that I’m building. The final version will have an upload feature, and when you sort the images they’ll hook up with their model in Rails using acts_as_list to save the sorting in the database. Right click the swf below to view source.
I’ve built something similar in Flash/AS2, and without sounding too much like a Adobe marketing rep, I have to say it’s so much easier in Flex/AS3. AS2 doesn’t have ArrayCollections so moving things around in an array was a bit of a headache, but in AS3 you can just remove an item from a list ( myCollection.removeItemAt(x) ) and then place it back anywhere ( myCollection.addItemAt( item, x ) ) and all the other items will shift down the list.
Another big time saver is the DragManager in AS2 you had to manually handle all kinds of dragging functions but with AS3 you just add a couple of events and you’re done. Even the Tile component saves having to layout the images by hand.
Anyways long story short the AS2 version took a couple of days to build and the Flex version took a couple of hours.
This entry was written by
Alastair, posted on
August 24, 2007 at 12:24 pm, filed under
ActionScript,
Flash,
Flex,
RIA,
Ruby on Rails. Bookmark the
permalink. Follow any comments here with the
RSS feed for this post.
or leave a trackback:
Trackback URL.
© Copyright 2006 - 2012 Alastair Dawson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 Comments
Cool example. Fits right in to my application. Works like a charm! Thanks.
I’m still trying to figure out what you can do in Flex that you can’t do in the flash IDE. You said that it was easier with flex/as3 than with flash/as2 — wouldn’t it be relatively the same to build it in flash/as3 ?
Yes you could build the same thing with Flash and CS3 but Flex really is a framework in that it gives you so many useful components to build upon. I can complete a project in Flex in 50-75% of the time it took me in Flash.
I was a Flex skeptic for a while and I hated it the first couple of weeks because you have to change how you approach stuff but now I love it (Flex 3 is a big improvement on 2).
One thing Flash doesn’t have error checking on the fly. In Flex Builder you’ll know right away if you have an error, in Flash you have to compile first then get the warning.
Solved my issue! Thanks a lot!
Ved