Flex Ant flexTasks, Manifests and Library Includes

I recently was working on a framework project where one of our front-end developers had written several UI components in Flash Profressional and compiled them into a SWC for me to leverage in an ActionScript project in Flash Builder.  Aside from the compiled SWF, we also had to deliver a SWC to third-party vendors that were developing content against our framework.  The SWC had to include a small subset of event classes from the ActionScript project along with the UI components library from my front-end dev.

The first step was to leverage the flexTasks Ant library included with the Flex SDK to use the compc task.  This is simple enough by specifying the classpath to the flexTasks.jar.  The next step was to create a manifest file specifying the classes in my ActionScript project that should be included in the SWC.  This involves defining a namespace for the manifest, then including the namespace in the compc task.  The final step was including the externally compiled SWC for the UI components.  As simple as it turned out to be, this was a much more difficult task to accomplish, primarily because of the lack of good documentation and examples from Adobe.  

Below are examples of the manifest and ant builder files I ended up using for the project.  Keep in mind some variables Ant variables are defined outside of the builder file itself as Ant properties in the builder launch configuration setup in Eclipse.

manifest.xml

<?xml version="1.0"?> 
<componentPackage> 
    <component class="com.genuinejd.events.NavEvent"/> 
    <component class="com.genuinejd.events.LayoutEvent"/> 
    <component class="com.genuinejd.events.ReferenceEvent"/> 
    <component class="com.genuinejd.events.ModalEvent"/> 
</componentPackage>

builder.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="SWC Builder" basedir=".">   
    <property name="SOURCE_DIR" value="${basedir}/src" />
    <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" /> 
    <target name="main"> 
        <compc output="${OUTPUT_DIR}/Lib.swc" >
            <source-path path-element="${SOURCE_DIR}/"/> 
            <namespace uri="http://genuinejd.com/2011" manifest="${basedir}/manifest.xml" />
            <include-namespaces>http://genuinejd.com/2011</include-namespaces>
         <compiler.include-libraries dir="${SOURCE_DIR}/../libs" append="true">
             <include name="UI_controls.swc" />
            </compiler.include-libraries>
        </compc> 
    </target> 
    <target name="clean"> 
        <delete> 
            <fileset dir="${OUTPUT_DIR}" includes="Lib.swc"/> 
        </delete> 
    </target>
</project>

 

Adding Windows 7 64-bit PDF Indexing

I have been using Windows 7 64-bit since its official release in October and have loved everything about it so far.  I was surprised at first when my PDFs weren't getting indexed, but was happy to know that it took very little work to get it to index them in just a few easy steps.

  1. Verify that PDF files are selected for indexing
    • Open the Indexing Options by clicking Start and typing, "indexing options" (without the quotes) and hitting enter
    • Click the Advanced button
    • Select the File Types tab
    • Scroll down to .pdf, which should already be selected, but probably says, "Registered IFilter not found"
  2. Download and install the Adobe PDF iFilter 9 for 64-bit platforms

That's it!  You may need to rebuild the index (click click the Rebuild button in the Indexing Options), but afterwards, you should be able to search on PDF content.  32-bit users should be able to index PDFs out of the box.

Reading Embedded XMP Packets using ColdFusion

In working more and more on our Digital Asset Management initiatives, I've become more involved in working with XMP.  Mostly as an experiment, I wanted to see if I could read and write this embedded metadata from and to a file.  The Adobe XMP Toolkit indicates how this can be done based on the structure of specific types of files.  It also indicates that packet scanning techniques can be used when file structure is unknown, however, is not encouraged. 

I recognize it might not be the BEST way to read the XMP packet, however, all is fair in love and ColdFusion experimentation :)  It's important to note that this code looks only for the FIRST instance of the string <x:xmpmeta and if there are multiple instances of XMP packets, subsequent instances are ignored.  Adobe also indicates that if there are multiple packets, there is no way to know which packet is the correct one.

Needless to say, using the code below, I was able to read and parse XMP packets from all the Adobe sample files included in their toolkit.  It may not be the end-all solution, and may not work for writing back to the file, but it's a start!

<cfparam name="URL.source" default="xmp-asset.jpg">
<cffile action="readbinary" file="#ExpandPath(URL.source)#" variable="data">
<!--- encode the binary data to hex --->
<cfset hex_data = BinaryEncode(data,"hex") />
<!--- string indicating beginning of packet '<x:xmpmeta' --->
<cfset xmp_string_begin = "3C783A786D706D657461" />
<!--- string indicating end of packet '</x:xmpmeta>' --->
<cfset xmp_string_end = "3C2F783A786D706D6574613E" />
<!--- find the starting index in the hex string --->
<cfset idx_start = FindNoCase(xmp_string_begin,hex_data) />
<!--- find the ending index in the hex string --->
<cfset idx_end = FindNoCase(xmp_string_end,hex_data,idx_start) + Len(xmp_string_end) />
<!--- using the start and end indices, extract the xmp packet --->
<cfset xmp_hex = Mid(hex_data,idx_start,Evaluate(idx_end-idx_start)) />
<!--- convert the hex to readable characters --->
<cfset xmp_string = ToString(BinaryDecode(xmp_hex,"hex")) />
<!--- parse the xml string to and xml structure --->
<cfset xmp_xml = XmlParse(xmp_string) />
<cfcontent type="text/xml">
<cfoutput>#xmp_string#</cfoutput>

Be sure to check out the Adobe XMP Developer Center for more information.

Cygwin Setup Finally Working

I had been trying to get my environment set up to play with Adobe Alchemy, but kept running into problems with my Cygwin setup.  After several frustrating hours of installs, re-installs, uninstalls and some out-of-control Perl threads, I think I've got it ready to go.

The problems I was running into were largely due to two things: 1) The path of my home directory containing spaces ("C:\Documents and Settings\...") and 2) my inexperience with Cygwin.

In regards to #1 above, I think this was causing my home directory (/home/username) to not get created properly.  That meant additional difficulties in customing my environment by editing my .bashrc file.  After the initial learning curve and interpreting the less than specific Adobe Getting Started on Windows instructions for Alchemy, I was able to get the sample library compiled and working correctly.

I did run into a few other problems, but I was able to get through them.  I'll be doing a write up for getting started with Alchemy and Cygwin for Windows users with very little Unix experience when I get some more time.  Of course, now that I've got Cygwin running, I'm hoping to do try out something more significant than Hello World :)

Adobe Alchemy: Initial Setup Impressions

My first thoughts on the Alchemy project were of doubt.  What would be the benefit of running C/C++ code on the AVM2?  It seemed more like a novelty, like running old school NES games on the Wii.  The more I started to think about it (and get past my bad memories of Computer Science C/C++ classes in college), the more I started to realize just how powerful this could be.  There are so many open source C/C++ libraries for a wide variety of applications that, when paired with Flash, could have an amazing impact on Flash and AIR.

I thought I would tinker with it a bit.  Of course, coming to the realization that Alchemy is still limited by the Flash player sandbox was a little disheartening, but I suppose understandable.  I found the initial download and setup quite cumbersome.  One of my biggest roadblocks was working with Cygwin.  I admit, that using Cygwin has its advantages, but configuration thus far has been a beast.  Additionally, the getting started section for Windows section left something to be desired in terms of details.  I'm the first to admit I'm no UNIX or Linux expert, but I'd like to think I know my way around a bit.

After a few hours of trying to just get my environment set up, something more important required my attention, so I have yet to get the provided examples working.  I hope to get back to this more in the next couple of weeks.  I've got a few open source C++ libraries I'd love to test out.  I'm extremely intrigued, but until I get my environment set up, I'm still skeptical.

Branden Hall has written a good overview of Alchemy.

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. genuinejd.com