Thursday, May 19, 2011

How to Crop Adobe Flash Movie in Flash CS4 : Cropping to Resize Flash Movie Output

I just ran into a situation where I needed to, for better lack of a term, "Crop" a Flash Movie using Adobe Flash Professional CS4 Professional.  I had an existing Flash animation at the top of my website that was 780-pixels wide by 205-pixes high — the width was fine, but I wanted to quickly perform some cropping on the Flash movie and remove a large portion of the height that I no longer needed (as I moved the navigation buttons out of the existing Flash movie and into CSS-based menu-buttons.  I wanted to resize the resulting .swf movie shown on my website, but  I was not resizing by scaling everything to my desired movie dimensions, but rather cropping out the parts of the existing movie that I no longer wished to be visible.

My goal was to preserve the middle-portion of the Flash Movie while chopping off the parts above and below that (i.e., cropping in order to resize the resulting movie people see), without spending a lot of time re-working the movie or its scenes.  So, I just assumed that Flash would have a cropping-tool or crop-movie feature included, but I quickly discovered otherwise.  I have the new movie cropped and ready to implement on my website in the coming days. Turns out it takes a few steps to "crop" a Flash movie, but it is not too bad.

Steps to Crop a Flash Movie (.fla and its .swf output)

  1. The first assumption is that you have an existing Adobe Flash (.fla) movie file and a version of Flash Professional CS4 to edit that Flash Movie with (this may or may not work with CS2, CS3, CS5, CS5.5; but, I suspect it will be similar procedure). The next assumption is that your existing movie has larger dimension(s) currently than you wish it to have when you are finished cropping it.

  2. Open the .fla file with Flash Pro or whatever Flash editor you are using.

  3. Modify the Canvas Size: go to the top menu-bar and under the "Modify" menu, choose the "Document..." menu item (or, CTRL-J will get you here quickly). You will be presented with a "Document Properties" popup window in which you can specify the new desired dimensions (width/height) that you want your cropped-Flash movie to be.  This process is just re-sizing the Stage to your chosen dimensions.

    When you are done, your existing Flash movie will essentially be over-hanging the Stage a bit — we will correct that issue in the upcoming steps as we essentially re-position the Movie scene in such a way that only the cropped-portion will remain showing in our resulting .swf file.

  4. Make sure all the layers in your movie are unlocked.  This is simple enough  — from the TimeLine view, just click the lock-symbol once or twice to make sure all are unlocked. See picture above: when all layers below the lock-symbol show just a bullet/dot in the column, they are unlocked.

  5. From that same Timeline-view, you want to make sure the "Edit Multiple Frames" button (see picture above) is depressed (selected). Edit Multiple Frames lets you edit the contents of all the frames within the Start Onion skin and End Onion Skin markers, which brings us to the reason for the next step...

  6. Also from within the Timeline-view, you want to click the "Modify Onion Markers" button (picture above); you will find this button just to the right of the button used for Step #5. When you click this button, a popup menu will appear from which you will want to select "Always Show Markers" (see picture below).  Once you do this, all frames of your movie will effectively be onion-skinned (which essentially allows you to view more than one frame at once, and in this case we will be viewing all frames at once).

  7. It is time to select everything that will be moved within our cropping-area / cropping-region (i.e., our newly resized stage).  To do this, go to the main menu-bar (at top of Flash environment) and choose Edit... Select All (or, CTRL-A).  All objects should now be selected and all Frames containing objects should be selected.

  8. Use your mouse and/or keyboard-arrow-keys to move the Flash movie objects as one large group now... you will want to change the position of these existing objects so that only the portion of the Flash movie that you wish to remain after cropping is what is positioned over the region of your Stage that is visible (this will be the white-rectangle in your work-area, by default).

  9. Go ahead and publish your movie so you can test the positioning and resizing you have accomplished with this cropping technique.  You will be able to move / reposition the entire group of objects repeatedly until you get it right, so long as they all remain selected. Your movie should reflect your new stage-size (i.e., the "cropped stage"), and if all the steps were followed correctly, your movie should retain all of its original animation, motion tweens, and layers in their original sequence and position, but now "cropped" as you wanted.

When I first went hunting for a solution to this problem, all I found were notes that referenced buttons and menu-items and such that I could not find (perhaps older versions of Flash had slightly varied layouts?)  I will admit: I am not an "expert" Flash developer by any means, though I can usually accomplish most of what I want given enough time to play with it.  In the end, I managed to piece together the steps to form this quick "how-to crop a flash movie" blog that I hope helps others accomplish the same thing quickly.

This may not be a perfect solution, but it seems to work, and this method saved me a lot of time compared to totally re-working some of the embedded art-work and such.  I did take time to delete the timeline-layers no longer in use (animated buttons, etc), but that was about it aside from chopping down the size of my background image to match my new target "cropped movie size"; this saved some kilobytes in the output too.

Thursday, May 05, 2011

SQL-Server Algorithms : Set-Based Running Subtotals, Moving Averages, and more.

Being an avid Microsoft SQL-Server developer, I love creating interesting algorithms for solving common business requirements — especially stored procedures and user-defined-functions that exploit the relational database strengths of set-based operations.

[UPDATE: JAN-2017] I moved all the free source code for SQL-Server, that I had previously published on another website of mine, onto this blog, and here is a link that searches this blog for all SQL postings.

Set-Based SQL Procedures Overview
I have implemented, using only set-based algorithms (i.e., no database cursors), functionality that many would consider "impossible" without cursors and without dynamic SQL; as such, these techniques may be intriguing and/or useful to other SQL-Server developers, especially web-based applications that need to be secure from SQL-injection attacks.  There is no dynamic-SQL used and no cursors used to implement these algorithms — seriously

The following table provides links to the various free source code for the stored procedures I have published under the terms of the MIT License (for freeware) on my company website's free source code library.  All of these techniques have been tested and developed using Microsoft SQL-Server versions: SQL Server 2005, SQL Server 2008, and SQL Server 2008r2.

SQL Server Set-Based Running Subtotals (i.e., Row-Level Accumulators)
SQL Server Set-Based Running Subtotals (i.e., Row-Level Accumulators) for Delimited-list Accumulator Functionality
SQL Server Parameterized GROUP BY Without Using Dynamic-SQL : The "impossible" is possible.
SQL Server Parameterized ORDER BY without Dynamic-SQL - Example 1
SQL Server Parameterized ORDER BY without Dynamic-SQL - Example 2 - With ASC/DESC by Column abilities
SQL Server Set-Based Moving Averages (without Cursors, self-joins, or sub-selects) - Example 1
SQL Server Set-Based Moving Averages (without Cursors, self-joins, or sub-selects) - with Break-Level Resets
SQL Server Set-Based Running String Accumulator with Break-Level Reset

There are also some related MS SQL-Server stored procedures and functions on the main-page of the "library" including routines and functions for splitting and parsing strings, padding numbers to fixed-width, accumulating totals of values within comma-delimited strings, comparing nullable columns, and more.  I also posted a series about tuning very large SQL-Server databases for anyone dealing with massive database performance-tuning issues.

I hope you find SQL-Server set-based algorithms, stored-procedures, and functions helpful when tackling common business-requirements.  I have used the SQL running-subtotals and moving-averages to implement some neat financial data modeling and analysis software (everyone is used to moving-average stock-prices and such, right?), and the order-by operations without dynamic-SQL have been quite handy on websites (preventing potential security issues associated with dynamic-SQL and SQL-Injection attacks).

Continue to read this Software Development and Technology Blog for computer programming articles (including useful free / OSS source-code and algorithms), software development insights, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Delphi, Nvidia CUDA, VMware, TypeScript, SVG, other technology tips and how-to's, plus my varied political and economic opinions.

Monday, May 02, 2011

VMware ESXi 5.0 Release Features of Interest

I am a rather ardent fan of VMware (Public, NYSE:VMW) computing hardware virtualization products, especially VMware Workstation and VMware vSphere ESXi (a "bare iron" virtualization product). As a software developer, these tools give me the ability to maintain many simultaneous testing environments on any given desktop or server I employ for writing, testing, or deploying software — a huge time and cost saver for me.

UPDATE (2011-07-20): VMware has released their official guides to What's New in ESXi 5.0 and vSphere 5.0 since this blog was first written, and I have now written a followup blog (to this one) about the New Features in VMware ESXi 5.0 and vSphere 5.0 that goes into much more detail about certain aspects of the products and the new features.  But, I did not necessarily repeat every bullet-point from this initial post, so you may find some nice info on this page also.


The most recent official release of VMware's vSphere ESXi server virtualization / hypervisor product — a free bare-metal hypervisor — was version 4.1 (with update 1), though VMware ESXi 5.0 is nearing on the horizon now, and promises to introduce some features I have been longing for.  In case you need help migrating from 4.0 to 4.1 (in preparation for the upcoming 5.0 release), I wrote a blog about How to Upgrade VMware ESXi 4.0 to 4.1 recently.

I find version 4.x of ESXi to be quite capable for most of my needs, but there were a couple features in the Workstation virtualization product that I wanted to see on my server (via ESXi).  Some early feature-set "leaks" and "rumors" are hitting the technology blogs and other technology news sites now, and if what I am reading comes to fruition in the vSphere 5.0 version of the ESXi hypervisor, I will be quite pleased.
Note: I may not be the "typical" ESXi user, since I do not necessarily use the platform for all its enterprise-grade features, but I doubt I am alone in my using ESXi as a sort of "big brother" to my VMware Workstation desktops.  I am a software developer and SQL-Server database aficionado, and this leads me to using my Server platforms for what is a mix of enterprise-level database-design/testing in addition to actually writing software inside VM's hosted on vSphere ESXi.  I need some of the large-CPU-count limits and memory-size limits the product offers as well as its support for some more enterprise-grade hardware, but I also like features (introduced in v4.x) that included high-resolution graphics for my "server" VMs so that I could enjoy screen-real-estate when editing large blocks of code and testing software sporting robust GUIs.
New Features to Expect
So, with the above in mind, client-connected USB devices are something I would really like to see in the VMware ESXi 5.0 new features, as there are times I am using my server with ESXi to test some software that interacts with a USB-based product — be it a USB printer, USB scanner, USB camera, USB memory-stick, or USB external hard-drive.  From what I am reading, this feature is coming in vSphere 5.0!  In addition, some other noteworthy vSphere 5 / ESXi 5 features that are being talked about include the following (with the ones I listed first being of most interest to me):
  • USB 3.0 device support — to me, this is a "must have" while on the topic of USB-connectivity these days.  I have seen first hand how much faster (than USB 2.0) my USB 3.0 is for large file-transfers to my Seagate FreeAgent GoFlex external USB 3.0 drive (using a Buffalo USB 3.O add-in card).  There is no comparison... the USB 3.0 is many multiples faster, and large-file transfers are done in a fraction of the time; as such, having this available within my ESXi 5.x virtual environment would be wonderful!
  • Smart card reader support for VMs — again, this is complements my desire for more "workstation-like" features when I need them. 
  • Swap to SSD (Solid State Disk)  — this should be really nice for speed-improvements.  I do not know the details, but I am a fan of SSD devices and their speed.  I blogged about my Intel X-25M benchmark results in a desktop I use for software development, and the SSD products have only gotten better, faster, and more affordable since then.  Being able to perhaps cache portions of frequently-accessed data using an SSD (much cheaper than RAM), will be nice indeed.
  • Apple Mac OS X Server 10.6 "Snow Leopard" guest OS support — this is a nice-to-have for me, as I have been wanting to play with more Apple code without necessarily purchasing an Apple server.
  • Non hardware-accelerated 3D graphics for Windows Aero support — again, a nice-to-have from where I stand, if I want to test Windows 7 guests on ESXi under certain circumstances
  • a new browser-based vSphere Client — what I find most interesting with this is that it may be *extensible*, which would perhaps make it easier for open-source (OSS) add-ons of things like free backup software for ESXi 5.x and similar much-desired functionality.  I look forward to seeing how truly extensible this product is, especially as a software-developer that would love to write some handy plug-ins for things I commonly desire.
  • iSCSI user interface support  — this could be interesting too.  I have been just starting to play with FreeNAS and NexentaStor and their iSCSI support and capabilities.  Anything that makes it easier to integrate this type of functionality with ESXi is welcome by me.
  • Support for 2TB+ LUN  — in this day and age of ever-increasing data and storage requirements, coupled with ever-cheaper storage, the existing 2TB LUN limit seems a bit dated.  So, being able to provision for very, very large storage requirements is sure to help with things like massive databases and the like.  I personally do not keep any "test databases" of that size laying around, but I can see the day coming where I may want to do so for performance testing, benchmarking, and similar optimization work.  I have some multi-hundred-gigabyte SQL-Server databases for testing some of my algorithms on, so perhaps the multi-TB threshold is coming (though, I am not sure if the native OS will support that anyhow? hmmm...)
  • 512 VMs  — I am not near that limit by any means, but I could see this making some sense if and when my vision of "a VM per application" ever comes to fruition; that is a vision I have written about elsewhere... perhaps I will publish it here soon.
  • 160 CPUs and 2TB of RAM!  uhh... wow!  Sounds nice, and wish I had such a system just for "kicks".
  • 32 vCPUs per VM
There were plenty of additional enterprise-focused features talked about on the web (for vSphere 5), but most of them will not be very applicable to me.  I will keep my eye out for more "official" release information from VMware, and once some of these rumors/leaks of new features can be confirmed, I will surely write about them (and/or test them out and write about them).  Stay tuned.

Something Amiss: Nvidia CUDA support in ESXi / vSphere?
I did not read anything about VMware implementing support for Nvidia CUDA technology in vSphere5 / ESXi 5.  I sure hope they are considering this, as I see parallel-computing with CUDA as a major and serious technology trend that can not be ignored, and that should be available to server-applications.  I have written a few blogs about CUDA-enabled graphics cards and the potential they offer us software-developers that can leverage the power of the many-GPU-cores for parallel operations; this is an emerging trend in high-powered software that needs to be more accessible via virtual machines.

The last time I researched whether there was any way to make the NVidia graphics cards and their CUDA processors available to ESXi virtual machines, I found that you were out of luck.  Even attempts to use an Nvidia CUDA card as a "pass through" device (to ESXi) would not work.  Basically, unless VMware implements (in their hypervisor) something to allow the CUDA processing architecture capabilities to be accessed through server-based virtual machines, any applications that implement such features will have to run outside of a VM.  

With server vendors offering dedicated parallel-compute modules (implemented using NVidia cards), there is bound to be more and more demand for VM support of CUDA.  Financial firms, medical technology, engineering firms, and other large corporations are embracing CUDA-based applications development, and this surely must translate into demand for CUDA-enabled virtual-machine infrastructures.  So, I sure hope this is addressed in v5 if not in a subsequent "point release" of ESXi 5.1 or 5.2 (though, it is a rather substantial feature for a dot-release perhaps).

I am waiting anxiously to see how EXSi CUDA support is addressed in upcoming releases.  Aside from that, ESXi 5.0 looks rather promising so far.