Appliness is a new digital magazine and the first of it’s kind to focus entirely on web application development! Appliness was created entirely using Adobe Digital Publishing Suite, and the effort was lead by our own Michael Chaize. Go download a copy today! It’s also FREE!
Be sure to also check out how this magazine was created using Adobes Digital Publishing Suite, and check out the video preview above. Interested in contributing in Appliness or providing us with valuable feedback? If so, you’re in luck–let us know here: http://appliness.com/give-us-feedback/. We’d love to hear from you!
I see questions and comments all the time with the general sentiment “it looks nice, but who really uses PhoneGap/Apache Cordova?”. There is no way to create a definitive list of everyone who uses it, but the general answer is “more people than you think”. Here are a few organizations that you might recognize who are using either PhoneGap or Apache Cordova in their cross-platform mobile solutions and/or tools. (PhoneGap is a distribution of Apache Cordova)
Wikipedia
The official Wikipedia mobile application is built using PhoneGap. This is currently available for Android and BlackBerry, and it is my understanding that the PhoneGap codebase will be deployed for iOS soon. This project is open source, and the full source code is available on GitHub at https://github.com/wikimedia/WikipediaMobile
Salesforce uses a fork of Apache Cordova for their mobile development SDK. The forked version of their SDK is included within both their iOS and Android SDK repositories on GitHub (inside of the “external” sub directories).
Microsoft is involved with core Apache Cordova development (specifically for the Windows Phone platform). Not only are staff from Microsoft committers for the core Apache Cordova project, Microsoft has also used PhoneGap on public mobile applications that target multiple platforms. This includes the XBox-Live integrated gaming application Halo Waypoint, for both iOS and Android. Check out Halo Waypoint in the video below, it looks awesome:
I think most people already know how deeply involved Adobe is with PhoneGap, but I’ll try to recap quickly… In late 2011, Adobe acquired Nitobi, the creators of PhoneGap, and contributed PhoneGap to the Apache Software Foundation as the Apache Cordova project. Adobe has resources dedicated to furthering PhoneGap and is dedicated to the success of the platform. Not only are we helping develop and mature PhoneGap/Apache Cordova, we also build some of our own applications with it. (Maybe I’ll be able to talk about those some day.)
Logitech used PhoneGap to develop the Logitech Squeezebox Controller application, which uses your home wifi connection to control a Squeezebox Internet radio device from your smart phone. You can read more about this application on the PhoneGap application showcase, or download it now for iOS or Android.
Still not sure if anyone uses PhoneGap? What about these, among many others?
I’ve been “out and about” lately, attending tech conferences, meetup groups, and meeting with developers in their offices, and I am getting great feedback on mobile development and PhoneGap. There are some common questions that I am often asked, and I hope this post helps everyone understand PhoneGap better.
PhoneGap
Before I go too far, let me attempt to clearly state what PhoneGap is… PhoneGap is an application container technology that allows you to create natively-installed applications for mobile devices using HTML, CSS, and JavaScript. The core engine for PhoneGap is also 100% open source, under the Apache Cordova project. You can read more about PhoneGap under my “What is PhoneGap?” & Other Common Questions post.
PhoneGap User Interface
The user interface for PhoneGap applications is created using HTML, CSS, and JavaScript. The UI layer of a PhoneGap application is a web browser view that takes up 100% of the device width and 100% of the device height.
Think of this as a “headless” web browser. It renders HTML content, without the “chrome” or window decoration of a regular web browser. You build your application to take advantage of this space, and you build navigational/interactive/content elements and application chrome into your HTML and CSS based user interface.
The web view used by PhoneGap is the same web view used by the native operating system. On iOS, this is the Objective-C UIWebView class; on Android, this is android.webkit.WebView. Since there are differences in the web view rendering engines between operating systems, make sure that you account for this in your UI implementation.
PhoneGap API
PhoneGap provides an application programming interface (API) that enables you to access native operating system functionality using JavaScript. You build your application logic using JavaScript, and the PhoneGap API handles communication with the native operating system.
You can read about the PhoneGap API and all of the native functionality it exposes at docs.phonegap.com.
In addition to the “out of the box” functionality, you can also leverage PhoneGap’s JavaScript-to-native communication mechanism to write “native plugins”. PhoneGap native plugins enable you to write your own custom native classes and corresponding JavaScript interfaces for use within your PhoneGap applications. You can read more about PhoneGap native plugins at: http://www.tricedesigns.com/2012/03/01/phonegap-native-plugins/ and http://wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins
PhoneGap Application Packaging and Distribution
PhoneGap applications are developed using HTML, CSS, and JavaScript, however the final product of a PhoneGap application is a binary application archive that can be distributed through standard application ecosystems.
For iOS applications the output is an IPA file (iOS Application Archive), for Android applications the output is an APK file (Android Package), for Window Phone the output is a XAP file (Application Package), etc… These are the same application packaging formats used by “native” applications, and can be distributed through the appropriate ecosystems (iTunes Store, Android Market, Amazon Market, BlackBerry App World, Windows Phone Marketplace, etc…)
PhoneGap High-Level Application Architecture
Specific application architectures are going to differ on a case-by-case basis, however most data-driven applications employ the following basic architecture. The PhoneGap application acts as a client for the user to interact with. The PhoneGap client communicates with an application server to receive data. The application server handles business logic and communicates with a back-end data repository.
The application server is normally a web server (Apache, IIS, etc…) and has a server side scripting language such as ColdFusion, Java, .NET, PHP, etc… PhoneGap is agnostic of back-end technologies and can work with any application server using standard web protocols. The application server performs business logic and calculations, and generally retrieves or persists data from a separate data repository – this is normally a relational database, but could be any structure or mechanism for data persistence.
PhoneGap applications generally do not talk directly to a database; communication is routed through an application server. The client to application server communication can be based upon standard HTTP requests for HTML content, REST-ful XML services, JSON services, or SOAP (or websockets if your OS supports it). These are the exact same techniques that you would use in a desktop-browser based AJAX application.
The client-side architecture generally uses the single-page application model, where the application logic is inside a single HTML page. This page is never unloaded from memory. All data will be displayed by updating the HTML DOM, data is retrieved from the application server using AJAX techniques, and variables are kept in-memory within JavaScript.
Multi-page client-side application architectures are supported, but are not recommended because you lose in-memory variables when loading a separate page.
Earlier this month, PhoneGap 1.5 was released. There were a lot of enhancements in this release. However, if you’ve tried to update an existing codebase from PhoneGap 1.4 to 1.5, you may have realized that things look a bit different. Basically, the entire PhoneGap codebase has migrated from PhoneGap naming to Apache Cordova naming conventions.
Every reference to “PhoneGap” is now “Cordova”. This includes, but is not necessarily limited to:
phonegap.js is now cordova.js
The “PhoneGap” object in JavaScript is now “Cordova” – this means every reference to “PhoneGap” should now reference “Cordova”
In native code, every PhoneGap class that was prefixed with “PG” is now prefixed with “CDV”; for example, “PGPlugin” is now “CDVPlugin”
Documentation that refers to the PhoneGap class may be out of date… just switch the name reference.
The “PhoneGap” project template in Xcode is now “Cordova”
This is just a naming convention change as the PhoneGap project is moving to its new identity as Apache Cordova. However, it is just a name. Be sure to read this article from the PhoneGap team to understand why the name changed and to understand the relationship between “PhoneGap” and “Cordova”.
As a PhoneGap developer, how you build applications has not changed, and the power of PhoneGap/Cordova has not changed. You can still create awesome apps with it, and it is still 100% open source.
If you are looking at code that doesn’t work in PhoneGap 1.5, then chances are you need to update to use the new naming conventions.
If you are just getting started, be sure to check out my “Getting Started with PhoneGap” guides on Adobe Developer Connection for both Android and iOS - both of these articles use the new naming conventions.
As promised, here are the slides from my presentation “Introduction to Mobile Development with PhoneGap” from the MobileDev@TU meetup last night. Many thanks to Towson University for hosting the event and inviting me to speak!
I am embarking on a new PhoneGap project that will have to run on many platforms… iOS, Android, BlackBerry, and Windows Phone. This will actually be my first foray into modern Window Phone development. (I did some experimental work with the Windows Mobile platform many years ago, but a lot has changed since then.)
One of the caveats with Windows Phone development is that it has to be done from Windows, just like iOS development has to be done from OS X (normally, although some cross platform technologies enable development via other OS/platforms).
Of course, I did not want to give up OS X, so here’s how I have my environment setup… I have a virtual machine running Windows 7, in which I can run the Visual Studio development tools. I am able to deploy to a physical Windows Phone device using the USB connection.
Windows Phone Development with PhoneGap, on OS X
However, with this configuration you will NOT be able to use the Window Phone emulator, which is a part of the Windows Phone development SDK. The Windows Phone emulator is not supported inside of a VMWare virtual machine because the emulated operating system environment does not meet the minimum requirements (specifically the graphics drivers are not WDDM 1.1 compliant). If you try to use the phone emulator inside the virtual machine, you will just get a blank screen. I spent a few hours trying to find a workaround, to no avail. You can use the Windows Phone emulator if you boot your Mac into Windows using Bootcamp, but I wanted to keep OS X as my primary operating system.
Being able to deploy directly to a device works for me, and is (in my opinion) better than being able to deploy to an emulator, thus I am happy with this workflow. I have heard that other people have had trouble deploying to Windows Phone devices through a VMWare emulator, so here are the details on how I have my environment setup and a few “getting started” links for PhoneGap development on Windows Phone:
Note: All of the project setup work will be done through the Windows virtual machine instance.
There is a detailed “Getting Started” guide for PhoneGap and Windows Phone available at http://phonegap.com/start#wp. This will provide you with all the information that you need to get started with PhoneGap applications for Windows Phone.
As a part of the setup process, you will need to download and install the Windows Phone SDK from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27570. This will include a copy of Visual Studio Express 2010 for Windows Phone, as well as additional tools for Windows Phone development.
To be able to deploy an application to a physical Windows Phone device, you will need to register as a Windows Phone developer on MSDN App Hub at http://create.msdn.com/en-US/home/membership. This is a very similar model to Apple’s iOS developer program. There is a $99 annual fee, and once you are registered, you will be able to debug on devices and distribute applications via the Windows Phone Marketplace. However, debug provisioning is much easier. Instead of signing each application with a debug certificate, you just have to register your device as a development device. Once the device is registered, you will be able to deploy to it without any other special steps; this is very similar to the provisioning model for Nook devices.
When linking my AppHub account to my Windows Live account (a required step), I ran into a vague error message “There’s a temporary problem with the service. Please try again. If you continue to get this error message, try again later.” After scouring the web for this error message, I found a few threads that mentioned this error is likely the result of an incomplete profile for your Windows Live account. Sure enough, I went into live.com and filled out my profile (including contact information), and this error went away.
My Setup
Below are the specifics for my setup; I did not have any issues connecting a Windows Phone device with this configuration.
To deploy an application to a Windows Phone device, you just have to use the Windows Phone Developer Registration Tool, and walk through a few simple steps to associate your phone with your developer account. This tool is installed when you install the Windows Phone SDK. You can read full details about debugging Windows Phone applications on MSDN.
As I mentioned above, I have heard that others have encountered problems when trying to deploy applications to Windows Phone devices via a virtual machine on OSX, but I have not had any problems with this configuration.
I was inspired to write this post by several recent conversations. I was in a debate about whether with the Flex/Flash platform you could easily repurpose content to the desktop using Adobe AIR (and vice-versa), but that you couldn’t easily do that with PhoneGap applications. (My stance was that yes, you could repurpose content.)
I wanted to make sure that people were aware that you can repurpose your content, and here’s an example of how.
A while back, I wrote a sample PhoneGap application that allows you to browse information from the 2010 US Census. You can read more about this application and download the source code here. This application supports lots of platforms… iOS, Android, BlackBerry, and web (everything except IE because I was targetting WebKit browsers).
While this application is a mobile app wrapped in the PhoneGap container, I actually didn’t use any PhoneGap-specific libraries, so it was very easy to repurpose as a desktop application. I created an AIR version of this application, which you can download at:
I had to use my Android 2.x branch of the US Census Browser code because the WebKit instance inside of AIR doesn’t support SVG. I also changed the container scrolling to use normal CSS “overflow: auto” instead of using iScroll for touch-based scrolling. There were a few other one-off CSS changes to tweak the layout in the AIR web container, but otherwise the code is identical.
You just need to create an AIR application XML file and point it to your HTML content, and then package it using ADT.
If you were using PhoneGap APIs, you would have to migrate your code to take advantage of AIR APIs, but all other HTML/CSS/JS could be reused with minimal changes.
Even though I used AIR for this example, AIR isn’t the only game in town for HTML-based desktop applications… There’s an open source project called MacGap, you can use HTA for Windows, and it’s not hard to write a HTML/Web View wrapper for any platform. It’s even been reported that you are going to be able to write apps for Windows 8 purely using HTML & JS, and you would be able to repurpose your code for this as well.
You can check out the AIR version of the US Census Browser at:
If you are manually building PhoneGap projects across multiple platforms, managing source files can sometimes become a little bit tricky. If you are building for Android, you need a project within Eclipse. If you are building for iOS, you need a project within Xcode. If you are building for both, you need to make sure that the code in the Eclipse project is in synch with the code in the Xcode project so that the platform-specific apps are in parity with each other.
Keeping the project source code in synch can be achieved using manual copy/paste between projects, but this is messy and error prone. The synchronization can also be scripted using ANT or other scripting language, but this requires an additional script and/or step in your build process. Although scripting is a reliable process, sometimes you just don’t need the script.
If you don’t want to manually synch things, and you don’t want a script, you can use a symlink to link directory paths. Basically, create a “src” folder outside of each project, and create a symlink reference to the src folder inside of the “www” folder for each project. Symlinks allow a logical directory mapping, which actually points to another location on the hard disk.
From the command line, you just use the following command:
ln -s source target
To setup your project, first create your directory structure. I created a parent folder for the project. Inside of that folder, I created a “project-ios” folder, “project-android” folder, and “src” folder. The “src” folder will contain the shared HTML/JavaScript for the application. The “project-ios” folder will contain the Xcode project, and the “project-android” folder will contain the Eclipse project.
Project Structure
Next, create the actual iOS and Android projects inside of these folders, following the normal setup instructions:
Once you have set up both projects, you’ll need to configure the symlinks. Put a copy of the “index.html” file into your “src” directory. Next, go to the “www” directory for each project and delete the “index.html” file to remove any ambiguity or chance for error.
However, DO NOT DELETE THE PHONEGAP.js files!
The phonegap.1.4.1.js files are platform specific. The Android version will not work with iOS, and the iOS version will not work with Android.
Next, navigate to your root folder that contains the “src”, “project-iOS”, and “project-Android” folders. Here you will create the actual symlink references. When doing so, be sure to use the full path to the source and target destinations. You will need to create a symlink reference from the “src” directory to “project-ios/www/src”, and a symlink reference from the “src” directory to “project-android/assets/www/src”.
If you try to use a relative path from your current location, it will give you errors and a massive headache. You can use “pwd” to get a reference to the full path of your current directory.
Here are the commands that I used on my system, where the root directory is “/Users/triceam/Documents/dev/phonegap-sharedsource”:
You can see this in my console in the image below:
Create Symlinks
This will create logical links to the root “src” folder, which can be treated like any other directory structure.
Symlink References
In both Eclipse and Xcode, this will show up as a normal folder. Any edits in one IDE will show up in the other IDE since they are pointing to the same physical directory on the hard disk.
Content in Eclipse & Xcode
Next, you’ll need to update the PhoneGap projects to point to the shared index.html file.
In the Eclipse project, open your main Android activity and change the call to super.loadUrl to refer to the index.html file inside of the linked “src” directory in the onCreate method.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/src/index.html");
}
In the iOS project, open AppDelegate.m. You’ll also need to update it to reference the index.html file inside of “src”. You’ll just need to edit the start page to “src/index.html” inside of the function: (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
Also, be sure to update the link inside of “src/index.html” to point to the project-specific PhoneGap JavaScript files in the parent directory “../phonegap-1.4.1.js”
(they are not inside of the linked folder):
While looking at the analytics for my blog, I’ve recently started to see a lot of search phrases similar to “what is phonegap?”, “how does a phonegap app look?”, “how to get started in phonegap?”, among many, many others. In this post, I hope to shed some light on some basic questions to help you understand and start working with PhoneGap.
In case you don’t feel like reading the whole thing, here are quicklinks to each question:
PhoneGap is an application framework that enables you to build natively installed applications using HTML and JavaScript. The easiest way to think of PhoneGap is a web view container that is 100% width and 100% height, with a JavaScript programming interface that allows you to access underlying operating system features. You build your user interface using traditional web development skills (HTML, CSS, & JavaScript), and use the PhoneGap container to deploy to different application ecosystems and devices. When packaged for deployment, the PhoneGap application is a binary distributable file that can be distributed by the “normal” application marketplaces (iTunes, Google App Market, Amazon Market, etc…).
PhoneGap can be used to build applications that target multiple platforms, including Apple iOS, Google Android, Windows Phone, BlackBerry, HP WebOS, Symbian, and Bada.
Since the UI rendering engine is the mobile device’s web browser, PhoneGap applications can literally look like anything. You can use standard HTML & CSS to make it look like a normal web page, you can use a UI framework like jQuery UI, Kendo UI, Sencha, Twitter Bootstrap, or Skeleton (or any other HTML/CSS/JS user interface framework). You can also use CSS styles/themes to make your web content look like native apps, such as iUI to mimic iOS or Android, or bbUI to mimic BlackBerry.
PhoneGap applications can have static UIs based on normal HTML, or can have dynamic & interactive experiences developed using JavaScript. It depends upon the specific application, user experience design, target audience, and use cases to dictate how a PhoneGap application will appear.
PhoneGap applications can use pinch/zoom gestures to zoom in & out, or you can lock the viewport scale using the viewport metadata tag. You can have the page scroll using normal browser behaviors, or you can use a library like iScroll to enable touch-based scrolling of specific container elements.
There really are lots of ways to create a user interface with HTML, CSS & JavaScript, so there really isn’t any “typical” look. If you do not apply any CSS styles at all, then all user interface elements will use the operating system/browser default for that specific platform. This includes buttons, links, and color/highlight states. This behaves in the exact same manner as the operating system’s default web browser.
How do I get started in PhoneGap?
Getting started in PhoneGap is easy. For 90% of a PhoneGap application, all you need is a text editor. PhoneGap also integrates with device-specific development environments very easily. You can view “getting started” guides for all application platforms at the links below:
When developing PhoneGap applications, just keep in mind that you are running code inside of a web browser instance. You develop your applications using HTML and JavaScript, not native code, so you don’t need anything special. In fact, I personally do most of my development on the desktop using an HTML editor and the Chrome browser. When I need device-specific functionality, or I need to test on a device, then I switch over the the device-specific environments.
How do you debug PhoneGap applications?
Debugging PhoneGap applications can sometimes be the trickiest part of development. If you are testing on a physical device, you can’t always get access to JavaScript exceptions when they happen. There are a few strategies for debugging PhoneGap applications.
Develop as much as possible on the desktop browser
Since PhoneGap applications are written with HTML, CSS, and JavaScript, you can develop most of them using any HTML editor and debug them within a desktop web browser. The latest versions of all major web browsers (including Chrome, IE, Firefox, Opera and Safari) provide rich debugging features. In the developer tools for the browsers, you can inspect HTML DOM elements, inspect CSS styles, set breakpoints in JavaScript, and introspect into memory & JavaScript variables. You can learn more about the desktop browser development tools at:
Once you build the main aspects of your application using desktop tools, you can switch over to a device-specific environment to add device-specific behavior and integrate with PhoneGap APIs.
It is imperative that you test your applications on actual devices! Actual devices will have different runtime performance than desktop browsers and simulators, and may unearth different bugs/issues including API differences and different UX scenarios.
Debug With debug.phonegap.com
PhoneGap provides a hosted service that allows you to perform remote, on-device debugging through debug.phonegap.com. This uses the Weinre (Web Inspector Remote) debugging tool to allow you to remotely inspect the DOM, resource loading, network usage, timeline, and console output. If you have used any of the developer tools listed above, this will look very familiar. You will not be able to set breakpoints on the mobile device, but it is certainly better than nothing at all.
Remote Web Inspector Through iOS 5
There is a little known undocumented API introduced in iOS5 that allows you to perform remote debugging through the iOS5 Simulator. You just need to enable remote debugging
Then launch the application in the desktop iOS Simulator. Once the app is running, open a local Safari instance to: http://localhost:9999/. This will launch the remote debugger, complete with breakpoints and script introspection.
You generally architect PhoneGap applications the same way that you create mobile web experiences. The difference is that the initial HTML assets are available locally, instead of on a remote server. The PhoneGap application loads the initial HTML, which can then request resources from a server, or from the local environment. Since PhoneGap is based in a browser, it behaves exactly as you would expect a web browser to behave. You can load multiple pages; however, keep in mind that once you load/unload a page you may lose any data that is stored in memory via JavaScript. PhoneGap also supports the single-page web experience model. I strongly suggest using the single-page architecture approach.
Single-Page Architecture
A single-page architecture refers to the practice of having a single HTML page that dynamically updates based upon data and/or user input. You can think of this as closer to a true client/server architecture where there is a client application (written with HTML & JS) and a separate server structure for serving data. All client-side application logic resides in JavaScript. The client application may request data and update its views without reloading the current web page.
Using a Single-Page architecture allows you to maintain data in-memory, in JavaScript, which allows you to have a stateful, yet dynamic user interface. You can read more about single-page architectures at: http://en.wikipedia.org/wiki/Single-page_application
How do you get PhoneGap apps on devices and into application ecosystems?
PhoneGap applications can be deployed using the same guidelines for native applications for each given platform. You must follow the rules of each hardware platform/vendor, and there is no way to get around that. You can compile the executables for each platform yourself using each platform’s specific build process, or you can use build.phonegap.com to compile them for you. build.phonegap.com is a hosted service that will compile platform-specific application distributable files for you. In either case, the output of the build process is a platform-specific binary file: IPA for iOS, APK for Android, etc… You can read more about distributing to various application ecosystems, and each system’s signing/certificate requirements at:
The most fundamental differences between PhoneGap and AIR is that you develop AIR applications using tools rooted in the Flash Platform (Flex, Flash, ActionScript, MXML), and you develop PhoneGap applications using HTML, CSS, & JavaScript. AIR applications use the AIR runtime, which allows you to have a single code base, with the exact same expected behavior across all supported platforms. PhoneGap applications run inside of the native web browser component for each supported platform. For this reason, a PhoneGap codebase may behave slightly different between separate platforms, and you will need to account for this during your development efforts.
Air applications can be built for iOS, Android, BlackBerry Playbook, and the desktop (mac and windows), with future support for Windows Metro (Windows 8 mobile interface). You can read more about AIR’s supported platforms at: http://www.adobe.com/products/air/tech-specs.html
PhoneGap applications can be built for iOS, Android, BlackBerry, Windows Phone 7, HP WebOS, Symbian, and Samsung Bada. You can read more about PhoneGap’s supported platforms at: http://phonegap.com/about/features
ActionScript has strongly-typed objects and supports classical inheritance programming models. AIR applications can also be built using the Flex framework, which allows you to rapidly build enterprise-class applications. Components in AIR applications are logical objects that have behaviors, properties, and a graphics context.
JavaScript-based applications support prototypal inheritance, and have numerous open-source frameworks/tools that can be used. HTML/JS applications are all visualized through HTML DOM elements. HTML interfaces can be created through basic string concatenation or JavaScript templating, but in the end you are really just creating DOM elements that have properties and styles.
There are some fundamental difference in the syntax of building these applications, however the basic concepts of interactive design and interactive development are identical. Both platforms have valid strengths, which I could write about ad nauseum… I’ll save that for another post.
Back in the summer, I was lucky enough to get my hands on some early builds of Stage3D for mobile. I built some simple examples, including basic geometric shapes and simple 3D bubble charts inside of mobile Flex/AIR applications. I have been asked numerous times for the source code, and I’ve finally given in, and am sharing some source code.
I am not posting the full mobile application source code, since Stage3D for mobile is not yet available. However, I have ported the 3D bubble chart example to run in a Flex application targeting the desktop (Flash Player 11). The bubble chart example extends the concepts explored in the basic geometric shapes example.
Before you say “shoot, he didn’t give us the mobile code”, let me explain… When I ported the code from the mobile project to the desktop Flex project, all I changed was code specific to the mobile Flex framework. I changed <s:ViewNavigatorapplication> to <s:Application> and the corresponding architecture changes that were required, and I changed the list item renderers to Spark item renderers based on <s:Group> instead of mobile item renderers. In the mobile item renderers, all my drawing logic was done using the ActionScript drawing API. For simplicity in the port, I just used <s:Rect> to add the colored regions in the desktop variant.
That is all I changed!
The stage3D code between the desktop and mobile implementations is identical. You can see the desktop port in action in the video below:
The source code was intended to be exploratory at best… I was simply experimenting with hardware accelerated content, and how it can be used within your applications. There is one big “gotcha” that you will have to watch out for if you want Stage3D content within a Flex application… Stage3D content shows up behind Flex content on the display list. By default, Flex apps have a background color, and they will hide the Stage3D content. If you want to display any Stage3D content within a Flex application (regardless of web, desktop AIR, or mobile), you must set the background alpha of the Flex application to zero (0). Otherwise you will pull out some hair trying to figure out why it doesn’t show up.
The source code for the web/Flex port of this example is available at:
Recent Comments