Flex Drag Drop: Cloned Data

June 22, 2009 08:06 by shawny

So I worked on a project recently that required drag/drop support for list based components, however, some custom porcessing was required when the item was dropped into the new list that would make my life easier when  the time came to save the data back to the database.  My data provider is an XMLListCollection that is being given as one large chunk of data.  That data is then broken up, using E4X, into smaller chunks, each of which is the source collection for my individual list-based components.  When an item is dropped into a different component, I want to update the xml values with values from the new list.  Using some of the manual drag/drop support techniques from the livedocs proved quite useful, however, I noticed that when the user released the item into the original list-component, cloned data would appear.  Let me say that another way... if a user began to drag an item from a list over another list without releasing the mouse, and then changed their mind and dropped the original item back into their original list, I would get duplicate data.  The fix for this was incredibly simple.  Setting the dragDrop event listener to our function is the first step:

<mx:Datagrid id="grd" dragDrop="{dragDrophandler(event)}"/>

Next we want to setup our handler:

private function dragDropHandler(event:DragEvent):void

{

 if (event.dragSource.hasFormat("items"))
                  {
                      event.preventDefault();
                      event.currentTarget.hideDropFeedback(event);
                      var dropTarget:DataGrid = DataGrid(event.currentTarget);
                      var dragSource:DataGrid = DataGrid(event.dragInitiator);
                      

                      // The following conditional ensures that our dragInitiator is not the same object as our drop target

                      if(dragSource != dropTarget)
                      {
                        var itemsArray:Array = event.dragSource.dataForFormat('items') as Array;
                        var tempItem:XML = itemsArray[0] as XML;
                        

                        // we can setup any custom processing here using the tempItem attributes.

                        // tempItem.@controlValue =  7;

                        // Get the drop location in the destination.
                        var dropLoc:int = dropTarget.calculateDropIndex(event);
               
                        IList(dropTarget.dataProvider).addItemAt(tempItem, dropLoc);
                      }

 

That's it.  No more cloned data. :)


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Flash 4 Styling: Know your Namespaces

June 18, 2009 20:41 by shawny

One difference between Flex 3 and Flex 4 is the extensive usage of namespaces.  Anyone who has used Flex 3 is familiar with namespaces on the most cursory level in the application tag as xmlns:mx="http://www.adobe.com/2006/mxml."  Creating custom components resulted in new namespaces such as xmlns:components="com.shawnyale.view.components", etc.  Namespaces help avoid collisions among components when they share the same name.  So if there were a button in my components dir, prefixing MY button with components:Button would help the compiler to locate the correct component and not use the standard mx:Button component.

In Flex 4, namespaces are also used in CSS stylesheets.  There is a difference in the style declaration in that the namespace(separated by spaces) is declared immediately in the css file and then any styles are declared using the | character (called a 'pipe' and is usually the shift backslash character).  So an example of the new style declaration is as follows:

@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";

s|Button{

      color:#FF0000;

}

Minor change, but important to know nonetheless.  I've noticed that Flash Builder 4 no longer has a design view for your stylesheets.  Not really thrilled about this change, but it is what it is. 


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Flash Builder 4: LOVE IT

June 16, 2009 14:26 by shawny

So in case you haven't heard, Adobe has released the beta version of the next version of Flex Builder.  The new IDE is going to be called "Flash Builder 4" and is still built on Eclipse.  Along with the rest of the world, I began playing around getting used to the new interface.  Already, I've noticed some MAJOR improvements not only in the full CSS support of Flex 4 from within the IDE, but a few minutes ago, I was BLOWN away at some other cool new features.

The first thing I noticed was the improved intellisense!  Now, when you ctrl+space you not only get a list of properties/events/effects, but you actually get them in groups.  Initially pressing ctrl+space will give you a list of component properties, pressing ctrl+space again will bring up events, again for effects, again for styles.  How amazingly cool and SUCH a time saver.  Having come along all the way from Flex 2, I can not tell you how many times I've had to trudge through the intellisense menus looking for whatever I needed at the time.  Now unlike some, I don't keep every property, event, etc in my memory and being able to find my item quickly is worth its weight in gold.  Very nice!!

The other REALLY cool thing I noticed is that Flash Builder 4 will now stub out your events for you.  WONDERFUL!!!  I came from Visual Studio and losing this type of functionality when moving to FB2 and FB3 was disheartening.  Again, I don't memorize every single method signature, and have had to spend countless hours going back to the livedocs having to look them up... especially when they are not used very often.  Now, in the property manager, you can double-click an event and Flash Builder 4 will automatically stub it out for you.  Gold Star to Adobe!  Wink  

You can now also click on a component class name like "Label" and the livedocs will open within Eclipse to allow rapid reference!!  

I'm sure there are developers out there who won't find these features very valuable, but I for one have already become VERY excited at the prospect of not having to constantly keep a browser window open to livedocs.  The next wave of Flex development is already VASTLY improved over Flex Builder 3 with the modifications to Flash Builder 4.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Southerly 42RST

June 3, 2009 22:26 by shawny

I... am in love.  A couple months ago, I happened upon an article in Cruising World on the Southerly 42RST.  This dual helm, dual rudder swing keel beauty is spacious, fast and elegant.  At least she looks to be from the pictures and reviews.  Boasting a draught of almost 9' with the keel lowered, and less than 3' keel raised, the Southerly can hold her own in almost any water and allowing her owner the freedom to shallow draft into the most private of areas.  After studying the plans and layouts, the thing that strikes me most are the little things... that extra attention to detail such as making use of the underside of the cockpit table to provide light into the master stateroom.  I also love the raised salon especially when considering the 42RST as a liveabaoard.

You can check her out at http://www.northshore.co.uk/Flash/S42RST.htm

Continents away from my budget doesn't mean a guy can't dream.

 


Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

HomeSpotHQ

June 3, 2009 22:11 by shawny

They say that the key to a successful business is finding a need or service and then filling that void.  A friend and former co-worker of mine has created a great new website called HomeSpotHQ and provides a great free service.  Your home is statistically your most expensive purchase and there has never been a way to keep up with your home maintenance needs, until now.  HomeSpotHQ offers users a way to track maintenance, home improvement projects, and more.  Wondering when to change the air filters in your house?  HomeSpotHQ can remind you.  Interested in building a new deck, HomeSpotHQ can help you.  Check it out!

Way to go Derek!


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Adobe Flex Builder is now beta Flash Builder 4

June 2, 2009 19:41 by shawny

After a long wait the newest version of the Adobe Flex IDE has been released in beta.  Flex Builder is now called Flash Builder 4 and boasts several new features, mainly:

  • designer/developer workflow
  • data-centric development
  • IDE productivity and testing

You can read about all of the new features and download the beta at http://labs.adobe.com/technologies/flashbuilder4/.Alongside Flash Builder 4, Adobe has released Flash Catalyst (formerly code-named "Thermo") to beta as well which promises to increase the productivity and speed of rich internet application development without coding.  Flash Catalyst provides the user with the means to turn standard Photoshop and Illustrator artwork into actual interfaces!!!  Now THAT'S entertainment!  Somebody bring me some cookies cause I'm gonna be here for awhile!

A couple of must read articles:

Differences between Flex 3 SDK and Flex 4 SDK beta by Joan Lafferty

Whats New in Flex 4 SDK Beta by Matt Chotin

What's New in Flash Builder 4 Beta by Tim Buntel

And some videos!!!

Videos Here

 


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Flex itemRenderer: using "outerDocument"

June 2, 2009 17:50 by shawny

I discovered a neat little trick today on the topic of inline item renderers for Flex components.  Let's say you have a property that you need to access, but that property is not part of the data object that is passed to the renderer.  Something like this:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

     <mx:CheckBox id="chkDisplayColor" label="Display Favorite Color"/>
     <mx:CheckBox id="chkDisplayFruit" label="Display Favorite Fruit"/>

     <mx:List>
           <mx:itemRenderer>
               <mx:Component>
                   <mx:HBox width="100%">
                       <mx:Label width="50%" text="{data.name}"/>
                       <mx:Label text="{data.@color}" visible="{outerDocument.chkDisplayColor.selected}"/>
                       <mx:Label text="{data.@fruit}" visible="{outerDocument.chkDisplayFruit.selected}"/>
                   </mx:HBox>                                
               </mx:Component>
           </mx:itemRenderer>
      </mx:List>

</mx:Application>

In this situation, you can use the outerDocument keyword to access the item you are trying to get to.  I haven't seen this work with non-inline renderers, but it is very helpful.  Since you are binding to the checkbox (or a Bindable getter/setter function) whenever the user checks/unchecks the checkboxes, the ui will automatically update to display the items you wish to see.


Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Flash & Flex Developer Magazine

May 28, 2009 10:10 by shawny

FFD is a great magainze for anyone interested in Flash and Flex development.  In this issue:

  • How to become a Flash/Flex Developer?…
  • Data Analytics and Tracking User-Behavior in Flex Applications…
  • Animating with ActionScript…
  • Create your first ActionScript game in minutes…
  • Flash DecalSheet System…
  • Flickr in Flash – Creating a portfolio…
  • How to use Yahoo! Maps in Flex…
  • Flex Application Architecture…
  • Google Analytics for Flash…
  • Miniblog Part 2…
  • Drag and Drop in AIR using Flash CS3…
  • FLEXing Your Business Application…
  • New 3D Methods of Display Objects in Flash Player 10…
  • Blender to Flash workflow…
  • How to view PowerPoint on YouTube…
  • Check them out at http://www.ffdmag.com/


    Currently rated 4.7 by 3 people

    • Currently 4.666667/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Masterful Manipulation: 'Get Motivated'

    May 28, 2009 08:53 by shawny

    Yesterday, I attended a seminar known as "Get Motivated" in Greensboro, NC.   Upon reaching the Coleseum exit on I-40 in Greensboro, it took almost an hour to travel the remaining 2-3 miles to arrive at my parking spot.  I arrived in time to see Dr. Robert Schuller announced and giving his talk.  I would like to say that he is a very likeable character, and I enjoyed and was inspired by his message.

    Following Dr. Schuller was Rudy Guliani, the major from New York City during 9/11.  His presentation was less inspiring.  Now I know it's not politically correct to say anything remotely negative about Rudy, but in complete honesty, his presentation sounded like "yadda yadda, 9/11, yadda yadda, my leadership during 9/11, yadda yadda, buy my book, yadda yadda..."

    I knew going in to the seminar that it was designed to sell products.  When an entire office attends for a $19 pricetag, it doesn't take a genius to know that these "big names" aren't coming to impart information for low dollars.  After Guliani, I watched one of the most masterful presenters and speakers I have ever seen.  His name was Phil Town and he was "teaching" about investing.  The product he was pushing was a $3200 package designed to teach "common people" how to invest like the pros.  Using historical data marked up with arrows, he convinced the crowd that with this new set of investing tools (Wealth Magazine) that anyone could easily hit it big in the stock market.  His presentation was a whirlwind.  At one point, he asked for volunteers ("single moms please") and brought them on stage.  Now this was where I began to really become impressed, not with the product, but in his masterful manipulation and "motivation" of the crowd.  Town asked the audience to give the "mothers of our next generation" a standing ovation... but "not a normal standing ovation.  I want you to cheers for them as if they were Aerosmith.  Give them a thrill of a lifetime."  On the count of three, the audience went ape-shit!!!  And this was the exact moment the cameras began scanning the crowd, lighting effects blazing... and looking on the giant monitors two words popped into my head... "sound byte."  I realized that the whole "applause for the single mother" portion of the show was really designed to get a massive reaction from the crowd that could be used for marketing of the seminar and/or presentation.  Brilliant!  Masterful manipulation.

    At the end of Phil Town's time, and after getting everyone all pumped up about learning how easy stock investing is, he literally had the crowd rushing tables dying to give him their money.  The product's retail price was $3200, but "since we were at the seminar, we were going to be given a great deal but only having to pay $99."  I watched the herd with interest as they lined up in droves to give this guy $99 of their money.  It was apparent that most of them were completely unaware that even learning HOW to invest in the market would not provide them with the MONEY needed TO invest in the market.  This point was avoided entirely in the presentation.  Don't get me wrong here, there was nothing unethical (that I could see) in getting people motivated to learn about investing.  There is nothing shady about offering courses on "underwater basket weaving" and if you are able to convince people the "importance and ease" of learning underwater basket weaving, and they jump out of their seats and rush to pay you to teach them, that is PRECISELY the desired end result.  What amazed me was how he was able to instill excitment in the audience (money gets me excited too), even if it was to learn something that most of them would no be able to use.  Just imagine someone getting a group of people really excited and anxious to pay RIGHT NOW for classroom lessons in sailing, even though they don't have a boat and live in the desert.  That's a MAGICAL skill.  I watched as literally thousands of people handed over $99 pumped up on dreams of wealth and pseudo-confidence that was engineered into the presentation.  While the herd rushed frantically to learn something that had the "potential" to make them wealthy, I stood to the side and envisioned standing above watching all that money rolling in.  I GREATLY enjoyed the presentation and the experience!!  I learned some small pieces (not too much mind you cause the indepth understanding would come from the course) of information about the market... "Covered Calls," "MARR," etc, but the highlight for me was watching Phil "close" the crowd.  He is a true master of public speaking, and "motivating" people.     


    Be the first to rate this post

    • Currently 0/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    Laptop Wishlist: Backlit Keyboard

    May 26, 2009 01:00 by shawny

    I've posted several times lately about my laptop, which has served me well for almost 4 years.  My current machine is an HP dv8000, single core AMD turion64 @ 2.0 GHz, 2 GB memory, dual 100Gb HDD @ 7200.  In all, it's a great machine but I've found that I could use a wee bit more power.  I've been window shopping for a couple months now and I've noticed that there is an extreme LACK of laptops with backlit keyboards.  I know of a couple machines with backlighting, mainly the HP HDX 16t and HDX 18t series premium laptops and the Apple MacBooks.  I'm curious if anyone knows of any others.

    My idea of a perfect machine is as follows: high-end dual or quad core, dual HDD (640Gb (2x320Gb) @ 7200) or dual SSD, 8Gb DDR3 memory, MATTE finish(non-reflective) instead of glossy screen, BACKLIT keyboard, webcam+fingerprint reader, 1Gb video DDR3.

    So far, the closest is the HP HDX 18t but the $3300 price tag is something I struggle to justify (as badass as it is).  So until the quads come down in price, I think I'll have to settle for a dual core machine, but Im having a hard time locating the backlit keyboard.  I do most of my work at night and it would be helpful to not have to keep the lights on in order to see the keys.    


    Currently rated 5.0 by 1 people

    • Currently 5/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5

    FLARToolkit: Demo Application - Sphere Orbit

    May 17, 2009 21:47 by shawny

    A couple days ago, I posted on the FLARToolkit and my desire to create a solar system demo using the toolkit.  I have since discovered that my machine will not handle the graphics when using non-wireframe materials.  I would like to give a great big "Thank You" to Lee Brimelow and his Introduction to Augmented Reality video on gotoandlearn().  The original FLARToolkit contains only Japanese comments and can be tricky to read.  Lee Has done a great job of walking through a setup of FLARTookit in FlexBuilder and if you are interested in getting started quickly, it is a MUST SEE.  Lee also walks you through the process of creating your own marker file using the FLAR pattern MakerGenerator AIR application.  Another option is to use the FLAR Marker Generator Online version.

    Working in FB3 is more comfortable for me as code-hinting works better in FB3 over Flash CS4.  As a Flex Dev, I spend most of my time in FB3 anyway, so it's just more comforting to do my work in it.

    Using PV3D, and the FLARToolkit I created a sphere demo containing a PhongMaterial applied to my sphere and had my sphere perform a simple orbit around a center point.  I also had the sphere perform a rotation around its own y-axis to simulate the rotation of the Earth.  I added a small moon that rotated around my "earth" but I need to make a couple changes to allow it to run with my "high speed" computer.

    You can download and try the application on the FlexMafia site.  You will need to print out the marker file, and will need to attach a webcam once you download the project  for this example, I used the marker from the GE Smart Grid demo. (Hope they don't mind.)

     


    Currently rated 5.0 by 2 people

    • Currently 5/5 Stars.
    • 1
    • 2
    • 3
    • 4
    • 5