Welcome!

Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

Related Topics: Adobe Flex

Adobe Flex: Article

Integrating a Flash Interface into Flex 2

A proof of concept

My goals here are to integrate www.adobe.com/products/flash/ Flash with www.adobe.com/products/flex/ Flex, i.e. not just treat it as a design asset tool, but as a contributor to the functionality of the client; using Flash for enhancing the design, and helping reduce transition code which tends to be verbose in Flex.

Below you'll find a sample application that has integration of a complicated Flash design done using many different techniques. I describe the reasons why you would want to work this way, compare with other techniques, and walk through the code and files in my example.

To be clear, this is a proof of concept, and uses a variety of techniques for the purposes of showing developers a variety of ways to do things. It is not meant to indicate all ways to integrate Flash and Flex, nor necessarily the best ways for all occasions. Yes, I did in fact abuse this design for schizzle my nizzle.

Why Integration?
Early on in Flex 2's release, many Flash developers recognized immediately that there were serious interop issues with Flash and Flex. This stems from the Flash Player 9's new AVM (or ActionScript Virtual Machine) that runs the new ActionScript 3.0 programming language. ActionScript 2.0, ActionScript 1.0, and Flash Player 4 scripting on down uses the old AVM engine. For security and various other engineering reasons, the AVMs cannot talk to each other. This results in a SWF written in the Flash 8 IDE not being able to "talk" to a Flex 2 SWF. The need for doing this is that the Flash IDE allows creation of design content that Flex cannot create on its own. Flex 2 is an awesome programming environment compared to Flash, is approachable by developers, and is more geared towards large programming projects vs. multimedia. Therefore, there is much incentive to get them to work together, and not just by using a loadMovie approach (dynamically loading in the Flash created SWF at runtime).

There are various solutions out there. One is do just that, load in the content dynamically by using a SWFLoader component in a Flex 2 project. In the cases of a ActionScript 3.0 only project, you merely use the Flash.display.Loader class. If the content can operate on its own, and/or show design content correctly, this is satisfactory.

Another is to utilize a small set of classes to communicate via LocalConnection. LocalConnection is a class that allows multiple SWFs on the same computer to talk to each other. This helps bridge the AVM gap via viable APIs. This is asynchronous, however, and error checking is faith based.

A third one is to utilize ExternalInterface. Flash Player 8 introduced the ExternalInterface, and API to allow Flash Player to talk, synchronously (a.k.a. to block) with its hosting environment and receive callbacks from those method calls. This not only allows strongly typing those external calls, but hosts can call into the SWF they are hosting as well. In this method an API is used to have the Flash Player 8 SWF that is loaded into a Flex 2 to make a call to ExternalInterface which calls out to JavaScript on the hosting HTML page. The hosting HTML page then forwards that call into the same Flex 2 SWF. The Flex 2 SWF can do the same thing going back since both SWFs can independently register callbacks in JavaScript.

A fourth option is to create the SWF using the Flash 9 Public Alpha up on Adobe Labs (http://labs.adobe.com/technologies/flash9as3preview/). It has the ability to not only use ActionScript 3 in the Flash IDE, but can also produce Flash Player 9 SWFs. One technique in doing this is to have have AS3 in the talk up to Flex who is loading it. There are some small gotchas with "digging" your way up to talk to Flex, but it can be done.

So, why not use one of the above methods? First off, Flash is powerful; it's not just a design asset. So, simply being loaded in isn't good enough for some functionality: Flash and Flex need to talk. Secondly, LocalConnection isn't synchronous, and doesn't have good error checking. This makes debugging long and frustrating. Third, Externalnterface uses JavaScript. You've now gone from two languages to three; ActionScript 3.0, ActionScript 2.0 (or 1.0), and JavaScript as well as at least two different tools; Flex Builder for ActionScript 3.0 and JavaScript and Flash 8 for < in compiling when out code specific sound that comment to have you preloading, without via control can so your tag Embed the use if So, example. for mx.core.BitmapAsset and mx.core.SoundAsset not does currently alpha 9 Flash Flex. assets embed are interop with encounter you?ll problems only classes 3 ActionScript same share You future. solution viable a is thus coming? ?is since fourth about said be much there said, That flow. work production of part major software want don?t typically yet, released isn?t 9) (Flash Blaze Fourth,>

What Does Integration Get You?
If I'm making it sound like integration isn't actually the best solution, merely the lesser of the various evils, that's because it is. This is how things are, and even when Flash 9 is released, things won't be much better. Regardless, Flash can produce design content that Flex cannot, and used together the tools are powerful with the right team. Integrating Flash into the developer's work flow rather than as a design afterthought is the best thing to do on larger programming projects - which is typically what Flex is used for. Either that, or the primary skill set on your team is traditional programming, and thus the natural choice is Flex vs. Flash, in which case, Flash is the odd man out, but still a valid contributor.

As mentioned above, you can use the same code. You can write a Flash component in ActionScript 3.0 and use that same component in Flex. You can integrate it into the same Flex project and check it into the same version control. Traditional programmers will get that good feeling they typically don't get with Flash projects with regards to maintenance.

You can compile the same code in both programs. Since you are using ActionScript 3.0, Flex Builder, mxmlc, and Flash 9 can compile it. Granted, there are caveats with embedding, and it's a bitch. If I knew RegExp, I'm sure I could get an http://ant.apache.org/ Ant script to do it. Either way, you can even create Flash based test cases that you only use to test the Flash symbol class using the new Document class feature. Flex, which typically wraps the symbol class created in Flash in a UIComponent class via composition, can have its own test case.

You can compile once in Flash. Like the www.jessewarden.com/archives/2005/04/tried_eclipse_a.html MTASC days of old, mxmlc, the command-line Flex compiler has the ability to do bytecode injection; a.k.a. compiling incrementally. What this means is that you can compile in Flash for the mere sake of "getting the design assets into theSWF." If you later change the code in Flex, it'll merely change the code, but leave the original SWF design assets intact. Since you are embedding the symbol class into a main Flex SWF anyway, it'll compile the assets in the Flash SWF into the main one, and use the updated code you just changed. This is nice because it basically treats the SWFs as little design asset DLLs, so to speak, and uses the most up to date code. Unlike DLLs, the SWFs aren't needed at runtime . It also means that you don't necessarily need Flash to compile the Flex project, which scores major points with some traditional programmers. Third party developers and/or contractors, based on requirements, can deliver just a SWF to some clients or a SWF and a class(es) without having to turn over a FLA. I always give my source to clients, but I know some people have legal reasons for not being able to do so.

Finally, you can produce more types of components. Since Flash can do some crazy design ideas that Flex can't, or can't quickly, you can integrate a lot of that into components to be used in Flex; 3D exported to FLV integration, various compositing, and other hardcore visualizations.


More Stories By Jesse Randall Warden

Jesse R. Warden, a member of the Editorial Board of Web Developer's & Designer's Journal, is a Flex, Flash and Flash Lite consultant for Universal Mind. A professional multimedia developer, he maintains a Website at jessewarden.com where he writes about technical topics that relate to Flash and Flex.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Peter Beckwith 03/15/07 12:02:08 PM EDT

< in compiling when out code specific sound that comment to have you preloading, without via control can so your tag Embed the use if So, example. for mx.core.BitmapAsset and mx.core.SoundAsset not does currently alpha 9 Flash Flex. assets embed are interop with encounter you?ll problems only classes 3 ActionScript same share You future. solution viable a is thus coming? ?is since fourth about said be much there said, That flow. work production of part major software want don?t typically yet, released isn?t 9) (Flash Blaze Fourth,>

???????????????????????????

want to explain why it reads like a korean spam e-mail?

@ThingsExpo Stories
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics gr...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things’). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing? IoT is not about the devices, it’s about the data consumed and generated. The devices are tools, mechanisms, conduits. In his session at Internet of Things at Cloud Expo | DXWor...