Home Web Development Flash with Drupal

Flash with Drupal

books-svg-icon Book
eBook $28.99 $19.99
Print $48.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $28.99 $19.99
Print $48.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Flash with Drupal
About this book
Due to its power and expandability, Drupal has become one of the most popular open source content management systems. At the same time, Flash has been adopted for its ability to create beautiful and dynamic web applications. By combining these technologies, you can create Flash applications that are both visually stunning and rich in content. This book is an in depth discussion and tutorial on how to integrate Flash applications with Drupal CMS. It will describe the best techniques and practices for integrating Flash technology with the power and flexibility of Drupal by building real-life Flash applications. Within this book, you will learn how to build Flash applications that show text from within Drupal and also present images, music, and video within a single Flash application. You will also be able to take advantage of the expandable fields and content filtering provided from the CCK and Views modules to add flexibility and power to your Flash applications. Finally, you will learn how to add your own custom functionality to Drupal and then utilize that from within your Flash applications leaving you with a world of possibilities. This book starts out with a simple introduction to Flash and Drupal technology where you will create a simple Flash application and then embed that within Drupal. From there, each subsequent chapter builds on the previous chapters tackling a new and challenging task. For each new task, you will take a step-by-step approach to building a real-life application that utilizes the feature introduced within that chapter. You will also explore alternative design approaches that will eliminate the current design challenges that developers face when building Flash-driven Drupal sites; and all this while staying true to the Object Oriented Principles that govern the foundation of the ActionScript 3 language. By the end of this book, you will be able to apply all the lessons learned from this book to any other use case you may encounter.
Publication date:
May 2009
Publisher
Packt
Pages
380
ISBN
9781847197580

 

Chapter 1. Flash with Drupal

It is no secret that the web sites that become the most popular on the Web are those which possess a series of traits that appeal to the masses; most prominently, content and beauty. Because of this trend, many web developers strive to produce sites that are not only beautiful, but also rich in content. In order to satisfy the beauty requirement, Flash has easily risen to the top as being an ideal portal to deliver dynamic and beautiful web experiences to its users. At the same time, with the explosion of content on the Internet, Drupal has stood out, among other content management systems, as a powerful and expandable means to manage content. It only seems natural, then, to combine these two incredible technologies together to create the ultimate user experience.

In this book, we will learn how to integrate Flash with Drupal by taking a hands-on approach to building real-life Flash applications for Drupal CMS. Each chapter will introduce a different and more difficult challenge, where we will continually build onto the skills learned from the previous chapters. It is my goal, that by the end of this book, you should be able to venture off on your own and build your very own Flash applications that integrate beautifully with Drupal. But before we get ahead of ourselves, we need to take a step back and understand the motivation for this book. We also need to touch base on some of the basics for integrating Flash with Drupal, which include:

  • Why Flash with Drupal?

  • Who is this book for?

  • Getting started with Drupal

  • Adding content to Drupal

  • Getting started with Flash

  • Creating a Flash application

  • Adding Flash content to Drupal

Why Flash with Drupal?

Within the past couple of years, there has been a major paradigm shift in the world of product development. Everything from phones, web sites, and automobiles has been affected from this movement, where the importance of functionality has seemed to have been replaced with style and usability. No longer do the products that offer maximum features sell more than their competitors. Instead, the products that offer style and ease of use are the ones that rule the trade and are considered to be the "next big thing".

Web development is no stranger to this trend. Just take a look at some of your favorite web sites and you will realize how important style and usability are to the world of web development. With this movement taking hold, it is easy to see how Flash technology has risen to the top as being the portal of choice for many web site user interfaces. Flash offers many tools that make it easy to create stylish and easy-to-use applications, and because of this, many people know a Flash web site when they see one (and usually, remember it). What is not so apparent about Flash, though, is its lack of ability to effectively manage and deliver dynamic content. Fortunately, this is where Drupal shines.

With the explosion of content on the Internet, Content Management Systems (CMS) have become mainstream for any web site administrator, who wishes to manage the onslaught of new content on his/her site. Although there are many different flavors of CMS, Drupal is rapidly becoming the system of choice because it offers a powerful and extensible framework that can mould to any application. However, when it comes to style and usability, Drupal requires a lot of work to get the look and feel in the way that you and your visitors would expect from any top-notch web site. With that said, one can easily see how the combination of Flash and Drupal is a match made in heaven between beauty and the brain.

 

Why Flash with Drupal?


Within the past couple of years, there has been a major paradigm shift in the world of product development. Everything from phones, web sites, and automobiles has been affected from this movement, where the importance of functionality has seemed to have been replaced with style and usability. No longer do the products that offer maximum features sell more than their competitors. Instead, the products that offer style and ease of use are the ones that rule the trade and are considered to be the "next big thing".

Web development is no stranger to this trend. Just take a look at some of your favorite web sites and you will realize how important style and usability are to the world of web development. With this movement taking hold, it is easy to see how Flash technology has risen to the top as being the portal of choice for many web site user interfaces. Flash offers many tools that make it easy to create stylish and easy-to-use applications, and because of this, many people know a Flash web site when they see one (and usually, remember it). What is not so apparent about Flash, though, is its lack of ability to effectively manage and deliver dynamic content. Fortunately, this is where Drupal shines.

With the explosion of content on the Internet, Content Management Systems (CMS) have become mainstream for any web site administrator, who wishes to manage the onslaught of new content on his/her site. Although there are many different flavors of CMS, Drupal is rapidly becoming the system of choice because it offers a powerful and extensible framework that can mould to any application. However, when it comes to style and usability, Drupal requires a lot of work to get the look and feel in the way that you and your visitors would expect from any top-notch web site. With that said, one can easily see how the combination of Flash and Drupal is a match made in heaven between beauty and the brain.

 

Who is this book for?


This book is written for developers who wish to build dynamic Flash applications, whose content is governed from a CMS. Although we will be using Drupal for our CMS, the lessons learned within this book can easily be applied to other content management systems such as Joomla or WordPress. Because of this, it is not assumed that you are familiar with how to use Drupal, and any interaction with Drupal will be described in full detail so that anyone can follow along. As for Flash, it is not necessary to be familiar with how to use Flash since the basics will also be covered in detail within this book. However, it is recommended that you have a modest understanding of ActionScript 3.0 and PHP, since there will be many code samples in this book. With that said, let's get started!

 

Getting started with Drupal


We will kick things off by first exploring Drupal and seeing how to utilize a few of its many features for our Flash applications. Although this will not be a complete guide to Drupal, it will give us a quick introduction, so that we can comfortably integrate its power into the Flash applications that we will create in this book. And, it all begins with the installation!

Installing Drupal

Since Drupal is a web-based application, our first goal is to install a server that will be able to run and execute the PHP code that makes up this incredible CMS. The most typical setup for running Drupal is to use an Apache web server along with PHP and MySQL services enabled.

Installing Apache-MySQL-PHP (AMP)

There are many ways to install Apache, MySQL, and PHP, but I would highly recommend installing a pre-built AMP package onto your computer, and then running Drupal on your machine through a local server. Luckily, there are several pre-built installers that make this step as simple as possible. Each operating system has its own version, and they all can be found at the following locations:

Each of these packages has an easy-to-follow installer that will install an AMP server on your local machine, so that we can then install Drupal. After we are done with the installation of these packages, we should be able to go to the following locations within your web browser, to see a welcome page.

  • Windows and Linux—http://localhost

  • Mac—http://localhost:8888/MAMP

If you are using MAMP, then I would highly recommend setting the default Apache and MySQL ports by clicking on the Preferences button in the MAMP application. Once you are in the Preferences section, we will then select the Ports tag and click on Set to default Apache and MySQL ports.

This will make it such that you can type http://localhost within your browser without the port (:8888), which is consistent with the rest of this book. Now, with a web server installed, our next step is to install Drupal.

Creating the Drupal database

Once we have our AMP server running, our next task is to create a database that we will use for our Drupal installation. This simply requires running phpMyAdmin that comes with the AMP packages, and can usually be found by navigating to the welcome screen at http://localhost (for XAMPP) and http://localhost/MAMP (for MAMP), and then clicking on the link that says phpMyAdmin. Once we are inside the phpMyAdmin front page, we can easily create a new database called drupal6 using the Create new database input field and clicking on the Create button.

Now that we have a new database, we will need to create a new user who can use our Drupal database.

Creating a database user

We will create a new user by first navigating back to the main phpMyAdmin screen, and then clicking on the link that says Privileges. Once we are in the Privileges section, we can create a new user by clicking on the Add a new user link. We will then fill out the user information by providing the following information (of course, you can use your own username):

Our next task is to make sure that we give our user the correct privileges to use the database that we just created. Since we are just using this as a local server, it is completely fine to give your new user global privileges by clicking on the Check All link that is next to the Global privileges section.

We can now click on the Go button, at the bottom right of the Privileges section, to create our new user. Our next step is to increase our PHP memory, so that Drupal does not timeout when it is installing.

Increasing PHP memory

This next step is almost always overlooked when installing Drupal. By default, the AMP packages do not allocate enough PHP memory required to install Drupal. Because of this, we will need to edit the php.ini file and manually increase this value. The php.ini file can be found within the conf/php5 directory of our AMP package installation directory. Once we open the php.ini file, we will perform a search for memory_limit and change it to 32M. While we are in this file, we should also probably increase the execution and input time as follows:

max_execution_time = 1000
max_input_time = 1000
memory_limit = 32M

After we save our changes, it is very important that we reset Apache so that these changes take effect. We can do this by opening up our AMP control application, and choosing to reset the Apache server, or we can simply close and restart this application to perform the required Apache restart. With this done, we are now ready to install Drupal!

Installing Drupal

Moving right along, we can download the latest version of Drupal by going to http://www.drupal.org and clicking on the download links found on the homepage. For this book, we will be using Drupal 6, so select the latest version of Drupal that begins with 6. At the time of writing, the release was version 6.10, which can be downloaded at http://ftp.drupal.org/files/projects/ drupal-6.10.tar.gz.

Once we have downloaded this package, the next step is to extract the contents into the document root of the web server. This is typically within the htdocs folder of the XAMPP or MAMP installation. Whatever resides in this folder is now visible when you navigate to http://localhost from your browser. For example, if we created an HTML file called index.html inside the htdocs folder, and then navigated to http://localhost, we would see that HTML file rendered within our browser as a web page. In this book, we will simply create a new folder within our htdocs called drupal6, and then extract the contents of the Drupal 6 package inside that new folder. Since we have placed all of our contents inside the htdocs/drupal6 folder, we can now open up our browser and type http://localhost/drupal6 to see the following:

We can begin our installation by clicking on the link that says Install Drupal in English, where we will then be greeted with the following page:

Don't let the red scare you. What this is telling us to do is find the default.settings.php file within the sites/default folder of our extracted Drupal folder. Once we find this file, we simply need to rename it as settings.php. After it has been renamed, we need to change the permissions of the file so that it is writable. When we are done, we can click on the try again link, and see the following:

From here, we will just enter all the database information that we set up in the previous section, and then click on the Save and continue button. This should then walk through the installation process. If it does not, then we can manually edit the settings.php file and manually put in our database information by changing the following line:

$db_url = 'mysql://travist:mypassword@localhost/drupal6';

We can now navigate to http://localhost/drupal6/install.php and kick off the installation. If all goes well, we should see the following page:

At this point, we can fill out all of the initial configurations for our Drupal web site, including the site name, email, user name, password, and so on. When we are done, we can click on the Save and Continue button at the bottom of the page, where we should see the following:

When we click on the link that says your new site, we should then be greeted with the most popular Drupal page (as shown in the following screenshot).

With Drupal installed, we will now add some content.

Adding content to Drupal

In order to build a Flash application that utilizes Drupal content, we will first need to understand how to add content to Drupal. Fortunately, this step is very simple and first requires us to click on the link that says Create content on the left navigation menu. Once we click on this menu item, we should be given an option to either create a Page or a Story. A page is simply a single page of content. An example of a page would be if you were to create an "About" page for your web site that simply describes the nature of your business. A Story is a collection of pages that, together, combine and create a common piece of content. An example of a Story would be a web site tutorial. We can now create some content on our web site by clicking on the Page link. We can provide a Title and Body for our page, as follows:

We can then click on the Save button, at the bottom of the page, to create our first page.

Now that we have created our first Drupal page, we are ready to move onto Flash.

 

Getting started with Flash


Adobe Flash is a multimedia platform that allows us to create animations and rich Internet applications. Each of these applications, created with Flash, is pre-compiled into the Shockwave Flash (SWF) file format. These applications can be embedded within a webpage or used on the desktop for local functionality. These SWF files are read and interpreted using the Flash Player, which must be installed as a plug-in for the browser viewing the page. This is rarely an issue though, since Flash is so widely used by so many web sites that it is rare to not have Flash installed on your visitor's browser.

So, our first task is to install Adobe Flash CS4 onto our computer, so that we are able to walk through the examples in this book. Although Flash CS4 is not a free application, you can easily download the 30-day trial version by going to http://www.adobe.com/go/tryflash and complete this book within that trial period. Once you have Flash CS4 installed on your machine, we are ready to move on.

Note

If you are using Flash CS3, you will still be able to use all of the tutorials in this book. Flash CS3 and CS4 are very similar, so there should not be any discrepancies between the two when following through the examples in this book.

Creating a new Flash project

With Flash CS4 installed on our computer, we can open up the application and create a new project. When the application first comes up, you should see a welcome screen, where we can Create a new project. For all of the examples in this book, we will be using ActionScript 3.0 for our Flash applications. So, we will continue by clicking on the link that says Flash File (ActionScript 3.0), which should then bring up an empty project. Since there are differences in the way that Flash CS3 and Flash CS4 look, our next task is to change the default workspace for Flash CS4 so that it looks like CS3. This will make it easier for everyone to follow every lesson in this book and keep any reference that I make regarding the location of certain tools consistent.

Setting up the workspace

In this step we will set the workspace layout so that it looks identical to the Flash CS3 default. In Flash CS4, we can accomplish this by clicking on the Window menu item. Once this menu item opens up, we will select the Workspace menu item, and then select Classic.

We should now have a workspace that resembles the following diagram. We will take a look at each highlighted section within this workspace, so that we know what they are when they are referenced in this book.

For each of the following sections, simply refer back to this diagram to see where to find the item under discussion.

A: The Stage

With our workspace set up the way that we want, we can shift our focus to the white square in the middle of the screen. This white square region is called the stage and will be referenced quite a bit in this book. The stage is simply the visible window for any object that is placed within our Flash application. By dragging an object off of the stage, we are removing the object from the visible region of our Flash application.

B: The Toolbar

The toolbar presents many of the tools that can be used to create or edit objects on the stage.

C: The Timeline

When you click on this tab, you should see the timeline for our Flash application. The timeline is a very important aspect in Flash since it allows us to create objects that can change in time. There are many elements within the timeline that will be important for us in this book, and each of these items is described as follows:

  • Within the timeline, there are a series of white blocks that span the width of the timeline. Each of these little white blocks are called frames. A frame is a snapshot in time for our Flash application. We can combine a series of frames to create an animation (where an object moves for each new frame), or define different states for our objects, where each frame shows a different state for our object.

  • Another important feature of the timeline is the ability to define multiple layers. We will use this quite often in this book since it not only allows us to control which objects are on top of other objects, but it also serves as a great way to organize our Flash applications for ease of use.

  • Having each object within its own layer also gives us the power to hide or lock each layer. This can be done by clicking on the dot within the column (visibility) or the column (lock). This will help us to keep other objects unaffected when we are working on a different layer.

  • We can also create new layers by clicking on the column (visibility) or the symbol. Once we have created a new layer, it is best practice to name that layer by clicking on the name until it turns into an edit box, where we can then provide any name we would like.

D: The Properties panel

The properties panel is used to describe the object that is currently selected. We will use this panel quite often in order to change the width and height, and to give names to our object's instance.

E: The Color Palette

We will use this tool to change the fill colors for the objects that we create. We will also use this tool to create gradients to give our application depth and character.

F: The Library

This tool is used to keep track of all objects that we have created within our Flash application. We will use this to edit existing objects as well as to create new objects that will be used in our Flash application.

Now that we are familiar with the Flash Integrated Development Environment (IDE), we can create something within Flash and then embed that within Drupal.

 

Creating a Flash application


For this example, our Flash application will be very basic. For the most part I would just like us to walk through the process of creating a Flash application within Flash, and then take that application and embed it within a page in Drupal. Once we have conquered this, we will be geared up to create some really cool applications that will surely wow your visitors. But keep in mind that your imagination is the key, so feel free to go crazy and create something very cool, and not feel limited with what we create in this section.

Before we begin, however, we will need to create a home for our Flash project. In this book we will always start out each chapter by first creating a new directory to hold the contents for that chapter. With that said, we first need to create a new folder called chapter1 and then save our currently opened up Flash application as chapter1.fla within this folder, by clicking on the File | Save As menu item. Once we have saved our Flash application, we can now start by adding objects to our stage.

Creating a background

Our first task will be to create a background for our Flash application so that it sticks out when viewing through Drupal. We can do this by clicking on the tool within our toolbar. This should then change our mouse to the cross-hair symbol when you move the mouse over the stage. Before we begin to draw our rectangle, though, we will need to make sure that all of our rectangle properties are set up just the way we want them.

Rectangle properties

We will now shift our focus to the PROPERTIES panel, which should show some of the options that we have for drawing a rectangle object.

The FILL AND STROKE region is used to describe how the rectangle will be drawn and what colors can be used to either fill or stroke (border) the rectangle. For this example we would like to have a rectangle that has a 3 pixel dark grey border, with a dark blue center, which we can configure by setting the following:

Finally, we would like our rectangle to have rounded corners. We can do this by adding a value within the RECTANGLE OPTIONS section that shows the symbols. To have a 15 pixel radius for the rounded corners, we can provide the following:

We can now move our cursor over the upper left-hand corner of our stage region (where the white square begins), and draw our rectangle region as follows:

Adding a gradient

We will now give our background some character by adding a gradient as the fill color. To do this, we will first click on the fill region of the rectangle using the Selection tool () and then open up the Color tool on the right side of the screen.

We can now give our background a linear gradient by clicking on the Type drop-down menu and selecting Linear. Next, change the gradient colors by first clicking on the right tab within the Gradient tool and then changing that color back to the dark blue color. Then, click on the left tab of the gradient tool and give it a lighter blue color.

Finally, to make this background more interesting, we will orient the gradient so that it is not completely horizontal. We can do this by first clicking and then holding down our mouse over the Transform tool(). By clicking and holding down our mouse over this tool, it should bring up a submenu, where we can then select the Gradient Transform tool () Once we have this tool selected, we will click on our fill region, which will expose some handles where we can resize and change the orientation of our gradient. The circle symbol , over our fill region, will allow us to change the orientation of our gradient, which we will use to change our fill gradient to be oriented at approximately 45 degrees.

We are now done with our background, and ready to move onto adding some text.

Adding text to a Flash application

Before we begin adding text, we first need to create a new layer so that our text does not collide with our newly created background. To do this, we will first click on our TIMELINE tab, where we will first rename the default layer name to background, and then lock this layer by clicking on the dot in the column.

After we have done this, we can create a new layer on top of the background layer by clicking on the within the bottom layer tool menu and then calling this new layer as text.

Now that we have a blank layer to add our text, we can click on the Text tool () within our toolbar and, and shift our focus to the PROPERTIES panel.

Text properties

The text properties are most likely familiar to anyone who has used a Word processor application. It allows you to change the color, size, style, and letter spacing. In our example, we want a fairly large size and light color so that our text will stand out against the dark background that we just created. For that reason, we should provide the following information for our text field properties:

After we have our properties set up, we can add our text to our stage by clicking anywhere on the stage we would like to show our text. When we are done, we should see the following:

Compiling our Flash application (making a SWF)

Now that we have created our Flash application, the next step is to run and compile this into a SWF file, so that we can embed it within our Drupal web site. This will first require us to take a look at the Publish Settings, so that we can make the necessary changes to our published SWF file.

Publish Settings

Publish Settings can be found by clicking on the File | Publish Settings menu item, where we will see the following page:

Since we are using Drupal to show our Flash applications, the first thing that we need to do is uncheck HTML from the publish type column. After we have done this, we can take a look at the Flash tab on the publish settings, which will show the following screen:

Since our goal is to stay consistent with the Flash CS3 readers, we will probably want to use Flash Player 9 to compile and run our SWF movies. We can do this by clicking on the Player drop-down box and then selecting Flash Player 9. When we are done, we can click on the OK button at the bottom of the settings page to accept the changes.

Now that we have our set tings in place, we can run and compile our Flash application by pressing +Enter for Mac, or Ctrl+Enter for Windows. If you wish to just compile your application, then you can alternatively select File | Publish from the main menu. When we are done with this step, we should be able to navigate to our chapter1 folder and see the following:

The SWF file is the compiled Flash file that we will now embed within our Drupal web site.

 

Adding Flash content to Drupal


There are many ways to add Flash content to Drupal, but what I am going to cover in this section is what I have found to be the easiest. Thanks to the wonderful Drupal community, there is already a fantastic module that was built to easily add Flash applications to Drupal. This module is called FlashNode and can be found at http://www.drupal.org/project/flashnode. Within this project page, we need to download the latest version for Drupal 6. We can determine a module's Drupal version by taking a look at the first number in the package version, where 6.x means it is for Drupal 6. After we have downloaded the version build for Drupal 6, which was version 6.x-3.1 at the time of writing, we can install this module in our local host Drupal installation.

Installing a contributed Drupal module

The first thing that we need to do to install a Drupal module is locate our Drupal installation that we placed in our computer earlier in this chapter. Within this directory, we should see the following files:

If we open up the sites folder, we should then see an all and a default folder. These folders are used to separate the files, modules, and themes for any web site that is sharing the single Drupal installation (called multisite). For example, if we wish to install a module for all of our web sites, then we would place this new module within the all folder. However, if we just wish to include this module in the default site (which is the site we are using right now), then we will have to place the module within the default folder. In a typical multisite configuration, there would be a separate folder within the sites directory for each web site that is being run off the single Drupal installation. But for our purposes, we will use the default folder for any additional module that we install to our Drupal web site. So, within the default folder, we will need to create a new folder called modules, and then place the extracted contents of the flashnode module within this directory as follows:

Now that we have the flashnode module in the right location on our server, we can navigate to our Drupal web site by going to http://localhost/drupal6. Once we are there, we can go to our administrator section by clicking on the Administer link on the left menu. Once we are within our Drupal administration section, we will click on the Modules link. Throughout this book I will refer to this type of navigation as saying "navigate to Administer | Modules".

Once we are within the Modules section, we can scroll down to the bottom of the page and enable the FlashNode module by clicking on the checkbox next to this module, and then clicking on the Save Configuration button at the bottom of the page.

Adding Flash!

We are now ready to add our Flash application to Drupal. We will first click on the Create Content link from the left navigation menu, and then select Flash from the list of items.

We will then see the Create Flash page, where we will start by giving our new Flash node a title.

After this, we will select the Flash file that we just created by clicking on the Browse button next to the Flash file input field, and then selecting our SWF file using the file browser window.

Finally, we can scroll down to the bottom of the page, where we can click on the Save button. Congratulations, you have added Flash to Drupal!

 

Summary


We now have the foundation for building some dynamic applications for Drupal. We can easily use the lessons learned in this chapter to build some very cool Flash widgets to be used within Drupal. But these applications would be limited, since they will be confined to only showing the content provided from within that Flash application. In the following chapters we will dive into how to incorporate Drupal content within our Flash applications. This will open up a whole new world of functionality that we can utilize to create some very exciting Flash applications.

Flash with Drupal
Unlock this book and the full library FREE for 7 days
Start now