The Actionscript 30 Quick Reference Guide For
Developers And Designers Using Flash Cs4
Professional David Stiller Et Al download
https://ebookbell.com/product/the-actionscript-30-quick-
reference-guide-for-developers-and-designers-using-flash-
cs4-professional-david-stiller-et-al-4137632
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
The Actionscript 30 Quick Reference Guide For Developers And Designers
Using Flash David Stiller
https://ebookbell.com/product/the-actionscript-30-quick-reference-
guide-for-developers-and-designers-using-flash-david-stiller-5475380
The Actionscript 30 Migration Guide Making The Move From Actionscript
20 1st Edition Kris Hadlock
https://ebookbell.com/product/the-actionscript-30-migration-guide-
making-the-move-from-actionscript-20-1st-edition-kris-hadlock-2135438
The Essential Guide To Flex 2 With Actionscript 30 Charles E Brown
https://ebookbell.com/product/the-essential-guide-to-flex-2-with-
actionscript-30-charles-e-brown-918654
The Essential Guide To Flash Games Building Interactive Entertainment
With Actionscript 30 Jeff Fulton
https://ebookbell.com/product/the-essential-guide-to-flash-games-
building-interactive-entertainment-with-actionscript-30-jeff-
fulton-42277314
Advanced Actionscript Components Mastering The Flash Component
Architecture 1st Edition Antonio De Donatis
https://ebookbell.com/product/advanced-actionscript-components-
mastering-the-flash-component-architecture-1st-edition-antonio-de-
donatis-920394
Actionscript For Flash Mx The Definitive Guide Second Edition Second
Edition Colin Moock
https://ebookbell.com/product/actionscript-for-flash-mx-the-
definitive-guide-second-edition-second-edition-colin-moock-1536410
The Flash Anthology Cool Effects And Practical Actionscript 1st
Edition Steve Grosvenor
https://ebookbell.com/product/the-flash-anthology-cool-effects-and-
practical-actionscript-1st-edition-steve-grosvenor-976680
The Essential Guide To Flash Cs4 With Actionscript 1st Edition Paul
Milbourne
https://ebookbell.com/product/the-essential-guide-to-flash-cs4-with-
actionscript-1st-edition-paul-milbourne-11852326
Macromedia Flash Mx 2004 Actionscript Training From The Source Derek
Franklin
https://ebookbell.com/product/macromedia-flash-mx-2004-actionscript-
training-from-the-source-derek-franklin-1675948
The ActionScript 3.0
Quick Reference Guide
For Developers and Designers
Using Flash CS4 Professional
David Stiller, Rich Shupe, Jen deHaan, and
Darren Richardson
Tomcat
™
The Definitive Guide
Jason Brittain and Ian F. Darwin
Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo
TheActionScript3.0QuickReferenceGuide:ForDevelopersandDesignersUsingFlash
CS4 Professional
by David Stiller, Rich Shupe, Jen deHaan, and Darren Richardson
Copyright © 2009 David Stiller and Rich Shupe. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol,
CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional
use. Online editions are also available for most titles (http://safari.oreilly.com). For
more information, contact our corporate/institutional sales department:
(800) 998-9938 or corporate@oreilly.com.
Editor: Robyn Thomas
Production Editor: Michele Filshie
Copyeditor: Sohaila Abdulali
Technical Editors: Matthew Woodruff,
Anselm Bradford, and Eric Kramer
Proofreader: Nancy Bell
Indexer: Ellen Troutman Zaig
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrators: Robert Romano and Jessa-
myn Read
Printing History:
October 2008: First Edition.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. The ActionScript
3.0 Quick Reference Guide: For Developers and Designers Using Flash CS4 Profes-
sional, the image of the Ophiops, and related trade dress are trademarks of O’Reilly
Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their
products are claimed as trademarks. Where those designations appear in this book,
and O’Reilly Media, Inc. was aware of a trademark claim, the designations have
been printed in caps or initial caps
While every precaution has been taken in the preparation of this book, the publisher
and authors assume no responsibility for errors or omissions, or for damages re-
sulting from the use of the information contained herein.
TM
This book uses RepKover, a durable and flexible lay-flat binding.
ISBN: 978-0-596-51735-9
[M]
1223315717
Adobe Developer Library, a copublishing partnership between O’Reilly Media Inc.
and Adobe Systems, Inc., is the authoritative resource for developers using Adobe
technologies. These comprehensive resources offer learning solutions to help devel-
opers create cutting-edge interactive web applications that can reach virtually any-
one on any platform.
With top-quality books and innovative online resources covering the latest tools for
rich-Internet application development, the Adobe Developer Library delivers expert
training, straight from the source. Topics include ActionScript, Adobe Flex®, Adobe
Flash®, and Adobe Acrobat® software.
Get the latest news about books, online resources, and more at adobedeveloper-
library.com.
To Scott Joplin, for doing his
thing like nobody’s business, then
sharing it.
-- David Stiller
To Jodi, Sally, and Claire for
putting up with so much.
-- Rich Shupe
Table of Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Part I. ActionScript 3.0 Introduced
1. Introducing ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Examining ActionScript 3.0, the Language 5
Exploring Flash Player API Updates 15
Understanding Players and Support 18
Learning ActionScript 3.0 on the Heels of 2.0 20
Deciding to Migrate or Write Code from Scratch 21
2. Discovering What You Need to Work with ActionScript 3.0 . . . . . . . . . . . . . 23
Flash CS4 Professional/Flex Builder 3 24
Flash Player 9 or Higher 24
Using Other Code Editors with Flash 32
3. Looking at the Changes in ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Major Changes and Obsolete Code 59
Major Syntax and Structure Changes 77
Additional ActionScript 3.0 Resources 84
4. Exploring the Benefits of Using ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . 85
Performance 86
Efficiency 93
Consistency 96
Standards and Portability Among Other Technologies 100
v
Part II. ActionScript and the Flash CS4 Authoring Tool
5. Creating and Working with Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Thinking in Terms of the Timeline 106
New Features in the Actions Panel and Script Windows 112
Setting ActionScript Preferences 120
Associating FLA Files with AS Files 126
Using Script Assist 130
6. Creating a Document Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
7. Working with Library and Linkage Changes . . . . . . . . . . . . . . . . . . . . . . . . 145
Linkages Now Reference Classes 145
8. Copying Motion as ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Copying Motion 163
Applying Motion to Other Objects 166
9. Using ActionScript 3.0 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Overview of the Component Set 179
New and Removed Components 185
Changes in Writing Code for Components 188
Changing the Appearance of Components 199
10. Making Up for a Reduced Component Set . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Working Without Data Components in ActionScript 3.0 207
ActionScript 2.0 Components in ActionScript 3.0 SWF Files 219
Exploring Third-Party UI Components 224
11. Debugging and Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Debugging Is a Good Thing 231
Testing Your ActionScript 3.0 Code 232
Reviewing Improvements in Debugging Over ActionScript 2.0 237
Exploring the Compiler Errors Panel 240
Using the Enhanced Debugging Workspace 250
vi | Table of Contents
Part III. How Do I?
12. How Do I Draw with Code? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
12.0 Introduction 267
12.1 Creating a Display Object Dynamically 268
12.2 Referencing an Object’s Graphics Property 269
12.3 Defining a Line Style 270
12.4 Drawing a Line 271
12.5 Drawing a Curve 272
12.6 Defining a Fill Style 273
12.7 Drawing a Rectangle 274
12.8 Drawing a Rectangle with Rounded Corners 274
12.9 Drawing a Circle 276
12.10 Creating a Gradient Fill 277
12.11 Using a Drawn Shape as a Dynamic Mask 278
12.12 Caching Vector as Bitmap 280
12.13 Applying a Simple Bitmap Filter 281
13. How Do I Work with the Display List? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
13.0 Introduction 283
13.1 Choosing Which Type of Display Object to Use 284
13.2 Creating a New Display Object 286
13.3 Adding a Display Object to the Display List 287
13.4 Specifying the Depth of a Display Object 289
13.5 Finding a Display Object 291
13.6 Removing a Display Object from the Display List 292
13.7 Working with Children of a Display Object Container 293
13.8 Working with Parents of a Display Object 296
13.9 Casting a Display Object from One Type to Another 297
13.10 Changing the Parent of a Display Object 299
13.11 Referencing the Stage Through a Display Object 300
14. How Do I Work with Events? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
14.0 Introduction 303
14.1 Understanding Event Listeners 303
14.2 Capturing Mouse Events 305
14.3 Understanding Event Flow 307
14.4 Using Event Bubbling 308
14.5 Using the target and currentTarget Event Properties 310
14.6 Simulating a Mouse Up Outside Event 311
14.7 Capturing Frame Events 312
Table of Contents | vii
14.8 Improving Performance by Removing Event Listeners 314
14.9 Capturing Keyboard Events 315
14.10 Capturing Stage Events 317
14.11 Using a Timer to Dispatch Events 321
14.12 Dispatching Your Own Events 323
14.13 Manually Calling Event Listener Functions 325
14.14 Capturing an Event Before It Reaches Its Target 326
14.15 Setting the Execution Order of Events 328
14.16 Using Weak Listeners 330
15. How Do I Work with Text? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
15.0 Introduction 333
15.1 Creating a Text Field 334
15.2 Styling a Text Field 334
15.3 Creating a Password Field 336
15.4 Focusing a Text Field 337
15.5 Populating a Text Field 338
15.6 Automatically Sizing a Text Field 339
15.7 Scrolling a Text Field 341
15.8 Using Embedded Fonts 343
15.9 Formatting Text Using TextFormat 344
15.10 Formatting Text Using HTML 346
15.11 Formatting Text Using CSS 348
15.12 Adding Hyperlinks to Text 350
15.13 Triggering ActionScript from HTML Links 351
15.14 Selecting Text 352
16. How Do I Work with XML? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
16.0 Introduction 355
16.1 Creating an XML Object 356
16.2 Loading XML 357
16.3 Reading an Element Node 359
16.4 Reading a Text Node 360
16.5 Working with Multiple Nodes of the Same Name 362
16.6 Reading an Attribute 363
16.7 Finding Content Using Shorthand 364
16.8 Finding Content Using Conditionals 366
16.9 Reading HTML or Entities in XML Nodes 367
16.10 Deleting XML 369
16.11 Writing XML 369
16.12 Writing XML with Variables 372
16.13 Sending and Loading XML 373
viii | Table of Contents
17. How Do I Work with External Assets? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
17.0 Introduction 377
17.1 Loading and Applying a Cascading Style Sheet 378
17.2 Loading and Displaying an Image or SWF File 380
17.3 Communicating with an ActionScript 3.0 Loaded SWF 382
17.4 Communicating with an ActionScript 2.0 Loaded SWF 384
17.5 Unloading an Image or SWF File 387
17.6 Loading and Playing a Sound 391
17.7 Setting the Volume and Pan of a Sound 392
17.8 Visualizing the Amplitude of a Sound 393
17.9 Unloading a Sound 395
17.10 Loading and Playing a Video 397
17.11 Unloading a Video 399
Part IV. Migration
18. A Sample Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
A Simple Particle System 404
ActionScript 2.0 404
ActionScript 3.0 413
Migration Sample Summary 424
19. Where Did It Go? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Introduction 425
Code Comparisons 426
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Table of Contents | ix
Foreword
The battle, as it stood, had clearly defined lines. The artists liked ActionScript
1.0 and the programmers, let’s just say they weren’t happy (if they used Flash
at all!).
Then ActionScript 2.0 appeared and many artists started getting nervous until
they realized that they could basically ignore it. Programmers were a bit more
happy until they realized that the changes were mostly superficial. But in many
cases, it was enough to bring new programmers to Flash—which made the
artists even more nervous.
Fast forward to just a couple of years ago and ActionScript 3.0 rears its head.
The programmers embrace it like a brother, like the saviour of the Flash plat-
form. The artists, for the most part, ran and hid. As they dashed away from
terms like “classes” and “interfaces” they bemoaned the loss of what, for many
of them, was their first programming language.
This was real programming, they said. ActionScript 3.0 had wandered into the
land populated by frightening giants like Java and C++. It wasn’t fun anymore,
it was just scary.
Enter this book and its talented authors.
For the developers reading this, I have a confession to make that will probably
ring true with you as well. At first, ActionScript 3.0 intimidated the heck out
of me. Everything that I knew how to do was different. It felt like the ground
had been ripped out from under me. It was all sort of familiar, but so many
little things were different, I often felt like it would have been easier for me if
I hadn’t ever learned ActionScript 1.0 and 2.0. It took me quite a long time to
get a good sense of the language and to get back to that level of comfort I had
with earlier versions.
The good news for you, dear coder, is that if you haven’t yet made that tran-
sition and gained that level of comfort, your road is going to be a lot easier
thanks to this book. Honestly, I’m a bit jealous.
xi
For the artists reading this, the authors of this book are here to explain that
no, it’s not hard, it’s just different. Different in a way that is more powerful,
that lets your ideas go further. You have been doing “real” programming all
along and this is just the next logical step.
ActionScript 3.0 is a giant of a programming language. There is a lot to learn,
and conquering will take time and patience. But at the end of day (and the end
of this book) you will find that by learning ActionScript 3.0 not only are you
a better Flash developer, but also a better developer period. You’ll have under
your belt a good understanding of many core object-oriented concepts and can
take them to any other language you want to tackle—whether that be Python,
Java, C++, or just about anything else.
No matter what your background, the pages that follow will provide you with
some excellent knowledge, insight, and even a little bit of wisdom in the realm
of Flash and ActionScript. I’m lucky enough to personally know some of the
authors of this book so I can honestly tell you that you’re about to learn from
some of the best developers and teachers I know.
Happy learning!
—Branden Hall
CTO, Automatic Studios Ltd.
September 2008
xii | Foreword
Preface
ActionScript 3.0 introduced Flash developers to a new realm. In this improved
territory, ActionScript has emerged from the gym with a new physique. The
language is more powerful, more efficient, and—thanks to a new internal con-
sistency—easier to learn for those new to the Flash Platform. As the saying
goes, change is a good thing. On the other hand, too much of anything can be,
well, nerve-wracking. For many, ActionScript’s change equates to a chronic
attack of growing pains. Others, used to the paradigms and occasional quirks
of ActionScript 2.0, find the new ActionScript 3.0 practically unrecognizable.
In any case, the ongoing support for ActionScript 1.0 and 2.0, in both the Flash
authoring environment and Flash Player, means that learning ActionScript 3.0
is, for the immediate future, still an option. For now, you can choose when to
learn the new version of the language (and to what degree), applying your
newlyearnedknowledgeonaproject-by-projectbasis,ifyouwant.Sometimes,
it’ll be easier to decide when to use ActionScript 3.0 than to decide whether
you should migrate existing code or start from scratch. For example, if you
want significant performance gains, or to use a new feature specific to Action-
Script 3.0, using the new language may be a foregone conclusion. How to arrive
at completed ActionScript 3.0 code, however, is another question, and that’s
where this book is useful.
This book aims to show you where Flash CS4 Professional and ActionScript
3.0 differ from prior releases of Flash and ActionScript, respectively. You can
use this text as a guide, helping you decide if new application features warrant
an upgrade, and assisting with the steeper learning curve imposed by the more
robust new language. Perhaps most importantly, this book will increase your
familiarity with ActionScript 3.0 structure and syntax, letting you adjust (or
abandon) ActionScript 2.0 coding practices more easily.
xiii
What Sets This Book Apart
Simple: Essentially, we’ve created two books in one. Or put another way, there
are two sections to the book, each using its own learning methodology.
Part I and Part II are written in classic tech-book formatting and prose. General
concepts are introduced and followed with expository prose and simple, de-
monstrative tutorials as necessary.
Part III and Part IV (especially Part III) are pure reference sections, designed
for you to quickly look up and learn from “How Do I...?” scenarios.
Think of the book as a seminar. The first half is presentation; the latter half is
Q&A.
What’s in This Book
When ActionScript 3.0 hit the streets, the reaction from the Flash crowd was
enormous, and not without a tremor of intimidation. Certain questions have
emerged—on the forums, in classrooms, user groups, and at conferences—
more often than others. This book answers the questions we most often en-
counter, questions that seem to pose the biggest stumbling blocks for longtime
users. The book’s in a hybrid format to serve two needs. The first half of the
book is something like a fireside chat, providing fairly broad coverage of Flash
CS4 Professional, and select overviews of ActionScript 3.0. The second half
presents many focused examples of ActionScript 3.0 syntax in small, digestible
chunks. Both halves are chock-full of hands-on demonstrations. Ideally, you
can hop between the two, and gear up or down to the pace that best suits your
needs at the time. Navigate the Table of Contents and/or Index to find quick
answers to specific questions about ActionScript 3.0 and its application.
Part I: Introduction to ActionScript 3.0
Part I of the text introduces a variety of tools to write ActionScript 3.0, while
relying on Flash CS4 Professional as its primary authoring environment. It then
discusses some of the attributes that make ActionScript 3.0 stand head and
shoulders above its predecessors. Topics include power and performance, the
benefits of strong data typing (including robust compile time warnings and
error messages) and how the new language architecture can improve your
workflow.
Chapter 1, Introducing ActionScript 3.0
Chapter 2, Discovering What You Need to Work with ActionScript 3.0
xiv | Preface
Chapter 3, Looking at the Changes in ActionScript 3.0
Chapter 4, Exploring the Benefits of Using ActionScript 3.0
Part II: ActionScript and the Flash CS4 Authoring Tool
Part II walks you through the Flash CS4 authoring tool with keen attention to
ActionScript-related interface elements, and helps you decide when to use the
timeline, and when to use classes, for coding. It also discusses the creation of
assets at runtime, how to convert timeline animation into ActionScript (for
manipulation and reuse), how to use, skin, and style user interface compo-
nents, and how to troubleshoot your code when things go awry.
Chapter 5, Creating and Working with Code
Chapter 6, Creating a Document Class
Chapter 7, Working with Library and Linkage Changes
Chapter 8, Copying Motion as ActionScript 3.0
Chapter 9, Using ActionScript 3.0 Components
Chapter 10, Making Up for a Reduced Component Set
Chapter 11, Debugging and Troubleshooting
Part III: How Do I?
Part III switches to cookbook-style—a concise look at a problem, solution,
and discussion for each of several issues. This format lets you hone in on syntax
and methodology in easily digestible recipes. It starts off by highlighting the
Graphics class, formerly the Drawing API, which the second half of the book
uses extensively for highly portable, code-only examples. It then discusses the
most significant changes introduced by ActionScript 3.0: the new display ar-
chitecture and event model. Next, you’ll discover new ways of using text for
display and interactivity. Finally, you’ll concentrate on input/output pro-
cesses, including sending and loading XML and variables, as well as loading
images, external SWFs, sound, and video.
Chapter 12, How Do I Draw with Code?
Chapter 13, How Do I Work with the Display List?
Chapter 14, How Do I Work with Events?
Chapter 15, How Do I Work with Text?
Chapter 16, How Do I Work with XML?
Chapter 17, How Do I Work with External Assets?
Preface | xv
Part IV: Migration
Part IV distills everything covered in Part I through Part III, and applies those
skills to the issue of migration—updating existing projects written in Action-
Script 2.0 to use ActionScript 3.0 code. This concept’s first application is the
migration of a simple particle system. The exercise highlights as many migra-
tion issues as possible in a short example, and helps you ask an important
question related to your own projects: should you migrate or rewrite? The final
chapter of the book serves as a cross-reference, and a code-comparison guide.
Specific migration issues are demonstrated in quick syntax examples, com-
paring ActionScript 2.0 and 3.0 uses. Where applicable, references to more
complete discussions elsewhere in the book are included, and select new ma-
terial in the same comparative format is also added.
Chapter 18, A Sample Migration
Chapter 19, Where Did It Go?
What’s Not in This Book
Duetothesizeandfocusconstraintsofthisbook,manyaspectsofActionScript
usage are necessarily excluded. First and foremost, this book focuses specifi-
cally on Flash CS4 Professional, although most of the examples work just fine
in Flash CS3. The Flash Platform has grown considerably, so if you prefer other
ActionScript coding environments, including Flex Builder, FDT, or
FlashDevelop (or even text editors, such as Notepad or TextMate, in conjunc-
tion with the Flex SDK command-line compiler), you may want to skim
through several of the examples to see if you think they’ll be helpful. In general,
you can easily adapt most of the book’s examples for ActionScript 3.0 projects
written in other tools, and you are introduced to a handful of those tools in
Chapter 2. However, very little additional material, such as Flex Builder
MXML documents or project files, is supplied. This book is a migration ref-
erence for Flash professionals, so you’ll see mostly FLA and AS files.
Secondly, this book is aimed at relatively experienced ActionScript 2.0 coders
who are making the move to ActionScript 3.0. It neither provides language
essentials nor serves as a comprehensive reference. As such, if you’re not al-
ready comfortable with ActionScript, and want to focus a bit more on funda-
mentals, you should seek out Learning ActionScript 3.0: A Beginner’s Guide by
Rich Shupe and Zevan Rosser (O’Reilly, 978-0-596-52787-7). Conversely, if
you’relookingformoreofanin-depthreferencebook,youmaypreferEssential
ActionScript 3.0 by Colin Moock (O’Reilly, 978-0-596-52694-8).
xvi | Preface
Finally, while it hits many of the high points, this volume doesn’t cover all
areas of ActionScript 3.0 interest, and may not satisfy advanced users’ needs.
If you want to immerse yourself in the more elaborate capabilities of the lan-
guage, you can either acquire the aforementioned Essential ActionScript 3.0
for broad coverage, or look into additional specialized books such as Action-
Script 3.0 Design Patterns: Object Oriented Programming Techniques by Wil-
liam Sanders and Chandima Cumaranatunge (O’Reilly, 978-0-596-52846-1)
for OOP and design patterns expertise.
Conventions Used in This Book
This book uses the following typographical conventions:
Menu options
Menu options are shown using the → character, such as File→Open.
Italic
Indicates new terms, URLs, email addresses, file names, and file
extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program
elements such as variable or function names, databases, data types, envi-
ronment variables, statements, and keywords.
Constant width bold
Shows commands or other text that the user should type literally.
Constant width italic
Shows text that should be replaced with user-supplied values or by values
determined by context.
This is a note. It contains useful information about the
topic at hand, often highlighting important concepts or
best practices.
This is a warning. It helps you solve and avoid annoying
problems. Ignore at your own peril.
This Book’s Example Files
You can download the example files for this book at:
http://www.oreilly.com/catalog/9780596517359
Preface | xvii
Note that, although alternative development platforms are discussed briefly,
the examples in this book are presented in the context of classes or timeline
frame scripts intended for use with the Flash authoring tool. Self-contained
examples are typically intended for inclusion in FLA files or as Flash document
classes, but you can adapt them for use in other environments (such as Flex
Builder) without support for those tools.
Using Code Examples
This book is here to help you get your job done. In general, you may use the
code in this book in your programs and documentation. You don’t need to
contact us for permission unless you’re reproducing a significant portion of
the code. For example, writing a program that uses several chunks of code
from this book doesn’t require permission. Selling or distributing a CD-ROM
of examples from O’Reilly books does require permission. Answering a ques-
tion by citing this book and quoting example code doesn’t require permission.
Incorporating a significant amount of example code from this book into your
product’s documentation does require permission.
We appreciate, but don’t require, attribution. An attribution usually includes
the title, author, publisher, and ISBN. For example: “The ActionScript 3.0
Quick Reference Guide: For Developers and Designers Using Flash CS4 Profes-
sional” by David Stiller, Rich Shupe, Jen deHaan, and Darren Richardson
Copyright © 2009 David Stiller and Rich Shupe, 978-0-596-51735-9.”
If you feel your use of code examples falls outside fair use or the permission
given above, feel free to contact us at permissions@oreilly.com.
Safari® Books Online
When you see a Safari® Books Online icon on the cover of your
favorite technology book, that means the book is available online
through the O’Reilly Network Safari Bookshelf.
Safari offers a solution that’s better than e-books. It’s a virtual library that lets
you easily search thousands of top tech books, cut and paste code samples,
download chapters, and find quick answers when you need the most accurate,
current information. Try it for free at http://safari.oreilly.com.
xviii | Preface
How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any
additional information. You can find this page at:
http://oreilly.com/catalog/ 9780596517359
Acknowledgments
From David
Thanks to Rich, Jen, Darren, and the gang at O’Reilly. We took a trip to Oz
and had enough adventures to write a book about it! (Rich, you owe me a face-
to-face sit-down with Pentago!) For technical assistance and encouragement,
I’d like to extend gratitude to Marisa Bozza, Tink (Stephen Downs), Greg
Dove, Chris Georgenes, Tom Green, Branden Hall, Keenan Keeling, San
Khong, John Mayhew, Colin Moock, Robert Penner, Nivesh Rajbhandari,
Robert Reinhardt, Steve Schelter, and Kenneth J. Toley. Thanks and love to
my #1 woman, Dawn, who introduced me to Georges Méliès, and my #1 girl,
Meridian, für unser Abenteur mit Andersen und den Brüdern Grimm.
From Rich
Thanks to David, Jen, and Darren for making me part of the team. Thanks to
Robyn Thomas, Michele Filshie, Steve Weiss, and Dennis Fitzgerald for work-
ing with me again. You’re unmatched in my professional experience. Thanks
to our tech editors Matthew Woodruff, Eric Kramer, and Anselm Bradford.
Thanks to Marisa Bozza, Lee Brimelow, John Dowdell, Richard Galvan, Mally
Gardner, Stefan Gruenwedel, Jeff Kamarer, Vishal Khandpur, San Khong,
John Mayhew, Tony Mowatt, John Nack, Chris Nuuja, Ted Patrick, Nivesh
Ragbhandari, and Adobe. Special thanks to my staff at FMA and Mike Wills,
and my family for endless support. Last but not least, extra special thanks go
to Jodi, Sally, and Claire for everything.
Preface | xix
PART I
ActionScript 3.0 Introduced
Part I seats you comfortably in the ActionScript 3.0 bistro, offers to take your
coat, and gives you a free basket of fresh bread, hot from the oven. You’ll get
drinks, of course, and be presented with a menu that unveils the variety of
tools you can use while exploring ActionScript 3.0. Specials include the Flash
authoring tool and Flash Player 10, with a dash of Flex Builder 3. You’ll also
see a few third-party script editors.
The first chapters touch on a number of ActionScript concepts, explored fur-
ther in Part II, Part III, and Part IV. These introductory tidbits are intended to
whet your appetite. They give you an overview of the new features of Action-
Script 3.0: what makes it easier to use and more powerful than its predecessor,
how to benefit from its richer warnings and error messages, and how the new
language can improve your workflow by helping you get organized.
Chapter 1, Introducing ActionScript 3.0
Chapter 2, Discovering What You Need to Work with ActionScript 3.0
Chapter 3, Looking at the Changes in ActionScript 3.0
Chapter 4, Exploring the Benefits of Using ActionScript 3.0
CHAPTER 1
Introducing ActionScript 3.0
Ifyouchaseperfection,youoftencatchexcellence.
—William Fowble
The term “perfect” is a powerful word. From a practical standpoint, it repre-
sents a state that arguably cannot be achieved. Hey, that’s a relief already! This
book doesn’t expect the impossible. This isn’t the print version of an office
know-it-all, itching for you to slip up. You won’t hear any anxious hand
wringing in these pages over why you haven’t yet upgraded to, much less mas-
tered, ActionScript 3.0. (Yes, even though it was available in Flash CS3 Pro-
fessional.) Instead, the following chapters will take their cue from a sage ob-
servation by William Fowble: If you chase perfection, you often catch excel-
lence. In other words, chin up! Aim for the best and enjoy the road trip.
ActionScript 3.0—the current version of the programming language for the
Adobe Flash Platform—is a language that indeed catches excellence. This
book is designed to explain a bit about why that is. In so doing, our hope is to
help you chase perfection by introducing you to the improved organization,
syntax, and workflows of the new language. Catching excellence, for all of us,
is a matter of practice, and comes with time.
This book is going to introduce you to new ways of thinking about the Flash
Platform. ActionScript 3.0 requires these new ways because the language is
actually structured around them. That’s a big part of why the new language
improves on previous versions. Like its precursor, but to a greater extent,
ActionScript 3.0 is based on a specification called ECMAScript, which is a
standard proposed by a body of experts known as Ecma International. This
group is something like the World Wide Web Consortium (W3C), whose re-
sponsibility includes HTML, XML, CSS, and other widely used markup lan-
guages. Such a standard’s benefit is that ActionScript 3.0 isn’t just an arbitrary
language invented to meet Adobe’s needs. ECMAScript is a relatively mature
specification, already in its third revision. The Ecma International team in-
3
cludes authorities from industry powerhouses like Microsoft, the Mozilla
Foundation, and Adobe. The specification is built on the collective insight and
success of these diverse experts in the field. Of all the versions of ActionScript,
the current version comes closest into full compliance with this specification
—at this point, closer even than the other famous ECMAScript derivative,
JavaScript. This makes ActionScript 3.0 a model of best practices, habits you
can use in both Flash CS4 Professional and Flex Builder 3. In many cases, you
may even find that these practices benefit your involvement with existing
projects coded in previous versions of ActionScript. Sure, the syntactical de-
tails change, but achievement in programming is all about structure and pur-
pose. It’s the concepts and good habits that carry you.
For the nuts and bolts, the relevant ActionScript Language Reference is always
a mere keystroke away (the F1 key). Even so, a new set of Help docs can be
daunting, especially if you’re already well-versed in ActionScript 2.0. Fortu-
nately, the ActionScript 3.0 documentation is every bit as helpful as it used to
be, even if it looks different. The layout of the Help docs is still organized
around the layout of the language itself—around the classes that define the
objects you will use—and its class entries still summarize the usable apparatus
of each object: its characteristics, called properties; the things it can do, called
methods; and the things it can react to, called events. In the new documenta-
tion, code samples are presented as custom classes, rather than frame scripts.
This requires you test them as standalone, simple text files, according to the
new document class concept described in Chapter 6. Fortunately, this also
means you can test these classes in other programs, such as Flex Builder. This
book will help you get familiar not only with the new language, but also with
the documentation that explains it.
Keep in mind, ramping up to ActionScript 3.0 isn’t merely about learning the
latest syntax: it’s about becoming a better, more efficient programmer. This
isn’t meant to slight ActionScript 2.0 at all, but plenty has changed since its
introduction in late 2003. It’s no exaggeration to say that several aspects of the
language have been completely overhauled. In fact, ActionScript 3.0 requires
an entirely new virtual machine, which is the module inside Flash Player that
interprets compiled ActionScript. As of Flash Player 9, the runtime that dis-
plays Flash movies does so with two virtual machines: AVM1 for legacy SWF
files based on ActionScript 1.0 and 2.0, and the new AVM2 for ActionScript
3.0. That’s a first in the history of Flash Player. Thanks to the new virtual
machine, ActionScript 3.0 runs faster and more efficiently by an order of mag-
nitude. This bodes well for the overriding goal of the new language: to facilitate
a wide range of interactive media and Rich Internet Applications (RIAs)—to
do so simply, with better performance, and highly compatible with industry
standards. As you can imagine, an upgrade of this scale means you may have
4 | Chapter 1: Introducing ActionScript 3.0
to reshape some of your current habits. But take heart. Reshape doesn’t nec-
essarily mean tear down and rebuild. As ActionScript has matured, it has con-
sistently moved in the direction it currently stands. Again, honing your skills
in light of ActionScript 3.0 will help you in your current projects and also in
legacy project maintenance. Migration can be intimidating, but much of that
uncertainty comes from trying to find your stride. Once you take the first few
steps, the momentum keeps you going.
Here’s a look at some of the new features.
Examining ActionScript 3.0, the Language
Section 4 of the ECMAScript standard (http://www.ecma-international.org/
publications/files/ECMA-ST/Ecma-262.pdf) defines an important facet of any
language that implements it. Such languages “will provide not only the objects
and other facilities described in this specification but also certain environment-
specific host objects, whose description and behaviour are beyond the scope
of this specification.” In other words, any ECMAScript derivative needs a set
core functionality that stands on its own and will then provide additional
functionality specific to the environment that interprets it. This is exactly what
ActionScript 3.0 does, and its host environments include Flash Player for web
browsers, intended for Flash-enabled websites such as http://YouTube.com;
Flash Lite for devices, such as video games for your cell phone; and Adobe
Integrated Runtime (AIR) for applications installed on the hard drive, such as
eBay Desktop (http://desktop.ebay.com/).
Here is a brief summary of a number of core updates.
Runtime Exceptions
In ActionScript 2.0, many runtime errors failed without drawing attention to
themselves. On the plus side—and this is a very weak plus—this meant that
errors of this sort often failed “gracefully.” In other words, they might not halt
someone’s experience with something abrupt or laden with technical jargon,
such as an alert or dialog box. On the minus side, this also meant such errors
might go unnoticed by the developer—until complaints started rolling in that
people were experiencing slow playback or even lockups. Such errors could
be hard for developers to pinpoint and repair, precisely because they were
silent.
ActionScript 3.0 allows for a variety of runtime exceptions to be handled with
purpose. This includes Error objects generated both by the runtime
environment and, potentially, by the programmer. In ActionScript 3.0, the
Error class is considerably more robust than its forerunner, and tailor-made
Examining ActionScript 3.0, the Language | 5
Error objects can be built from this class as desired, inheriting and extending
its functionality to provide highly customized error messages. Exceptions can
even provide source file and line number information, which greatly enhances
the debugging experience, letting developers quickly track down errors.
Runtime Types
ActionScript 2.0 introduced the ability to strongly type variables, parameters,
and function return values. This was, and still is, an optional way to let Flash
know exactly what sort of data a particular variable, parameter, or return value
could cope with. This ability was a boon to developers in terms of debugging,
because it gave you a way to display error messages in cases of a type mis-
match. For example, if you were going to perform a math operation on two
numbers provided by the user, you might take those numbers from input text
fields. This would actually make them strings, which meant your math oper-
ation would give you unexpected results (for example, 1 + 2 would become
“12” instead of 3). By strongly typing the parameters of the function that per-
formed this operation—in other words, by specifying intended variable types
with a colon (:), then the type—you could benefit from a meaningful error
message in the Output panel such as this:
// ActionScript 2.0
var userVar1:String = inputField1.text;
var userVar2:String = inputField2.text;
function getSum(a:Number, b:Number):Number {
return a + b;
}
trace(getSum(userVar1, userVar2));
// Displays:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 8: Type mismatch.
getSum(userVar1, userVar2);.
A type mismatch notice is a great reminder to use something like parseInt()
or parseFloat() to convert those strings into numeric values. Useful indeed,
but this was only a first step in a good direction. In ActionScript 2.0, this sort
of error checking only occurred at compile time. Under many circumstances
—such as evaluating data from dynamic sources like XML—the feature wasn’t
“smart” enough to catch every contingency. In ActionScript 3.0, it is.
Sealed Classes
Following in the same vein as runtime exceptions and runtime types, Action-
Script 3.0 establishes the concept of sealed classes in a stricter, more formalized
way than in ActionScript 2.0. A sealed class is one that can’t have properties
6 | Chapter 1: Introducing ActionScript 3.0
or methods assigned to it at runtime, such as String. By default, classes in
ActionScript3.0aresealed,butthiscanbeoverruledwhenyouwriteyourown.
var str:String = "" // Or: new String();
str.customProperty = "This generates a compiler error.";
// Displays: Access of possibly undefined property customProperty
// through a reference with static type String.
In contrast, a class that actually can have properties and methods assigned to
it at runtime is called dynamic. One of the most familiar dynamic classes is
MovieClip, though historically speaking, many frame script developers haven’t
considered movie clips in terms of a class. The same could be said of buttons
and text fields, because you can create such elements with Flash’s drawing
tools. (Of the elements just mentioned, only movie clips are dynamic.) For
frame script coders, movie clips are often thought of simply as symbols or
timelines, and timelines have always been able to receive new variables at run-
time. True enough. What’s really going on, though, is that variables defined
in keyframe scripts are in reality dynamic properties of a MovieClip instance;
functions are actually dynamic methods.
Declaring a variable in a keyframe of the main timeline or in a movie clip’s
timeline is conceptually the same as the following:
var mc:MovieClip = new MovieClip();
mc.customProperty = "This is perfectly acceptable.";
Custom classes in ActionScript 3.0 can behave this way too, if and only if they
are declared with the dynamic attribute:
package {
public dynamic class CustomClass() {
// class code here
}
}
On paper, this is also how it was in ActionScript 2.0, but in fact, even non-
dynamic classes could be altered at runtime by manipulation of the
Object.prototype property (inherited by all objects) or by the array access op-
erator ([]). Advanced programmers who used such an approach in the past
will find it no longer works in ActionScript 3.0 for sealed classes.
// ActionScript 2.0
var str:String = "";
str.customProperty = "Secret back door.";
// Displays: There is no property with the name 'customProperty'.
str["customProperty"] = "Secret back door.";
// Works just fine in ActionScript 2.0, but in 3.0 displays:
Cannot create property customProperty on String.
Examining ActionScript 3.0, the Language | 7
In ActionScript 3.0, non-dynamic classes actually are what they claim to be.
This makes for stricter compile-time checking and improves memory usage
because class instances can now be guaranteed to require no more than a pre-
declared amount of system memory.
Method Closures
Of all the updates to ActionScript 3.0, it’s no surprise that developers, regard-
less of skill level, encounter one in particular early on: method closures. Why?
Because the introduction of method closures changes the point of view, or
scope, of methods in ActionScript 3.0.
Scope refers to the conceptual area of a program in which code executes. The
availability of code definitions, such as variables, functions, properties, and
methods, depends on the scope of the code being executed. For example, if a
variable is declared in a timeline frame, that variable can be referenced by any
other code in that frame, as long as that code appears after the declaration.
Even a function defined in that frame can reference the variable scoped to the
timeline, because scopes can be nested, and the flow moves from outer scope
to inner: the timeline’s definitions become available to the function.
// A variable declared here ...
var favoriteCereal:String = "Star Crunchers!";
// can be referenced here ...
trace(favoriteCereal); // Displays: Star Crunchers!
function myFunction():void {
// and here ...
trace(favoriteCereal); // Displays: Star Crunchers!
}
myFunction();
In contrast, a variable declared inside a function can only be referenced by that
function, because the scope of the function is confined to itself.
function myFunction():void {
// A variable declared here ...
var favoriteCereal:String = "Star Crunchers!";
// can only be referenced here ...
trace(favoriteCereal); // Displays: Star Crunchers!
}
myFunction();
// but not in the outer scope ...
trace(favoriteCereal);
// Displays:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 10:
Access of undefined property favoriteCereal.
8 | Chapter 1: Introducing ActionScript 3.0
Up to now, this should be familiar to ActionScript 2.0 developers. How, then,
have things changed? Consider the next few examples.
In ActionScript 2.0, a button click might be handled like this:
// ActionScript 2.0
myButton.onRelease = buttonHandler;
function buttonHandler():Void {
trace(this); // Displays: _level0.myButton
// other event handler code
}
Prior to ActionScript 3.0, the scope of the function shown belonged to the
myButton instance. In this case, the button code could conveniently be abbre-
viated with the use of the this keyword, which self-referenced the current
scope (myButton). In some cases, this made for a handy way to achieve certain
goals. For example, to repeatedly loop a Sound instance in ActionScript 2.0,
the following would do:
// ActionScript 2.0
var audio:Sound = new Sound();
audio.loadSound("externalFile.mp3", true);
audio.onSoundComplete = completeHandler;
function completeHandler():Void {
this.start();
}
Again, the function is scoped to the instance. In this case, the expression
this.start() amounts to invoking the Sound.start() method on the audio
instance. Although convenient in this sort of situation, difficulties arose when
the event handler needed to reference objects outside the scope of the function,
especially in custom classes.
To a large extent, this issue could be addressed in ActionScript 2.0 with the
Delegate class, which allowed you to reroute the scope as desired:
// ActionScript 2.0
import mx.utils.Delegate;
var audio:Sound = new Sound();
audio.loadSound("externalFile.mp3", true);
audio.onSoundComplete = Delegate.create(this, completeHandler);
function completeHandler():Void {
audio.start();
}
The Delegate.create() method accepted two parameters: first, the desired
scope; second, the function or method to execute in that scope. Note that
because of this change, the function invokes audio.start() directly. In this
case, the this keyword no longer refers to the audio instance to which the
Examining ActionScript 3.0, the Language | 9
listener was attached, but rather to the timeline frame in which the listener
was assigned.
In ActionScript 3.0, method closures let a function or method remember where
it was defined. In short, you get the best of both worlds. In the following
ActionScript 3.0, written in a keyframe, the reference to this shows that the
scope belongs to the main timeline—to the frame in which the function is
defined, rather than to the myButton instance. No extra baggage, like the Dele
gate class, is required.
myButton.addEventListener(MouseEvent.CLICK, buttonHandler);
function buttonHandler(evt:MouseEvent):void {
trace(this); // Displays: [object MainTimeline]
}
To reference the button rather than the frame, use the Event.target property
of the parameter that is passed into the function automatically by the event.
In this snippet, the parameter is arbitrarily named evt:
myButton.addEventListener(MouseEvent.CLICK, buttonHandler);
function buttonHandler(evt:MouseEvent):void {
trace(evt.target); // Displays: [object SimpleButton]
trace(evt.target.name); // Displays: myButton
}
ECMAScript for XML (E4X)
FlashhaslongsupportedXML,buttheadditionofECMAScriptforXML(E4X)
syntax is a significant productivity boost. Like ActionScript, E4X is an Ecma
International specification, which affords a powerful yet concise set of lan-
guage constructs for retrieving data from XML, and manipulating it.
In ActionScript 2.0, you can certainly navigate among the nodes of a loaded
XML document, but the effort becomes progressively more tedious as the
XML’s complexity increases. The ActionScript 2.0 XML class provides a handful
of necessary navigation properties, such as firstChild, nextSibling,
lastChild, and childNodes. Choosing from these, and assuming an XML docu-
ment has already been loaded and parsed into an XML instance named myXML,
you might select the title of the fifth track of The Beatles’ Abbey Road album
(“Octopus’s Garden”) like this:
// ActionScript 2.0
myXML.firstChild.firstChild.firstChild.childNodes[4].attributes.¬
title;
// Contents of the loaded XML document
<?xml version="1.0" encoding="iso-8859-1"?>
<library>
<artist name="The Beatles">
<album name="Abbey Road">
10 | Chapter 1: Introducing ActionScript 3.0
<track title="Come Together" />
<track title="Something" />
<track title="Maxwell's Silver Hammer" />
<track title="Oh! Darling" />
<track title="Octopus's Garden" />
<track title="I Want You (She's So Heavy)" />
<track title="Here Comes the Sun" />
<track title="Because" />
<track title="You Never Give Me Your Money" />
<track title="Sun King" />
<track title="Mean Mr. Mustard" />
<track title="Polythene Pam" />
<track title="She Came in Through the Bathroom Window" />
<track title="Golden Slumbers" />
<track title="Carry That Weight" />
<track title="The End" />
<track title="Her Majesty" />
</album>
</artist>
</library>
In the preceding whopping expression, myXML refers to the parsed XML docu-
ment; the three mentions of firstChild refer, respectively, to the <library>,
<artist>,and<album> nodes;andchildNodes[4] referstothefifth<track> node
(bear in mind, childNodes returns an array, and arrays start at zero). Finally,
the attributes property leads to the title attribute of the selected node.
E4X lets parsed XML be referenced as if it were a native object. This lets you
traverse the loaded data incredibly more intuitively. In the ActionScript 3.0
equivalent, the same track can be referenced like this:
// ActionScript 3.0
myXML.artist[0].album[0].track[4].@title;
or, thanks to the descendent accessor operator (..), even something as short
as this:
myXML..track[4].@title;
Which would you rather type?
In addition, you can compare data using a familiar set of operators. For ex-
ample, if the XML document at hand contains numerous recording artists, The
Beatles’ <artist> node could be singled out as easily as this:
myXML.artist.(@name == "The Beatles")
The E4X specification is available in Adobe PDF format at the
Ecma International website: http://www.ecma-international
.org/publications/files/ECMA-ST/Ecma-357.pdf.
Examining ActionScript 3.0, the Language | 11
Regular Expressions
The term regular expressions refers to a set of specialized language constructs
for retrieving data from strings (that is, text content), and manipulating such
data. In this regard, regular expressions (often abbreviated as regex) shares a
number of similarities with E4X: both mechanisms are compact and efficient
in their tasks. The syntax of regex tends to be initially harder to grasp than
E4X—here, normal letters and punctuation are used to represent whole sets
of characters, in addition to filtering rules—but the results are well worth the
effort.
What can you do with regular expressions? To answer that, consider two fa-
miliar methods of the String class, indexOf() and lastIndexOf(), which have
been available in ActionScript for years. These methods both accept two pa-
rameters: first, a string to look for within a container string; second, optionally,
where to start looking within the container string. Each method takes its start-
ing point from opposite ends of the container string.
var pangram:String = "The quick, brown fox jumps over a lazy dog.";
trace(pangram.indexOf("o")); // Displays 13
trace(pangram.indexOf("o", 14)); // Displays 18
trace(pangram.lastIndexOf("o")); // Displays 40
In the first trace() statement, only one parameter is supplied, "o", and the
return value is 13 because the letter “o” makes its first appearance at index 13
(starting with 0, the thirteenth character in the string pangram). In the second
statement, the return value is 18 because of the optional second parameter
14, which instructs the method to begin after the index of the first “o”. In the
third statement, the return value is 40 because the method lastIndexOf() be-
gins its search from the end of the string.
For simple searches, indexOf() and lastIndexOf() fit the bill, but what if the
requirement is something like “find all US ZIP codes,” which could be any 5-
number combination, or “find all words in this paragraph that contain three
or more vowels”? Suddenly, the task seems considerably more difficult, if not
impossible. Believe it or not, the RegExp class in ActionScript 3.0 handles this
requirement very easily. The solution requires a pattern of specialized charac-
ters, expressed either as an instance of the RegExp class or passed as a parameter
to one of the regex-related methods of the String class (match(), replace(), or
search()).
Given a variable, paragraph, set to the text content of the previous paragraph,
the following code shows how to retrieve words with three or more vowels:
var re:RegExp = /b(w*[aeiou]w*){3}b/gi;
var result:Object = re.exec(paragraph);
12 | Chapter 1: Introducing ActionScript 3.0
while (result != null) {
trace(result[0]);
result = re.exec(paragraph);
}
// Displays: searches, indexOf, lastIndexOf, requirement,
// something, and other words with three or more vowels
A full discussion of regular expressions syntax is beyond the scope of this book,
but here’s a brief overview of how the previous example works. A variable,
re, is set to an instance of the RegExp class by way of the RegExp delimiter
operator (/pattern/flags). Between the two slashes of this operator, the pat-
tern b(w*[aeiou]w*){3}b spells out the search requirement. After the sec-
ond slash, the flags (gi) configure the pattern as global and case insensitive.
The RegExp.exec() method executes the pattern on the string paragraph and
returns an object (result) that contains information about the search. The
search is repeated until result is null.
If the preceding example seems outlandish, imagine the same sort of power
applied to the validation of user input. You can manage even potentially com-
plex requirements without much difficulty. These include questions such as,
“Is this email address correctly formed?” (Checking for the “@” character isn’t
enough!) “Is this a valid telephone number?” (People might enter anything
from (123) 456-7890 to 123.456.46789 to 123456789.) “Has the user tried to
sneak in an inappropriate word by using a nonstandard spelling?” Patterns
that match these requirements not only find the strings in question, but can
also manipulate them in order to, for example, format telephone numbers
consistently or replace questionable words with Xs.
For an exhaustive and highly regarded treatise on regular ex-
pressions, be sure to read Mastering Regular Expressions, by
Jeffrey Friedl (O’Reilly). Numerous tutorials are also available
online at the unrelated http://www.regular-expressions.info/
website.
Namespaces
In advanced programming scenarios, the concept of namespaces brings a val-
uable new mechanism to ActionScript 3.0. In short, namespaces are essentially
custom access specifiers—like public, private, protected, and internal—ex-
cept with names you choose. Namespaces let you control the visibility of your
properties and methods, even to the point of overriding package structures.
They also let you qualify members under various guises. As a quick example,
you might develop an AIR application that performs one behavior while an
Internet connection is present, and another when no connection is present. By
using namespaces, you can define multiple versions of the same method that,
Examining ActionScript 3.0, the Language | 13
for instance, checks an online inventory when the user’s WiFi connection is
available but defaults to a cached version otherwise. Or you might define series
of variables in several languages, where the value of a variable depends on the
user’s regional settings. These distinctions are determined by custom prefixes
and the name qualifier operator (::):
// Three versions of the same String variable
english::newFeatures // Value of "Lots of new stuff"
german::newFeatures // Value of "Viele neue Sachen"
french::newFeatures // Value of "Plien de nouvelles choses"
Namespaces are outfitted with a Universal Resource Identifier (URI) to avoid
collisions, and are also used to represent XML namespaces when working with
E4X.
New Primitive Types
ActionScript 3.0 introduces two new primitive types, int and uint, bringing
thefulllisttoBoolean,int,Null,Number,String,uint,andvoid (notethechange
in capitalization from Void). These new numeric types reduce memory usage
in cases when a numeric value need only be an integer. How? The familiar
Number data type is an IEEE-754 double-precision floating-point number,
which, thanks to its structure, always requires 64 bits of memory. Number ob-
jects range from 1.79e+308 (1.79 with over 300 zeroes after it!) down to
5e-324. That’s an unimaginably large range, which isn’t always necessary.
Sometimes you just want to count through a for loop, and all you need is an
integer.
Enter int, which is a relatively small 32-bit number (only 4 bytes), whose range
is still an impressive 2,147,483,647 (over two billion) down to−2,147,483,648.
That range should do for most of the for loops you’ll encounter. By contrast,
uint numbers (unsigned integers) range from 0 to 4,294,967,295, which is the
same span as int, but entirely on the positive side of the number line. If your
for loop’s counter, or any other integer value, needs a higher range than offered
by int, uint makes a good choice—provided the range doesn’t dip below zero.
Neither type ever requests more than 32 bits of system memory.
One note of caution: because uint values are always positive,
take care when trying to subtract a uint into negative territory.
A uint rolls around to 4,294,967,295 if you subtract it past
zero, as the following code demonstrates.
var n:uint = 0;
trace(n); // Displays 0
n--;
trace(n); // Displays 4294967295
14 | Chapter 1: Introducing ActionScript 3.0
Exploring Flash Player API Updates
In the “ActionScript 3.0, the Language” section of this chapter, you learned
that the ECMAScript specification on which ActionScript is based actually
expectsthelanguagetoprovidefunctionalitytailoredtotheplatformthathosts
it. In the case of ActionScript, hosts include Flash Player, AIR, and Flash Lite
—all various flavors of the Flash Platform. Though each host is designed to
meet specific needs—websites, desktop applications, and mobile content, re-
spectively—their overlap is considerable. ActionScript 3.0 institutes a signifi-
cant restructuring of its application programming interface (API), summarized
handily in the colossal migration table available on the Adobe LiveDocs web-
site (http://help.adobe.com/en_US/AS3LCR/Flash_10.0/migration.html) and
also in the Help panel in the appendices of the ActionScript 3.0 Language and
Component Reference, under the heading “ActionScript 2.0 Migration”. In
large part, existing functionality has been restructured into packages that make
better sense from an organizational standpoint. However, Flash does have a
number of philosophical changes in the way it carries out its fundamental
tasks. The following paragraphs list some of the more notable updates.
As of the publication of this book, Flash Lite does not yet
support ActionScript 3.0, due to the inherent processor and
memory limitations of mobile devices. The features recounted
here apply to Flash Player 9 (and higher) and AIR, but won’t
apply to Flash Lite until that runtime adds support for
ActionScript 3.0.
DOM3 Event Model
Before ActionScript 3.0, you could handle events in Flash in at least five dif-
ferent ways, some of which were interchangeable:
• The legacy on() handler, available since Flash 2 and still in wide use, even
in ActionScript 2.0 scenarios, but gone in ActionScript 3.0
• The legacy onClipEvent() handler, also widely used and unavailable in
ActionScript 3.0
• The dot notation syntax that combined and replaced on() and
onClipevent() (for example Button.onPress = functionDefinition,
MovieClip.onEnterFrame, and so on)
• The addListener() method of several—but not all!—ActionScript 2.0
classes, such as TextField, Mouse, and MovieClipLoader
• The addEventListener() method used by the v2 component set (user in-
terface, data, and media components)
Exploring Flash Player API Updates | 15
This varied assortment was a result of incremental improvements to Action-
Script with every new release of the authoring tool, with the older approaches
retained for backward compatibility. For longtime Flash developers, each new
technique was simply a small addition to the workflow, but newcomers to
recent versions, such as Flash 8 or Flash CS3, were understandably confused
by an API with so many seemingly arbitrary possibilities.
Are on() and onClipEvent() really so bad? From a workflow
standpoint, no. From a practical standpoint, they aren’t nearly
as valuable as their dot notation replacement. In ActionScript
2.0,thecombinationofon() andonClipEvent() provideaccess
to only slightly more than half the events available to movie
clips and buttons. In addition, you can’t assign, manipulate,
or remove their event handlers at runtime. Their absence in
ActionScript 3.0 marks the end of a long transition period
from ActionScript 1.0 through 2.0.
Because ActionScript 3.0 relies on a new virtual machine, it can afford to make
a clean break in the way it handles events. With one small exception (discussed
in Chapter 4), event handling is now consolidated across the board into a
single, consistent approach: the EventDispatcher.addEventListener()
method. This mechanism is based on the W3C’s Document Object Model
(DOM) Level 3 Events Specification (http://www.w3.org/TR/DOM-Level-3
-Events/). This means that in ActionScript 3.0, event handling syntax is the
same in nearly all cases, no matter if the event dispatcher is a button, an audio
clip, or a loader object for XML or JPEG files. The basic structure looks like
this:
eventDispatchingObject.addEventListener(
EventType,
functionToPerform
);
Display List API
In ActionScript 3.0, movie clips can be instantiated with the new keyword as
easily as this:
var mc:MovieClip = new MovieClip();
which is more intuitive than what it took in ActionScript 2.0:
var mc:MovieClip = existingMovieClip.createEmptyMovieClip(¬
instanceName, depth);
And it gets better. Depth management is now automatic. Notice that the ex-
pression new MovieClip() does not require a depth parameter. This change is
16 | Chapter 1: Introducing ActionScript 3.0
due to a fundamental new approach to the display of visual objects in Action-
Script 3.0: a concept called the display list, which represents the hierarchical
display of all graphical objects in Flash Player. This concept is embodied in
the DisplayObjectContainer class, the base class for all objects that can serve
as visual containers, including movie clips, the new Sprite and Loader classes,
and more. Thanks to inheritance, DisplayObjectContainer provides new meth-
ods to these classes for considerably better control over the management of
object z-order. For example, while the MovieClip class in ActionScript 2.0 fea-
tured getDepth() and swapDepths(), the ActionScript 3.0 version offers all of
these:
• addChild()
• addChildAt()
• contains()
• getChildAt()
• getChildByName()
• getChildIndex()
• removeChild()
• removeChildAt()
• setChildIndex()
• swapChildren()
• swapChildtenAt()
How’s that for control?
These methods are also available to Sprite, which is effectively a movie clip
without the overhead of a timeline; Loader, which loads external SWF files and
image files (JPEG, PNG, or GIF) at runtime; and any other class in the
DisplayObjectContainer family tree.
Under the display list system, objects can be re-parented at any time. This
ability simplifies cases in which groups of objects need to be manipulated at
once. Consider a jigsaw puzzle game, for example. If you want to combine
partially solved areas, so that snapped-together pieces move as one unit, you
can simply remove the piece from its current parent and add it as a child to the
parent that represents the partially solved group. Before ActionScript 3.0, this
action would have required individual sophisticated tracking of each jigsaw
piece.
Exploring Flash Player API Updates | 17
New Sound APIs
Flash Player 8 was the first to support 32 simultaneous sound channels, a
significant increase from the original eight-sound channel limit. Although
present for as long as Flash Player has supported sound, these sound channels,
as such, had no clear representation in code before ActionScript 3.0. In previ-
ous versions of the language, the Sound class was self-contained, handling all
of its functionality in a relatively simple manner, but at the cost of some clarity
of purpose. For example, in order to control the volume and panning of one
sound distinctly from another, you had to associate each sound with its own
movie clip. You made this association by way of an optional “target” parameter
in the Sound constructor function. Because target movie clips might or might
not contain other content, their ambiguous roles had the potential to confuse.
ActionScript 3.0 clarifies programmed sound by complementing the Sound
class with three companions: SoundChannel, SoundTransform, and SoundMixer.
These new APIs give you more explicit control over imported and embedded
sounds. The SoundMixer.computeSpectrum() method even lets you retrieve
spectral data from sounds, which you can use to program responses to changes
in audio pitch and volume.
Binary Data and Sockets
The new ByteArray class enables interoperability with existing custom proto-
cols, and lets advanced developers read, write, and manipulate data on the
byte level. This has led adventurous programmers to cultivate projects previ-
ously unheard of in Flash, such as Tinic Uro’s PNG encoder (http://www
.kaourantin.net/2005/10/png-encoder-in-as3.html, now updated and featured
in the as3corelib library at http://code.google.com/p/as3corelib/) and a dynamic
tone generator by André Michelle and Joa Ebert, capable of playing MIDI-like
Amiga MOD files (http://8bitboy.popforge.de/).
Understanding Players and Support
Although this book focuses primarily on the Flash authoring tool, it’s impor-
tant to realize that Adobe offers two official ActionScript 3.0 compilers. One
of these compilers is built into Flash CS4 itself. As you would expect, this one
takes into consideration objects in the document’s Library, as well as global
SWF file settings, such as background color and frame rate, as configured in
the Property inspector. This compiler can also compile previous versions of
ActionScript. Separate from that, there’s the command line compiler included
with the free Flex Software Development Kit (SDK) available at www.adobe
.com/go/flex_trial/. This second compiler is the one used by the Flex Builder
18 | Chapter 1: Introducing ActionScript 3.0
integrated development environment (IDE), which doesn’t include drawing
tools, timelines, or a library. In addition to ActionScript 3.0, the Flex compiler
understands MXML, the declarative markup language used for laying out Flex
applications. For want of a library, the second compiler lets metadata embed
assets into resultant SWF files. The Flash authoring tool supports only limited
metadata, an undocumented feature at the time of writing.
These distinct compilers serve independent workflows. To facilitate the de-
velopment of RIAs, the Flex SDK features an elaborate framework of user
controls and data handlers that aren’t available to the Flash authoring tool,
even though the framework is written in ActionScript 3.0. By comparison,
Flash offers a modest subset of user controls in its Components panel, includ-
ing support for the playback and manipulation of Flash video files (FLV).
In the end, there’s only one ActionScript 3.0, and it behaves the same when
compiled under either tool. The reason for this consistency is that Flash CS4
and the Flex SDK both publish SWF files for the same Flash Player 9 or higher.
It’s quite possible—and often done—to create custom classes that can be used
under either circumstance. The concept of the document class (see Chap-
ter 6), introduced in Flash CS3, means that an entire application, composed
of numerous external classes, can be compiled by Flash or the Flex command
line compiler (including Flex Builder) from identical source files.
Because ActionScript 3.0 requires AVM2, as mentioned earlier in this chapter,
Flash Player 9 is the minimum required runtime to display such content. Flash
Player 9 runs on numerous operating systems, including several versions of
Windows, Macintosh, Linux, and Solaris. Due to the varied nature of these
operating systems and occasional bug fixes required by each, in addition to
ongoing new features, Flash Player 9 includes a number of minor point relea-
ses, as summarized in Table 1-1. Flash CS4’s default output is aimed at Flash
Player 10, which may eventually see a list of minor point releases just as long.
Time will tell. To determine what version of Flash Player the user has installed,
reference the static version property of the Capabilities class.
Table 1-1. Flash Player 9 minor point releases
Flash Player
version Notable changes
9.0.16.0 ActionScript 3.0, including runtime exceptions and error handling, sealed classes, method clo-
sures, ECMAScript for XML (E4X), regular expressions, namespaces, new primitive types, DOM3
event model, display list APIs, new sound APIs, and binary data and sockets.
9.0.20.0 Bug fixes and optimizations related to the Intel-based Macintosh platform.
9.0.28.0 Support for Windows Vista operating system. Addition of ADDED_TO_STAGE and
REMOVED_FROM_STAGEeventconstantstoletaDisplayObjectmonitorandknowwhen
it can or cannot access its stage property. Security enhancements.
Understanding Players and Support | 19
Flash Player
version Notable changes
9.0.31.0 Support for Linux operating systems.
9.0.45.0 Bug fixes and improvements for Adobe Flash CS3 Professional. Affects only Windows and Mac-
intosh platforms.
9.0.47.0 Support for Solaris operating system. Security enhancements.
9.0.48.0 Linux security enhancements.
9.0.115.0 H.264 video and High Efficiency AAC (HE-AAC) audio codec support. Hardware acceleration,
hardware scaling, multi-threaded video decoding, and enhanced image scaling. Flash Player
cacheenablescommoncomponents,suchastheFlexFramework,tobecachedlocallyandthen
usedbyanySWFfromanydomain.FlashMediaServerbufferingmaintainsstreambufferwhile
a stream is paused.
9.0.124.0 Media streaming security patch and minor display update for Windows Vista.
A full listing of all Flash Player release notes, including bug
fixes, can be found at http://www.adobe.com/support/documen
tation/en/flashplayer/releasenotes.html.
Learning ActionScript 3.0 on the Heels of 2.0
Pretend for a moment you’re a carpenter. For years, you were making do with
a hand-crank drill, but then the Macromedia Hardware Company introduced
an electric model called ActionScript 1.0 stamped with gold letters on the
handle. Beautiful thing! No reason to ever use anything else. Sure, you could
operate the drill only within six feet of an electrical outlet (because that was
the length of the cord), but the advantages were resoundingly clear. Plus, you
could always carry around an extension cable. A few years later, Macromedia
announced a new and improved ActionScript 2.0 model. This drill had an
optional battery back. For some, the new battery pack was a godsend, because
it freed them from the previous six foot limitation. They embraced the new
feature and literally found themselves running with it. Other carpenters found
the battery pack a bit too advanced. They weren’t sure, for example, if they
were supposed to drain the batteries completely before recharging. And hon-
estly, that was fine: the drill still had a cord, of course, so they continued within
their previous comfort zone, which was still a considerable improvement over
the hand-crank days. Carpenters were a happy bunch. Eventually, the Mac-
romedia Hardware Company became Adobe. Everyone looked forward to the
new drill—ActionScript 3.0—and when it came ... they found that the cord
had been replaced with a docking station. Suddenly, carpenters who had opted
not to use the ActionScript 2.0 battery pack felt trapped. They had no expe-
20 | Chapter 1: Introducing ActionScript 3.0
rience with batteries, but if they were going to use an ActionScript 3.0 model,
they had no choice.
It goes without saying that every analogy has its flaws. Certainly, the changes
in ActionScript 3.0 amount to more than the obvious benefit of a battery pack.
Clearly, the new APIs are more complex than the question of how to recharge
a set of batteries. In any case, ActionScript does a lot more than drill holes!
Still, it can be useful to think of ActionScript 2.0 as a preparatory transitional
period between, on one hand, the very roots of the language—that is, Action-
Script 1.0 and even earlier—and, on the other hand, the current version. As
with the carpenter story, numerous features in ActionScript 2.0, such as strict
typing (:Number, :Void, etc.) and formalized custom class files, were optional.
(Unlike the analogy, those particular features are still optional in ActionScript
3.0.) Voluntary though they were, such then-new conventions were an early
invitation to practice a more efficient workflow. Developers who opted to ex-
periment with object-oriented programming (OOP), to the point of writing
their own custom classes, may feel more at home with ActionScript 3.0 than
others. For those who were perfectly comfortable with the conventions of
ActionScript 1.0, they might understandably feel trepidation in light of the
current version, especially now that ActionScript 3.0 has dropped support for
some previously optional features, such as on() and onClipEvent(). Flipping
through the ActionScript 3.0 Language and Components Reference takes con-
siderably longer than before. Everything has been arranged into a potentially
overwhelming new hierarchy of packages. Most of the Help panel sample code
has been written as class files, to make it applicable both for keyframe and
class file programmers.
These changes are big, but not insurmountable. One of this book’s driving
purposes is to help you feel caught up, whether or not you pursued the optional
new conventions of ActionScript 2.0—the features that, in hindsight, were a
gentle ramp up to today’s recommended best practices. The important thing
to keep in mind is that ActionScript 3.0 is scalable in terms of complexity. If
you want to plunge headlong into OOP principles such as inheritance and
design patterns, ActionScript 3.0 will oblige. If you prefer to stick with tradi-
tional timeline coding, ActionScript 3.0 will oblige—with a number of provi-
sos covered in the following chapters.
Deciding to Migrate or Write Code from Scratch
If you work with a set of in-house templates, be they FLA files, custom classes,
or a combination of both, sooner or later you’ll have to decide how to update
them. For the sake of discussion, these files are stable ones that have made
your company money for years, and they work just fine. Nonetheless, you’d
Deciding to Migrate or Write Code from Scratch | 21
like to take advantage of the speed increases—or any of the other benefits—
afforded by ActionScript 3.0. Should you painstakingly tinker with existing
files, tweaking as you go, or should you ditch everything and start from square
one? Which approach would require less effort?
For better or worse, there is no sure-fire way to determine which endeavor is
more advantageous in a given situation. While you can theoretically upgrade
a FLA file’s Publish Settings to ActionScript 3.0 and compile without errors or
warnings, the prospect becomes progressively more unlikely as a project gains
in complexity. Chances are high that one incompatibility will occur in concert
with many: in other words, when it rains, it pours. That said, here are a few
thoughts to consider.
If all or most of your code exists on frames in a FLA file, you may have no
realistic choice but to migrate the ActionScript in place, for the obvious reason
that the code is so closely tied to the file’s visual design. To start from scratch
could require careful transportation of symbols from one FLA file to another,
possibly including intricate nested timeline effects. For simple banner ads and
linear slideshows, an in-place update may not be as difficult as it sounds.
Standalone calls to stop(), gotoAndPlay(), and the like, will carry over without
a hitch. By all means, select File→Publish Settings→Flash→Script→ActionScript
3.0, and then hold your breath and see what happens.
Don’t forget to exhale if the compile works, and frankly, prepare yourself now
for numerous entries in the Compiler Errors panel. If any of the frame code
involves event handlers, loads external assets, or even calls a new web page
(getURL() is now navigateToURL()), you’ll have to update it. The good news is,
the Compiler Errors panel is one of many helpful new tools in Flash CS4
(introduced in Flash CS3). This panel not only tells you where the erroneous
code is, by class file, scene, layer, keyframe, and line number, it often makes
suggestions on what to change, including a list of common migration issues.
The Compiler Errors panel and other debugging tools are cov-
ered in Chapter 11.
If most of your code exists in external class files, your project probably involves
more than a smattering of ActionScript. Although this likely means you’ll
spend more time on code migration (because there’s more of it!), the fact that
your code is separate means you can test and revise each class individually. In
either case, frame code or class files, this book will help you get your bearings.
22 | Chapter 1: Introducing ActionScript 3.0
CHAPTER 2
Discovering What You Need to
Work with ActionScript 3.0
Working with ActionScript 3.0 is an equation composed of two parts: you
need something to compile a program written in the language, and you need
something to display the results of that programming. In compiler territory,
you have quite a few development choices. In the most basic approach, Adobe
makes the Flex Software Development Kit (SDK) available to the public free
of charge (http://www.adobe.com/go/flex_trial/). This SDK includes the full
ActionScript 3.0 application programming interface (API), which is the full list
of core and Flash Player API classes described in the ActionScript 3.0 Language
and Components Reference, published on the Adobe LiveDocs website (http:
//help.adobe.com/en_US/AS3LCR/Flash_10.0/). In addition, the SDK includes
the Flex framework (component class library) and Flex command line com-
piler, letting programmers freely develop and deploy Flex applications using
any scripting integrated development environment (IDE). Because the Flex
framework is, itself, written in ActionScript 3.0, you don’t necessarily have to
learn a new language to use Flex. Without spending a dime, interested pro-
grammers can build anything from basic ActionScript 3.0 class files—which
you can also write in the Script window of Flash CS4 Professional—to full-
scale Flex applications that you can write with Flex Builder 3.
Displaying the results of your work requires Flash Player 9 or higher (Flash
CS4 publishes to Flash Player 10 by default). That may seem like the easy half
the equation, but there are actually several versions of Flash Player 9 and will
likely be several versions of Flash Player 10. The following sections give a brief
overview of the tools necessary to work with ActionScript 3.0. Later in the
chapter, you’ll learn about alternative scripting IDEs that you can use in co-
operation with the Flash authoring tool.
23
Flash CS4 Professional/Flex Builder 3
The Flash CS4 Professional authoring tool is the latest in a running line of the
production tool that originally began life as a vector animation program. When
designers and developers hear the word “Flash,” they probably think first of
the Flash authoring tool, rather than Flex Builder, even though both applica-
tions are Adobe products that publish SWF files for the same Flash Player
runtime. In a few words, Flash CS4 can be summed up as the most appropriate
toolfortraditionalFlashdesignersanddevelopers.Thisauthoringtoolfeatures
numerous panels aimed at drawing and animation—consider the Timeline,
Color, Align, Transform, and Tools panels.
Flash authoring techniques often take advantage of a timeline metaphor, in
which the goings-on of a SWF file are thought of in terms of a playhead moving
along a timeline: navigation from one display state to another is the result of
“going to” and “playing” desired keyframes. In contrast, Flex Builder can be
summed up as the most appropriate tool for traditional programmers, espe-
cially those familiar with tools like Borland JBuilder for Java and Microsoft
Visual Studio for Visual Basic or C#. In fact, Flex Builder is built on the popular
open source Eclipse platform (http://www.eclipse.org/), and you can even buy
it as an Eclipse plug-in. Flex Builder is a coder’s environment and, as such,
provides no drawing tools or timelines, and only the most basic of color pa-
lettes. Even though ActionScript’s MovieClip class features methods such as
play(), stop(), and gotoAndPlay(), a Flex Builder developer is more likely to
think of movie clips—that is, timelines—in an abstract way, in terms of an
object-oriented programming (OOP) point of view.
To program and deploy ActionScript 3.0, you need only an ActionScript 3.0
compiler. Flash CS4 provides one, which is used when a FLA file’s publish
settings are configured for ActionScript 3.0. The Flex SDK also provides one,
which you can use with a command line interface (no graphical user interface,
just typing) or Flex Builder 3, which does the command line typing for you. If
Flash CS4 (or CS3) isn’t used, then you don’t need (indeed, you can’t create)
the FLA file familiar to traditional Flash developers. In either case, you may
use any simple text editor at a bare minimum, such as Notepad on Windows
or TextEdit on Mac, though most developers type their code into the Actions
panel or a Script window of Flash CS4, an edit window in Flex Builder, or one
of the external script editors discussed later in this chapter.
Flash Player 9 or Higher
Once a SWF file is compiled, it must be viewed in some version of Flash Player;
specifically, Flash Player 9 or higher, if the SWF file contains ActionScript 3.0.
24 | Chapter 2: Discovering What You Need to Work with ActionScript 3.0
Generally speaking, this tends to be a straightforward enterprise. As a reader
of this book, you’re presumably a Flash professional, which means you build
your content in the Flash authoring tool, and publish using either File→Publish
or Control→Test Movie. You already have Flash Player installed, of course, so
when you launch the SWF file, or view it in an HTML document, you see the
content, and then decide whether or not to upload it to a web server. For simple
projects, this process is often all it takes.
You might, however, find yourself in need of a particular minor point release
of Flash Player 9 or 10, like those listed in Table 1-1 of Chapter 1. If you want
to display your SWF file in full screen mode, for example, you need to test in
Flash Player 9.0.28.0 or higher. If you want to display H.264-encoded high
definition video, you need to test in Flash Player 9.0.115.0 or higher. Further,
you need to ensure that people visiting your website also have the same minor
point release. The Flash authoring tool gives you more than one version of
Flash Player for testing during development: debug and release players.
Debug Vs. Release Players
The application folder of Flash CS4 Professional includes installation files for
two distinct versions of Flash Player. These versions are located in Debug and
Release subfolders of the following locations:
• Windows: C:Program FilesAdobeAdobe Flash CS4Players
• Mac: /Applications/Adobe Flash CS4/Players/
These installation files include:
• Debug:
• Install Flash Player 10 ActiveX.exe: Debug installer for the ActiveX ver-
sion of Flash Player used by Internet Explorer on Windows.
• InstallFlashPlayer10Plugin.exe:Debuginstallerfortheplug-inversion
of Flash Player used by Mozilla compatible browsers.
• Install Flash Player 10 UB.dmg: Debug installer for Flash Player on Mac.
• Release:
• Install Flash Player 10 ActiveX.exe: Release installer for the ActiveX
version of Flash Player used by Internet Explorer on Windows.
• Install Flash Player 10 Plugin.exe: Release installer for the plug-in ver-
sion of Flash Player used by Mozilla compatible browsers.
• Install Flash Player 10 UB.dmg: Release installer for Mac Flash Player.
Flash Player 9 or Higher | 25
Both folders, Debug and Release, contain identically named
files. Don’t let that confuse you!
These installation files let you install debug versions of Flash Player for testing
locally inside a browser—then to switch back to release versions any time you
please. Debug versions are identical to the non-debug-enabled (release) ver-
sions, except that the debug versions contain additional code to communicate
with Flash CS4. While convenient, because they avoid the delay of a download
from http://adobe.com, these files are limited to whatever minor point release
they represent. If the Adobe update utility hasn’t yet updated Flash CS4 on
your computer, these installation files might not let you test everything you’d
like to from within the authoring tool.
The latest installation files are available at http://www.adobe.com/support/flash
player/downloads.html. Older versions are archived at http://www.adobe.com/
go/tn_14266/ for testing purposes. To ensure that installations succeed, Adobe
recommends that you uninstall existing ActiveX controls and/or plug-ins be-
fore re-installing different versions. This can become tedious, so you may want
to consider downloading Flash Switcher, a third party Firefox extension to do
the work for you. Flash Switcher was written by Alessandro Crugnola and is
freely available on his website for Firefox 3 on Windows, Mac, and Linux:
http://www.sephiroth.it/weblog/archives/2008/04/flash_switcher_for_win
dows_osx_and_li.php
Flash Switcher includes the files necessary to test many, but
not all, versions of Flash Player. To make additional versions
available to the extension, install the desired version by hand
from http://www.adobe.com/go/tn_14266/, then select the ex-
tension’s icon from within Firefox and select Save As, as
shown in Figure 2-1.
In addition to installation files, the Release and Debug folders contain a stand-
alone executable: FlashPlayer.exe on Windows and Flash Player.app on Mac.
Flash CS4 uses this executable to create Projectors or view standalone content.
When you select Control→Test Movie, for example, the executable inside the
Release folder displays your SWF file in the authoring tool. When you select
Debug→Debug Movie, the executable inside the Debug folder is used instead.
The parent folder, Players, contains a copy of this executable. This copy is the
one used when you launch a local SWF file outside of the authoring tool, for
example by double-clicking a SWF file from the desktop. You can control
26 | Chapter 2: Discovering What You Need to Work with ActionScript 3.0
which version is used—debug or release—by copying (not moving!) the de-
sired executable from its respective Debug or Release folder into the Players
folder.
Debug versions of Flash Player are capable of logging trace() statement output
to a text file. For more information on this topic, see Chapter 11.
Making Sure Users Have the Necessary Version of Flash Player
Flash CS4 provides a convenient mechanism for ensuring that website visitors
have the version of Flash Player they need in order to view your content. It’s
a simple configuration under File→Publish Settings→HTML, as seen in Fig-
ure2-2.Select“DetectFlashVersion”asshown,andspecifythedesiredversion
numbers—here, 10, 0, and 2—which indicate the minimum version of Flash
Player your content requires. The fourth number, seen in the series 10.0.2.0,
identifies the internal build number, which may run a wide range during pri-
vate Adobe beta testing but is typically 0 for public releases; in any event, the
fourth number is irrelevant for ensuring compatibility in this context.
The first number isn’t editable from the HTML tab of this dialog box, and, in
any case, needs to be 9 or higher to support ActionScript 3.0. If you choose to
Figure 2-1. Adding a version of the Flash Player plug-in to the Flash Switcher Firefox
extension
Flash Player 9 or Higher | 27
publish to older versions of Flash Player, you may change the first number in
the version series by selecting this dialog box’s Flash tab, and then changing
the Version listbox selection to a previous version of Flash Player. Anything
lower than Flash Player 9 will force the Script listbox to change to ActionScript
2.0 or lower.
Version detection requires publishing for Flash Player 4 or
greater.
Employing version detection changes the way the authoring tool writes the
HTML it uses to embed a published SWF file. For that reason, it’s useful to
understand how the HTML is written by default. At the time this book was
being written (before the public release of Flash CS4), the default HTML tem-
plate—that is, no Flash Player version detection—generated an HTML docu-
ment with inline JavaScript (not an external .js file). This JavaScript embedded
the SWF file dynamically, a feature that was necessary for the Internet Explorer
browser between February of 2006 and April of 2008. Without such Java-
Figure 2-2. Detecting Flash Player version in HTML publish settings
28 | Chapter 2: Discovering What You Need to Work with ActionScript 3.0
Another Random Scribd Document
with Unrelated Content
rédigeaient, en donnant surtout des vers de Verlaine, de Moréas, et
de Morice, Léo Trèzenick, l'ancien hydropathe Pierre Infernal,
dessinateur au chapeau breton, devenu imprimeur et directeur de
journal, au Quartier Latin, simultanément comme en province. Il y
avait un dîner intitulé les Têtes de pipes, où allaient certains poètes,
qui donna à Vicaire et Bauclair des sources vagues. Willy y débutait
alors dans un nuage de calembours et de mélancolie, avec un bruit
de sonnette folle, et était la moitié de la direction. Vielé-Griffin y
donnait des vers signé Alric Thom. On n'y trouverait point de vers
libres, mais beaucoup de bonnes choses, connues depuis par
l'impression en volume, pas mal de gaieté et de sarcasme. Tout cela
un peu bousingot, mais ce n'est la faute de personne, si les idées
nouvelles germent dans les cerveaux jeunes, et que la jeunesse est
un peu rive gauche. Lutèce et les Déliquescences sont très rive
gauche, et pour cela fort incomplètes comme document à consulter.
Car enfin, il y a deux rives. Ces jeunes gens ne s'en doutaient pas
trop, et l'un d'eux, Stanislas de Guaïta, a donné la note exacte d'un
certain état d'esprit, quand, après avoir énuméré dans une préface à
un volume de vers, tous les nouveaux poètes existant à sa
connaissance, doutant de son universalité il termina en disant: il y
en a peut-être d'autres, mais je ne les connais pas; en tout cas, ils
ne viennent pas à mon café. Vicaire et Bauclair ne tinrent point ce
langage, n'étant ni naïfs ni occultistes et mages, mais ils agirent
ainsi; et le gai déjeuner de soleil qu'ils servirent à leurs
contemporains aux dépens de quelques poètes, outre qu'il est fané,
paraît incompréhensible, à force de peu parodier les vers connus et
classés du symbolisme. On trouvera dans ce volume une étude sur
Vicaire où j'explique, plus longuement que je ne puis le faire en cette
préface, les pourquois de sa parodie. Les Déliquescences ont eu la
même importance que le Parnassiculet; elles n'ont su ni caractériser,
ni prévoir, et le fait de railler quelques snobs épris, à l'excès, de
nouveauté n'a point d'importance. Ces snobs devenus plus
nombreux, cela forme le public. Tout récemment, M. André Rivoire,
un charmant poète intimiste mais trop académique, dans une étude
sur Albert Samain, un parnassien éclectique qui fit du symbolisme,
disait que notre public avait paru être très nombreux, beaucoup plus
qu'en réalité, qu'en somme il avait été mince. C'est une erreur
profonde. Nous avons eu avec nous, à un certain moment, tous les
curieux du vers, et de plus, nous avons eu tous les curieux de la
littérature qui s'étaient détachés du vers et qui y revenaient pour
nous lire. Nous avons fait une renaissance poétique dans le rythme
et la curiosité sympathique des lettrés nous accompagna. Qu'il fut
facile de rallier, grâce à nos discordes et en lui offrant des
transactions, une partie de ce public bienveillant mais indécis, c'est
possible. Le jeu est connu des traditionnistes qui s'appuient sur une
gloire de tout un passé à laquelle ils n'ajoutent qu'une faible glose,
et dont ils usurpent le rayonnement. Ce sont petites haltes sans
importance et réactions fatales et brèves. La masse est toujours
enchantée de couvrir des transactions qui prennent des nouveautés
ce qu'elles ont de plus simple et se réservent sur le reste; posture
facile, opportunisme toujours opportun! C'est même un bien que ces
réactions. Elles servent plus tard singulièrement à clarifier l'histoire
littéraire.
Il y eut dans ces époques d'incertitude et de développement mental
incertain, sur lesquelles je n'insiste si longtemps que parce qu'elles
ont donné beaucoup plus de résultats que cela n'était alors
généralement prévu et que les écrivains dont je parle se sont
développés sur les mêmes principes qu'ils énonçaient alors, (toute
part faite au progrès), quelques êtres falots, dont le souvenir ne doit
point être banni, au contraire, pas plus que celui des petits
romantiques; ils furent le sourire de nos années de lutte, si on peut
appeler lutte la production paresseuse et tranquille, au milieu de
sarcasmes qui ne nous touchaient point. Parmi ces hommes
aimables je voudrais citer au moins Baju, Anatole Baju qui fut un
brave homme de self-government. En effet, Baju, humble débarqué
de la Creuse lointaine, sous couleur d'éduquer les enfants de la
laïque de Saint-Denis, loua une mansarde rue de la Victoire et non
seulement il y fonda un journal mais il y installa une imprimerie. Ses
directeurs de conscience littéraire furent alternativement, ou tout
ensemble, je ne m'en souviens plus, M. Paterne Berrichon et M.
Maurice Du Plessys; le journal s'appelait le Décadent. Encore qu'il fut
décadent, Baju louchait du côté des Symbolistes. Il pourparla. Peut-
être eûmes-nous tort, M. Jean Moréas, qui se voyait grand, et moi-
même de l'autoriser seulement à reproduire de nous ce que bon lui
semblerait. Baju s'entêta, nous offrit son journal et la rédaction de
La Vogue, écrivit un no
du Décadent. L'idée de Baju, idée juste au
premier chef, était d'être éclectique dans un exclusivisme donné;
nous fûmes trop exclusifs et le Décadent retourna aux Décadents, ce
qui était fort juste, et puis il mourut, car rien n'est éternel. Le
Symboliste, un hebdomadaire à deux sous, que nous avions créé,
Adam, Moréas, Laforgue et moi pour être accessible aux petites
bourses et avec les capitaux (parfaitement) de la maison Tresse et
de la maison Soirat ne vécut que quatre numéros. Un vieux
communard l'imprimait dans les fonds de Vaugirard, pour une
rétribution, je pense, un peu stricte; le Décadent ne survécut guère
au Symboliste. Etéocle et Polynice s'étaient porté des blessures
mortelles, et puis la survie du Décadent n'eut qu'une importance
relative, il était devenu petite revue; c'était bien gros pour Baju; il y
perdait son arome de journal, d'hebdomadaire, ce n'était plus un
léger papier drôlet, où toutes les lettres dansaient. Baju avait un
imprimeur. Il fut étouffé par le luxe, et depuis il eut des succès
politiques; un arrondissement de la Creuse lui donna un jour 2 000
voix, insuffisantes à l'installer parmi nos parlementaires. Il se
pourrait que Baju ait été un boulangiste de marque.
La Vogue était plus sérieuse; elle fut la première revue symboliste,
et si elle mourut jeune, au moins ses collections furent-elles
presqu'immédiatement recherchées. On sentit tout de suite combien
on avait eu tort de l'acheter si peu, et elle donna aux libraires avisés
et à des courtiers teintés de littérature d'assez agréables bénéfices.
Elle eut de la gloire mi-vivante mi-posthume. Pourtant, tout en
contenant de fort belles choses, et notamment les Moralités
légendaires de Jules Laforgue en grande partie, elle était dirigée
avec assez de paresse, et son directeur, c'est-à-dire moi, avait une
tendance excessive à juxtaposer à de la copie purement littéraire des
textes d'érudition qui n'y étaient point absolument nécessaires. Mais
on comptait sur l'avenir, et l'on voulait être complet. La collection de
La Vogue, sur laquelle je n'insisterai point autrement, démontre
pourtant deux choses: d'abord que le fameux dénigrement qu'on
nous reprocha n'était point notre tendance, et que si nous
dénigrâmes nous ne le fîmes que pour notre légitime défense et
après d'injustes attaques, puisqu'on ne saurait trouver dans La
Vogue d'autres articles critiques qu'un article très camarade que je
fis pour l'apparition des Cantilènes de Jean Moréas, en dehors de
ceux très intéressants de Félix Fénéon sur les Impressionnistes.
Pourtant nous avions le papier tout prêt et la plume alerte et l'on ne
nous ménageait pas, mais nous étions fort pacifiques.
Tout récemment, j'eus l'occasion de retracer le passé de La Vogue;
deux jeunes poètes, Tristan Klingsor et Henry Degron, me
demandèrent l'autorisation d'arborer mon vieux titre sur une jeune
revue qui devait se conformer, m'affirmait-on, aux traditions
intransigeantes de l'ancienne Vogue. Je leur donnai une lettre-
préface, on pourrait dire, étant donné l'épigraphe, «Vogue la
Galère», auteur Jules Laforgue, parrain de la revue, des lettres de
marque. Encore une fois, le petit steamer partit, chargé d'espoirs
argonautiques, avec le salut amical de son ancien pilote. Le rôle
grave de préfacier que j'avais assumé fait qu'il manque pourtant
dans ces pages quelques détails que le côté d'apparat de ma
besogne me commandait de passer sous silence. Et, d'abord, je n'y
pouvais faire remarquer combien le titre, il est vrai, heureusement
corrigé par l'épigraphe, était mauvais. C'est l'éloge de La Vogue et
des œuvres qu'elle publia, dans sa première série, qu'on ne pensa
jamais en citant son titre, devenu une sorte de nom propre, à la
vulgarité du mot «vogue» conçu en son sens ordinaire, et à tout ce
qu'il indique de plate poursuite du succès courant, et de course à
quatre pattes vers la vulgarité. Le titre avait été trouvé par M. Léo
d'Orfer, un décadent qui avait fondé cette revue et m'en avait confié
le secrétariat de la rédaction, à cause de sa foi en mon génie et
surtout parce qu'il me considérait très apte, en cas de difficultés
vitales, à assurer la vie de l'organe. M. Léo d'Orfer avait découvert,
c'est trop peu dire, inventé un éditeur, M. Barbou, venu à Paris pour
y acquérir un fonds de papeterie au quartier des écoles. M. d'Orfer,
qui avait la pratique des affaires et le don communicatif du mirage,
transforma avec rapidité, semble-t-il, les ambitions de M. Barbou.
Quand je vis celui-ci, il ne demandait pas mieux que de fonder une
revue et d'éditer tous les livres; il assurait même, à chaque auteur,
qu'il tenait à ses œuvres d'une façon toute espéciale; et comme les
plus belles choses ont le pire destin, au bout de cinq semaines M.
Barbou lâchait pied et repartait à la campagne se refaire une santé.
J'avais dû déjà annoncer à M. d'Orfer que je partirais, que je
démissionnerais, s'il persistait à vouloir publier, à côté de la revue,
un supplément où son intention était de considérer avec indulgence
les productions de l'abonné, ou d'amis dont il jugeait indispensable,
autrement que littérairement, de publier les œuvres. Ce n'était point
que toutes ces pages fussent sans intérêt, mais l'ensemble du choix
ne me paraissait pas cadrer avec mes intentions de revue
intransigeante.
Nous choisîmes donc cette occasion de l'effacement de M. Barbou
pour nous séparer, et je fis reparaître, après trois semaines
d'intervalle qui me parurent opportunes, La Vogue, mieux à mon
image. Ce fut encore un petit épisode de la lutte entre les décadents
et les symbolistes sur le même tremplin.
Mallarmé m'avait dit quand je lui avais conté l'apparition prochaine
de la revue, et son nom: «C'est le dernier titre que je choisirais» je
répondis «et moi donc, mais je pense bien le faire oublier.» nous y
avons réussi.
Ce fut à ce moment que deux excellents écrivains, M. Jean Moréas
et M. Paul Adam, jugèrent que le moment était venu de saisir le
monde par la voix des quotidiens de la nouvelle bonne nouvelle
littéraire. Les tendances nouvelles se vulgarisaient, il se formait des
groupes et des sous-groupes, malgré qu'il y eut des individualités
suffisantes; donc MM. Jean Moréas et Paul Adam s'en furent trouver,
au Figaro, M. Marcade et obtinrent l'insertion d'un manifeste
littéraire quelque peu égoïste, où ils dépeignaient le mouvement
symboliste à leurs couleurs, en assumaient, de leur propre mandat,
la tâche et tentaient de se constituer chefs d'école. On leur en
adressa de justes reproches, et puis l'on en sourit. On se rendit
compte que si M. Marcade avait voulu considérer en MM. Moréas et
Adam les chefs de l'école symboliste, c'était pour cette raison seule,
qu'ignorant tout à fait du symbolisme, comme de toute autre
matière littéraire, il en était réduit à se fier aux lumières des
personnes qui prenaient la peine de l'aller voir. Il faut dire aussi que
M. Marcade était sourd comme une cave, et qu'il n'eut même de M.
Paul Adam, qu'une idée purement visuelle. Seul M. Moréas, dont la
voix contenait des tonnerres, put faire parvenir à l'entendement de
M. Marcade quelques propos esthétiques. M. Marcade, bon vieillard,
portait, il est vrai, tout près de la bouche de son interlocuteur, sa
conque auditive, mais pour utiliser cet accueil amène, une voix de
stentor était au moins nécessaire.
Le lendemain de la publication de ce manifeste M. Paul Adam dit à
M. Jean Moréas «On va vous traiter de Daudet» et M. Moréas assura
que cela lui était égal; pour l'intelligence de ce propos on se
souviendra que Daudet, le plus faible et le moins inventeur des
écrivains naturalistes, fut celui qui força le premier le succès, avec
Fromont jeune, et plut aux masses en vulgarisant la formule
naturaliste. Néanmoins, on ne tint pas longtemps rigueur à ces
Messieurs de l'extension de pouvoirs qu'ils s'étaient offerts, ou de
l'initiative abusive et usurpatrice qu'ils avaient prise. En tout cas, j'y
demeurais fort indifférent; s'ils avaient le Figaro, n'avais-je pas La
Vogue, et sachant à quoi s'en tenir, on continuait à marcher
ensemble, la jeunesse cordiale étant chez tous (encore que M.
Moréas nous devança tous d'un bon lustre), trop forte pour qu'on
s'arrêtât longtemps à des misères de publicité.
Jules Laforgue était alors à Berlin, ou aux villes d'eaux d'Allemagne,
lecteur de l'impératrice Augusta. Cette place lui avait été assurée par
les soins de ce sans-patrie de Paul Bourget, chargé par M. Amédée
Pigeon, lecteur précédent, de pourvoir à son remplacement. M.
Pigeon ayant appris par la voie du Figaro qu'un petit héritage lui
incombait, voulait incontinent retrouver ses loisirs et ses travaux de
critique d'art. Il fallait un jeune homme aimable et doux, capable de
ne point s'occuper de politique. M. Bourget pensa avec raison que la
pitié universelle de Laforgue pourrait être assez forte pour s'exercer
au moins quelques années au profit des pauvres puissants de ce
monde, et connaissant l'urbanité exquise de Jules Laforgue, il le fit
choisir; c'était d'Allemagne que m'arrivait sur papier bleu criblé de
pattes d'abeilles traînées dans l'encre rouge, la copie de Laforgue;
sauf vacances.
M. Moréas était déjà, depuis plusieurs années, un poète intéressant
et élégant. Après avoir fait de bons vers réguliers, il pratiquait le vers
libéré, abondait en curiosités rhythmiques, intercalait des poëmes en
prose dans des romans réalistes sans considérable portée, et après
les Cantilènes, où figuraient des assonnances d'après les chansons
populaires, recherchait une sorte de vers libre. Son défaut était de
tenir extrêmement peu à l'originalité de ses idées; personne ne
pratiqua aussi fort le fameux: «Je prends mon bien où je le trouve»,
sans avoir l'excuse de Molière, qui, lorsqu'il disait cela, à propos
d'une scène du Pédant joué, faisait allusion à une vieille
collaboration avec Cyrano, et en effet reprenait une scène ébauchée
jadis par lui; c'était de la reprise individuelle. Mais M. Moréas croyant
peu à l'idée, et féru de la forme, l'entendait dans un autre sens;
outre que ses vers faisaient montre souvent de connaissances
étendues, il ne dédaignait pas d'intercaler dans ses œuvres en
grande proportion des traductions, ou, selon son expression, des
paraphrases. Il y réussissait fort bien. De là une antinomie avec les
autres promoteurs du symbolisme, qu'il résolut en s'en détachant
lorsqu'il fonda l'Ecole romane, remettant, en somme, lui-même les
choses en place. M. Moréas, alors, avait, parmi ses défauts, dont le
moindre était de vouloir étendre son importance au-delà du vrai
devant les journalistes (nous pensions que c'était aussi un défaut de
se soucier des journalistes) une belle qualité, soit un très sincère
amour de l'art, qui ne l'a pas quitté, et s'il s'en fait une conception
un peu étroite, c'est bien son affaire.
M. Paul Adam nous arrivait du naturalisme, il avait subi une de ces
condamnations pour liberté d'écrire, fort bien portées depuis
Baudelaire et Flaubert. Il ne s'en faisait pas trop gloire, et ne se
targuait pas de Chair molle. Il était aimable et dandy. Un grand
lévrier rhumatisant suivait ses pas; l'esthétique de Paul Adam était
alors assez confuse, ainsi que ses rêves politiques, littéraires,
industriels, dramatiques, brummellesques. Il travaillait beaucoup et
avait une peine infinie à tirer un parti pratique d'une production
acharnée. Il y avait, dans ses efforts, de l'inquiétude et du disparate,
mais il était déjà plein de talent, encore qu'il n'en fît pas toujours le
meilleur usage et qu'il ne contrôlât pas assez l'intérêt de son effort; il
était mage et reporter de tempérament, historien en plus, fantaisiste
follement et ces quatre courants d'idées n'étaient point sans falotes
synthèses. Sa perpétuelle chimère, analogue aux rêveries de Balzac,
était souvent distrayante. Un bel amour de l'art le tenait comme
nous tous et contribuait à resserrer les liens d'amitié avec lui.
C'était Félix Fénéon qui assurait la bonne périodicité de la revue; très
dévoué aux poètes, il corrigeait les épreuves, méticuleusement,
artistement. Ce fut grâce à lui que nous fûmes réguliers; les articles
de critique d'art qu'il nous donna font regretter qu'il s'abstienne
depuis longtemps d'écrire.
La Vogue avait été une revue de combats et malgré qu'on n'ait pas
songé à prendre de temps d'une exposition de théories, une revue
théorique, au moins par les exemples. Ces revues, purement
littéraires, ne durent pas. La mienne eut trente et un numéros, et
puis s'arrêta. Il y eut une seconde série, encore plus brève, en 1889.
La Vogue avait fait le départ entre les symbolistes et les décadents.
Elle avait reçu des adhésions et des sympathies multiples, entre
autres hors frontières celle d'Emile Verhaeren, alors le poète des
beaux alexandrins des Flamandes et des Flambeaux noirs. Elle ne
faisait que camarader avec des esprits distingués, mais autrement
orientés, comme M. Charles Morice dont un bon livre de critique
(sauf divergences) présenta un bon tableau de la littérature de cette
heure. Laurent Tailhade n'y écrivit pas, parce qu'absent en longue
villégiature durant ce semestre et demi que la revue vécut. Maurice
Barrès, alors rédacteur au Voltaire, préparait ses livrets et ses
préoccupations n'étaient pas identiques aux nôtres; le côté art pur
de notre revue l'effarait un peu et nous nous étonnions de ses désirs
multiples; nous eûmes aussi des ennemis, je ne m'arrête pas à
énumérer des chroniqueurs, c'est à peu près les mêmes que
maintenant; mais parmi les poètes, de ceux qu'on rencontrait chez
Mallarmé, nous soulevâmes un adversaire, M. René Ghil.
M. René Ghil se partageait alors entre le sonnet, l'esthétique et
l'épopée. Ses sonnets, il y en a de pires, son épopée, je n'en parle
pas, parce que si je ne l'aime pas ce n'est pas une raison pour en
dégoûter les autres, et aussi parce que je n'y attache point une
extrême importance. Son esthétique c'était l'instrumentation colorée
ou l'instrumentation verbale, un commentaire extraordinaire du
sonnet des voyelles d'Arthur Rimbaud, une adaptation d'Helmholtz,
téméraire héroïque. M. René Ghil était d'une parfaite bonne foi, et
l'allure du symbolisme, en ce manifeste de M. Moréas et de M.
Adam, et dans La Vogue, lui parut attentatoire; il voulut avoir sa
tribune, et fonda, avec M. d'Orfer, la Renaissance, ainsi nommée, je
pense, à cause des similitudes que M. Ghil a de tout temps
reconnues entre lui et Guillaume-Salluste Du Bartas. De là, il fulmina
contre tous l'excommunication majeure, puis la Renaissance ayant
été éphémère parmi les éphémères, il fonda les Ecrits pour l'art, où
l'on se publiait entre amis, œuvres et portraits. M. de Régnier et M.
Vielé-Griffin y parvinrent pour la première fois, de façon publique à
l'héliogravure.
Le mot symbolisme avait pris dès lors sa carrure et son sens. Ce
n'était pas qu'il fut très précis, mais il est bien difficile de trouver un
mot qui caractérise bien des efforts différents, et symbolisme valait à
tout prendre, romantisme. Paul Adam proposait d'écrire un dogme
dans le symbole; le mot dogme répugnait à des tempéraments
plutôt anarchistes et critiques comme le mien; c'était Mallarmé qui
avait surtout parlé du symbole, y voyant un équivalent au mot
synthèse et concevant que le symbole était une synthèse vivante et
ornée, sans commentaires critiques. L'union entre les symbolistes,
outre un indéniable amour de l'art, et une tendresse commune pour
les méconnus de l'heure précédente, était surtout faite par un
ensemble de négations des habitudes antérieures. Se refuser à
l'anecdote lyrique et romanesque, se refuser à écrire à ce va-
comme-je-te-pousse, sous prétexte d'appropriation à l'ignorance du
lecteur, rejeter l'art fermé des Parnassiens, le culte d'Hugo poussé au
fétichisme, protester contre la platitude des petits naturalistes,
retirer le roman du commérage et du document trop facile, renoncer
à de petites analyses pour tenter des synthèses, tenir compte de
l'apport étranger quand il était comme celui des grands Russes ou
des Scandinaves, révélateur, tels étaient les points communs. Ce qui
se détache nettement comme résultat tangible de l'année 1886, ce
fut l'instauration du vers libre. Elle est présentée très judicieusement
et très exactement par M. Albert Mockel dans ses Propos de
littérature, et trop bien pour que je n'y renvoie pas le lecteur.
Ce fut au début de la publication de La Vogue que j'allais voir Paul
Verlaine. Si Verlaine eût été en France, avant 1880, alors qu'il était
parfaitement méconnu, nul doute que je n'eusse cherché à lui
témoigner mon admiration, parmi celles peu nombreuses qu'il
comptait. Mais, à mon retour en France, il était en pleine gloire. Il ne
m'attirait pas d'ailleurs aussi complètement que Mallarmé; on
pouvait penser que le meilleur et même tout de lui était dans ses
livres. Quoiqu'il en soit, j'attendis une occasion et ce fut pour lui
demander sa collaboration à La Vogue que je l'allai voir.
C'était Cour Saint-François, presque Cour des Miracles. Sous le
tonnerre intermittent du chemin de fer de Vincennes, à côté des
boutiques aux devantures à plein cintre, une petite impasse; un
chantier de bois appuyait contre le viaduc de longs madriers et des
échafaudages savants de poutres équarries décorait l'horizon d'une
petite boutique de marchands de vins, où je trouvais Verlaine
uniment placé devant un verre; il m'en offrit la rime, car sa
plaisanterie était demeurée banvillesque. Il voulut bien me dire, en
exagérant amicalement, qu'il connaissait ma jeune réputation, et à
ma demande de copie, il répondit par des phrases modestes;
pourtant il constata que c'était là une consécration, et que c'était la
récompense de la vie, au début d'une vieillesse infirme, de
s'entendre dire par des jeunes hommes qu'on avait bien fait, et
qu'on pouvait être revendiqué par eux, en tant qu'exemple
quoiqu'indigne, et presque traité de dieu, comme un ancêtre. Je
voulus lui spécifier ce que j'attendais de lui, c'était une suite à ses
Poëtes maudits que je savais en train. Verlaine, d'abord, rompit les
chiens, biaisa, me parla de Mallarmé dont il me savait le fidèle, me
récita des vers de Mallarmé avec de curieuses intonations
grandiloquentes, et nous esthétisâmes pour le plaisir d'esthétiser, et
de se trouver des points communs. Il me raconta son retour à Paris,
et puis ses chagrins, une partie au moins; là dessus un petit
bonhomme, un gosse passait, fin et svelte, grêle même. Verlaine
l'appela, lui donna un sou pour en user avec magnificence, me dit:
j'en ai fait un Pierrot, et récita une courte pièce fort jolie; craignant
d'avoir paru trop homme de lettres, et soucieux d'offrir la réciprocité,
comme excuse, il s'informa de mes derniers vers, mais je le
ramenais à notre sujet qui était lui, et ce qu'il voudrait bien donner à
La Vogue. Verlaine me parla de son portrait de Desbordes Valmore,
et alla quérir non point son article, mais les œuvres de Desbordes
Valmore, mit son lorgnon, leva la tête et, paraissant lire par dessus
son lorgnon, droit à l'orifice de son corridor, dans une vieille
redingote bleue qui avait des aspects de lévite, il me lut en pleurant
quelques beaux poèmes. Cette affaire conclue et des vers promis,
une lettre donnée pour prendre chez Vanier le manuscrit de l'article,
je pris congé, trop tôt à mon gré et ne songeais qu'au dernier
moment à assurer Verlaine d'une infime rétribution, unique dans les
habitudes de la Revue; il n'y avait pas pensé, et m'affirma qu'il n'en
touchait pas d'habitude de supérieure.
Je le revis souvent Cour Saint-François. Dans ce pittoresque quartier
populaire, il s'était créé une vie, il contait ses joies matinales à aller
clopin-clopant chercher ses journaux place de la Bastille, et assister
au chassé-croisé, alors déjà considérable, des omnibus, au passage
ouvrier du faubourg Saint-Antoine. Il m'expliqua un jour, et je
regrette de ne m'en point souvenir exactement, le plan d'un Louis
XVII. Il n'était point tous les jours d'humeur égale et je déclinai de
publier des pamphlets très courts et très vifs qu'il eut aimé décocher
à qui de droit, c'est-à-dire à Mme
Verlaine. Il me conta beaucoup de
ce qu'il a écrit dans les Confessions (je sais bien que je ne suis pas
le seul à avoir recueilli ces confidences) mais avec un brio, un relief
que je n'ai pas retrouvé dans son livre, notamment une promenade
au matin dans Paris insurgé, et une lecture de la proclamation du
gouvernement de la Commune, à son gré si belle, si fière et tout
émanée d'anonymes, ce qui en rehaussait la valeur. Il avait
rencontré ces jours-là Goncourt en garde national (ça lui paraissait
très drôle). Nous étions compatriotes, étant tous deux nés à Metz,
lui par accident; car son père était capitaine du génie qui avait alors
comme garnisons Arras, Metz et Montpellier, en sorte que Paul
Verlaine eut pu naître félibre; son vrai pays était l'Ardenne.
Il se rappelait fort bien impressions d'enfance, assez identiques aux
miennes (la ville de province change si peu) de l'Esplanade, dont,
hasard amusant, c'est Gérard de Nerval qui parla le premier dans la
littérature, de l'Esplanade, superbe terrasse sur la plus jolie vallée,
actuellement si bouleversée, hérissée de forts et de glacis, sur les
ossuaires de 1870, qu'un Messin ne saurait retrouver après tant de
terrassements une seule des mottes de terre qu'il a jadis foulées, et
qu'il y a suppression totale de la petite patrie pour lui. Nous
causâmes des rues silencieuses où poussait l'herbe près de l'Evêché,
et des gens qui eurent comme nous le sort de naître dans cette ville;
l'idée que Pilatre des Roziers, l'aéronaute, fut notre compatriote, lui
fut agréable, mais le voisinage futur dans le Bouillet avec Ambroise
Thomas le laissa plus froid.
C'est Nancy qui a assumé la tâche de remplacer Metz et d'en
recueillir les nationaux illustres. Nous fûmes, de ce chef, un certain
nombre réunis un jour chez M. Poincaré, sous la présidence de M.
André Theuriet, de l'Académie française; il s'agissait d'avoir des idées
et de dresser vite les bustes de Goncourt et celui de Verlaine dans ce
beau jardin de la Pépinière, encore que ces hommes de valeur
n'avaient point paré l'Académie de leur reflet plus radieux que celui
des palmes vertes. M. Roger Marx avait acquis le concours de
Carrière pour un buste de Verlaine qui eut été digne du beau portrait
qu'il a peint. Mais dans cette ville, livrée aux plus basses menées
nationalistes et à un dégoûtant antisémitisme, on n'a pas le temps
de fêter des artistes.
Je fis part à Verlaine de mon intention de publier dans La Vogue des
œuvres de Rimbaud autres que celles qui figuraient dans les Pactes
Maudits, et supérieures aux Premières Communions que le premier
numéro de La Vogue avait données d'après une copie. Il s'agissait de
retrouver le manuscrit des Illuminations. Verlaine l'avait prêté pour
qu'il circulât, et il circulait. Au dire de Verlaine, ce devait être dans
les environs de Le Cardonnel qu'on pouvait trouver une piste
sérieuse; c'était vague; heureusement Fénéon, consulté par moi, se
souvint que le manuscrit avait été aux mains de M. Zénon Fiére,
poète et son collègue aux bureaux de la guerre dont Fénéon faisait
alors un petit musée impressionniste et un bureau d'esprit à parois
vertes, avant qu'il en fît un arsenal, comme assermenté, des
anarchistes. Entre temps Fénéon apprenait à tous ses confrères,
comme lui commis au bon ordre du recrutement, à trousser
cordialement le sonnet, et ce n'est pas une idée sans valeur que
d'avoir voulu rendre le sonnet corporatif et bureaucratique. Fénéon
apprit de M. Zénon Fiére que le manuscrit était entre les mains de
son frère, le poète Louis Fiére; nous l'eûmes le soir même, le lûmes,
le classâmes et le publiâmes avec empressement. Verlaine fit une
petite préface, pour le tirage à part, étant le seul ayant droit, et ce
fut parce qu'il ne se dépêcha point à en écrire une pour la Saison en
enfer que le tirage à part, préparé, n'en fut point fait; les
Illuminations, sous leur forme de brochure, après qu'un service
assez copieux en eût été fait, n'eurent de quelques semaines qu'un
seul acheteur; ce fut M. Paul Bourget, à ce que m'apprit le
dépositaire, M. Stock.
Concurremment à la publication de La Vogue ou un peu après,
diverses plaquettes paraissaient dont le but était de répondre à des
attaques de juges sévères, ou de fournir quelques explications, car il
arrivait que nous en sentions l'opportunité. Ces cahiers parurent
pour la plupart chez Léon Vanier, alors le grand éditeur des
symbolistes, des décadents, avec Verlaine en étoile sur son
catalogue. Ainsi fut donné l'Art symboliste de Georges Vanor qui
contient des renseignements techniques sur l'esthétique symboliste.
Le brillant conférencier était alors un aède jeune et enthousiaste,
très intelligent et son petit bouquin, qui demeurera une pièce
curieuse, eût été parfait, s'il n'avait jugé nécessaire de couronner le
livre par une glose à lui spéciale du symbolisme qu'il désirait
chrétien. Cette vue a un peu contribué, ainsi que certaines des
théories d'antan de Paul Adam, à entacher le symbolisme, pour
certains, de mysticisme occultiste. Mystiques, nous l'étions dans un
certain sens, par notre poursuite de l'inconnaissable et de la nuance
imprécise; occultistes non pas, au moins ni M. Jean Moréas ni moi.
Mais de même que pour le gros public les décadents, les auteurs
difficiles, c'était tout un énorme groupe, un peuple d'écrivains qui
englobait Goncourt, Villiers de l'Isle-Adam, Poictevin, Rosny, tous les
discutés, tous les méconnus, tous les passionnés d'écriture artiste,
ou plutôt d'écriture expressive et de forme nouvelle, les occultistes,
les symbolistes, les anarchistes aussi ce fut, pour ce même public,
une masse en marche. La foule apercevait un brouillard bariolé, avec
des lueurs indécises de fanal au-dessus d'une marche naturellement
un peu cahotante, et voyait passer sa génération montante, comme
dit Rosny, en groupes voisins, mêlés par des conversations
engagées, plus indistincts à des haltes où on confrontait des idées et
où l'on discutait ensemble, plus confus de la présence
d'indépendants égaillés au long des groupes. Longtemps nous ne
pûmes espérer prouver à un critique que nous n'étions pas des
Rose-Croix; on nous objectait que les Rose-Croix se déclaraient
symbolistes, que Péladan c'était presque Paul Adam. Il fallait
expliquer qu'il y avait symbole et symbole, symbole religieux,
symbole pour Rose-Croix, symbole pour symboliste, variété de
symboles pour chaque symboliste; le critique hagard reculait, et s'en
allait répétant: les symbolistes sont des occultistes; plus tard, en
1895, lorsque parut mon livre La Pluie et le beau Temps
qu'épigraphiait une belle phrase de La Mettrie, le matérialiste pur,
dont j'aimai fixer le nom sur un de mes livres, des interviewers qui,
justement, venaient d'être chargés de savoir si la littérature était
mystique, religieuse ou pas, vinrent me voir; et quoique je leur en ai
dit, quoique je leur ai fait remarquer le nom de La Mettrie, et que j'ai
cru devoir leur expliquer à peu près ce qu'il avait été, rentrés à leur
journal ils se recueillirent, et conclurent que, plein de mysticisme
religieux, je le prouvai en parant ma couverture d'une phrase de La
Mettrie, éminemment religieuse et occultiste. Tant le préjugé a de
force et roule l'évidence comme paille dans le torrent.
A un autre temps, nous fûmes d'un bloc, des anarchistes; on le crut
de tous, sans nuance, avec une égale fermeté, avec cette certitude
infrangible qui caractérise les reporters. Après l'acte de Vaillant, un
journal boulevardier, celui qui règne sur les élégances, le Gaulois,
crut bon de réunir dans sa salle des dépêches les portraits des
anarchistes intellectuels.
Une des lumières du journal, j'aime à le croire, fut détachée chez
Vanier, à cette fin d'y prendre et d'en rapporter une collection des
Hommes d'Aujourd'hui, intéressante publication hebdomadaire où
Verlaine écrivit passablement, qui donnait des biographies et des
portraits-charges des hommes du jour, avec plus ou moins de
précision et de certitude; l'antichambre publique du Gaulois offrit
plusieurs jours à la foule, à côté des images de Laurent Tailhade et
de moi, pour lesquels cette attribution d'idées était juste, celle, par
exemple, de M. Jean Moréas, qui je pense n'énonça jamais la
moindre opinion politique, et s'éloigne de toute question sociale de
toute la vitesse de sa trirème. Ceci dit, pour réduire à ses
proportions exactes la responsabilité de Georges Vanor dans la
comédie des erreurs qui se joua toujours, en ces temps lointains, à
propos de nous.
Le Glossaire de Plowert, petit dictionnaire à l'usage des gens du
monde, moins curieux à certains égards, le fut beaucoup plus à
d'autres. Plowert est le nom d'un manchot qui évolue non sans grâce
dans un roman de Moréas et Paul Adam, de leur plus vieille manière.
Il parut piquant sans doute à Paul Adam de mettre le nom d'un
héros à un seul bras, sur la couverture d'un petit volume qui allait
être écrit par une demi-douzaine de dextres, car Paul Adam
n'entendait pas se risquer à donner des néologismes de ses
collègues, des interprétations hasardées et éloignées de la plus
exacte précision. Il avait la connaissance des bonnes méthodes
érudites et aussi des habitudes du journalisme (il y fut toujours
expert), il résolut donc d'avoir recours à l'interview, et de nous
demander à chacun le choix de nos mots nouveaux, mais point de
cette façon verbale de l'interview ordinaire qui laisse tomber des
détails, mais de façon scripturaire et, pour ainsi dire, ferme.
L'idée de ce glossaire avait été engendrée chez Paul Adam par une
commande à moi faite. Un jeune éditeur, M. Dupret, qui, après avoir
mis au jour quelques plaquettes curieuses, s'alla retremper dans un
fructueux commerce de bois, avait reçu de moi l'offre d'une sorte de
grammaire française, avec rhythmique, projet que je reprendrai
quelque jour de loisir un peu large. Comme il n'éditait résolument
que de petites plaquettes in-32, M. Dupret me proposa d'en éditer
les derniers chapitres (nous raisonnions sur plan) ceux qui auraient
trait à l'époque que nous traversions, c'eût été une petite grammaire
et rhythmique symboliste. Mon indolence était alors assez grande
pour qu'il n'existât, de longtemps, de ce petit livre, qu'un schéma
détaillé. J'avais conté le fait de la prochaine éclosion de ce livre à
mes camarades, et par conséquent à Paul Adam.
Le lendemain, Adam vint nous trouver, quelques-uns, dans un café
du boulevard d'où nous aimions voir s'écouler les passants de
l'heure; on vit bien à son approche qu'il s'était passé quelque chose;
le paletot mastic de notre ami, paletot alors célèbre, flottait avec des
plis d'étendard. Sur la hampe de cet étendard son chapeau avait une
inclinaison martiale comme s'il se fût douté de la victoire d'Uhde.
Notre ami abordait avec des performances de galion. Il s'assit et
tous ses gestes éclatèrent en munificence. Il nous confia alors que
Vanier, consulté par lui sur l'opportunité d'un petit dictionnaire de
nos néologismes, complément plus qu'indispensable de mon futur
travail, avait adhéré avec empressement à ses projets, et qu'un fort
lexique allait naître. Il demandait notre concours avec une face
rayonnante, et il eût été criminel d'adresser des objections à un ami
aussi heureux. Plowert naquit et besogna dare-dare.
Nous n'attachâmes pas à son œuvre assez d'importance. A le faire, il
eût fallu fondre nos projets et donner, d'un coup, importants, cette
grammaire et ce dictionnaire des symbolistes qui eussent été des
documents curieux, et qui auraient été fort utiles. Nous érigions ainsi
notre monument en face celui qu'élaborent sans cesse les doctes
ralentisseurs du Verbe qui s'évertuent à l'Académie. Tel qu'il est et
malgré l'abondance de ses fautes d'impression le petit volume, qui
ne contient que nos néologismes alors parus, qui n'est qu'un petit
répertoire, offre cet intérêt, qu'en le parcourant on pourra voir que
tous nos postulats d'alors ont été accueillis, et sont entrés dans le
courant de la langue et ne dérangent plus que de très périmés
dilettantes.
L'automne de 1886, j'allais prendre, au débarqué de l'Orient-Express,
Jules Laforgue qui revenait d'Allemagne, décidé à n'y point
retourner; il se mariait et essayait de vivre à Paris de sa plume. Par
un abandon de ses droits à de petites sœurs très cadettes, Laforgue
se trouvait sans fortune aucune, et il n'avait aucune espèce
d'économies. Quelques fonds que lui prêtèrent les siens lui
fournirent juste de quoi s'installer. Sa santé, assez faible, avait
souffert d'un voyage d'hiver en Angleterre, où il était allé se marier,
et d'un retour brusque dans un appartement pas préparé en plein
froid décembre. Sauf quelques articles au supplément du Figaro, à la
Gazette des Beaux-Arts, une chronique mensuelle à la Revue
Indépendante, maigrement payée et sans fixité dans les dates, il
n'avait rien. La librairie ne voulait point de ses Moralités légendaires,
malgré mes conseils il ajournait la publication de ses Fleurs de
bonne volonté (que j'ai publiées dans l'année 1888 de la Revue
Indépendante); ce livre d'ailleurs ne lui eût rien rapporté
pratiquement. Laforgue ne trouva pas, dans Paris, trois cent
cinquante francs pour ses Moralités légendaires, et ce fut bientôt la
misère entière à deux, sans remède, sans amis, qui fussent en
mesure de l'aider efficacement. C'était la détresse fière et décente,
le ménage soutenu par la vente lente d'albums, de collections, de
bouquins rares, et puis la maladie aggravée. Il était à peu près
certain d'obtenir un poste suffisamment rétribué dans un pays
chaud, en Algérie ou en Egypte (il ne pouvait s'agir pour lui de
passer un nouvel hiver à Paris, M. Charles Ephrussi et M. Paul
Bourget s'étaient employés à le lui épargner), lorsque la mort arriva,
une nuit, soudaine, Mme
Laforgue, au réveil, trouvait son mari mort à
coté d'elle.
Ah! le funèbre enterrement! dans un jour saumâtre, fumeux, un
matin jaunâtre et moite; enterrement simple, sans aucune tenture à
la porte, hâtivement parti à huit heures, sans attendre un instant
quelque ami retardataire, et nous étions si peu derrière ce cercueil:
Emile Laforgue, son frère, Th. Ysaye le pianiste, quelques parents
lointains fixés à Paris, dans une voiture, avec Mme
Jules Laforgue;
Paul Bourget, Fénéon, Moréas, Adam et moi; et la montée lente,
lente à travers la rue des Plantes, à travers les quartiers sales, de
misère, d'incurie et de nonchalance, où le crime social suait à toutes
les fenêtres pavoisées de linge sale, aux devantures sang de bœuf,
rues fermées, muettes, obscures, sans intelligence, la ville telle que
la rejette sur ses barrières les quartiers de luxe, sourds et égoïstes;
on avait dépassé si vite ces quartiers de couvents égoïstes et clos où
quelques baguettes dépouillées de branches accentuent ces
tristesses de dimanche et d'automne qu'il avait dites dans ses
Complaintes et, parmi le demi-silence, nous arrivons à ce cimetière
de Bagneux, alors neuf, plus sinistre encore d'être vide, avec des
morts comme sous des plates-bandes de croix de bois, concessions
provisoires, comme dit bêtement le langage officiel, et sur la tombe
fraîche, avec l'empressement, auprès du convoi, du menuisier à qui
on a commandé la croix de bois, et qui s'informe si c'est bien son
client qui passe, avec trop de mots dits trop haut, on voit, du fiacre,
Mme
Laforgue, riant d'un gloussement déchirant et sans pleurs, et,
sur cet effondrement de deux vies, personne de nous ne pensait à
de la rhétorique tumulaire.
La mort de Laforgue était, pour les lettres, irréparable; il emportait la
grâce de notre mouvement, une nuance d'esprit varié, humain et
philosophique; une place est demeurée vide parmi nous. C'était le
pauvre Yorik qui avait eu un si joli sourire, le pauvre Yorik qui avait
professé la sagesse à Wittemberg, et en avait fait la comparaison la
plus sérieuse avec la folie; c'était un musicien du grand tout, un
passereau tout transpercé d'infini qui s'en allait, et qu'on blotissait
dans une glaise froide et collante—la plus pauvre mort de grand
artiste, et le destin y eut une part hostile, qui ne laisse vivre les plus
délicats que s'ils paient à la société la rançon d'un emploi qui les
rend semblables à tous, connaissant le bien et le mal à la façon d'un
comptable, et ne leur jette pas, des mille fenêtres indifférentes à
l'art, de la presse, un sou pour subsister pauvrement et fièrement,
en restant des artistes—à moins qu'une robustesse sans tare
morbide ne leur permette de franchir, en les descendant et en les
remontant ensuite, tous les cycles de l'enfer social.
La Revue Indépendante qu'avaient dirigée en 1884 Félix Fénéon et
M. Chevrier dans un sens très intelligemment naturaliste, avait laissé
de brillants souvenirs, et des personnes songeaient à la ressusciter.
M. Dujardin, écrivain des plus médiocres et qui pensait faire une
affaire du symbolisme et des symbolistes, ancien directeur de la
Revue Wagnérienne, entreprit de la refonder avec MM. Félix Fénéon
et Téodor de Wyzewa comme inspirateurs et rédacteurs en chef.
Félix Fénéon s'étant presque immédiatement retiré, M. de Wyzewa
en demeura le principal moteur et y appliqua ses idées qui
consistaient à y faire écrire des écrivains déjà nantis du succès, mais
pas encore accueillis par le triomphe. On y voulait servir cette idée
du bourgeois lettré que nous indiquions plus haut, que le
Mouvement nouveau comprenait Goncourt et Verlaine et Mallarmé,
et M. Anatole France, et M. Robert de Bonnières, et M. Octave
Mirbeau, en somme ceux que le journalisme littéraire ne mettait pas
en première ligne. Il y avait d'ailleurs, à cette époque, un groupe de
romanciers psychologues qu'on réunissait dans une sorte de
communion intellectuelle, Bourget, Bonnières, Hervieu, Mirbeau, il y
avait Huysmans un peu à part, Becque très à part, dont l'heure allait
approximativement sonner avec les débuts d'Antoine. M. Anatole
France n'avait pas encore pris tout son développement ni toute
l'ampleur de sérénité qui ont mis si haut son génie ardent et calme.
C'était l'auteur gracieux de Sylvestre Bonnard, et le critique littéraire,
le meilleur d'un temps où ils ne furent pas extraordinaires; on peut
penser sans injustice que chez M. Anatole France, le critique des
faits, l'historien de la vie contemporaine, selon la belle méthode
neuve qu'il s'est instaurée et l'écrivain original sont plus importants
que le critique littéraire. Il était englobé dans cette conception de
revue, à côté des précurseurs du symbolisme, déjà connus au moins
de nom du grand public, Mallarmé et Verlaine, et que Villiers de
l'Isle-Adam, qu'admettaient ou plutôt qu'admiraient tous les
novateurs. Laforgue y avait sa place, et moi aussi, mais on entendait
ne pas effaroucher le public et ne pas montrer trop tôt les
symbolistes, et donner d'eux comme des échantillons importants
avant de proclamer toute la sympathie qu'on disait savoir pour nous.
Pour des raisons diverses M. Dujardin m'offrit la rédaction en chef de
sa revue qui devint dès lors plus nette et plus progressiste et
accepta tout le symbolisme en tenant compte, ainsi qu'il me
paraissait nécessaire, des efforts intéressants de romanciers comme
les Rosny. La revue qui marchait fort bien littérairement périt de la
gestion plus que chimérique de son directeur et administrateur, ou
du moins passa chez le libraire Savine aux mains de M. de Nion qui
en fit la revue des néo-naturalistes, et elle ne fit plus que décliner,
passant de mains en mains, sans retrouver un instant l'importance
que j'avais pu lui donner en 1888.
Le symbolisme avait alors acquis sa pleine importance, car il n'était
plus représenté seulement par ses promoteurs, il avait reçu des
adhésions précieuses. C'était Francis Vielé-Griffin et Henri de
Régnier, sortis avec éclat des premiers tâtonnements, apportant l'un
des visions élégantes et hiératiques, l'autre un sentiment très vif de
la nature, une sorte de lakisme curieux de folk-lore, avec une liberté
encore hésitante du rhythme, mais une décision complète sur cette
liberté rythmique. Albert Mockel qui donnait sa jolie Chantefable, et
Ajalbert, Albert Saint-Paul Adolphe, Retté; il y eut beaucoup de
symbolistes, et puis plus encore, et un instant tous les poètes furent
symbolistes.
C'est alors que chacun tira de son coté, dégageant son originalité
propre, complétant les données premières du premier groupe, dont
les demeurants Moréas, Adam et moi, eurent à développer et à faire
prévaloir chacun sa manière propre; les divergences, qu'on ne s'était
jamais tues, mais qui ne pouvaient éclater lors des premières luttes
contre des adversaires communs, devenaient nécessairement plus
visibles puisque nous avions des idéaux différents. Moréas, d'esprit
classique, redevenait classique, Adam reprenait, après une course
dans la politique, ses ambitions balzaciennes. Ma façon particulière
de comprendre le symbolisme avait ses partisans; bref, nous
entrions dans l'histoire littéraire: les prémisses posées allaient
donner leurs effets, des surgeons vivaces allaient se projeter, des
originalités curieuses s'affirmer à côté de nous, Maurice Maeterlinck,
Charles Von Lerberghe, Remy de Gourmont, etc. Ce serait dépasser
le sujet de ces notes que de décrire tout le mouvement de 1889 et
des années suivantes, encore que certains articles réunis dans ce
volume présenteront là-dessus ce que, comme critique, j'en ai pu
penser.
Un mot encore.
M. Henri de Régnier écrivait récemment dans un article que j'étais
demeuré à peu près le seul symboliste, presque tous ceux qui furent
du premier ou du second ban du symbolisme ayant varié, sur une
foule de points, leur façon de voir. C'est leur affaire, et je n'y ai rien
à voir qu'à constater, lorsque l'occasion s'en impose, au hasard de
mon métier de critique, les variations sur lesquelles je puis donner
mon simple avis. Si M. Moréas est arrivé au classicisme pur, non sans
le parer de beauté—si M. Paul Adam ne trouve pas l'étiquette assez
large pour son effort multiple (ce qu'il n'a point dit, je pense)—si,
parmi les autres du second ban, encore que je ne vois qu'un
développement et non un changement chez M. Francis Vielé-Griffin,
M. Henri de Régnier présente une formule combinée, entre autres
éléments, de classicisme, de symbolisme et de romantisme,—si M.
Maeterlinck n'appelle pas symbolistes ses beaux drames
symboliques, ce qui est son droit, tout cela ne constitue pas des
raisons pour que je modifie mon art; je fais de mon mieux pour
suivre un développement logique, et ne peux me froisser d'être
considéré comme d'accord avec moi-même.
Il m'a paru nécessaire de reformer l'instrument lyrique. On m'a cru.
La bibliothèque du vers libre est nombreuse, et de belles œuvres
portent aux dos de leurs reliures des noms divers, illustres ou
notoires. Depuis le symbolisme il existe, à côté du roman
romanesque et du roman romantique, une manière de roman qui
n'est pas le roman naturaliste, qu'on peut appeler le roman
symboliste; j'en ai donné qui valent ce qu'ils valent, mais ils ne sont
pas ceux du voisin.
De même que j'ai toujours dit que je n'entendais pas fournir, en
créant les vers libres, un canon fixe de nouvelles strophes, mais
prouver que chacun pouvait trouver en lui sa rythmique propre,
obéissante toujours, malgré qu'il en aie, sauf clowneries, aux lois du
langage, je n'ai jamais pensé à enfermer le symbolisme dans une
trop étroite définition.
Il y a place pour beaucoup d'efforts sur le terrain de l'analyse
caractéristique et de la synthèse du nouveau roman. Un jour peut-
être développerai-je avec exemples ce que peut être le roman
symboliste; il y en a, et qui ne ressemblent pas aux miens. Mais je
passe, et ferai simplement observer à M. Henri de Régnier, qui le sait
d'ailleurs, que si je suis resté à peu près le seul symboliste, c'est que
j'étais un des rares qui l'étaient vraiment de fond, parce que le
symbolisme était l'expression de leur tempérament propre et de leur
opinion critique.
Et puis, aussi, il faut en tenir compte, les temps ont changé. En
1886, et aux années suivantes, nous étions plus attentifs à notre
développement littéraire qu'à la marche du monde. Nous avons
édifié une partie de ce que nous voulions édifier, et il est moins
important que nous n'ayons renversé qu'une partie de ce que nous
voulions renverser. Si l'on évoquait le passé de notre littérature et
ses écoles variées, comme on fait aux expositions, pour les peuples
par des séries de pavillons, le pavillon du symbolisme ne serait point
indigne des autres, et pourrait lancer ses clochetons et ses minarets,
fièrement auprès des coupoles du Parnasse. Les beautés de l'entrée
et du hall central, pour lesquelles, je le déclare avec joie, beaucoup
de peintres, de décorateurs, d'harmonistes auraient été convoqués
autour de chefs d'équipe, dont je serais, je pense, seraient
augmentées de l'inconnu de salles encore non terminées, et dont
nous annoncerions l'ouverture pour la prochaine exposition. Le
Symbolisme n'a qu'une vingtaine d'années, il lui faut du temps pour
produire encore, et qu'on étudie chez lui les symptômes de vieillesse
en même temps qu'on en pourra dénombrer et résumer les
complexités et les influences.
De plus, nous fûmes amenés, à un certain moment, tous les
symbolistes, à comparer notre développement particulier à la
marche du monde, nous avons tiré des opinions différentes et
personnelles, mais à moi il m'a paru nécessaire d'accorder, dans nos
préoccupations d'aujourd'hui, une prééminence à l'art social, mais
sans rien aliéner des droits de la synthèse et du style.
Le peuple comprendra; ce sont ses Académies, et ses critiques jurés
qui l'abusent et lui affadissent l'intellect de boissons tièdes. Notre
bourgeoisie est saturée de Coppée, elle n'écoute que par exception,
elle ne comprend que par hasard et par surprise. Il y a un Quatrième
État qui saura écouter et comprendre. Il se peut que cette certitude
fasse sourire des chroniqueurs élégants et des penseurs mondains;
quoi soumettre au peuple, ces choses que tous jugèrent
hermétiques! elles le parurent, elles ne le sont pas en réalité; la
preuve est faite, nos jeunes amis de l'Art social le savent, comme ils
savent leurs contacts avec le Symbolisme, le vrai, le plus large. La
preuve fut faite dans les réunions populaires. Elle le fut aux samedis
de l'Odéon et du théâtre Sarah Bernhardt, où les poèmes
symbolistes, et les poèmes des vers libristes reçurent un bel accueil,
qui eût été plus grand si le spectacle eût pu être plus populaire. La
preuve fut faite aussi dans des réunions purement populaires, à but
social, où tonnait la voix généreuse de Laurent Tailhade qui, après
avoir donné à la bibliothèque du symbolisme, après le jardin des
Rêves, ses admirables Vitraux, a dédié à l'art social des poèmes
animés d'un rire à la Daumier. C'est devant ces publics nouveaux que
les œuvres d'art nouvelles, écoutées avec sincérité, sont applaudies,
seront applaudies, et ce qui ne sera pas compris demain le sera
après-demain.
Une campagne du Symbolisme.
Articles de la Revue Indépendante
1888
Les pages qui suivent sont extraites passim de douze Chroniques de
la littérature et de l'art, publiées dans la Revue Indépendante durant
l'année 1888.
Elles précisent, sur quelques points, le mouvement. Elles expliquent
des états d'esprit.
J'ai choisi dans ces articles ce qui se rapportait davantage aux
poètes, aux circonstances adventices du mouvement, soit les
linéaments d'influence étrangère qui se sont présentés
concurremment au symbolisme et ont contribué à son aspect
général. De là des études sur Tolstoï.
J'ai conservé des pages sur Poictevin qu'on oublie trop.
J'ai donné une chronique entière, parce que le groupement des
livres de ce mois-là permettait d'esquisser tout le groupement
littéraire du moment, avant et en dehors des Symbolistes, au moins
d'indiquer une esquisse, de Hugo à Lavedan.
Je n'ai pas retouché ni comme fond ni comme forme ces études.
Leur seule valeur étant d'être documentaire sur l'état d'esprit des
novateurs, et l'essence du Symbolisme en 1888, près des débuts; je
resignerais d'ailleurs, en des articles d'aujourd'hui, presque tout ce
qui se trouve au cours de ces pages.
Paysages
Par Francis Poictevin
Entre tous, M. Francis Poictevin est un artiste sincère et ému.
Tourmenté, perpétuellement inquiet du but même de son art, très
soucieux des moyens d'expression, inquiet des lignes générales de la
sensation, il est de ceux qui poussent le plus vers l'achèvement
définitif une page, et non par la surprise du mot, ou l'accord fortuit
des sonorités, mais par la recherche d'un ordre logique des mots
étiquetant chacun une des variations de la sensation.
L'ordre de sensations qui se meut à travers ses livres est une
contemplation des choses de la nature en leur accord avec l'âme
humaine; avec la sienne surtout, prise comme exemple, car c'est la
seule qu'il puisse connaître à fond; non qu'il ne se permette hors de
lui-même des divinations, qu'il ne tente de se rendre compte de ce
qui peut se passer derrière les grilles perpétuellement closes d'un
hôtel vieilli, qu'il ne tente d'animer des profils de jeunes filles, ou des
silhouettes d'êtres rencontrés au hasard des courses à travers les
paysages; mais ces êtres sont silhouettes ou symboles destinés à
marquer les différences entre lui et les autres hommes, et à faire
comprendre sa façon différente de saisir et de traduire les
phénomènes d'aspect qui, à travers sa rétine, arrivent à son
cerveau.
A cela, que l'on joigne une grande inquiétude de l'être vrai, latent
sous les apparences et les illusions de présences féminines; puis,
que chez l'écrivain, homme avant tout de foi, s'est lentement
façonnée une manière de panthéisme mystique qui empreint de
mouvements quasi humains les eaux, les arbres et les lignes
d'horizons: et l'on aura la clef de la disposition des idées chez
l'auteur des Songes.
Le drame étant ainsi compris, c'est-à-dire un personnage unique
jouissant ou souffrant par la variation des minutes de la vie
extérieure, il est fort inutile à M. Poictevin de donner à ses livres une
affabulation compliquée; l'extériorité du drame est toujours, en tous
ses livres, homologue: un être souffre ou jouit de la réaction des
choses; deux êtres unis souffrent ou jouissent de la réaction du
présent et des souvenirs et des sites sur eux, et vivent d'une vie
commune remplie par les rêves divergents qu'inspirent les mêmes
faits et les mêmes lignes vues par des cerveaux différents.
L'historiette qui fait le fond du roman est en général quasi superflue;
et M. Poictevin arrive en ce livre de Paysages à la supprimer et se
lier à la juxtaposition des sensations pour évoquer, par leur série, le
symbole d'une année de vie sans incidents autres que les
déplacements de Paris à divers littorals.
Deux parties: d'abord, les Paysages—c'est-à-dire des essais de
rendre en quelques lignes un aspect fugace.
«C'était, sous un jour pluvieux, le jaune mouillé du phare du Cap,
vers Bordighère, dans le ciel une nappe citrine laissant transparaître
à son milieu un vert d'iris. Au-dessus de la mer se développait une
bande gris lilas à déchiquetures. Peu à peu des nues à gauche se
trempant fanées, elle s'étendit devant le ciel même, plus doucement
que lividement violâtre. Et la mer se mouvait en une somptuosité
vieux-vert teintée d'améthystes.»
Et s'animent ainsi des coins de Paris, de Menton, de Toulouse, des
salles d'attente où l'attention se fixe sur tel ou tel être
caractéristique autour duquel s'ébrouent des formes vagues, des
sites de Luchon, des Pyrénées, de Fontarabie, du pays basque, de la
Bretagne, de la Suisse, du Rhin, de la Hollande, des notations au
Bois de Boulogne, sur les cygnes du parc Monceau, et, brusques,
des théories sur le choix des fleurs, puis un été en Normandie
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

The Actionscript 30 Quick Reference Guide For Developers And Designers Using Flash Cs4 Professional David Stiller Et Al

  • 1.
    The Actionscript 30Quick Reference Guide For Developers And Designers Using Flash Cs4 Professional David Stiller Et Al download https://ebookbell.com/product/the-actionscript-30-quick- reference-guide-for-developers-and-designers-using-flash- cs4-professional-david-stiller-et-al-4137632 Explore and download more ebooks at ebookbell.com
  • 2.
    Here are somerecommended products that we believe you will be interested in. You can click the link to download. The Actionscript 30 Quick Reference Guide For Developers And Designers Using Flash David Stiller https://ebookbell.com/product/the-actionscript-30-quick-reference- guide-for-developers-and-designers-using-flash-david-stiller-5475380 The Actionscript 30 Migration Guide Making The Move From Actionscript 20 1st Edition Kris Hadlock https://ebookbell.com/product/the-actionscript-30-migration-guide- making-the-move-from-actionscript-20-1st-edition-kris-hadlock-2135438 The Essential Guide To Flex 2 With Actionscript 30 Charles E Brown https://ebookbell.com/product/the-essential-guide-to-flex-2-with- actionscript-30-charles-e-brown-918654 The Essential Guide To Flash Games Building Interactive Entertainment With Actionscript 30 Jeff Fulton https://ebookbell.com/product/the-essential-guide-to-flash-games- building-interactive-entertainment-with-actionscript-30-jeff- fulton-42277314
  • 3.
    Advanced Actionscript ComponentsMastering The Flash Component Architecture 1st Edition Antonio De Donatis https://ebookbell.com/product/advanced-actionscript-components- mastering-the-flash-component-architecture-1st-edition-antonio-de- donatis-920394 Actionscript For Flash Mx The Definitive Guide Second Edition Second Edition Colin Moock https://ebookbell.com/product/actionscript-for-flash-mx-the- definitive-guide-second-edition-second-edition-colin-moock-1536410 The Flash Anthology Cool Effects And Practical Actionscript 1st Edition Steve Grosvenor https://ebookbell.com/product/the-flash-anthology-cool-effects-and- practical-actionscript-1st-edition-steve-grosvenor-976680 The Essential Guide To Flash Cs4 With Actionscript 1st Edition Paul Milbourne https://ebookbell.com/product/the-essential-guide-to-flash-cs4-with- actionscript-1st-edition-paul-milbourne-11852326 Macromedia Flash Mx 2004 Actionscript Training From The Source Derek Franklin https://ebookbell.com/product/macromedia-flash-mx-2004-actionscript- training-from-the-source-derek-franklin-1675948
  • 7.
    The ActionScript 3.0 QuickReference Guide For Developers and Designers Using Flash CS4 Professional David Stiller, Rich Shupe, Jen deHaan, and Darren Richardson Tomcat ™ The Definitive Guide Jason Brittain and Ian F. Darwin Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo
  • 8.
    TheActionScript3.0QuickReferenceGuide:ForDevelopersandDesignersUsingFlash CS4 Professional by DavidStiller, Rich Shupe, Jen deHaan, and Darren Richardson Copyright © 2009 David Stiller and Rich Shupe. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com. Editor: Robyn Thomas Production Editor: Michele Filshie Copyeditor: Sohaila Abdulali Technical Editors: Matthew Woodruff, Anselm Bradford, and Eric Kramer Proofreader: Nancy Bell Indexer: Ellen Troutman Zaig Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrators: Robert Romano and Jessa- myn Read Printing History: October 2008: First Edition. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. The ActionScript 3.0 Quick Reference Guide: For Developers and Designers Using Flash CS4 Profes- sional, the image of the Ophiops, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages re- sulting from the use of the information contained herein. TM This book uses RepKover, a durable and flexible lay-flat binding. ISBN: 978-0-596-51735-9 [M] 1223315717
  • 9.
    Adobe Developer Library,a copublishing partnership between O’Reilly Media Inc. and Adobe Systems, Inc., is the authoritative resource for developers using Adobe technologies. These comprehensive resources offer learning solutions to help devel- opers create cutting-edge interactive web applications that can reach virtually any- one on any platform. With top-quality books and innovative online resources covering the latest tools for rich-Internet application development, the Adobe Developer Library delivers expert training, straight from the source. Topics include ActionScript, Adobe Flex®, Adobe Flash®, and Adobe Acrobat® software. Get the latest news about books, online resources, and more at adobedeveloper- library.com.
  • 10.
    To Scott Joplin,for doing his thing like nobody’s business, then sharing it. -- David Stiller To Jodi, Sally, and Claire for putting up with so much. -- Rich Shupe
  • 11.
    Table of Contents Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii Part I. ActionScript 3.0 Introduced 1. Introducing ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Examining ActionScript 3.0, the Language 5 Exploring Flash Player API Updates 15 Understanding Players and Support 18 Learning ActionScript 3.0 on the Heels of 2.0 20 Deciding to Migrate or Write Code from Scratch 21 2. Discovering What You Need to Work with ActionScript 3.0 . . . . . . . . . . . . . 23 Flash CS4 Professional/Flex Builder 3 24 Flash Player 9 or Higher 24 Using Other Code Editors with Flash 32 3. Looking at the Changes in ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Major Changes and Obsolete Code 59 Major Syntax and Structure Changes 77 Additional ActionScript 3.0 Resources 84 4. Exploring the Benefits of Using ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . 85 Performance 86 Efficiency 93 Consistency 96 Standards and Portability Among Other Technologies 100 v
  • 12.
    Part II. ActionScriptand the Flash CS4 Authoring Tool 5. Creating and Working with Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Thinking in Terms of the Timeline 106 New Features in the Actions Panel and Script Windows 112 Setting ActionScript Preferences 120 Associating FLA Files with AS Files 126 Using Script Assist 130 6. Creating a Document Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 7. Working with Library and Linkage Changes . . . . . . . . . . . . . . . . . . . . . . . . 145 Linkages Now Reference Classes 145 8. Copying Motion as ActionScript 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Copying Motion 163 Applying Motion to Other Objects 166 9. Using ActionScript 3.0 Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Overview of the Component Set 179 New and Removed Components 185 Changes in Writing Code for Components 188 Changing the Appearance of Components 199 10. Making Up for a Reduced Component Set . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Working Without Data Components in ActionScript 3.0 207 ActionScript 2.0 Components in ActionScript 3.0 SWF Files 219 Exploring Third-Party UI Components 224 11. Debugging and Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Debugging Is a Good Thing 231 Testing Your ActionScript 3.0 Code 232 Reviewing Improvements in Debugging Over ActionScript 2.0 237 Exploring the Compiler Errors Panel 240 Using the Enhanced Debugging Workspace 250 vi | Table of Contents
  • 13.
    Part III. HowDo I? 12. How Do I Draw with Code? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 12.0 Introduction 267 12.1 Creating a Display Object Dynamically 268 12.2 Referencing an Object’s Graphics Property 269 12.3 Defining a Line Style 270 12.4 Drawing a Line 271 12.5 Drawing a Curve 272 12.6 Defining a Fill Style 273 12.7 Drawing a Rectangle 274 12.8 Drawing a Rectangle with Rounded Corners 274 12.9 Drawing a Circle 276 12.10 Creating a Gradient Fill 277 12.11 Using a Drawn Shape as a Dynamic Mask 278 12.12 Caching Vector as Bitmap 280 12.13 Applying a Simple Bitmap Filter 281 13. How Do I Work with the Display List? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 13.0 Introduction 283 13.1 Choosing Which Type of Display Object to Use 284 13.2 Creating a New Display Object 286 13.3 Adding a Display Object to the Display List 287 13.4 Specifying the Depth of a Display Object 289 13.5 Finding a Display Object 291 13.6 Removing a Display Object from the Display List 292 13.7 Working with Children of a Display Object Container 293 13.8 Working with Parents of a Display Object 296 13.9 Casting a Display Object from One Type to Another 297 13.10 Changing the Parent of a Display Object 299 13.11 Referencing the Stage Through a Display Object 300 14. How Do I Work with Events? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 14.0 Introduction 303 14.1 Understanding Event Listeners 303 14.2 Capturing Mouse Events 305 14.3 Understanding Event Flow 307 14.4 Using Event Bubbling 308 14.5 Using the target and currentTarget Event Properties 310 14.6 Simulating a Mouse Up Outside Event 311 14.7 Capturing Frame Events 312 Table of Contents | vii
  • 14.
    14.8 Improving Performanceby Removing Event Listeners 314 14.9 Capturing Keyboard Events 315 14.10 Capturing Stage Events 317 14.11 Using a Timer to Dispatch Events 321 14.12 Dispatching Your Own Events 323 14.13 Manually Calling Event Listener Functions 325 14.14 Capturing an Event Before It Reaches Its Target 326 14.15 Setting the Execution Order of Events 328 14.16 Using Weak Listeners 330 15. How Do I Work with Text? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 15.0 Introduction 333 15.1 Creating a Text Field 334 15.2 Styling a Text Field 334 15.3 Creating a Password Field 336 15.4 Focusing a Text Field 337 15.5 Populating a Text Field 338 15.6 Automatically Sizing a Text Field 339 15.7 Scrolling a Text Field 341 15.8 Using Embedded Fonts 343 15.9 Formatting Text Using TextFormat 344 15.10 Formatting Text Using HTML 346 15.11 Formatting Text Using CSS 348 15.12 Adding Hyperlinks to Text 350 15.13 Triggering ActionScript from HTML Links 351 15.14 Selecting Text 352 16. How Do I Work with XML? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 16.0 Introduction 355 16.1 Creating an XML Object 356 16.2 Loading XML 357 16.3 Reading an Element Node 359 16.4 Reading a Text Node 360 16.5 Working with Multiple Nodes of the Same Name 362 16.6 Reading an Attribute 363 16.7 Finding Content Using Shorthand 364 16.8 Finding Content Using Conditionals 366 16.9 Reading HTML or Entities in XML Nodes 367 16.10 Deleting XML 369 16.11 Writing XML 369 16.12 Writing XML with Variables 372 16.13 Sending and Loading XML 373 viii | Table of Contents
  • 15.
    17. How DoI Work with External Assets? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377 17.0 Introduction 377 17.1 Loading and Applying a Cascading Style Sheet 378 17.2 Loading and Displaying an Image or SWF File 380 17.3 Communicating with an ActionScript 3.0 Loaded SWF 382 17.4 Communicating with an ActionScript 2.0 Loaded SWF 384 17.5 Unloading an Image or SWF File 387 17.6 Loading and Playing a Sound 391 17.7 Setting the Volume and Pan of a Sound 392 17.8 Visualizing the Amplitude of a Sound 393 17.9 Unloading a Sound 395 17.10 Loading and Playing a Video 397 17.11 Unloading a Video 399 Part IV. Migration 18. A Sample Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 A Simple Particle System 404 ActionScript 2.0 404 ActionScript 3.0 413 Migration Sample Summary 424 19. Where Did It Go? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 Introduction 425 Code Comparisons 426 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451 Table of Contents | ix
  • 17.
    Foreword The battle, asit stood, had clearly defined lines. The artists liked ActionScript 1.0 and the programmers, let’s just say they weren’t happy (if they used Flash at all!). Then ActionScript 2.0 appeared and many artists started getting nervous until they realized that they could basically ignore it. Programmers were a bit more happy until they realized that the changes were mostly superficial. But in many cases, it was enough to bring new programmers to Flash—which made the artists even more nervous. Fast forward to just a couple of years ago and ActionScript 3.0 rears its head. The programmers embrace it like a brother, like the saviour of the Flash plat- form. The artists, for the most part, ran and hid. As they dashed away from terms like “classes” and “interfaces” they bemoaned the loss of what, for many of them, was their first programming language. This was real programming, they said. ActionScript 3.0 had wandered into the land populated by frightening giants like Java and C++. It wasn’t fun anymore, it was just scary. Enter this book and its talented authors. For the developers reading this, I have a confession to make that will probably ring true with you as well. At first, ActionScript 3.0 intimidated the heck out of me. Everything that I knew how to do was different. It felt like the ground had been ripped out from under me. It was all sort of familiar, but so many little things were different, I often felt like it would have been easier for me if I hadn’t ever learned ActionScript 1.0 and 2.0. It took me quite a long time to get a good sense of the language and to get back to that level of comfort I had with earlier versions. The good news for you, dear coder, is that if you haven’t yet made that tran- sition and gained that level of comfort, your road is going to be a lot easier thanks to this book. Honestly, I’m a bit jealous. xi
  • 18.
    For the artistsreading this, the authors of this book are here to explain that no, it’s not hard, it’s just different. Different in a way that is more powerful, that lets your ideas go further. You have been doing “real” programming all along and this is just the next logical step. ActionScript 3.0 is a giant of a programming language. There is a lot to learn, and conquering will take time and patience. But at the end of day (and the end of this book) you will find that by learning ActionScript 3.0 not only are you a better Flash developer, but also a better developer period. You’ll have under your belt a good understanding of many core object-oriented concepts and can take them to any other language you want to tackle—whether that be Python, Java, C++, or just about anything else. No matter what your background, the pages that follow will provide you with some excellent knowledge, insight, and even a little bit of wisdom in the realm of Flash and ActionScript. I’m lucky enough to personally know some of the authors of this book so I can honestly tell you that you’re about to learn from some of the best developers and teachers I know. Happy learning! —Branden Hall CTO, Automatic Studios Ltd. September 2008 xii | Foreword
  • 19.
    Preface ActionScript 3.0 introducedFlash developers to a new realm. In this improved territory, ActionScript has emerged from the gym with a new physique. The language is more powerful, more efficient, and—thanks to a new internal con- sistency—easier to learn for those new to the Flash Platform. As the saying goes, change is a good thing. On the other hand, too much of anything can be, well, nerve-wracking. For many, ActionScript’s change equates to a chronic attack of growing pains. Others, used to the paradigms and occasional quirks of ActionScript 2.0, find the new ActionScript 3.0 practically unrecognizable. In any case, the ongoing support for ActionScript 1.0 and 2.0, in both the Flash authoring environment and Flash Player, means that learning ActionScript 3.0 is, for the immediate future, still an option. For now, you can choose when to learn the new version of the language (and to what degree), applying your newlyearnedknowledgeonaproject-by-projectbasis,ifyouwant.Sometimes, it’ll be easier to decide when to use ActionScript 3.0 than to decide whether you should migrate existing code or start from scratch. For example, if you want significant performance gains, or to use a new feature specific to Action- Script 3.0, using the new language may be a foregone conclusion. How to arrive at completed ActionScript 3.0 code, however, is another question, and that’s where this book is useful. This book aims to show you where Flash CS4 Professional and ActionScript 3.0 differ from prior releases of Flash and ActionScript, respectively. You can use this text as a guide, helping you decide if new application features warrant an upgrade, and assisting with the steeper learning curve imposed by the more robust new language. Perhaps most importantly, this book will increase your familiarity with ActionScript 3.0 structure and syntax, letting you adjust (or abandon) ActionScript 2.0 coding practices more easily. xiii
  • 20.
    What Sets ThisBook Apart Simple: Essentially, we’ve created two books in one. Or put another way, there are two sections to the book, each using its own learning methodology. Part I and Part II are written in classic tech-book formatting and prose. General concepts are introduced and followed with expository prose and simple, de- monstrative tutorials as necessary. Part III and Part IV (especially Part III) are pure reference sections, designed for you to quickly look up and learn from “How Do I...?” scenarios. Think of the book as a seminar. The first half is presentation; the latter half is Q&A. What’s in This Book When ActionScript 3.0 hit the streets, the reaction from the Flash crowd was enormous, and not without a tremor of intimidation. Certain questions have emerged—on the forums, in classrooms, user groups, and at conferences— more often than others. This book answers the questions we most often en- counter, questions that seem to pose the biggest stumbling blocks for longtime users. The book’s in a hybrid format to serve two needs. The first half of the book is something like a fireside chat, providing fairly broad coverage of Flash CS4 Professional, and select overviews of ActionScript 3.0. The second half presents many focused examples of ActionScript 3.0 syntax in small, digestible chunks. Both halves are chock-full of hands-on demonstrations. Ideally, you can hop between the two, and gear up or down to the pace that best suits your needs at the time. Navigate the Table of Contents and/or Index to find quick answers to specific questions about ActionScript 3.0 and its application. Part I: Introduction to ActionScript 3.0 Part I of the text introduces a variety of tools to write ActionScript 3.0, while relying on Flash CS4 Professional as its primary authoring environment. It then discusses some of the attributes that make ActionScript 3.0 stand head and shoulders above its predecessors. Topics include power and performance, the benefits of strong data typing (including robust compile time warnings and error messages) and how the new language architecture can improve your workflow. Chapter 1, Introducing ActionScript 3.0 Chapter 2, Discovering What You Need to Work with ActionScript 3.0 xiv | Preface
  • 21.
    Chapter 3, Lookingat the Changes in ActionScript 3.0 Chapter 4, Exploring the Benefits of Using ActionScript 3.0 Part II: ActionScript and the Flash CS4 Authoring Tool Part II walks you through the Flash CS4 authoring tool with keen attention to ActionScript-related interface elements, and helps you decide when to use the timeline, and when to use classes, for coding. It also discusses the creation of assets at runtime, how to convert timeline animation into ActionScript (for manipulation and reuse), how to use, skin, and style user interface compo- nents, and how to troubleshoot your code when things go awry. Chapter 5, Creating and Working with Code Chapter 6, Creating a Document Class Chapter 7, Working with Library and Linkage Changes Chapter 8, Copying Motion as ActionScript 3.0 Chapter 9, Using ActionScript 3.0 Components Chapter 10, Making Up for a Reduced Component Set Chapter 11, Debugging and Troubleshooting Part III: How Do I? Part III switches to cookbook-style—a concise look at a problem, solution, and discussion for each of several issues. This format lets you hone in on syntax and methodology in easily digestible recipes. It starts off by highlighting the Graphics class, formerly the Drawing API, which the second half of the book uses extensively for highly portable, code-only examples. It then discusses the most significant changes introduced by ActionScript 3.0: the new display ar- chitecture and event model. Next, you’ll discover new ways of using text for display and interactivity. Finally, you’ll concentrate on input/output pro- cesses, including sending and loading XML and variables, as well as loading images, external SWFs, sound, and video. Chapter 12, How Do I Draw with Code? Chapter 13, How Do I Work with the Display List? Chapter 14, How Do I Work with Events? Chapter 15, How Do I Work with Text? Chapter 16, How Do I Work with XML? Chapter 17, How Do I Work with External Assets? Preface | xv
  • 22.
    Part IV: Migration PartIV distills everything covered in Part I through Part III, and applies those skills to the issue of migration—updating existing projects written in Action- Script 2.0 to use ActionScript 3.0 code. This concept’s first application is the migration of a simple particle system. The exercise highlights as many migra- tion issues as possible in a short example, and helps you ask an important question related to your own projects: should you migrate or rewrite? The final chapter of the book serves as a cross-reference, and a code-comparison guide. Specific migration issues are demonstrated in quick syntax examples, com- paring ActionScript 2.0 and 3.0 uses. Where applicable, references to more complete discussions elsewhere in the book are included, and select new ma- terial in the same comparative format is also added. Chapter 18, A Sample Migration Chapter 19, Where Did It Go? What’s Not in This Book Duetothesizeandfocusconstraintsofthisbook,manyaspectsofActionScript usage are necessarily excluded. First and foremost, this book focuses specifi- cally on Flash CS4 Professional, although most of the examples work just fine in Flash CS3. The Flash Platform has grown considerably, so if you prefer other ActionScript coding environments, including Flex Builder, FDT, or FlashDevelop (or even text editors, such as Notepad or TextMate, in conjunc- tion with the Flex SDK command-line compiler), you may want to skim through several of the examples to see if you think they’ll be helpful. In general, you can easily adapt most of the book’s examples for ActionScript 3.0 projects written in other tools, and you are introduced to a handful of those tools in Chapter 2. However, very little additional material, such as Flex Builder MXML documents or project files, is supplied. This book is a migration ref- erence for Flash professionals, so you’ll see mostly FLA and AS files. Secondly, this book is aimed at relatively experienced ActionScript 2.0 coders who are making the move to ActionScript 3.0. It neither provides language essentials nor serves as a comprehensive reference. As such, if you’re not al- ready comfortable with ActionScript, and want to focus a bit more on funda- mentals, you should seek out Learning ActionScript 3.0: A Beginner’s Guide by Rich Shupe and Zevan Rosser (O’Reilly, 978-0-596-52787-7). Conversely, if you’relookingformoreofanin-depthreferencebook,youmaypreferEssential ActionScript 3.0 by Colin Moock (O’Reilly, 978-0-596-52694-8). xvi | Preface
  • 23.
    Finally, while ithits many of the high points, this volume doesn’t cover all areas of ActionScript 3.0 interest, and may not satisfy advanced users’ needs. If you want to immerse yourself in the more elaborate capabilities of the lan- guage, you can either acquire the aforementioned Essential ActionScript 3.0 for broad coverage, or look into additional specialized books such as Action- Script 3.0 Design Patterns: Object Oriented Programming Techniques by Wil- liam Sanders and Chandima Cumaranatunge (O’Reilly, 978-0-596-52846-1) for OOP and design patterns expertise. Conventions Used in This Book This book uses the following typographical conventions: Menu options Menu options are shown using the → character, such as File→Open. Italic Indicates new terms, URLs, email addresses, file names, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, envi- ronment variables, statements, and keywords. Constant width bold Shows commands or other text that the user should type literally. Constant width italic Shows text that should be replaced with user-supplied values or by values determined by context. This is a note. It contains useful information about the topic at hand, often highlighting important concepts or best practices. This is a warning. It helps you solve and avoid annoying problems. Ignore at your own peril. This Book’s Example Files You can download the example files for this book at: http://www.oreilly.com/catalog/9780596517359 Preface | xvii
  • 24.
    Note that, althoughalternative development platforms are discussed briefly, the examples in this book are presented in the context of classes or timeline frame scripts intended for use with the Flash authoring tool. Self-contained examples are typically intended for inclusion in FLA files or as Flash document classes, but you can adapt them for use in other environments (such as Flex Builder) without support for those tools. Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You don’t need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book doesn’t require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a ques- tion by citing this book and quoting example code doesn’t require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but don’t require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “The ActionScript 3.0 Quick Reference Guide: For Developers and Designers Using Flash CS4 Profes- sional” by David Stiller, Rich Shupe, Jen deHaan, and Darren Richardson Copyright © 2009 David Stiller and Rich Shupe, 978-0-596-51735-9.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com. Safari® Books Online When you see a Safari® Books Online icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf. Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari.oreilly.com. xviii | Preface
  • 25.
    How to ContactUs Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) We have a web page for this book, where we list errata, examples, and any additional information. You can find this page at: http://oreilly.com/catalog/ 9780596517359 Acknowledgments From David Thanks to Rich, Jen, Darren, and the gang at O’Reilly. We took a trip to Oz and had enough adventures to write a book about it! (Rich, you owe me a face- to-face sit-down with Pentago!) For technical assistance and encouragement, I’d like to extend gratitude to Marisa Bozza, Tink (Stephen Downs), Greg Dove, Chris Georgenes, Tom Green, Branden Hall, Keenan Keeling, San Khong, John Mayhew, Colin Moock, Robert Penner, Nivesh Rajbhandari, Robert Reinhardt, Steve Schelter, and Kenneth J. Toley. Thanks and love to my #1 woman, Dawn, who introduced me to Georges Méliès, and my #1 girl, Meridian, für unser Abenteur mit Andersen und den Brüdern Grimm. From Rich Thanks to David, Jen, and Darren for making me part of the team. Thanks to Robyn Thomas, Michele Filshie, Steve Weiss, and Dennis Fitzgerald for work- ing with me again. You’re unmatched in my professional experience. Thanks to our tech editors Matthew Woodruff, Eric Kramer, and Anselm Bradford. Thanks to Marisa Bozza, Lee Brimelow, John Dowdell, Richard Galvan, Mally Gardner, Stefan Gruenwedel, Jeff Kamarer, Vishal Khandpur, San Khong, John Mayhew, Tony Mowatt, John Nack, Chris Nuuja, Ted Patrick, Nivesh Ragbhandari, and Adobe. Special thanks to my staff at FMA and Mike Wills, and my family for endless support. Last but not least, extra special thanks go to Jodi, Sally, and Claire for everything. Preface | xix
  • 27.
    PART I ActionScript 3.0Introduced Part I seats you comfortably in the ActionScript 3.0 bistro, offers to take your coat, and gives you a free basket of fresh bread, hot from the oven. You’ll get drinks, of course, and be presented with a menu that unveils the variety of tools you can use while exploring ActionScript 3.0. Specials include the Flash authoring tool and Flash Player 10, with a dash of Flex Builder 3. You’ll also see a few third-party script editors. The first chapters touch on a number of ActionScript concepts, explored fur- ther in Part II, Part III, and Part IV. These introductory tidbits are intended to whet your appetite. They give you an overview of the new features of Action- Script 3.0: what makes it easier to use and more powerful than its predecessor, how to benefit from its richer warnings and error messages, and how the new language can improve your workflow by helping you get organized. Chapter 1, Introducing ActionScript 3.0 Chapter 2, Discovering What You Need to Work with ActionScript 3.0 Chapter 3, Looking at the Changes in ActionScript 3.0 Chapter 4, Exploring the Benefits of Using ActionScript 3.0
  • 29.
    CHAPTER 1 Introducing ActionScript3.0 Ifyouchaseperfection,youoftencatchexcellence. —William Fowble The term “perfect” is a powerful word. From a practical standpoint, it repre- sents a state that arguably cannot be achieved. Hey, that’s a relief already! This book doesn’t expect the impossible. This isn’t the print version of an office know-it-all, itching for you to slip up. You won’t hear any anxious hand wringing in these pages over why you haven’t yet upgraded to, much less mas- tered, ActionScript 3.0. (Yes, even though it was available in Flash CS3 Pro- fessional.) Instead, the following chapters will take their cue from a sage ob- servation by William Fowble: If you chase perfection, you often catch excel- lence. In other words, chin up! Aim for the best and enjoy the road trip. ActionScript 3.0—the current version of the programming language for the Adobe Flash Platform—is a language that indeed catches excellence. This book is designed to explain a bit about why that is. In so doing, our hope is to help you chase perfection by introducing you to the improved organization, syntax, and workflows of the new language. Catching excellence, for all of us, is a matter of practice, and comes with time. This book is going to introduce you to new ways of thinking about the Flash Platform. ActionScript 3.0 requires these new ways because the language is actually structured around them. That’s a big part of why the new language improves on previous versions. Like its precursor, but to a greater extent, ActionScript 3.0 is based on a specification called ECMAScript, which is a standard proposed by a body of experts known as Ecma International. This group is something like the World Wide Web Consortium (W3C), whose re- sponsibility includes HTML, XML, CSS, and other widely used markup lan- guages. Such a standard’s benefit is that ActionScript 3.0 isn’t just an arbitrary language invented to meet Adobe’s needs. ECMAScript is a relatively mature specification, already in its third revision. The Ecma International team in- 3
  • 30.
    cludes authorities fromindustry powerhouses like Microsoft, the Mozilla Foundation, and Adobe. The specification is built on the collective insight and success of these diverse experts in the field. Of all the versions of ActionScript, the current version comes closest into full compliance with this specification —at this point, closer even than the other famous ECMAScript derivative, JavaScript. This makes ActionScript 3.0 a model of best practices, habits you can use in both Flash CS4 Professional and Flex Builder 3. In many cases, you may even find that these practices benefit your involvement with existing projects coded in previous versions of ActionScript. Sure, the syntactical de- tails change, but achievement in programming is all about structure and pur- pose. It’s the concepts and good habits that carry you. For the nuts and bolts, the relevant ActionScript Language Reference is always a mere keystroke away (the F1 key). Even so, a new set of Help docs can be daunting, especially if you’re already well-versed in ActionScript 2.0. Fortu- nately, the ActionScript 3.0 documentation is every bit as helpful as it used to be, even if it looks different. The layout of the Help docs is still organized around the layout of the language itself—around the classes that define the objects you will use—and its class entries still summarize the usable apparatus of each object: its characteristics, called properties; the things it can do, called methods; and the things it can react to, called events. In the new documenta- tion, code samples are presented as custom classes, rather than frame scripts. This requires you test them as standalone, simple text files, according to the new document class concept described in Chapter 6. Fortunately, this also means you can test these classes in other programs, such as Flex Builder. This book will help you get familiar not only with the new language, but also with the documentation that explains it. Keep in mind, ramping up to ActionScript 3.0 isn’t merely about learning the latest syntax: it’s about becoming a better, more efficient programmer. This isn’t meant to slight ActionScript 2.0 at all, but plenty has changed since its introduction in late 2003. It’s no exaggeration to say that several aspects of the language have been completely overhauled. In fact, ActionScript 3.0 requires an entirely new virtual machine, which is the module inside Flash Player that interprets compiled ActionScript. As of Flash Player 9, the runtime that dis- plays Flash movies does so with two virtual machines: AVM1 for legacy SWF files based on ActionScript 1.0 and 2.0, and the new AVM2 for ActionScript 3.0. That’s a first in the history of Flash Player. Thanks to the new virtual machine, ActionScript 3.0 runs faster and more efficiently by an order of mag- nitude. This bodes well for the overriding goal of the new language: to facilitate a wide range of interactive media and Rich Internet Applications (RIAs)—to do so simply, with better performance, and highly compatible with industry standards. As you can imagine, an upgrade of this scale means you may have 4 | Chapter 1: Introducing ActionScript 3.0
  • 31.
    to reshape someof your current habits. But take heart. Reshape doesn’t nec- essarily mean tear down and rebuild. As ActionScript has matured, it has con- sistently moved in the direction it currently stands. Again, honing your skills in light of ActionScript 3.0 will help you in your current projects and also in legacy project maintenance. Migration can be intimidating, but much of that uncertainty comes from trying to find your stride. Once you take the first few steps, the momentum keeps you going. Here’s a look at some of the new features. Examining ActionScript 3.0, the Language Section 4 of the ECMAScript standard (http://www.ecma-international.org/ publications/files/ECMA-ST/Ecma-262.pdf) defines an important facet of any language that implements it. Such languages “will provide not only the objects and other facilities described in this specification but also certain environment- specific host objects, whose description and behaviour are beyond the scope of this specification.” In other words, any ECMAScript derivative needs a set core functionality that stands on its own and will then provide additional functionality specific to the environment that interprets it. This is exactly what ActionScript 3.0 does, and its host environments include Flash Player for web browsers, intended for Flash-enabled websites such as http://YouTube.com; Flash Lite for devices, such as video games for your cell phone; and Adobe Integrated Runtime (AIR) for applications installed on the hard drive, such as eBay Desktop (http://desktop.ebay.com/). Here is a brief summary of a number of core updates. Runtime Exceptions In ActionScript 2.0, many runtime errors failed without drawing attention to themselves. On the plus side—and this is a very weak plus—this meant that errors of this sort often failed “gracefully.” In other words, they might not halt someone’s experience with something abrupt or laden with technical jargon, such as an alert or dialog box. On the minus side, this also meant such errors might go unnoticed by the developer—until complaints started rolling in that people were experiencing slow playback or even lockups. Such errors could be hard for developers to pinpoint and repair, precisely because they were silent. ActionScript 3.0 allows for a variety of runtime exceptions to be handled with purpose. This includes Error objects generated both by the runtime environment and, potentially, by the programmer. In ActionScript 3.0, the Error class is considerably more robust than its forerunner, and tailor-made Examining ActionScript 3.0, the Language | 5
  • 32.
    Error objects canbe built from this class as desired, inheriting and extending its functionality to provide highly customized error messages. Exceptions can even provide source file and line number information, which greatly enhances the debugging experience, letting developers quickly track down errors. Runtime Types ActionScript 2.0 introduced the ability to strongly type variables, parameters, and function return values. This was, and still is, an optional way to let Flash know exactly what sort of data a particular variable, parameter, or return value could cope with. This ability was a boon to developers in terms of debugging, because it gave you a way to display error messages in cases of a type mis- match. For example, if you were going to perform a math operation on two numbers provided by the user, you might take those numbers from input text fields. This would actually make them strings, which meant your math oper- ation would give you unexpected results (for example, 1 + 2 would become “12” instead of 3). By strongly typing the parameters of the function that per- formed this operation—in other words, by specifying intended variable types with a colon (:), then the type—you could benefit from a meaningful error message in the Output panel such as this: // ActionScript 2.0 var userVar1:String = inputField1.text; var userVar2:String = inputField2.text; function getSum(a:Number, b:Number):Number { return a + b; } trace(getSum(userVar1, userVar2)); // Displays: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 8: Type mismatch. getSum(userVar1, userVar2);. A type mismatch notice is a great reminder to use something like parseInt() or parseFloat() to convert those strings into numeric values. Useful indeed, but this was only a first step in a good direction. In ActionScript 2.0, this sort of error checking only occurred at compile time. Under many circumstances —such as evaluating data from dynamic sources like XML—the feature wasn’t “smart” enough to catch every contingency. In ActionScript 3.0, it is. Sealed Classes Following in the same vein as runtime exceptions and runtime types, Action- Script 3.0 establishes the concept of sealed classes in a stricter, more formalized way than in ActionScript 2.0. A sealed class is one that can’t have properties 6 | Chapter 1: Introducing ActionScript 3.0
  • 33.
    or methods assignedto it at runtime, such as String. By default, classes in ActionScript3.0aresealed,butthiscanbeoverruledwhenyouwriteyourown. var str:String = "" // Or: new String(); str.customProperty = "This generates a compiler error."; // Displays: Access of possibly undefined property customProperty // through a reference with static type String. In contrast, a class that actually can have properties and methods assigned to it at runtime is called dynamic. One of the most familiar dynamic classes is MovieClip, though historically speaking, many frame script developers haven’t considered movie clips in terms of a class. The same could be said of buttons and text fields, because you can create such elements with Flash’s drawing tools. (Of the elements just mentioned, only movie clips are dynamic.) For frame script coders, movie clips are often thought of simply as symbols or timelines, and timelines have always been able to receive new variables at run- time. True enough. What’s really going on, though, is that variables defined in keyframe scripts are in reality dynamic properties of a MovieClip instance; functions are actually dynamic methods. Declaring a variable in a keyframe of the main timeline or in a movie clip’s timeline is conceptually the same as the following: var mc:MovieClip = new MovieClip(); mc.customProperty = "This is perfectly acceptable."; Custom classes in ActionScript 3.0 can behave this way too, if and only if they are declared with the dynamic attribute: package { public dynamic class CustomClass() { // class code here } } On paper, this is also how it was in ActionScript 2.0, but in fact, even non- dynamic classes could be altered at runtime by manipulation of the Object.prototype property (inherited by all objects) or by the array access op- erator ([]). Advanced programmers who used such an approach in the past will find it no longer works in ActionScript 3.0 for sealed classes. // ActionScript 2.0 var str:String = ""; str.customProperty = "Secret back door."; // Displays: There is no property with the name 'customProperty'. str["customProperty"] = "Secret back door."; // Works just fine in ActionScript 2.0, but in 3.0 displays: Cannot create property customProperty on String. Examining ActionScript 3.0, the Language | 7
  • 34.
    In ActionScript 3.0,non-dynamic classes actually are what they claim to be. This makes for stricter compile-time checking and improves memory usage because class instances can now be guaranteed to require no more than a pre- declared amount of system memory. Method Closures Of all the updates to ActionScript 3.0, it’s no surprise that developers, regard- less of skill level, encounter one in particular early on: method closures. Why? Because the introduction of method closures changes the point of view, or scope, of methods in ActionScript 3.0. Scope refers to the conceptual area of a program in which code executes. The availability of code definitions, such as variables, functions, properties, and methods, depends on the scope of the code being executed. For example, if a variable is declared in a timeline frame, that variable can be referenced by any other code in that frame, as long as that code appears after the declaration. Even a function defined in that frame can reference the variable scoped to the timeline, because scopes can be nested, and the flow moves from outer scope to inner: the timeline’s definitions become available to the function. // A variable declared here ... var favoriteCereal:String = "Star Crunchers!"; // can be referenced here ... trace(favoriteCereal); // Displays: Star Crunchers! function myFunction():void { // and here ... trace(favoriteCereal); // Displays: Star Crunchers! } myFunction(); In contrast, a variable declared inside a function can only be referenced by that function, because the scope of the function is confined to itself. function myFunction():void { // A variable declared here ... var favoriteCereal:String = "Star Crunchers!"; // can only be referenced here ... trace(favoriteCereal); // Displays: Star Crunchers! } myFunction(); // but not in the outer scope ... trace(favoriteCereal); // Displays: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 10: Access of undefined property favoriteCereal. 8 | Chapter 1: Introducing ActionScript 3.0
  • 35.
    Up to now,this should be familiar to ActionScript 2.0 developers. How, then, have things changed? Consider the next few examples. In ActionScript 2.0, a button click might be handled like this: // ActionScript 2.0 myButton.onRelease = buttonHandler; function buttonHandler():Void { trace(this); // Displays: _level0.myButton // other event handler code } Prior to ActionScript 3.0, the scope of the function shown belonged to the myButton instance. In this case, the button code could conveniently be abbre- viated with the use of the this keyword, which self-referenced the current scope (myButton). In some cases, this made for a handy way to achieve certain goals. For example, to repeatedly loop a Sound instance in ActionScript 2.0, the following would do: // ActionScript 2.0 var audio:Sound = new Sound(); audio.loadSound("externalFile.mp3", true); audio.onSoundComplete = completeHandler; function completeHandler():Void { this.start(); } Again, the function is scoped to the instance. In this case, the expression this.start() amounts to invoking the Sound.start() method on the audio instance. Although convenient in this sort of situation, difficulties arose when the event handler needed to reference objects outside the scope of the function, especially in custom classes. To a large extent, this issue could be addressed in ActionScript 2.0 with the Delegate class, which allowed you to reroute the scope as desired: // ActionScript 2.0 import mx.utils.Delegate; var audio:Sound = new Sound(); audio.loadSound("externalFile.mp3", true); audio.onSoundComplete = Delegate.create(this, completeHandler); function completeHandler():Void { audio.start(); } The Delegate.create() method accepted two parameters: first, the desired scope; second, the function or method to execute in that scope. Note that because of this change, the function invokes audio.start() directly. In this case, the this keyword no longer refers to the audio instance to which the Examining ActionScript 3.0, the Language | 9
  • 36.
    listener was attached,but rather to the timeline frame in which the listener was assigned. In ActionScript 3.0, method closures let a function or method remember where it was defined. In short, you get the best of both worlds. In the following ActionScript 3.0, written in a keyframe, the reference to this shows that the scope belongs to the main timeline—to the frame in which the function is defined, rather than to the myButton instance. No extra baggage, like the Dele gate class, is required. myButton.addEventListener(MouseEvent.CLICK, buttonHandler); function buttonHandler(evt:MouseEvent):void { trace(this); // Displays: [object MainTimeline] } To reference the button rather than the frame, use the Event.target property of the parameter that is passed into the function automatically by the event. In this snippet, the parameter is arbitrarily named evt: myButton.addEventListener(MouseEvent.CLICK, buttonHandler); function buttonHandler(evt:MouseEvent):void { trace(evt.target); // Displays: [object SimpleButton] trace(evt.target.name); // Displays: myButton } ECMAScript for XML (E4X) FlashhaslongsupportedXML,buttheadditionofECMAScriptforXML(E4X) syntax is a significant productivity boost. Like ActionScript, E4X is an Ecma International specification, which affords a powerful yet concise set of lan- guage constructs for retrieving data from XML, and manipulating it. In ActionScript 2.0, you can certainly navigate among the nodes of a loaded XML document, but the effort becomes progressively more tedious as the XML’s complexity increases. The ActionScript 2.0 XML class provides a handful of necessary navigation properties, such as firstChild, nextSibling, lastChild, and childNodes. Choosing from these, and assuming an XML docu- ment has already been loaded and parsed into an XML instance named myXML, you might select the title of the fifth track of The Beatles’ Abbey Road album (“Octopus’s Garden”) like this: // ActionScript 2.0 myXML.firstChild.firstChild.firstChild.childNodes[4].attributes.¬ title; // Contents of the loaded XML document <?xml version="1.0" encoding="iso-8859-1"?> <library> <artist name="The Beatles"> <album name="Abbey Road"> 10 | Chapter 1: Introducing ActionScript 3.0
  • 37.
    <track title="Come Together"/> <track title="Something" /> <track title="Maxwell's Silver Hammer" /> <track title="Oh! Darling" /> <track title="Octopus's Garden" /> <track title="I Want You (She's So Heavy)" /> <track title="Here Comes the Sun" /> <track title="Because" /> <track title="You Never Give Me Your Money" /> <track title="Sun King" /> <track title="Mean Mr. Mustard" /> <track title="Polythene Pam" /> <track title="She Came in Through the Bathroom Window" /> <track title="Golden Slumbers" /> <track title="Carry That Weight" /> <track title="The End" /> <track title="Her Majesty" /> </album> </artist> </library> In the preceding whopping expression, myXML refers to the parsed XML docu- ment; the three mentions of firstChild refer, respectively, to the <library>, <artist>,and<album> nodes;andchildNodes[4] referstothefifth<track> node (bear in mind, childNodes returns an array, and arrays start at zero). Finally, the attributes property leads to the title attribute of the selected node. E4X lets parsed XML be referenced as if it were a native object. This lets you traverse the loaded data incredibly more intuitively. In the ActionScript 3.0 equivalent, the same track can be referenced like this: // ActionScript 3.0 myXML.artist[0].album[0].track[4].@title; or, thanks to the descendent accessor operator (..), even something as short as this: myXML..track[4].@title; Which would you rather type? In addition, you can compare data using a familiar set of operators. For ex- ample, if the XML document at hand contains numerous recording artists, The Beatles’ <artist> node could be singled out as easily as this: myXML.artist.(@name == "The Beatles") The E4X specification is available in Adobe PDF format at the Ecma International website: http://www.ecma-international .org/publications/files/ECMA-ST/Ecma-357.pdf. Examining ActionScript 3.0, the Language | 11
  • 38.
    Regular Expressions The termregular expressions refers to a set of specialized language constructs for retrieving data from strings (that is, text content), and manipulating such data. In this regard, regular expressions (often abbreviated as regex) shares a number of similarities with E4X: both mechanisms are compact and efficient in their tasks. The syntax of regex tends to be initially harder to grasp than E4X—here, normal letters and punctuation are used to represent whole sets of characters, in addition to filtering rules—but the results are well worth the effort. What can you do with regular expressions? To answer that, consider two fa- miliar methods of the String class, indexOf() and lastIndexOf(), which have been available in ActionScript for years. These methods both accept two pa- rameters: first, a string to look for within a container string; second, optionally, where to start looking within the container string. Each method takes its start- ing point from opposite ends of the container string. var pangram:String = "The quick, brown fox jumps over a lazy dog."; trace(pangram.indexOf("o")); // Displays 13 trace(pangram.indexOf("o", 14)); // Displays 18 trace(pangram.lastIndexOf("o")); // Displays 40 In the first trace() statement, only one parameter is supplied, "o", and the return value is 13 because the letter “o” makes its first appearance at index 13 (starting with 0, the thirteenth character in the string pangram). In the second statement, the return value is 18 because of the optional second parameter 14, which instructs the method to begin after the index of the first “o”. In the third statement, the return value is 40 because the method lastIndexOf() be- gins its search from the end of the string. For simple searches, indexOf() and lastIndexOf() fit the bill, but what if the requirement is something like “find all US ZIP codes,” which could be any 5- number combination, or “find all words in this paragraph that contain three or more vowels”? Suddenly, the task seems considerably more difficult, if not impossible. Believe it or not, the RegExp class in ActionScript 3.0 handles this requirement very easily. The solution requires a pattern of specialized charac- ters, expressed either as an instance of the RegExp class or passed as a parameter to one of the regex-related methods of the String class (match(), replace(), or search()). Given a variable, paragraph, set to the text content of the previous paragraph, the following code shows how to retrieve words with three or more vowels: var re:RegExp = /b(w*[aeiou]w*){3}b/gi; var result:Object = re.exec(paragraph); 12 | Chapter 1: Introducing ActionScript 3.0
  • 39.
    while (result !=null) { trace(result[0]); result = re.exec(paragraph); } // Displays: searches, indexOf, lastIndexOf, requirement, // something, and other words with three or more vowels A full discussion of regular expressions syntax is beyond the scope of this book, but here’s a brief overview of how the previous example works. A variable, re, is set to an instance of the RegExp class by way of the RegExp delimiter operator (/pattern/flags). Between the two slashes of this operator, the pat- tern b(w*[aeiou]w*){3}b spells out the search requirement. After the sec- ond slash, the flags (gi) configure the pattern as global and case insensitive. The RegExp.exec() method executes the pattern on the string paragraph and returns an object (result) that contains information about the search. The search is repeated until result is null. If the preceding example seems outlandish, imagine the same sort of power applied to the validation of user input. You can manage even potentially com- plex requirements without much difficulty. These include questions such as, “Is this email address correctly formed?” (Checking for the “@” character isn’t enough!) “Is this a valid telephone number?” (People might enter anything from (123) 456-7890 to 123.456.46789 to 123456789.) “Has the user tried to sneak in an inappropriate word by using a nonstandard spelling?” Patterns that match these requirements not only find the strings in question, but can also manipulate them in order to, for example, format telephone numbers consistently or replace questionable words with Xs. For an exhaustive and highly regarded treatise on regular ex- pressions, be sure to read Mastering Regular Expressions, by Jeffrey Friedl (O’Reilly). Numerous tutorials are also available online at the unrelated http://www.regular-expressions.info/ website. Namespaces In advanced programming scenarios, the concept of namespaces brings a val- uable new mechanism to ActionScript 3.0. In short, namespaces are essentially custom access specifiers—like public, private, protected, and internal—ex- cept with names you choose. Namespaces let you control the visibility of your properties and methods, even to the point of overriding package structures. They also let you qualify members under various guises. As a quick example, you might develop an AIR application that performs one behavior while an Internet connection is present, and another when no connection is present. By using namespaces, you can define multiple versions of the same method that, Examining ActionScript 3.0, the Language | 13
  • 40.
    for instance, checksan online inventory when the user’s WiFi connection is available but defaults to a cached version otherwise. Or you might define series of variables in several languages, where the value of a variable depends on the user’s regional settings. These distinctions are determined by custom prefixes and the name qualifier operator (::): // Three versions of the same String variable english::newFeatures // Value of "Lots of new stuff" german::newFeatures // Value of "Viele neue Sachen" french::newFeatures // Value of "Plien de nouvelles choses" Namespaces are outfitted with a Universal Resource Identifier (URI) to avoid collisions, and are also used to represent XML namespaces when working with E4X. New Primitive Types ActionScript 3.0 introduces two new primitive types, int and uint, bringing thefulllisttoBoolean,int,Null,Number,String,uint,andvoid (notethechange in capitalization from Void). These new numeric types reduce memory usage in cases when a numeric value need only be an integer. How? The familiar Number data type is an IEEE-754 double-precision floating-point number, which, thanks to its structure, always requires 64 bits of memory. Number ob- jects range from 1.79e+308 (1.79 with over 300 zeroes after it!) down to 5e-324. That’s an unimaginably large range, which isn’t always necessary. Sometimes you just want to count through a for loop, and all you need is an integer. Enter int, which is a relatively small 32-bit number (only 4 bytes), whose range is still an impressive 2,147,483,647 (over two billion) down to−2,147,483,648. That range should do for most of the for loops you’ll encounter. By contrast, uint numbers (unsigned integers) range from 0 to 4,294,967,295, which is the same span as int, but entirely on the positive side of the number line. If your for loop’s counter, or any other integer value, needs a higher range than offered by int, uint makes a good choice—provided the range doesn’t dip below zero. Neither type ever requests more than 32 bits of system memory. One note of caution: because uint values are always positive, take care when trying to subtract a uint into negative territory. A uint rolls around to 4,294,967,295 if you subtract it past zero, as the following code demonstrates. var n:uint = 0; trace(n); // Displays 0 n--; trace(n); // Displays 4294967295 14 | Chapter 1: Introducing ActionScript 3.0
  • 41.
    Exploring Flash PlayerAPI Updates In the “ActionScript 3.0, the Language” section of this chapter, you learned that the ECMAScript specification on which ActionScript is based actually expectsthelanguagetoprovidefunctionalitytailoredtotheplatformthathosts it. In the case of ActionScript, hosts include Flash Player, AIR, and Flash Lite —all various flavors of the Flash Platform. Though each host is designed to meet specific needs—websites, desktop applications, and mobile content, re- spectively—their overlap is considerable. ActionScript 3.0 institutes a signifi- cant restructuring of its application programming interface (API), summarized handily in the colossal migration table available on the Adobe LiveDocs web- site (http://help.adobe.com/en_US/AS3LCR/Flash_10.0/migration.html) and also in the Help panel in the appendices of the ActionScript 3.0 Language and Component Reference, under the heading “ActionScript 2.0 Migration”. In large part, existing functionality has been restructured into packages that make better sense from an organizational standpoint. However, Flash does have a number of philosophical changes in the way it carries out its fundamental tasks. The following paragraphs list some of the more notable updates. As of the publication of this book, Flash Lite does not yet support ActionScript 3.0, due to the inherent processor and memory limitations of mobile devices. The features recounted here apply to Flash Player 9 (and higher) and AIR, but won’t apply to Flash Lite until that runtime adds support for ActionScript 3.0. DOM3 Event Model Before ActionScript 3.0, you could handle events in Flash in at least five dif- ferent ways, some of which were interchangeable: • The legacy on() handler, available since Flash 2 and still in wide use, even in ActionScript 2.0 scenarios, but gone in ActionScript 3.0 • The legacy onClipEvent() handler, also widely used and unavailable in ActionScript 3.0 • The dot notation syntax that combined and replaced on() and onClipevent() (for example Button.onPress = functionDefinition, MovieClip.onEnterFrame, and so on) • The addListener() method of several—but not all!—ActionScript 2.0 classes, such as TextField, Mouse, and MovieClipLoader • The addEventListener() method used by the v2 component set (user in- terface, data, and media components) Exploring Flash Player API Updates | 15
  • 42.
    This varied assortmentwas a result of incremental improvements to Action- Script with every new release of the authoring tool, with the older approaches retained for backward compatibility. For longtime Flash developers, each new technique was simply a small addition to the workflow, but newcomers to recent versions, such as Flash 8 or Flash CS3, were understandably confused by an API with so many seemingly arbitrary possibilities. Are on() and onClipEvent() really so bad? From a workflow standpoint, no. From a practical standpoint, they aren’t nearly as valuable as their dot notation replacement. In ActionScript 2.0,thecombinationofon() andonClipEvent() provideaccess to only slightly more than half the events available to movie clips and buttons. In addition, you can’t assign, manipulate, or remove their event handlers at runtime. Their absence in ActionScript 3.0 marks the end of a long transition period from ActionScript 1.0 through 2.0. Because ActionScript 3.0 relies on a new virtual machine, it can afford to make a clean break in the way it handles events. With one small exception (discussed in Chapter 4), event handling is now consolidated across the board into a single, consistent approach: the EventDispatcher.addEventListener() method. This mechanism is based on the W3C’s Document Object Model (DOM) Level 3 Events Specification (http://www.w3.org/TR/DOM-Level-3 -Events/). This means that in ActionScript 3.0, event handling syntax is the same in nearly all cases, no matter if the event dispatcher is a button, an audio clip, or a loader object for XML or JPEG files. The basic structure looks like this: eventDispatchingObject.addEventListener( EventType, functionToPerform ); Display List API In ActionScript 3.0, movie clips can be instantiated with the new keyword as easily as this: var mc:MovieClip = new MovieClip(); which is more intuitive than what it took in ActionScript 2.0: var mc:MovieClip = existingMovieClip.createEmptyMovieClip(¬ instanceName, depth); And it gets better. Depth management is now automatic. Notice that the ex- pression new MovieClip() does not require a depth parameter. This change is 16 | Chapter 1: Introducing ActionScript 3.0
  • 43.
    due to afundamental new approach to the display of visual objects in Action- Script 3.0: a concept called the display list, which represents the hierarchical display of all graphical objects in Flash Player. This concept is embodied in the DisplayObjectContainer class, the base class for all objects that can serve as visual containers, including movie clips, the new Sprite and Loader classes, and more. Thanks to inheritance, DisplayObjectContainer provides new meth- ods to these classes for considerably better control over the management of object z-order. For example, while the MovieClip class in ActionScript 2.0 fea- tured getDepth() and swapDepths(), the ActionScript 3.0 version offers all of these: • addChild() • addChildAt() • contains() • getChildAt() • getChildByName() • getChildIndex() • removeChild() • removeChildAt() • setChildIndex() • swapChildren() • swapChildtenAt() How’s that for control? These methods are also available to Sprite, which is effectively a movie clip without the overhead of a timeline; Loader, which loads external SWF files and image files (JPEG, PNG, or GIF) at runtime; and any other class in the DisplayObjectContainer family tree. Under the display list system, objects can be re-parented at any time. This ability simplifies cases in which groups of objects need to be manipulated at once. Consider a jigsaw puzzle game, for example. If you want to combine partially solved areas, so that snapped-together pieces move as one unit, you can simply remove the piece from its current parent and add it as a child to the parent that represents the partially solved group. Before ActionScript 3.0, this action would have required individual sophisticated tracking of each jigsaw piece. Exploring Flash Player API Updates | 17
  • 44.
    New Sound APIs FlashPlayer 8 was the first to support 32 simultaneous sound channels, a significant increase from the original eight-sound channel limit. Although present for as long as Flash Player has supported sound, these sound channels, as such, had no clear representation in code before ActionScript 3.0. In previ- ous versions of the language, the Sound class was self-contained, handling all of its functionality in a relatively simple manner, but at the cost of some clarity of purpose. For example, in order to control the volume and panning of one sound distinctly from another, you had to associate each sound with its own movie clip. You made this association by way of an optional “target” parameter in the Sound constructor function. Because target movie clips might or might not contain other content, their ambiguous roles had the potential to confuse. ActionScript 3.0 clarifies programmed sound by complementing the Sound class with three companions: SoundChannel, SoundTransform, and SoundMixer. These new APIs give you more explicit control over imported and embedded sounds. The SoundMixer.computeSpectrum() method even lets you retrieve spectral data from sounds, which you can use to program responses to changes in audio pitch and volume. Binary Data and Sockets The new ByteArray class enables interoperability with existing custom proto- cols, and lets advanced developers read, write, and manipulate data on the byte level. This has led adventurous programmers to cultivate projects previ- ously unheard of in Flash, such as Tinic Uro’s PNG encoder (http://www .kaourantin.net/2005/10/png-encoder-in-as3.html, now updated and featured in the as3corelib library at http://code.google.com/p/as3corelib/) and a dynamic tone generator by André Michelle and Joa Ebert, capable of playing MIDI-like Amiga MOD files (http://8bitboy.popforge.de/). Understanding Players and Support Although this book focuses primarily on the Flash authoring tool, it’s impor- tant to realize that Adobe offers two official ActionScript 3.0 compilers. One of these compilers is built into Flash CS4 itself. As you would expect, this one takes into consideration objects in the document’s Library, as well as global SWF file settings, such as background color and frame rate, as configured in the Property inspector. This compiler can also compile previous versions of ActionScript. Separate from that, there’s the command line compiler included with the free Flex Software Development Kit (SDK) available at www.adobe .com/go/flex_trial/. This second compiler is the one used by the Flex Builder 18 | Chapter 1: Introducing ActionScript 3.0
  • 45.
    integrated development environment(IDE), which doesn’t include drawing tools, timelines, or a library. In addition to ActionScript 3.0, the Flex compiler understands MXML, the declarative markup language used for laying out Flex applications. For want of a library, the second compiler lets metadata embed assets into resultant SWF files. The Flash authoring tool supports only limited metadata, an undocumented feature at the time of writing. These distinct compilers serve independent workflows. To facilitate the de- velopment of RIAs, the Flex SDK features an elaborate framework of user controls and data handlers that aren’t available to the Flash authoring tool, even though the framework is written in ActionScript 3.0. By comparison, Flash offers a modest subset of user controls in its Components panel, includ- ing support for the playback and manipulation of Flash video files (FLV). In the end, there’s only one ActionScript 3.0, and it behaves the same when compiled under either tool. The reason for this consistency is that Flash CS4 and the Flex SDK both publish SWF files for the same Flash Player 9 or higher. It’s quite possible—and often done—to create custom classes that can be used under either circumstance. The concept of the document class (see Chap- ter 6), introduced in Flash CS3, means that an entire application, composed of numerous external classes, can be compiled by Flash or the Flex command line compiler (including Flex Builder) from identical source files. Because ActionScript 3.0 requires AVM2, as mentioned earlier in this chapter, Flash Player 9 is the minimum required runtime to display such content. Flash Player 9 runs on numerous operating systems, including several versions of Windows, Macintosh, Linux, and Solaris. Due to the varied nature of these operating systems and occasional bug fixes required by each, in addition to ongoing new features, Flash Player 9 includes a number of minor point relea- ses, as summarized in Table 1-1. Flash CS4’s default output is aimed at Flash Player 10, which may eventually see a list of minor point releases just as long. Time will tell. To determine what version of Flash Player the user has installed, reference the static version property of the Capabilities class. Table 1-1. Flash Player 9 minor point releases Flash Player version Notable changes 9.0.16.0 ActionScript 3.0, including runtime exceptions and error handling, sealed classes, method clo- sures, ECMAScript for XML (E4X), regular expressions, namespaces, new primitive types, DOM3 event model, display list APIs, new sound APIs, and binary data and sockets. 9.0.20.0 Bug fixes and optimizations related to the Intel-based Macintosh platform. 9.0.28.0 Support for Windows Vista operating system. Addition of ADDED_TO_STAGE and REMOVED_FROM_STAGEeventconstantstoletaDisplayObjectmonitorandknowwhen it can or cannot access its stage property. Security enhancements. Understanding Players and Support | 19
  • 46.
    Flash Player version Notablechanges 9.0.31.0 Support for Linux operating systems. 9.0.45.0 Bug fixes and improvements for Adobe Flash CS3 Professional. Affects only Windows and Mac- intosh platforms. 9.0.47.0 Support for Solaris operating system. Security enhancements. 9.0.48.0 Linux security enhancements. 9.0.115.0 H.264 video and High Efficiency AAC (HE-AAC) audio codec support. Hardware acceleration, hardware scaling, multi-threaded video decoding, and enhanced image scaling. Flash Player cacheenablescommoncomponents,suchastheFlexFramework,tobecachedlocallyandthen usedbyanySWFfromanydomain.FlashMediaServerbufferingmaintainsstreambufferwhile a stream is paused. 9.0.124.0 Media streaming security patch and minor display update for Windows Vista. A full listing of all Flash Player release notes, including bug fixes, can be found at http://www.adobe.com/support/documen tation/en/flashplayer/releasenotes.html. Learning ActionScript 3.0 on the Heels of 2.0 Pretend for a moment you’re a carpenter. For years, you were making do with a hand-crank drill, but then the Macromedia Hardware Company introduced an electric model called ActionScript 1.0 stamped with gold letters on the handle. Beautiful thing! No reason to ever use anything else. Sure, you could operate the drill only within six feet of an electrical outlet (because that was the length of the cord), but the advantages were resoundingly clear. Plus, you could always carry around an extension cable. A few years later, Macromedia announced a new and improved ActionScript 2.0 model. This drill had an optional battery back. For some, the new battery pack was a godsend, because it freed them from the previous six foot limitation. They embraced the new feature and literally found themselves running with it. Other carpenters found the battery pack a bit too advanced. They weren’t sure, for example, if they were supposed to drain the batteries completely before recharging. And hon- estly, that was fine: the drill still had a cord, of course, so they continued within their previous comfort zone, which was still a considerable improvement over the hand-crank days. Carpenters were a happy bunch. Eventually, the Mac- romedia Hardware Company became Adobe. Everyone looked forward to the new drill—ActionScript 3.0—and when it came ... they found that the cord had been replaced with a docking station. Suddenly, carpenters who had opted not to use the ActionScript 2.0 battery pack felt trapped. They had no expe- 20 | Chapter 1: Introducing ActionScript 3.0
  • 47.
    rience with batteries,but if they were going to use an ActionScript 3.0 model, they had no choice. It goes without saying that every analogy has its flaws. Certainly, the changes in ActionScript 3.0 amount to more than the obvious benefit of a battery pack. Clearly, the new APIs are more complex than the question of how to recharge a set of batteries. In any case, ActionScript does a lot more than drill holes! Still, it can be useful to think of ActionScript 2.0 as a preparatory transitional period between, on one hand, the very roots of the language—that is, Action- Script 1.0 and even earlier—and, on the other hand, the current version. As with the carpenter story, numerous features in ActionScript 2.0, such as strict typing (:Number, :Void, etc.) and formalized custom class files, were optional. (Unlike the analogy, those particular features are still optional in ActionScript 3.0.) Voluntary though they were, such then-new conventions were an early invitation to practice a more efficient workflow. Developers who opted to ex- periment with object-oriented programming (OOP), to the point of writing their own custom classes, may feel more at home with ActionScript 3.0 than others. For those who were perfectly comfortable with the conventions of ActionScript 1.0, they might understandably feel trepidation in light of the current version, especially now that ActionScript 3.0 has dropped support for some previously optional features, such as on() and onClipEvent(). Flipping through the ActionScript 3.0 Language and Components Reference takes con- siderably longer than before. Everything has been arranged into a potentially overwhelming new hierarchy of packages. Most of the Help panel sample code has been written as class files, to make it applicable both for keyframe and class file programmers. These changes are big, but not insurmountable. One of this book’s driving purposes is to help you feel caught up, whether or not you pursued the optional new conventions of ActionScript 2.0—the features that, in hindsight, were a gentle ramp up to today’s recommended best practices. The important thing to keep in mind is that ActionScript 3.0 is scalable in terms of complexity. If you want to plunge headlong into OOP principles such as inheritance and design patterns, ActionScript 3.0 will oblige. If you prefer to stick with tradi- tional timeline coding, ActionScript 3.0 will oblige—with a number of provi- sos covered in the following chapters. Deciding to Migrate or Write Code from Scratch If you work with a set of in-house templates, be they FLA files, custom classes, or a combination of both, sooner or later you’ll have to decide how to update them. For the sake of discussion, these files are stable ones that have made your company money for years, and they work just fine. Nonetheless, you’d Deciding to Migrate or Write Code from Scratch | 21
  • 48.
    like to takeadvantage of the speed increases—or any of the other benefits— afforded by ActionScript 3.0. Should you painstakingly tinker with existing files, tweaking as you go, or should you ditch everything and start from square one? Which approach would require less effort? For better or worse, there is no sure-fire way to determine which endeavor is more advantageous in a given situation. While you can theoretically upgrade a FLA file’s Publish Settings to ActionScript 3.0 and compile without errors or warnings, the prospect becomes progressively more unlikely as a project gains in complexity. Chances are high that one incompatibility will occur in concert with many: in other words, when it rains, it pours. That said, here are a few thoughts to consider. If all or most of your code exists on frames in a FLA file, you may have no realistic choice but to migrate the ActionScript in place, for the obvious reason that the code is so closely tied to the file’s visual design. To start from scratch could require careful transportation of symbols from one FLA file to another, possibly including intricate nested timeline effects. For simple banner ads and linear slideshows, an in-place update may not be as difficult as it sounds. Standalone calls to stop(), gotoAndPlay(), and the like, will carry over without a hitch. By all means, select File→Publish Settings→Flash→Script→ActionScript 3.0, and then hold your breath and see what happens. Don’t forget to exhale if the compile works, and frankly, prepare yourself now for numerous entries in the Compiler Errors panel. If any of the frame code involves event handlers, loads external assets, or even calls a new web page (getURL() is now navigateToURL()), you’ll have to update it. The good news is, the Compiler Errors panel is one of many helpful new tools in Flash CS4 (introduced in Flash CS3). This panel not only tells you where the erroneous code is, by class file, scene, layer, keyframe, and line number, it often makes suggestions on what to change, including a list of common migration issues. The Compiler Errors panel and other debugging tools are cov- ered in Chapter 11. If most of your code exists in external class files, your project probably involves more than a smattering of ActionScript. Although this likely means you’ll spend more time on code migration (because there’s more of it!), the fact that your code is separate means you can test and revise each class individually. In either case, frame code or class files, this book will help you get your bearings. 22 | Chapter 1: Introducing ActionScript 3.0
  • 49.
    CHAPTER 2 Discovering WhatYou Need to Work with ActionScript 3.0 Working with ActionScript 3.0 is an equation composed of two parts: you need something to compile a program written in the language, and you need something to display the results of that programming. In compiler territory, you have quite a few development choices. In the most basic approach, Adobe makes the Flex Software Development Kit (SDK) available to the public free of charge (http://www.adobe.com/go/flex_trial/). This SDK includes the full ActionScript 3.0 application programming interface (API), which is the full list of core and Flash Player API classes described in the ActionScript 3.0 Language and Components Reference, published on the Adobe LiveDocs website (http: //help.adobe.com/en_US/AS3LCR/Flash_10.0/). In addition, the SDK includes the Flex framework (component class library) and Flex command line com- piler, letting programmers freely develop and deploy Flex applications using any scripting integrated development environment (IDE). Because the Flex framework is, itself, written in ActionScript 3.0, you don’t necessarily have to learn a new language to use Flex. Without spending a dime, interested pro- grammers can build anything from basic ActionScript 3.0 class files—which you can also write in the Script window of Flash CS4 Professional—to full- scale Flex applications that you can write with Flex Builder 3. Displaying the results of your work requires Flash Player 9 or higher (Flash CS4 publishes to Flash Player 10 by default). That may seem like the easy half the equation, but there are actually several versions of Flash Player 9 and will likely be several versions of Flash Player 10. The following sections give a brief overview of the tools necessary to work with ActionScript 3.0. Later in the chapter, you’ll learn about alternative scripting IDEs that you can use in co- operation with the Flash authoring tool. 23
  • 50.
    Flash CS4 Professional/FlexBuilder 3 The Flash CS4 Professional authoring tool is the latest in a running line of the production tool that originally began life as a vector animation program. When designers and developers hear the word “Flash,” they probably think first of the Flash authoring tool, rather than Flex Builder, even though both applica- tions are Adobe products that publish SWF files for the same Flash Player runtime. In a few words, Flash CS4 can be summed up as the most appropriate toolfortraditionalFlashdesignersanddevelopers.Thisauthoringtoolfeatures numerous panels aimed at drawing and animation—consider the Timeline, Color, Align, Transform, and Tools panels. Flash authoring techniques often take advantage of a timeline metaphor, in which the goings-on of a SWF file are thought of in terms of a playhead moving along a timeline: navigation from one display state to another is the result of “going to” and “playing” desired keyframes. In contrast, Flex Builder can be summed up as the most appropriate tool for traditional programmers, espe- cially those familiar with tools like Borland JBuilder for Java and Microsoft Visual Studio for Visual Basic or C#. In fact, Flex Builder is built on the popular open source Eclipse platform (http://www.eclipse.org/), and you can even buy it as an Eclipse plug-in. Flex Builder is a coder’s environment and, as such, provides no drawing tools or timelines, and only the most basic of color pa- lettes. Even though ActionScript’s MovieClip class features methods such as play(), stop(), and gotoAndPlay(), a Flex Builder developer is more likely to think of movie clips—that is, timelines—in an abstract way, in terms of an object-oriented programming (OOP) point of view. To program and deploy ActionScript 3.0, you need only an ActionScript 3.0 compiler. Flash CS4 provides one, which is used when a FLA file’s publish settings are configured for ActionScript 3.0. The Flex SDK also provides one, which you can use with a command line interface (no graphical user interface, just typing) or Flex Builder 3, which does the command line typing for you. If Flash CS4 (or CS3) isn’t used, then you don’t need (indeed, you can’t create) the FLA file familiar to traditional Flash developers. In either case, you may use any simple text editor at a bare minimum, such as Notepad on Windows or TextEdit on Mac, though most developers type their code into the Actions panel or a Script window of Flash CS4, an edit window in Flex Builder, or one of the external script editors discussed later in this chapter. Flash Player 9 or Higher Once a SWF file is compiled, it must be viewed in some version of Flash Player; specifically, Flash Player 9 or higher, if the SWF file contains ActionScript 3.0. 24 | Chapter 2: Discovering What You Need to Work with ActionScript 3.0
  • 51.
    Generally speaking, thistends to be a straightforward enterprise. As a reader of this book, you’re presumably a Flash professional, which means you build your content in the Flash authoring tool, and publish using either File→Publish or Control→Test Movie. You already have Flash Player installed, of course, so when you launch the SWF file, or view it in an HTML document, you see the content, and then decide whether or not to upload it to a web server. For simple projects, this process is often all it takes. You might, however, find yourself in need of a particular minor point release of Flash Player 9 or 10, like those listed in Table 1-1 of Chapter 1. If you want to display your SWF file in full screen mode, for example, you need to test in Flash Player 9.0.28.0 or higher. If you want to display H.264-encoded high definition video, you need to test in Flash Player 9.0.115.0 or higher. Further, you need to ensure that people visiting your website also have the same minor point release. The Flash authoring tool gives you more than one version of Flash Player for testing during development: debug and release players. Debug Vs. Release Players The application folder of Flash CS4 Professional includes installation files for two distinct versions of Flash Player. These versions are located in Debug and Release subfolders of the following locations: • Windows: C:Program FilesAdobeAdobe Flash CS4Players • Mac: /Applications/Adobe Flash CS4/Players/ These installation files include: • Debug: • Install Flash Player 10 ActiveX.exe: Debug installer for the ActiveX ver- sion of Flash Player used by Internet Explorer on Windows. • InstallFlashPlayer10Plugin.exe:Debuginstallerfortheplug-inversion of Flash Player used by Mozilla compatible browsers. • Install Flash Player 10 UB.dmg: Debug installer for Flash Player on Mac. • Release: • Install Flash Player 10 ActiveX.exe: Release installer for the ActiveX version of Flash Player used by Internet Explorer on Windows. • Install Flash Player 10 Plugin.exe: Release installer for the plug-in ver- sion of Flash Player used by Mozilla compatible browsers. • Install Flash Player 10 UB.dmg: Release installer for Mac Flash Player. Flash Player 9 or Higher | 25
  • 52.
    Both folders, Debugand Release, contain identically named files. Don’t let that confuse you! These installation files let you install debug versions of Flash Player for testing locally inside a browser—then to switch back to release versions any time you please. Debug versions are identical to the non-debug-enabled (release) ver- sions, except that the debug versions contain additional code to communicate with Flash CS4. While convenient, because they avoid the delay of a download from http://adobe.com, these files are limited to whatever minor point release they represent. If the Adobe update utility hasn’t yet updated Flash CS4 on your computer, these installation files might not let you test everything you’d like to from within the authoring tool. The latest installation files are available at http://www.adobe.com/support/flash player/downloads.html. Older versions are archived at http://www.adobe.com/ go/tn_14266/ for testing purposes. To ensure that installations succeed, Adobe recommends that you uninstall existing ActiveX controls and/or plug-ins be- fore re-installing different versions. This can become tedious, so you may want to consider downloading Flash Switcher, a third party Firefox extension to do the work for you. Flash Switcher was written by Alessandro Crugnola and is freely available on his website for Firefox 3 on Windows, Mac, and Linux: http://www.sephiroth.it/weblog/archives/2008/04/flash_switcher_for_win dows_osx_and_li.php Flash Switcher includes the files necessary to test many, but not all, versions of Flash Player. To make additional versions available to the extension, install the desired version by hand from http://www.adobe.com/go/tn_14266/, then select the ex- tension’s icon from within Firefox and select Save As, as shown in Figure 2-1. In addition to installation files, the Release and Debug folders contain a stand- alone executable: FlashPlayer.exe on Windows and Flash Player.app on Mac. Flash CS4 uses this executable to create Projectors or view standalone content. When you select Control→Test Movie, for example, the executable inside the Release folder displays your SWF file in the authoring tool. When you select Debug→Debug Movie, the executable inside the Debug folder is used instead. The parent folder, Players, contains a copy of this executable. This copy is the one used when you launch a local SWF file outside of the authoring tool, for example by double-clicking a SWF file from the desktop. You can control 26 | Chapter 2: Discovering What You Need to Work with ActionScript 3.0
  • 53.
    which version isused—debug or release—by copying (not moving!) the de- sired executable from its respective Debug or Release folder into the Players folder. Debug versions of Flash Player are capable of logging trace() statement output to a text file. For more information on this topic, see Chapter 11. Making Sure Users Have the Necessary Version of Flash Player Flash CS4 provides a convenient mechanism for ensuring that website visitors have the version of Flash Player they need in order to view your content. It’s a simple configuration under File→Publish Settings→HTML, as seen in Fig- ure2-2.Select“DetectFlashVersion”asshown,andspecifythedesiredversion numbers—here, 10, 0, and 2—which indicate the minimum version of Flash Player your content requires. The fourth number, seen in the series 10.0.2.0, identifies the internal build number, which may run a wide range during pri- vate Adobe beta testing but is typically 0 for public releases; in any event, the fourth number is irrelevant for ensuring compatibility in this context. The first number isn’t editable from the HTML tab of this dialog box, and, in any case, needs to be 9 or higher to support ActionScript 3.0. If you choose to Figure 2-1. Adding a version of the Flash Player plug-in to the Flash Switcher Firefox extension Flash Player 9 or Higher | 27
  • 54.
    publish to olderversions of Flash Player, you may change the first number in the version series by selecting this dialog box’s Flash tab, and then changing the Version listbox selection to a previous version of Flash Player. Anything lower than Flash Player 9 will force the Script listbox to change to ActionScript 2.0 or lower. Version detection requires publishing for Flash Player 4 or greater. Employing version detection changes the way the authoring tool writes the HTML it uses to embed a published SWF file. For that reason, it’s useful to understand how the HTML is written by default. At the time this book was being written (before the public release of Flash CS4), the default HTML tem- plate—that is, no Flash Player version detection—generated an HTML docu- ment with inline JavaScript (not an external .js file). This JavaScript embedded the SWF file dynamically, a feature that was necessary for the Internet Explorer browser between February of 2006 and April of 2008. Without such Java- Figure 2-2. Detecting Flash Player version in HTML publish settings 28 | Chapter 2: Discovering What You Need to Work with ActionScript 3.0
  • 55.
    Another Random ScribdDocument with Unrelated Content
  • 56.
    rédigeaient, en donnantsurtout des vers de Verlaine, de Moréas, et de Morice, Léo Trèzenick, l'ancien hydropathe Pierre Infernal, dessinateur au chapeau breton, devenu imprimeur et directeur de journal, au Quartier Latin, simultanément comme en province. Il y avait un dîner intitulé les Têtes de pipes, où allaient certains poètes, qui donna à Vicaire et Bauclair des sources vagues. Willy y débutait alors dans un nuage de calembours et de mélancolie, avec un bruit de sonnette folle, et était la moitié de la direction. Vielé-Griffin y donnait des vers signé Alric Thom. On n'y trouverait point de vers libres, mais beaucoup de bonnes choses, connues depuis par l'impression en volume, pas mal de gaieté et de sarcasme. Tout cela un peu bousingot, mais ce n'est la faute de personne, si les idées nouvelles germent dans les cerveaux jeunes, et que la jeunesse est un peu rive gauche. Lutèce et les Déliquescences sont très rive gauche, et pour cela fort incomplètes comme document à consulter. Car enfin, il y a deux rives. Ces jeunes gens ne s'en doutaient pas trop, et l'un d'eux, Stanislas de Guaïta, a donné la note exacte d'un certain état d'esprit, quand, après avoir énuméré dans une préface à un volume de vers, tous les nouveaux poètes existant à sa connaissance, doutant de son universalité il termina en disant: il y en a peut-être d'autres, mais je ne les connais pas; en tout cas, ils ne viennent pas à mon café. Vicaire et Bauclair ne tinrent point ce langage, n'étant ni naïfs ni occultistes et mages, mais ils agirent ainsi; et le gai déjeuner de soleil qu'ils servirent à leurs contemporains aux dépens de quelques poètes, outre qu'il est fané, paraît incompréhensible, à force de peu parodier les vers connus et classés du symbolisme. On trouvera dans ce volume une étude sur Vicaire où j'explique, plus longuement que je ne puis le faire en cette préface, les pourquois de sa parodie. Les Déliquescences ont eu la même importance que le Parnassiculet; elles n'ont su ni caractériser, ni prévoir, et le fait de railler quelques snobs épris, à l'excès, de nouveauté n'a point d'importance. Ces snobs devenus plus nombreux, cela forme le public. Tout récemment, M. André Rivoire, un charmant poète intimiste mais trop académique, dans une étude sur Albert Samain, un parnassien éclectique qui fit du symbolisme, disait que notre public avait paru être très nombreux, beaucoup plus
  • 57.
    qu'en réalité, qu'ensomme il avait été mince. C'est une erreur profonde. Nous avons eu avec nous, à un certain moment, tous les curieux du vers, et de plus, nous avons eu tous les curieux de la littérature qui s'étaient détachés du vers et qui y revenaient pour nous lire. Nous avons fait une renaissance poétique dans le rythme et la curiosité sympathique des lettrés nous accompagna. Qu'il fut facile de rallier, grâce à nos discordes et en lui offrant des transactions, une partie de ce public bienveillant mais indécis, c'est possible. Le jeu est connu des traditionnistes qui s'appuient sur une gloire de tout un passé à laquelle ils n'ajoutent qu'une faible glose, et dont ils usurpent le rayonnement. Ce sont petites haltes sans importance et réactions fatales et brèves. La masse est toujours enchantée de couvrir des transactions qui prennent des nouveautés ce qu'elles ont de plus simple et se réservent sur le reste; posture facile, opportunisme toujours opportun! C'est même un bien que ces réactions. Elles servent plus tard singulièrement à clarifier l'histoire littéraire. Il y eut dans ces époques d'incertitude et de développement mental incertain, sur lesquelles je n'insiste si longtemps que parce qu'elles ont donné beaucoup plus de résultats que cela n'était alors généralement prévu et que les écrivains dont je parle se sont développés sur les mêmes principes qu'ils énonçaient alors, (toute part faite au progrès), quelques êtres falots, dont le souvenir ne doit point être banni, au contraire, pas plus que celui des petits romantiques; ils furent le sourire de nos années de lutte, si on peut appeler lutte la production paresseuse et tranquille, au milieu de sarcasmes qui ne nous touchaient point. Parmi ces hommes aimables je voudrais citer au moins Baju, Anatole Baju qui fut un brave homme de self-government. En effet, Baju, humble débarqué de la Creuse lointaine, sous couleur d'éduquer les enfants de la laïque de Saint-Denis, loua une mansarde rue de la Victoire et non seulement il y fonda un journal mais il y installa une imprimerie. Ses directeurs de conscience littéraire furent alternativement, ou tout ensemble, je ne m'en souviens plus, M. Paterne Berrichon et M. Maurice Du Plessys; le journal s'appelait le Décadent. Encore qu'il fut
  • 58.
    décadent, Baju louchaitdu côté des Symbolistes. Il pourparla. Peut- être eûmes-nous tort, M. Jean Moréas, qui se voyait grand, et moi- même de l'autoriser seulement à reproduire de nous ce que bon lui semblerait. Baju s'entêta, nous offrit son journal et la rédaction de La Vogue, écrivit un no du Décadent. L'idée de Baju, idée juste au premier chef, était d'être éclectique dans un exclusivisme donné; nous fûmes trop exclusifs et le Décadent retourna aux Décadents, ce qui était fort juste, et puis il mourut, car rien n'est éternel. Le Symboliste, un hebdomadaire à deux sous, que nous avions créé, Adam, Moréas, Laforgue et moi pour être accessible aux petites bourses et avec les capitaux (parfaitement) de la maison Tresse et de la maison Soirat ne vécut que quatre numéros. Un vieux communard l'imprimait dans les fonds de Vaugirard, pour une rétribution, je pense, un peu stricte; le Décadent ne survécut guère au Symboliste. Etéocle et Polynice s'étaient porté des blessures mortelles, et puis la survie du Décadent n'eut qu'une importance relative, il était devenu petite revue; c'était bien gros pour Baju; il y perdait son arome de journal, d'hebdomadaire, ce n'était plus un léger papier drôlet, où toutes les lettres dansaient. Baju avait un imprimeur. Il fut étouffé par le luxe, et depuis il eut des succès politiques; un arrondissement de la Creuse lui donna un jour 2 000 voix, insuffisantes à l'installer parmi nos parlementaires. Il se pourrait que Baju ait été un boulangiste de marque. La Vogue était plus sérieuse; elle fut la première revue symboliste, et si elle mourut jeune, au moins ses collections furent-elles presqu'immédiatement recherchées. On sentit tout de suite combien on avait eu tort de l'acheter si peu, et elle donna aux libraires avisés et à des courtiers teintés de littérature d'assez agréables bénéfices. Elle eut de la gloire mi-vivante mi-posthume. Pourtant, tout en contenant de fort belles choses, et notamment les Moralités légendaires de Jules Laforgue en grande partie, elle était dirigée avec assez de paresse, et son directeur, c'est-à-dire moi, avait une tendance excessive à juxtaposer à de la copie purement littéraire des textes d'érudition qui n'y étaient point absolument nécessaires. Mais on comptait sur l'avenir, et l'on voulait être complet. La collection de
  • 59.
    La Vogue, surlaquelle je n'insisterai point autrement, démontre pourtant deux choses: d'abord que le fameux dénigrement qu'on nous reprocha n'était point notre tendance, et que si nous dénigrâmes nous ne le fîmes que pour notre légitime défense et après d'injustes attaques, puisqu'on ne saurait trouver dans La Vogue d'autres articles critiques qu'un article très camarade que je fis pour l'apparition des Cantilènes de Jean Moréas, en dehors de ceux très intéressants de Félix Fénéon sur les Impressionnistes. Pourtant nous avions le papier tout prêt et la plume alerte et l'on ne nous ménageait pas, mais nous étions fort pacifiques. Tout récemment, j'eus l'occasion de retracer le passé de La Vogue; deux jeunes poètes, Tristan Klingsor et Henry Degron, me demandèrent l'autorisation d'arborer mon vieux titre sur une jeune revue qui devait se conformer, m'affirmait-on, aux traditions intransigeantes de l'ancienne Vogue. Je leur donnai une lettre- préface, on pourrait dire, étant donné l'épigraphe, «Vogue la Galère», auteur Jules Laforgue, parrain de la revue, des lettres de marque. Encore une fois, le petit steamer partit, chargé d'espoirs argonautiques, avec le salut amical de son ancien pilote. Le rôle grave de préfacier que j'avais assumé fait qu'il manque pourtant dans ces pages quelques détails que le côté d'apparat de ma besogne me commandait de passer sous silence. Et, d'abord, je n'y pouvais faire remarquer combien le titre, il est vrai, heureusement corrigé par l'épigraphe, était mauvais. C'est l'éloge de La Vogue et des œuvres qu'elle publia, dans sa première série, qu'on ne pensa jamais en citant son titre, devenu une sorte de nom propre, à la vulgarité du mot «vogue» conçu en son sens ordinaire, et à tout ce qu'il indique de plate poursuite du succès courant, et de course à quatre pattes vers la vulgarité. Le titre avait été trouvé par M. Léo d'Orfer, un décadent qui avait fondé cette revue et m'en avait confié le secrétariat de la rédaction, à cause de sa foi en mon génie et surtout parce qu'il me considérait très apte, en cas de difficultés vitales, à assurer la vie de l'organe. M. Léo d'Orfer avait découvert, c'est trop peu dire, inventé un éditeur, M. Barbou, venu à Paris pour y acquérir un fonds de papeterie au quartier des écoles. M. d'Orfer,
  • 60.
    qui avait lapratique des affaires et le don communicatif du mirage, transforma avec rapidité, semble-t-il, les ambitions de M. Barbou. Quand je vis celui-ci, il ne demandait pas mieux que de fonder une revue et d'éditer tous les livres; il assurait même, à chaque auteur, qu'il tenait à ses œuvres d'une façon toute espéciale; et comme les plus belles choses ont le pire destin, au bout de cinq semaines M. Barbou lâchait pied et repartait à la campagne se refaire une santé. J'avais dû déjà annoncer à M. d'Orfer que je partirais, que je démissionnerais, s'il persistait à vouloir publier, à côté de la revue, un supplément où son intention était de considérer avec indulgence les productions de l'abonné, ou d'amis dont il jugeait indispensable, autrement que littérairement, de publier les œuvres. Ce n'était point que toutes ces pages fussent sans intérêt, mais l'ensemble du choix ne me paraissait pas cadrer avec mes intentions de revue intransigeante. Nous choisîmes donc cette occasion de l'effacement de M. Barbou pour nous séparer, et je fis reparaître, après trois semaines d'intervalle qui me parurent opportunes, La Vogue, mieux à mon image. Ce fut encore un petit épisode de la lutte entre les décadents et les symbolistes sur le même tremplin. Mallarmé m'avait dit quand je lui avais conté l'apparition prochaine de la revue, et son nom: «C'est le dernier titre que je choisirais» je répondis «et moi donc, mais je pense bien le faire oublier.» nous y avons réussi. Ce fut à ce moment que deux excellents écrivains, M. Jean Moréas et M. Paul Adam, jugèrent que le moment était venu de saisir le monde par la voix des quotidiens de la nouvelle bonne nouvelle littéraire. Les tendances nouvelles se vulgarisaient, il se formait des groupes et des sous-groupes, malgré qu'il y eut des individualités suffisantes; donc MM. Jean Moréas et Paul Adam s'en furent trouver, au Figaro, M. Marcade et obtinrent l'insertion d'un manifeste littéraire quelque peu égoïste, où ils dépeignaient le mouvement symboliste à leurs couleurs, en assumaient, de leur propre mandat, la tâche et tentaient de se constituer chefs d'école. On leur en
  • 61.
    adressa de justesreproches, et puis l'on en sourit. On se rendit compte que si M. Marcade avait voulu considérer en MM. Moréas et Adam les chefs de l'école symboliste, c'était pour cette raison seule, qu'ignorant tout à fait du symbolisme, comme de toute autre matière littéraire, il en était réduit à se fier aux lumières des personnes qui prenaient la peine de l'aller voir. Il faut dire aussi que M. Marcade était sourd comme une cave, et qu'il n'eut même de M. Paul Adam, qu'une idée purement visuelle. Seul M. Moréas, dont la voix contenait des tonnerres, put faire parvenir à l'entendement de M. Marcade quelques propos esthétiques. M. Marcade, bon vieillard, portait, il est vrai, tout près de la bouche de son interlocuteur, sa conque auditive, mais pour utiliser cet accueil amène, une voix de stentor était au moins nécessaire. Le lendemain de la publication de ce manifeste M. Paul Adam dit à M. Jean Moréas «On va vous traiter de Daudet» et M. Moréas assura que cela lui était égal; pour l'intelligence de ce propos on se souviendra que Daudet, le plus faible et le moins inventeur des écrivains naturalistes, fut celui qui força le premier le succès, avec Fromont jeune, et plut aux masses en vulgarisant la formule naturaliste. Néanmoins, on ne tint pas longtemps rigueur à ces Messieurs de l'extension de pouvoirs qu'ils s'étaient offerts, ou de l'initiative abusive et usurpatrice qu'ils avaient prise. En tout cas, j'y demeurais fort indifférent; s'ils avaient le Figaro, n'avais-je pas La Vogue, et sachant à quoi s'en tenir, on continuait à marcher ensemble, la jeunesse cordiale étant chez tous (encore que M. Moréas nous devança tous d'un bon lustre), trop forte pour qu'on s'arrêtât longtemps à des misères de publicité. Jules Laforgue était alors à Berlin, ou aux villes d'eaux d'Allemagne, lecteur de l'impératrice Augusta. Cette place lui avait été assurée par les soins de ce sans-patrie de Paul Bourget, chargé par M. Amédée Pigeon, lecteur précédent, de pourvoir à son remplacement. M. Pigeon ayant appris par la voie du Figaro qu'un petit héritage lui incombait, voulait incontinent retrouver ses loisirs et ses travaux de critique d'art. Il fallait un jeune homme aimable et doux, capable de
  • 62.
    ne point s'occuperde politique. M. Bourget pensa avec raison que la pitié universelle de Laforgue pourrait être assez forte pour s'exercer au moins quelques années au profit des pauvres puissants de ce monde, et connaissant l'urbanité exquise de Jules Laforgue, il le fit choisir; c'était d'Allemagne que m'arrivait sur papier bleu criblé de pattes d'abeilles traînées dans l'encre rouge, la copie de Laforgue; sauf vacances. M. Moréas était déjà, depuis plusieurs années, un poète intéressant et élégant. Après avoir fait de bons vers réguliers, il pratiquait le vers libéré, abondait en curiosités rhythmiques, intercalait des poëmes en prose dans des romans réalistes sans considérable portée, et après les Cantilènes, où figuraient des assonnances d'après les chansons populaires, recherchait une sorte de vers libre. Son défaut était de tenir extrêmement peu à l'originalité de ses idées; personne ne pratiqua aussi fort le fameux: «Je prends mon bien où je le trouve», sans avoir l'excuse de Molière, qui, lorsqu'il disait cela, à propos d'une scène du Pédant joué, faisait allusion à une vieille collaboration avec Cyrano, et en effet reprenait une scène ébauchée jadis par lui; c'était de la reprise individuelle. Mais M. Moréas croyant peu à l'idée, et féru de la forme, l'entendait dans un autre sens; outre que ses vers faisaient montre souvent de connaissances étendues, il ne dédaignait pas d'intercaler dans ses œuvres en grande proportion des traductions, ou, selon son expression, des paraphrases. Il y réussissait fort bien. De là une antinomie avec les autres promoteurs du symbolisme, qu'il résolut en s'en détachant lorsqu'il fonda l'Ecole romane, remettant, en somme, lui-même les choses en place. M. Moréas, alors, avait, parmi ses défauts, dont le moindre était de vouloir étendre son importance au-delà du vrai devant les journalistes (nous pensions que c'était aussi un défaut de se soucier des journalistes) une belle qualité, soit un très sincère amour de l'art, qui ne l'a pas quitté, et s'il s'en fait une conception un peu étroite, c'est bien son affaire. M. Paul Adam nous arrivait du naturalisme, il avait subi une de ces condamnations pour liberté d'écrire, fort bien portées depuis
  • 63.
    Baudelaire et Flaubert.Il ne s'en faisait pas trop gloire, et ne se targuait pas de Chair molle. Il était aimable et dandy. Un grand lévrier rhumatisant suivait ses pas; l'esthétique de Paul Adam était alors assez confuse, ainsi que ses rêves politiques, littéraires, industriels, dramatiques, brummellesques. Il travaillait beaucoup et avait une peine infinie à tirer un parti pratique d'une production acharnée. Il y avait, dans ses efforts, de l'inquiétude et du disparate, mais il était déjà plein de talent, encore qu'il n'en fît pas toujours le meilleur usage et qu'il ne contrôlât pas assez l'intérêt de son effort; il était mage et reporter de tempérament, historien en plus, fantaisiste follement et ces quatre courants d'idées n'étaient point sans falotes synthèses. Sa perpétuelle chimère, analogue aux rêveries de Balzac, était souvent distrayante. Un bel amour de l'art le tenait comme nous tous et contribuait à resserrer les liens d'amitié avec lui. C'était Félix Fénéon qui assurait la bonne périodicité de la revue; très dévoué aux poètes, il corrigeait les épreuves, méticuleusement, artistement. Ce fut grâce à lui que nous fûmes réguliers; les articles de critique d'art qu'il nous donna font regretter qu'il s'abstienne depuis longtemps d'écrire. La Vogue avait été une revue de combats et malgré qu'on n'ait pas songé à prendre de temps d'une exposition de théories, une revue théorique, au moins par les exemples. Ces revues, purement littéraires, ne durent pas. La mienne eut trente et un numéros, et puis s'arrêta. Il y eut une seconde série, encore plus brève, en 1889. La Vogue avait fait le départ entre les symbolistes et les décadents. Elle avait reçu des adhésions et des sympathies multiples, entre autres hors frontières celle d'Emile Verhaeren, alors le poète des beaux alexandrins des Flamandes et des Flambeaux noirs. Elle ne faisait que camarader avec des esprits distingués, mais autrement orientés, comme M. Charles Morice dont un bon livre de critique (sauf divergences) présenta un bon tableau de la littérature de cette heure. Laurent Tailhade n'y écrivit pas, parce qu'absent en longue villégiature durant ce semestre et demi que la revue vécut. Maurice Barrès, alors rédacteur au Voltaire, préparait ses livrets et ses
  • 64.
    préoccupations n'étaient pasidentiques aux nôtres; le côté art pur de notre revue l'effarait un peu et nous nous étonnions de ses désirs multiples; nous eûmes aussi des ennemis, je ne m'arrête pas à énumérer des chroniqueurs, c'est à peu près les mêmes que maintenant; mais parmi les poètes, de ceux qu'on rencontrait chez Mallarmé, nous soulevâmes un adversaire, M. René Ghil. M. René Ghil se partageait alors entre le sonnet, l'esthétique et l'épopée. Ses sonnets, il y en a de pires, son épopée, je n'en parle pas, parce que si je ne l'aime pas ce n'est pas une raison pour en dégoûter les autres, et aussi parce que je n'y attache point une extrême importance. Son esthétique c'était l'instrumentation colorée ou l'instrumentation verbale, un commentaire extraordinaire du sonnet des voyelles d'Arthur Rimbaud, une adaptation d'Helmholtz, téméraire héroïque. M. René Ghil était d'une parfaite bonne foi, et l'allure du symbolisme, en ce manifeste de M. Moréas et de M. Adam, et dans La Vogue, lui parut attentatoire; il voulut avoir sa tribune, et fonda, avec M. d'Orfer, la Renaissance, ainsi nommée, je pense, à cause des similitudes que M. Ghil a de tout temps reconnues entre lui et Guillaume-Salluste Du Bartas. De là, il fulmina contre tous l'excommunication majeure, puis la Renaissance ayant été éphémère parmi les éphémères, il fonda les Ecrits pour l'art, où l'on se publiait entre amis, œuvres et portraits. M. de Régnier et M. Vielé-Griffin y parvinrent pour la première fois, de façon publique à l'héliogravure. Le mot symbolisme avait pris dès lors sa carrure et son sens. Ce n'était pas qu'il fut très précis, mais il est bien difficile de trouver un mot qui caractérise bien des efforts différents, et symbolisme valait à tout prendre, romantisme. Paul Adam proposait d'écrire un dogme dans le symbole; le mot dogme répugnait à des tempéraments plutôt anarchistes et critiques comme le mien; c'était Mallarmé qui avait surtout parlé du symbole, y voyant un équivalent au mot synthèse et concevant que le symbole était une synthèse vivante et ornée, sans commentaires critiques. L'union entre les symbolistes, outre un indéniable amour de l'art, et une tendresse commune pour
  • 65.
    les méconnus del'heure précédente, était surtout faite par un ensemble de négations des habitudes antérieures. Se refuser à l'anecdote lyrique et romanesque, se refuser à écrire à ce va- comme-je-te-pousse, sous prétexte d'appropriation à l'ignorance du lecteur, rejeter l'art fermé des Parnassiens, le culte d'Hugo poussé au fétichisme, protester contre la platitude des petits naturalistes, retirer le roman du commérage et du document trop facile, renoncer à de petites analyses pour tenter des synthèses, tenir compte de l'apport étranger quand il était comme celui des grands Russes ou des Scandinaves, révélateur, tels étaient les points communs. Ce qui se détache nettement comme résultat tangible de l'année 1886, ce fut l'instauration du vers libre. Elle est présentée très judicieusement et très exactement par M. Albert Mockel dans ses Propos de littérature, et trop bien pour que je n'y renvoie pas le lecteur. Ce fut au début de la publication de La Vogue que j'allais voir Paul Verlaine. Si Verlaine eût été en France, avant 1880, alors qu'il était parfaitement méconnu, nul doute que je n'eusse cherché à lui témoigner mon admiration, parmi celles peu nombreuses qu'il comptait. Mais, à mon retour en France, il était en pleine gloire. Il ne m'attirait pas d'ailleurs aussi complètement que Mallarmé; on pouvait penser que le meilleur et même tout de lui était dans ses livres. Quoiqu'il en soit, j'attendis une occasion et ce fut pour lui demander sa collaboration à La Vogue que je l'allai voir. C'était Cour Saint-François, presque Cour des Miracles. Sous le tonnerre intermittent du chemin de fer de Vincennes, à côté des boutiques aux devantures à plein cintre, une petite impasse; un chantier de bois appuyait contre le viaduc de longs madriers et des échafaudages savants de poutres équarries décorait l'horizon d'une petite boutique de marchands de vins, où je trouvais Verlaine uniment placé devant un verre; il m'en offrit la rime, car sa plaisanterie était demeurée banvillesque. Il voulut bien me dire, en exagérant amicalement, qu'il connaissait ma jeune réputation, et à ma demande de copie, il répondit par des phrases modestes; pourtant il constata que c'était là une consécration, et que c'était la
  • 66.
    récompense de lavie, au début d'une vieillesse infirme, de s'entendre dire par des jeunes hommes qu'on avait bien fait, et qu'on pouvait être revendiqué par eux, en tant qu'exemple quoiqu'indigne, et presque traité de dieu, comme un ancêtre. Je voulus lui spécifier ce que j'attendais de lui, c'était une suite à ses Poëtes maudits que je savais en train. Verlaine, d'abord, rompit les chiens, biaisa, me parla de Mallarmé dont il me savait le fidèle, me récita des vers de Mallarmé avec de curieuses intonations grandiloquentes, et nous esthétisâmes pour le plaisir d'esthétiser, et de se trouver des points communs. Il me raconta son retour à Paris, et puis ses chagrins, une partie au moins; là dessus un petit bonhomme, un gosse passait, fin et svelte, grêle même. Verlaine l'appela, lui donna un sou pour en user avec magnificence, me dit: j'en ai fait un Pierrot, et récita une courte pièce fort jolie; craignant d'avoir paru trop homme de lettres, et soucieux d'offrir la réciprocité, comme excuse, il s'informa de mes derniers vers, mais je le ramenais à notre sujet qui était lui, et ce qu'il voudrait bien donner à La Vogue. Verlaine me parla de son portrait de Desbordes Valmore, et alla quérir non point son article, mais les œuvres de Desbordes Valmore, mit son lorgnon, leva la tête et, paraissant lire par dessus son lorgnon, droit à l'orifice de son corridor, dans une vieille redingote bleue qui avait des aspects de lévite, il me lut en pleurant quelques beaux poèmes. Cette affaire conclue et des vers promis, une lettre donnée pour prendre chez Vanier le manuscrit de l'article, je pris congé, trop tôt à mon gré et ne songeais qu'au dernier moment à assurer Verlaine d'une infime rétribution, unique dans les habitudes de la Revue; il n'y avait pas pensé, et m'affirma qu'il n'en touchait pas d'habitude de supérieure. Je le revis souvent Cour Saint-François. Dans ce pittoresque quartier populaire, il s'était créé une vie, il contait ses joies matinales à aller clopin-clopant chercher ses journaux place de la Bastille, et assister au chassé-croisé, alors déjà considérable, des omnibus, au passage ouvrier du faubourg Saint-Antoine. Il m'expliqua un jour, et je regrette de ne m'en point souvenir exactement, le plan d'un Louis XVII. Il n'était point tous les jours d'humeur égale et je déclinai de
  • 67.
    publier des pamphletstrès courts et très vifs qu'il eut aimé décocher à qui de droit, c'est-à-dire à Mme Verlaine. Il me conta beaucoup de ce qu'il a écrit dans les Confessions (je sais bien que je ne suis pas le seul à avoir recueilli ces confidences) mais avec un brio, un relief que je n'ai pas retrouvé dans son livre, notamment une promenade au matin dans Paris insurgé, et une lecture de la proclamation du gouvernement de la Commune, à son gré si belle, si fière et tout émanée d'anonymes, ce qui en rehaussait la valeur. Il avait rencontré ces jours-là Goncourt en garde national (ça lui paraissait très drôle). Nous étions compatriotes, étant tous deux nés à Metz, lui par accident; car son père était capitaine du génie qui avait alors comme garnisons Arras, Metz et Montpellier, en sorte que Paul Verlaine eut pu naître félibre; son vrai pays était l'Ardenne. Il se rappelait fort bien impressions d'enfance, assez identiques aux miennes (la ville de province change si peu) de l'Esplanade, dont, hasard amusant, c'est Gérard de Nerval qui parla le premier dans la littérature, de l'Esplanade, superbe terrasse sur la plus jolie vallée, actuellement si bouleversée, hérissée de forts et de glacis, sur les ossuaires de 1870, qu'un Messin ne saurait retrouver après tant de terrassements une seule des mottes de terre qu'il a jadis foulées, et qu'il y a suppression totale de la petite patrie pour lui. Nous causâmes des rues silencieuses où poussait l'herbe près de l'Evêché, et des gens qui eurent comme nous le sort de naître dans cette ville; l'idée que Pilatre des Roziers, l'aéronaute, fut notre compatriote, lui fut agréable, mais le voisinage futur dans le Bouillet avec Ambroise Thomas le laissa plus froid. C'est Nancy qui a assumé la tâche de remplacer Metz et d'en recueillir les nationaux illustres. Nous fûmes, de ce chef, un certain nombre réunis un jour chez M. Poincaré, sous la présidence de M. André Theuriet, de l'Académie française; il s'agissait d'avoir des idées et de dresser vite les bustes de Goncourt et celui de Verlaine dans ce beau jardin de la Pépinière, encore que ces hommes de valeur n'avaient point paré l'Académie de leur reflet plus radieux que celui des palmes vertes. M. Roger Marx avait acquis le concours de
  • 68.
    Carrière pour unbuste de Verlaine qui eut été digne du beau portrait qu'il a peint. Mais dans cette ville, livrée aux plus basses menées nationalistes et à un dégoûtant antisémitisme, on n'a pas le temps de fêter des artistes. Je fis part à Verlaine de mon intention de publier dans La Vogue des œuvres de Rimbaud autres que celles qui figuraient dans les Pactes Maudits, et supérieures aux Premières Communions que le premier numéro de La Vogue avait données d'après une copie. Il s'agissait de retrouver le manuscrit des Illuminations. Verlaine l'avait prêté pour qu'il circulât, et il circulait. Au dire de Verlaine, ce devait être dans les environs de Le Cardonnel qu'on pouvait trouver une piste sérieuse; c'était vague; heureusement Fénéon, consulté par moi, se souvint que le manuscrit avait été aux mains de M. Zénon Fiére, poète et son collègue aux bureaux de la guerre dont Fénéon faisait alors un petit musée impressionniste et un bureau d'esprit à parois vertes, avant qu'il en fît un arsenal, comme assermenté, des anarchistes. Entre temps Fénéon apprenait à tous ses confrères, comme lui commis au bon ordre du recrutement, à trousser cordialement le sonnet, et ce n'est pas une idée sans valeur que d'avoir voulu rendre le sonnet corporatif et bureaucratique. Fénéon apprit de M. Zénon Fiére que le manuscrit était entre les mains de son frère, le poète Louis Fiére; nous l'eûmes le soir même, le lûmes, le classâmes et le publiâmes avec empressement. Verlaine fit une petite préface, pour le tirage à part, étant le seul ayant droit, et ce fut parce qu'il ne se dépêcha point à en écrire une pour la Saison en enfer que le tirage à part, préparé, n'en fut point fait; les Illuminations, sous leur forme de brochure, après qu'un service assez copieux en eût été fait, n'eurent de quelques semaines qu'un seul acheteur; ce fut M. Paul Bourget, à ce que m'apprit le dépositaire, M. Stock. Concurremment à la publication de La Vogue ou un peu après, diverses plaquettes paraissaient dont le but était de répondre à des attaques de juges sévères, ou de fournir quelques explications, car il arrivait que nous en sentions l'opportunité. Ces cahiers parurent
  • 69.
    pour la plupartchez Léon Vanier, alors le grand éditeur des symbolistes, des décadents, avec Verlaine en étoile sur son catalogue. Ainsi fut donné l'Art symboliste de Georges Vanor qui contient des renseignements techniques sur l'esthétique symboliste. Le brillant conférencier était alors un aède jeune et enthousiaste, très intelligent et son petit bouquin, qui demeurera une pièce curieuse, eût été parfait, s'il n'avait jugé nécessaire de couronner le livre par une glose à lui spéciale du symbolisme qu'il désirait chrétien. Cette vue a un peu contribué, ainsi que certaines des théories d'antan de Paul Adam, à entacher le symbolisme, pour certains, de mysticisme occultiste. Mystiques, nous l'étions dans un certain sens, par notre poursuite de l'inconnaissable et de la nuance imprécise; occultistes non pas, au moins ni M. Jean Moréas ni moi. Mais de même que pour le gros public les décadents, les auteurs difficiles, c'était tout un énorme groupe, un peuple d'écrivains qui englobait Goncourt, Villiers de l'Isle-Adam, Poictevin, Rosny, tous les discutés, tous les méconnus, tous les passionnés d'écriture artiste, ou plutôt d'écriture expressive et de forme nouvelle, les occultistes, les symbolistes, les anarchistes aussi ce fut, pour ce même public, une masse en marche. La foule apercevait un brouillard bariolé, avec des lueurs indécises de fanal au-dessus d'une marche naturellement un peu cahotante, et voyait passer sa génération montante, comme dit Rosny, en groupes voisins, mêlés par des conversations engagées, plus indistincts à des haltes où on confrontait des idées et où l'on discutait ensemble, plus confus de la présence d'indépendants égaillés au long des groupes. Longtemps nous ne pûmes espérer prouver à un critique que nous n'étions pas des Rose-Croix; on nous objectait que les Rose-Croix se déclaraient symbolistes, que Péladan c'était presque Paul Adam. Il fallait expliquer qu'il y avait symbole et symbole, symbole religieux, symbole pour Rose-Croix, symbole pour symboliste, variété de symboles pour chaque symboliste; le critique hagard reculait, et s'en allait répétant: les symbolistes sont des occultistes; plus tard, en 1895, lorsque parut mon livre La Pluie et le beau Temps qu'épigraphiait une belle phrase de La Mettrie, le matérialiste pur, dont j'aimai fixer le nom sur un de mes livres, des interviewers qui,
  • 70.
    justement, venaient d'êtrechargés de savoir si la littérature était mystique, religieuse ou pas, vinrent me voir; et quoique je leur en ai dit, quoique je leur ai fait remarquer le nom de La Mettrie, et que j'ai cru devoir leur expliquer à peu près ce qu'il avait été, rentrés à leur journal ils se recueillirent, et conclurent que, plein de mysticisme religieux, je le prouvai en parant ma couverture d'une phrase de La Mettrie, éminemment religieuse et occultiste. Tant le préjugé a de force et roule l'évidence comme paille dans le torrent. A un autre temps, nous fûmes d'un bloc, des anarchistes; on le crut de tous, sans nuance, avec une égale fermeté, avec cette certitude infrangible qui caractérise les reporters. Après l'acte de Vaillant, un journal boulevardier, celui qui règne sur les élégances, le Gaulois, crut bon de réunir dans sa salle des dépêches les portraits des anarchistes intellectuels. Une des lumières du journal, j'aime à le croire, fut détachée chez Vanier, à cette fin d'y prendre et d'en rapporter une collection des Hommes d'Aujourd'hui, intéressante publication hebdomadaire où Verlaine écrivit passablement, qui donnait des biographies et des portraits-charges des hommes du jour, avec plus ou moins de précision et de certitude; l'antichambre publique du Gaulois offrit plusieurs jours à la foule, à côté des images de Laurent Tailhade et de moi, pour lesquels cette attribution d'idées était juste, celle, par exemple, de M. Jean Moréas, qui je pense n'énonça jamais la moindre opinion politique, et s'éloigne de toute question sociale de toute la vitesse de sa trirème. Ceci dit, pour réduire à ses proportions exactes la responsabilité de Georges Vanor dans la comédie des erreurs qui se joua toujours, en ces temps lointains, à propos de nous. Le Glossaire de Plowert, petit dictionnaire à l'usage des gens du monde, moins curieux à certains égards, le fut beaucoup plus à d'autres. Plowert est le nom d'un manchot qui évolue non sans grâce dans un roman de Moréas et Paul Adam, de leur plus vieille manière. Il parut piquant sans doute à Paul Adam de mettre le nom d'un héros à un seul bras, sur la couverture d'un petit volume qui allait
  • 71.
    être écrit parune demi-douzaine de dextres, car Paul Adam n'entendait pas se risquer à donner des néologismes de ses collègues, des interprétations hasardées et éloignées de la plus exacte précision. Il avait la connaissance des bonnes méthodes érudites et aussi des habitudes du journalisme (il y fut toujours expert), il résolut donc d'avoir recours à l'interview, et de nous demander à chacun le choix de nos mots nouveaux, mais point de cette façon verbale de l'interview ordinaire qui laisse tomber des détails, mais de façon scripturaire et, pour ainsi dire, ferme. L'idée de ce glossaire avait été engendrée chez Paul Adam par une commande à moi faite. Un jeune éditeur, M. Dupret, qui, après avoir mis au jour quelques plaquettes curieuses, s'alla retremper dans un fructueux commerce de bois, avait reçu de moi l'offre d'une sorte de grammaire française, avec rhythmique, projet que je reprendrai quelque jour de loisir un peu large. Comme il n'éditait résolument que de petites plaquettes in-32, M. Dupret me proposa d'en éditer les derniers chapitres (nous raisonnions sur plan) ceux qui auraient trait à l'époque que nous traversions, c'eût été une petite grammaire et rhythmique symboliste. Mon indolence était alors assez grande pour qu'il n'existât, de longtemps, de ce petit livre, qu'un schéma détaillé. J'avais conté le fait de la prochaine éclosion de ce livre à mes camarades, et par conséquent à Paul Adam. Le lendemain, Adam vint nous trouver, quelques-uns, dans un café du boulevard d'où nous aimions voir s'écouler les passants de l'heure; on vit bien à son approche qu'il s'était passé quelque chose; le paletot mastic de notre ami, paletot alors célèbre, flottait avec des plis d'étendard. Sur la hampe de cet étendard son chapeau avait une inclinaison martiale comme s'il se fût douté de la victoire d'Uhde. Notre ami abordait avec des performances de galion. Il s'assit et tous ses gestes éclatèrent en munificence. Il nous confia alors que Vanier, consulté par lui sur l'opportunité d'un petit dictionnaire de nos néologismes, complément plus qu'indispensable de mon futur travail, avait adhéré avec empressement à ses projets, et qu'un fort lexique allait naître. Il demandait notre concours avec une face
  • 72.
    rayonnante, et ileût été criminel d'adresser des objections à un ami aussi heureux. Plowert naquit et besogna dare-dare. Nous n'attachâmes pas à son œuvre assez d'importance. A le faire, il eût fallu fondre nos projets et donner, d'un coup, importants, cette grammaire et ce dictionnaire des symbolistes qui eussent été des documents curieux, et qui auraient été fort utiles. Nous érigions ainsi notre monument en face celui qu'élaborent sans cesse les doctes ralentisseurs du Verbe qui s'évertuent à l'Académie. Tel qu'il est et malgré l'abondance de ses fautes d'impression le petit volume, qui ne contient que nos néologismes alors parus, qui n'est qu'un petit répertoire, offre cet intérêt, qu'en le parcourant on pourra voir que tous nos postulats d'alors ont été accueillis, et sont entrés dans le courant de la langue et ne dérangent plus que de très périmés dilettantes. L'automne de 1886, j'allais prendre, au débarqué de l'Orient-Express, Jules Laforgue qui revenait d'Allemagne, décidé à n'y point retourner; il se mariait et essayait de vivre à Paris de sa plume. Par un abandon de ses droits à de petites sœurs très cadettes, Laforgue se trouvait sans fortune aucune, et il n'avait aucune espèce d'économies. Quelques fonds que lui prêtèrent les siens lui fournirent juste de quoi s'installer. Sa santé, assez faible, avait souffert d'un voyage d'hiver en Angleterre, où il était allé se marier, et d'un retour brusque dans un appartement pas préparé en plein froid décembre. Sauf quelques articles au supplément du Figaro, à la Gazette des Beaux-Arts, une chronique mensuelle à la Revue Indépendante, maigrement payée et sans fixité dans les dates, il n'avait rien. La librairie ne voulait point de ses Moralités légendaires, malgré mes conseils il ajournait la publication de ses Fleurs de bonne volonté (que j'ai publiées dans l'année 1888 de la Revue Indépendante); ce livre d'ailleurs ne lui eût rien rapporté pratiquement. Laforgue ne trouva pas, dans Paris, trois cent cinquante francs pour ses Moralités légendaires, et ce fut bientôt la misère entière à deux, sans remède, sans amis, qui fussent en mesure de l'aider efficacement. C'était la détresse fière et décente,
  • 73.
    le ménage soutenupar la vente lente d'albums, de collections, de bouquins rares, et puis la maladie aggravée. Il était à peu près certain d'obtenir un poste suffisamment rétribué dans un pays chaud, en Algérie ou en Egypte (il ne pouvait s'agir pour lui de passer un nouvel hiver à Paris, M. Charles Ephrussi et M. Paul Bourget s'étaient employés à le lui épargner), lorsque la mort arriva, une nuit, soudaine, Mme Laforgue, au réveil, trouvait son mari mort à coté d'elle. Ah! le funèbre enterrement! dans un jour saumâtre, fumeux, un matin jaunâtre et moite; enterrement simple, sans aucune tenture à la porte, hâtivement parti à huit heures, sans attendre un instant quelque ami retardataire, et nous étions si peu derrière ce cercueil: Emile Laforgue, son frère, Th. Ysaye le pianiste, quelques parents lointains fixés à Paris, dans une voiture, avec Mme Jules Laforgue; Paul Bourget, Fénéon, Moréas, Adam et moi; et la montée lente, lente à travers la rue des Plantes, à travers les quartiers sales, de misère, d'incurie et de nonchalance, où le crime social suait à toutes les fenêtres pavoisées de linge sale, aux devantures sang de bœuf, rues fermées, muettes, obscures, sans intelligence, la ville telle que la rejette sur ses barrières les quartiers de luxe, sourds et égoïstes; on avait dépassé si vite ces quartiers de couvents égoïstes et clos où quelques baguettes dépouillées de branches accentuent ces tristesses de dimanche et d'automne qu'il avait dites dans ses Complaintes et, parmi le demi-silence, nous arrivons à ce cimetière de Bagneux, alors neuf, plus sinistre encore d'être vide, avec des morts comme sous des plates-bandes de croix de bois, concessions provisoires, comme dit bêtement le langage officiel, et sur la tombe fraîche, avec l'empressement, auprès du convoi, du menuisier à qui on a commandé la croix de bois, et qui s'informe si c'est bien son client qui passe, avec trop de mots dits trop haut, on voit, du fiacre, Mme Laforgue, riant d'un gloussement déchirant et sans pleurs, et, sur cet effondrement de deux vies, personne de nous ne pensait à de la rhétorique tumulaire.
  • 74.
    La mort deLaforgue était, pour les lettres, irréparable; il emportait la grâce de notre mouvement, une nuance d'esprit varié, humain et philosophique; une place est demeurée vide parmi nous. C'était le pauvre Yorik qui avait eu un si joli sourire, le pauvre Yorik qui avait professé la sagesse à Wittemberg, et en avait fait la comparaison la plus sérieuse avec la folie; c'était un musicien du grand tout, un passereau tout transpercé d'infini qui s'en allait, et qu'on blotissait dans une glaise froide et collante—la plus pauvre mort de grand artiste, et le destin y eut une part hostile, qui ne laisse vivre les plus délicats que s'ils paient à la société la rançon d'un emploi qui les rend semblables à tous, connaissant le bien et le mal à la façon d'un comptable, et ne leur jette pas, des mille fenêtres indifférentes à l'art, de la presse, un sou pour subsister pauvrement et fièrement, en restant des artistes—à moins qu'une robustesse sans tare morbide ne leur permette de franchir, en les descendant et en les remontant ensuite, tous les cycles de l'enfer social. La Revue Indépendante qu'avaient dirigée en 1884 Félix Fénéon et M. Chevrier dans un sens très intelligemment naturaliste, avait laissé de brillants souvenirs, et des personnes songeaient à la ressusciter. M. Dujardin, écrivain des plus médiocres et qui pensait faire une affaire du symbolisme et des symbolistes, ancien directeur de la Revue Wagnérienne, entreprit de la refonder avec MM. Félix Fénéon et Téodor de Wyzewa comme inspirateurs et rédacteurs en chef. Félix Fénéon s'étant presque immédiatement retiré, M. de Wyzewa en demeura le principal moteur et y appliqua ses idées qui consistaient à y faire écrire des écrivains déjà nantis du succès, mais pas encore accueillis par le triomphe. On y voulait servir cette idée du bourgeois lettré que nous indiquions plus haut, que le Mouvement nouveau comprenait Goncourt et Verlaine et Mallarmé, et M. Anatole France, et M. Robert de Bonnières, et M. Octave Mirbeau, en somme ceux que le journalisme littéraire ne mettait pas en première ligne. Il y avait d'ailleurs, à cette époque, un groupe de romanciers psychologues qu'on réunissait dans une sorte de communion intellectuelle, Bourget, Bonnières, Hervieu, Mirbeau, il y avait Huysmans un peu à part, Becque très à part, dont l'heure allait
  • 75.
    approximativement sonner avecles débuts d'Antoine. M. Anatole France n'avait pas encore pris tout son développement ni toute l'ampleur de sérénité qui ont mis si haut son génie ardent et calme. C'était l'auteur gracieux de Sylvestre Bonnard, et le critique littéraire, le meilleur d'un temps où ils ne furent pas extraordinaires; on peut penser sans injustice que chez M. Anatole France, le critique des faits, l'historien de la vie contemporaine, selon la belle méthode neuve qu'il s'est instaurée et l'écrivain original sont plus importants que le critique littéraire. Il était englobé dans cette conception de revue, à côté des précurseurs du symbolisme, déjà connus au moins de nom du grand public, Mallarmé et Verlaine, et que Villiers de l'Isle-Adam, qu'admettaient ou plutôt qu'admiraient tous les novateurs. Laforgue y avait sa place, et moi aussi, mais on entendait ne pas effaroucher le public et ne pas montrer trop tôt les symbolistes, et donner d'eux comme des échantillons importants avant de proclamer toute la sympathie qu'on disait savoir pour nous. Pour des raisons diverses M. Dujardin m'offrit la rédaction en chef de sa revue qui devint dès lors plus nette et plus progressiste et accepta tout le symbolisme en tenant compte, ainsi qu'il me paraissait nécessaire, des efforts intéressants de romanciers comme les Rosny. La revue qui marchait fort bien littérairement périt de la gestion plus que chimérique de son directeur et administrateur, ou du moins passa chez le libraire Savine aux mains de M. de Nion qui en fit la revue des néo-naturalistes, et elle ne fit plus que décliner, passant de mains en mains, sans retrouver un instant l'importance que j'avais pu lui donner en 1888. Le symbolisme avait alors acquis sa pleine importance, car il n'était plus représenté seulement par ses promoteurs, il avait reçu des adhésions précieuses. C'était Francis Vielé-Griffin et Henri de Régnier, sortis avec éclat des premiers tâtonnements, apportant l'un des visions élégantes et hiératiques, l'autre un sentiment très vif de la nature, une sorte de lakisme curieux de folk-lore, avec une liberté encore hésitante du rhythme, mais une décision complète sur cette liberté rythmique. Albert Mockel qui donnait sa jolie Chantefable, et
  • 76.
    Ajalbert, Albert Saint-PaulAdolphe, Retté; il y eut beaucoup de symbolistes, et puis plus encore, et un instant tous les poètes furent symbolistes. C'est alors que chacun tira de son coté, dégageant son originalité propre, complétant les données premières du premier groupe, dont les demeurants Moréas, Adam et moi, eurent à développer et à faire prévaloir chacun sa manière propre; les divergences, qu'on ne s'était jamais tues, mais qui ne pouvaient éclater lors des premières luttes contre des adversaires communs, devenaient nécessairement plus visibles puisque nous avions des idéaux différents. Moréas, d'esprit classique, redevenait classique, Adam reprenait, après une course dans la politique, ses ambitions balzaciennes. Ma façon particulière de comprendre le symbolisme avait ses partisans; bref, nous entrions dans l'histoire littéraire: les prémisses posées allaient donner leurs effets, des surgeons vivaces allaient se projeter, des originalités curieuses s'affirmer à côté de nous, Maurice Maeterlinck, Charles Von Lerberghe, Remy de Gourmont, etc. Ce serait dépasser le sujet de ces notes que de décrire tout le mouvement de 1889 et des années suivantes, encore que certains articles réunis dans ce volume présenteront là-dessus ce que, comme critique, j'en ai pu penser. Un mot encore. M. Henri de Régnier écrivait récemment dans un article que j'étais demeuré à peu près le seul symboliste, presque tous ceux qui furent du premier ou du second ban du symbolisme ayant varié, sur une foule de points, leur façon de voir. C'est leur affaire, et je n'y ai rien à voir qu'à constater, lorsque l'occasion s'en impose, au hasard de mon métier de critique, les variations sur lesquelles je puis donner mon simple avis. Si M. Moréas est arrivé au classicisme pur, non sans le parer de beauté—si M. Paul Adam ne trouve pas l'étiquette assez large pour son effort multiple (ce qu'il n'a point dit, je pense)—si, parmi les autres du second ban, encore que je ne vois qu'un développement et non un changement chez M. Francis Vielé-Griffin, M. Henri de Régnier présente une formule combinée, entre autres
  • 77.
    éléments, de classicisme,de symbolisme et de romantisme,—si M. Maeterlinck n'appelle pas symbolistes ses beaux drames symboliques, ce qui est son droit, tout cela ne constitue pas des raisons pour que je modifie mon art; je fais de mon mieux pour suivre un développement logique, et ne peux me froisser d'être considéré comme d'accord avec moi-même. Il m'a paru nécessaire de reformer l'instrument lyrique. On m'a cru. La bibliothèque du vers libre est nombreuse, et de belles œuvres portent aux dos de leurs reliures des noms divers, illustres ou notoires. Depuis le symbolisme il existe, à côté du roman romanesque et du roman romantique, une manière de roman qui n'est pas le roman naturaliste, qu'on peut appeler le roman symboliste; j'en ai donné qui valent ce qu'ils valent, mais ils ne sont pas ceux du voisin. De même que j'ai toujours dit que je n'entendais pas fournir, en créant les vers libres, un canon fixe de nouvelles strophes, mais prouver que chacun pouvait trouver en lui sa rythmique propre, obéissante toujours, malgré qu'il en aie, sauf clowneries, aux lois du langage, je n'ai jamais pensé à enfermer le symbolisme dans une trop étroite définition. Il y a place pour beaucoup d'efforts sur le terrain de l'analyse caractéristique et de la synthèse du nouveau roman. Un jour peut- être développerai-je avec exemples ce que peut être le roman symboliste; il y en a, et qui ne ressemblent pas aux miens. Mais je passe, et ferai simplement observer à M. Henri de Régnier, qui le sait d'ailleurs, que si je suis resté à peu près le seul symboliste, c'est que j'étais un des rares qui l'étaient vraiment de fond, parce que le symbolisme était l'expression de leur tempérament propre et de leur opinion critique. Et puis, aussi, il faut en tenir compte, les temps ont changé. En 1886, et aux années suivantes, nous étions plus attentifs à notre développement littéraire qu'à la marche du monde. Nous avons édifié une partie de ce que nous voulions édifier, et il est moins
  • 78.
    important que nousn'ayons renversé qu'une partie de ce que nous voulions renverser. Si l'on évoquait le passé de notre littérature et ses écoles variées, comme on fait aux expositions, pour les peuples par des séries de pavillons, le pavillon du symbolisme ne serait point indigne des autres, et pourrait lancer ses clochetons et ses minarets, fièrement auprès des coupoles du Parnasse. Les beautés de l'entrée et du hall central, pour lesquelles, je le déclare avec joie, beaucoup de peintres, de décorateurs, d'harmonistes auraient été convoqués autour de chefs d'équipe, dont je serais, je pense, seraient augmentées de l'inconnu de salles encore non terminées, et dont nous annoncerions l'ouverture pour la prochaine exposition. Le Symbolisme n'a qu'une vingtaine d'années, il lui faut du temps pour produire encore, et qu'on étudie chez lui les symptômes de vieillesse en même temps qu'on en pourra dénombrer et résumer les complexités et les influences. De plus, nous fûmes amenés, à un certain moment, tous les symbolistes, à comparer notre développement particulier à la marche du monde, nous avons tiré des opinions différentes et personnelles, mais à moi il m'a paru nécessaire d'accorder, dans nos préoccupations d'aujourd'hui, une prééminence à l'art social, mais sans rien aliéner des droits de la synthèse et du style. Le peuple comprendra; ce sont ses Académies, et ses critiques jurés qui l'abusent et lui affadissent l'intellect de boissons tièdes. Notre bourgeoisie est saturée de Coppée, elle n'écoute que par exception, elle ne comprend que par hasard et par surprise. Il y a un Quatrième État qui saura écouter et comprendre. Il se peut que cette certitude fasse sourire des chroniqueurs élégants et des penseurs mondains; quoi soumettre au peuple, ces choses que tous jugèrent hermétiques! elles le parurent, elles ne le sont pas en réalité; la preuve est faite, nos jeunes amis de l'Art social le savent, comme ils savent leurs contacts avec le Symbolisme, le vrai, le plus large. La preuve fut faite dans les réunions populaires. Elle le fut aux samedis de l'Odéon et du théâtre Sarah Bernhardt, où les poèmes symbolistes, et les poèmes des vers libristes reçurent un bel accueil,
  • 79.
    qui eût étéplus grand si le spectacle eût pu être plus populaire. La preuve fut faite aussi dans des réunions purement populaires, à but social, où tonnait la voix généreuse de Laurent Tailhade qui, après avoir donné à la bibliothèque du symbolisme, après le jardin des Rêves, ses admirables Vitraux, a dédié à l'art social des poèmes animés d'un rire à la Daumier. C'est devant ces publics nouveaux que les œuvres d'art nouvelles, écoutées avec sincérité, sont applaudies, seront applaudies, et ce qui ne sera pas compris demain le sera après-demain.
  • 80.
    Une campagne duSymbolisme. Articles de la Revue Indépendante 1888 Les pages qui suivent sont extraites passim de douze Chroniques de la littérature et de l'art, publiées dans la Revue Indépendante durant l'année 1888. Elles précisent, sur quelques points, le mouvement. Elles expliquent des états d'esprit. J'ai choisi dans ces articles ce qui se rapportait davantage aux poètes, aux circonstances adventices du mouvement, soit les linéaments d'influence étrangère qui se sont présentés concurremment au symbolisme et ont contribué à son aspect général. De là des études sur Tolstoï. J'ai conservé des pages sur Poictevin qu'on oublie trop. J'ai donné une chronique entière, parce que le groupement des livres de ce mois-là permettait d'esquisser tout le groupement littéraire du moment, avant et en dehors des Symbolistes, au moins d'indiquer une esquisse, de Hugo à Lavedan. Je n'ai pas retouché ni comme fond ni comme forme ces études. Leur seule valeur étant d'être documentaire sur l'état d'esprit des novateurs, et l'essence du Symbolisme en 1888, près des débuts; je
  • 81.
    resignerais d'ailleurs, endes articles d'aujourd'hui, presque tout ce qui se trouve au cours de ces pages. Paysages Par Francis Poictevin Entre tous, M. Francis Poictevin est un artiste sincère et ému. Tourmenté, perpétuellement inquiet du but même de son art, très soucieux des moyens d'expression, inquiet des lignes générales de la sensation, il est de ceux qui poussent le plus vers l'achèvement définitif une page, et non par la surprise du mot, ou l'accord fortuit des sonorités, mais par la recherche d'un ordre logique des mots étiquetant chacun une des variations de la sensation. L'ordre de sensations qui se meut à travers ses livres est une contemplation des choses de la nature en leur accord avec l'âme humaine; avec la sienne surtout, prise comme exemple, car c'est la seule qu'il puisse connaître à fond; non qu'il ne se permette hors de lui-même des divinations, qu'il ne tente de se rendre compte de ce qui peut se passer derrière les grilles perpétuellement closes d'un hôtel vieilli, qu'il ne tente d'animer des profils de jeunes filles, ou des silhouettes d'êtres rencontrés au hasard des courses à travers les paysages; mais ces êtres sont silhouettes ou symboles destinés à marquer les différences entre lui et les autres hommes, et à faire comprendre sa façon différente de saisir et de traduire les phénomènes d'aspect qui, à travers sa rétine, arrivent à son cerveau. A cela, que l'on joigne une grande inquiétude de l'être vrai, latent sous les apparences et les illusions de présences féminines; puis, que chez l'écrivain, homme avant tout de foi, s'est lentement façonnée une manière de panthéisme mystique qui empreint de mouvements quasi humains les eaux, les arbres et les lignes
  • 82.
    d'horizons: et l'onaura la clef de la disposition des idées chez l'auteur des Songes. Le drame étant ainsi compris, c'est-à-dire un personnage unique jouissant ou souffrant par la variation des minutes de la vie extérieure, il est fort inutile à M. Poictevin de donner à ses livres une affabulation compliquée; l'extériorité du drame est toujours, en tous ses livres, homologue: un être souffre ou jouit de la réaction des choses; deux êtres unis souffrent ou jouissent de la réaction du présent et des souvenirs et des sites sur eux, et vivent d'une vie commune remplie par les rêves divergents qu'inspirent les mêmes faits et les mêmes lignes vues par des cerveaux différents. L'historiette qui fait le fond du roman est en général quasi superflue; et M. Poictevin arrive en ce livre de Paysages à la supprimer et se lier à la juxtaposition des sensations pour évoquer, par leur série, le symbole d'une année de vie sans incidents autres que les déplacements de Paris à divers littorals. Deux parties: d'abord, les Paysages—c'est-à-dire des essais de rendre en quelques lignes un aspect fugace. «C'était, sous un jour pluvieux, le jaune mouillé du phare du Cap, vers Bordighère, dans le ciel une nappe citrine laissant transparaître à son milieu un vert d'iris. Au-dessus de la mer se développait une bande gris lilas à déchiquetures. Peu à peu des nues à gauche se trempant fanées, elle s'étendit devant le ciel même, plus doucement que lividement violâtre. Et la mer se mouvait en une somptuosité vieux-vert teintée d'améthystes.» Et s'animent ainsi des coins de Paris, de Menton, de Toulouse, des salles d'attente où l'attention se fixe sur tel ou tel être caractéristique autour duquel s'ébrouent des formes vagues, des sites de Luchon, des Pyrénées, de Fontarabie, du pays basque, de la Bretagne, de la Suisse, du Rhin, de la Hollande, des notations au Bois de Boulogne, sur les cygnes du parc Monceau, et, brusques, des théories sur le choix des fleurs, puis un été en Normandie
  • 83.
    Welcome to ourwebsite – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com