287
Chapter 9
Talking with JavaScript and HTML:
Web Page Integration
by Elad Elrom
There are many cases where you need integration of your Flex applications with JavaScript. For instance,
you want to leverage existing JavaScript code in conjunction with your Flex application or you want a
better Search Engine Optimization (SEO) by creating part of the page in HTML/JavaScript while
integrating a Flex Widget or component.
This chapter will cover JavaScript integration—both in the sense of JavaScript getting called by your Flex
application and having the JavaScript on the page call the Flex application code. We will also cover a real
life example of a widget using JavaScript integration and leveraging Runtime Shared Libraries (RSL)
technology in Flash 9/10 and Flex to build Flash applications small enough to be widgets.
Hacking the Flash Builder Page Template
Since a lot of the work you will be doing in this chapter involves JavaScript, you are going to be messing
around with the HTML of the page. Flash Builder 4 maintains an HTML template for your application in the
html-template directory. This file is shown in Figure 9-1.
CHAPTER 9
288
Figure 9-1. The HTML page template
We recommend installing an Eclipse plug-in for JavaScript called JSEclipse.
From the top menu select: Help
Software updates Find and install… New Remote Site…
Name: JSEclipse
URL: http://download.macromedia.com/pub/labs/jseclipse/autoinstall/
See Figure 9-2.
Figure 9-2. Add a remote site properties window

Get AdvancED Flex 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.