The Knack to Rotating Device Fonts in Flash 10
Posted in "Flash" at 6:00 am on May 21, 2009 by Allen Rabinovich | 8 commentsIn Flash Player 10, Adobe developers added a great new feature: the ability to rotate dynamic text generated using device fonts already present on the user’s machine, not the fonts embedded in the SWF. However, using this feature is a bit tricky, and we’ll describe two possible methods here.
Rotating device fonts is quite useful in many applications (as labels on a Chart, for example), and not embedding the fonts is essential to keeping the SWFs small and taking advantage of the internationalization already built into the user’s system. In previous versions of the Flash player, rotating dynamic text was only possible if the Sprite containing a dynamic TextField was first copied into a Bitmap object, and then rotated. This somewhat “hacky” approach produced results, albeit not very visually pleasing ones.
In the new Flash player, the new feature is not as simple as modifying the TextField.rotation property — if you set rotation of a TextField to anything other than 0, your text will disappear, just as in previous versions of the player. Instead, there are two new methods of producing rotated text — let’s look at both of them, and then discuss their advantages and disadvantages:
The first method, used in the top row in the example above, simply modifies the rotationZ property of the TextField. This property, newly introduced in player 10, is generally used to rotate display objects in 3D space; however, rotation in Z-plane is mathematically equivalent to the regular, flat rotation. In some sense, it behaves similarly to the “old” method of rotating dynamic text: it first caches text as a bitmap, and only then rotates it. You can ascertain its bitmap nature by simply zooming in on the SWF: you’ll see the obvious pixelation around the edges of the text.
Depending on the end user’s platform (Windows, OS X or Linux), this method may actually produce better-looking results for small to medium font sizes. It’s also quite simple to use — there is only one property to modify.
The second method (used for the bottom row) is using new native AS3 class, called TextBlock. Part of the new flash.text.engine package, TextBlock allows you to generate a special kind of DisplayObject, called TextLine, which can be subjected to all standard DisplayObject transformations.
This method is a bit more involved, because TextLines cannot be instantiated on their own — you have to use the factory within TextBlock to generate them. This method also behaves somewhat differently on different platforms. I have given it a cursory test on OS X and Windows XP, and it appears that on OS X, all but the smallest TextLines are anti-aliased properly. On Windows, however, some of the medium-size lines come out looking very jagged, whereas the smallest and largest font sizes are properly anti-aliased. Of course, another thing to note with this method is that it preserves font glyphs as vector objects: if you zoom in on the SWF, you’ll see that they remain sharp and anti-aliased.
There’s a lot more investigating to do with these two methods, but I hope this will be a good start for you. The code for the example is below.
Continue reading The Knack to Rotating Device Fonts in Flash 10…
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
Astra Stimulus Package
Posted in "Flash, Flex, accessibility" at 1:39 pm on April 15, 2009 by Alaric Cole | 10 commentsWe’re filing late this year but we were determined to get this thing in before midnight. We thought about asking for an extension, but decided the paperwork was too complicated. So here we go, crossing our fingers…
Astra 1.4 is now ready for direct deposit into your Flash or Flex applications.
New this season is a component called Form which will help with those gathering and validating data in Flash. Also notable to mention is that most of Astra is now accessible. We’ve added a section to each component on developer.yahoo.com/flash speaking directly to those trying to get components to work with screen readers. There are also, as always, some nice bug fixes and new features. The full list follows:
Flash
- New Form component and form data manager utility
- Carousel:
- enhanced keyboard navigation
- added accessibility
- fixed bug: null reference error when setting multiple data providers
- Charts:
- allow for negative values in stacked bar and column charts.
- fixed bug in stacked bar and column charts in which markers were sized incorrectly for multiple series.
- fixed bug in TimeAxis in which majorUnit was not being calculated correctly.
- fixed bug in TimeAxis in which minorUnit was not being calculated.
- fixed bug in which
hideOverlappingLabelsstyle did not work on the y-axis - refactored origin axes,
TimeAxisandNumericAxis, to allow for factoring in the label size when calculating amajorUnit. - added option to
CategoryAxisto allow for a more systematic dropping of labels when there is not enough space for all categories on the axis. - fixed bug in which null values break line series.
- fixed bug in NumericAxis in which external data was not being casted as a Number.
- allow option for rotating text when fonts are not embedded.
- fixed bug in which Cartesian Charts, were not being updated when the length of the
dataSourcewas different. - added enhanced styling of series by allowing the specification of fill, border and line color and alpha styles.
- added option of styling a highlighted zero gridline when the zero is beyond the origin of a
NumericAxis.
- Menu:
- enhanced keyboard navigation
- fixed bug in labelField property
- added support for non-XML data providers
- added beta accessibility implementation
- fixed bug where focusing out would not close menus
- MenuBar:
- enhanced keyboard navigation
- added beta accessibility implementation
- added support for non-XML data providers
- added labelField property
- added support for disabled menu bar items
- Tree:
- Fixed out-of-bounds index error that appeared under certain conditions.
- improved keyboard navigation
- added events for opening and closing of nodes
- added accessibility implementation
- added TreeEvent
- AlertManager:
- fixed issue with keyboard focus on disabled controls
- made some properties publicly accessible
- added beta accessibility implementation
- AudioPlayback:
- enhanced keyboard navigation – added keyboard support for volume control
- made some properties publicly accessible
- added accessibility implementations for subcontrols (volume, current track)
Flex
- AutoCompleteManager:
- Added ability to retrieve specific popup instances and control them
- Enhanced algorithm for target resizing and moving
- IPv4AddressInput, TimeInput, TimeStepper, DropdownColorPicker:
- Added accessibility implementation
Utils
- Improved performance of layout for very large containers
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
Creating Accessible Components in Flash and Flex (Part 2)
Posted in "Articles, Flash, Flex, General, accessibility" at 5:54 am on January 12, 2009 by Alaric Cole | 5 commentsIn this article, I’ll go over the steps needed to enable accessibility for a custom component. While it takes a bit of getting used to, I think you’ll find that enabling accessibility for your components is not only beneficial to the many users who would like to interact with your component, but helps you to fine-tune and further enhance your components in general. To enable use with screen readers, follow these three (simple?) steps:
- Determine object role
- Create the Accessibility Implementation class for component
- Add accessibility tie-ins to component class
a) Create a placeholder for the staticcreateAccessibilityImplementation()method
b) OverrideinitializeAccessibility()method
c) (Flex only) Add AccessibilityClass metadata
Continue reading Creating Accessible Components in Flash and Flex (Part 2)…
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
Flash 10 Experiments: The Warholizer (Loading and Processing Local Images)
Posted in "Examples, Flash, Flex, General" at 10:21 am on December 22, 2008 by Allen Rabinovich | 3 commentsOne of the new features in Flash Player 10 is the ability to read local files. We’ve been looking at this feature for some of our upcoming components, and built a small example that demonstrates how to load, display, and process local images. This example, dubbed “The Warholizer”, allows you to open any image file on your machine, and without uploading it to the server, extract the image’s bitmap data, and run it through some color filters, achieving an effect not unlike the one in some of Andy Warhol’s work. Try it out by dropping in a photo of your own for those 15 minutes of fame (though make sure the image is not too large: Flash has an upper limit on the size of bitmaps):
The code for the example is below the fold.
Continue reading Flash 10 Experiments: The Warholizer (Loading and Processing Local Images)…
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
Creating Accessible Components in Flash and Flex
Posted in "Articles, Flash, Flex, General" at 6:00 am on December 5, 2008 by Alaric Cole | 1 commentIt’s been in the works for a while, but I finally had the chance to focus on making ASTRA components more accessible. Accessibility is not something many developers look at, but it’s slowly gaining ground. For many developers, even figuring out how to enable the built-in accessibility of Flash components is a job. But when you create custom components, implementing accessibility is another job entirely. Accessibility doesn’t come for free.
| This set of articles will be geared towards component developers who want to ensure compatibility with screen readers. However, any developer will find this information useful, especially those want to learn how accessibility works in Flash. |
To begin my assessment of ASTRA components, I first had to learn to use a screen reader. I installed a trial of JAWS for Windows, which is the de facto screen reader technology, especially in regards to Flash. It’s important to note that although I develop on a Mac, I have to use Windows for accessibility testing. This is because Flash accessibility is based on Microsoft’s Active Accessibility standards, and only work on Windows machines. It can be argued that real accessibility is quite limited on the Mac, so this is more of an OS X limitation than a limitation of Flash. I also installed the Flex scripts add-ons, which are touted to provide more fine-grained info for the screen reader when using accessible Flex components.
Using a screen reader, I quickly discovered, is a more involved process than it might seem. Your natural tendencies and habits have to be thrown out the window. For example, opening a browser window with an embedded swf, my first inclination was to use the mouse to navigate to a text input control and start typing. That didn’t work as planned. For one, a typical user of a screen reader is not going to be grabbing the mouse first thing, but using keyboard navigation to interact with an application, so I’d already cheated. Along with this, because of the way JAWS works, navigating to an input field won’t necessarily allow you to begin editing text–you must enter into “forms mode” in order to even start typing.
Once I got the basics of using JAWS down, I started to test our components. My original assumption was that the components would “mostly work” because many of them are based on lower-level components which have accessibility implementations built.
I was “mostly wrong.” A component is not the sum of its parts, in regards to a screen reader. For a component to be successfully understood by the user, it needs its own accessibility implementation built from scratch.
In the next article I’ll discuss what steps I took to create those implementations.
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
3D with Flash 10 (part 2)
Posted in "Flash, General" at 8:41 am on November 12, 2008 by Michael Hoch | 5 commentsOverview
When I came across Flash 10 two things caught my attention: 3D Effects and PixelBender Filters. This post will explore the former: Flash 10 adds a set of utility functions to do 3D Effects that were previously difficult or costly. I wanted to explore the possibility to export 3D Models from 3D animation packages to Flash 10 directly. Now, there are existing 3D engines like Papervision, Away3D, and Sandy that provide the functionality for rendering 3D objects and scenes. There are also functions for reading in data from 3D formats like 3DMax. However, the purpose of this blog post is an exploration of the new functionality offered in Flash 10 and describe a minimalist approach to how to render a 3D object using some of these new functions.
Note: The proper version of Flash Player is not installed or JavaScript is not enabled. Unable to display SWF content.
New functions
Vector
Flash 10 introduces the notion of typed arrays – arrays that can only contain values of a certain type – which improves performance and makes your code also more transparent. We can use it to store the vertex data of our 3D object (as well as a similar vector for our indices that define the face set). You can simply create an empty Vector and then push the vertices:
var vertices3D:Vector.<Number> = new Vector.<Number>();
vertices3D.push(x, y, z);
You can also pre-specify the size:
var vertices3D:Vector.<Number> = new Vector.<Number>(30);
vertices3D[0] = x;
vertices3D[1] = y;
vertices3D[2] = z;
or just pass in an array:
var vertices3D:Vector.<Number> = Vector.<Number>([ 0.3, 0.7, 0.1 ]);
Watch out for not using “new” when initializing a Vector with an array.
Perspective Projection
Once we have our vertex data we can set up our rendering pipeline with a perspective projection. Flash 10 offers the class PerspectiveProjection that allows us to set the projection center and the field of view through properties.
var pp:PerspectiveProjection = new PerspectiveProjection();
pp.projectionCenter = new Point(0, 0);
pp.fieldOfView = 45;
Project Vectors
Next, we use the projection matrix and one of the new 3D utility functions to project our vertex data into 2D space. Below we use the typed array vertices2D to hold the resulting data (note that this function also calculates the t-value of the uvtData which can be used for texture mapping).
m:Matrix3D = pp.toMatrix();
Utils3D.projectVectors(m, myMesh.vertices3D, myMesh.vertices2D, myMesh.uvtData);
Draw Triangles
Finally, we can draw our resulting 2D mesh on the screen using the new drawTriangles() function. This function takes our calculated 2D vertex data array, the original index data, and specifies which sides should be rendered through the culling parameter. A parameter of TriangleCulling.POSITIVE results in only positively wound triangles to be drawn.
container.graphics.clear();
container.graphics.beginFill(0xbbbbbb, 1);
container.graphics.lineStyle(0, 0×666666, 1);
container.graphics.drawTriangles(myMesh.vertices2D, myMesh.indices, null, TriangleCulling.POSITIVE);
Adding interactivity
In order to add interactivity – say rotate our object via mouse movements – we can introduce one additional step before we call projectVectors(): We can use the new Matrix3D functions to add translation and rotation parameters.
m2:Matrix3D = new Matrix3D();
m2.identity();
m2.prependTranslation(1, 0, 5);
m2.prependRotation(rotY, Vector3D.Y_AXIS);
m2.prependRotation(rotX, Vector3D.X_AXIS);
m2.transformVectors(myMesh.vertices3D, myMesh.vertices3D2);
Utils3D.projectVectors(m, myMesh.vertices3D2, myMesh.vertices2D, myMesh.uvtData);
Export from 3D Package
Now that we can render 3D objects we like to use polygonal models from a 3D package. There are a set of ASCII formats that can easily be converted to ActionScript arrays (e.g. VRML or obj). In case of the open source animation system Blender there are also scripts that directly export to Actionscript compatible with Sandy, Papervision and Away3D. It is easy to create a similar script to export to a simple AS3 mesh class that holds the data for our vertices3D, our indices of the face set, as well as provides the arrays for vertices2D and uvtData.
See some results of simple 3D objects:
Note: The proper version of Flash Player is not installed or JavaScript is not enabled. Unable to display SWF content.
Note: The proper version of Flash Player is not installed or JavaScript is not enabled. Unable to display SWF content.
Attached is the source for the 3d Cube.
… to be continued
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
3D with Flash 10: Simple Way First
Posted in "Flash, Flex, General" at 6:00 am on November 10, 2008 by Allen Rabinovich | 8 commentsAs you are probably well-aware, Flash Player 10 was recently released. In this milestone release, Adobe once again introduced a number of great new features, making the player ever so powerful and useful in a wide range of projects. As we are actively exploring the new player for the many upcoming components and libraries in the ASTRA toolkit, we thought it would help to dedicate a few blog posts to the features we found most interesting.
To start off, we’ll take a look at the feature we like to call “the new dimension.” For the first 9 versions, the native rendering in Flash was limited to the Cartesian coordinates. During that time, many ways to “fake” 3-dimensionality were invented and publicized, from the simple “skewing” methods to entire bitmap-based 3D rendering libraries, like Papervision and Alternativa. Now, in the 10th version of Flash, a fair amount of 3D rendering capabilities have finally become native.
To check out this new feature, take a look at a simple application (Note that you need to install Flash Player 10 to see it):
Note: The proper version of Flash Player is not installed or JavaScript is not enabled. Unable to display SWF content.
Notice that instead of the old-time z-plane rotation (DisplayObject.rotation), we can now rotate a display object in all three planes (DisplayObject.rotationX, DisplayObject.rotationY, and DisplayObject.rotationZ), with perspective distortion thrown in for free. Also, in addition to the x and y coordinates, we can modify the z coordinate, which is visually equivalent to “scaling” the display object, but doesn’t actually change the scale values.
The beauty of this new feature is that it preserves the relation among coordinate systems of nested display objects. What does that mean? Well, let’s say you had a few display objects that you wanted to place in a stack, and then observe that stack as a 3D object — well, long story short, you can do just that. Any changes to the 3D coordinates of the parent display object propagate down to the child, and so we can take the example above, and kick it up a notch:
Note: The proper version of Flash Player is not installed or JavaScript is not enabled. Unable to display SWF content.
Now we’re cooking with gas! With just a few lines of code (included below the cut), we put together a simple and elegant way to look at a stack of images.
These newly added features for creating 3D interfaces will greatly facilitate building rich interactive applications, but they are not quite perfect. As Justin Everett-Church once explained, using these properties is akin to creating “postcards in space” — it’s still a far cry from creating true 3D objects and environments, because modifying the three dimensions of rotation and position of planar objects doesn’t deal with more complex issues like back-face and occlusion culling, drawing primitive elements in 3D, etc. We’ll look at new features that go further in enabling more complex 3D work in the next post.
The MXML code for the examples above is below the cut.
Continue reading 3D with Flash 10: Simple Way First…
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
Yahoo! Open Strategy (Y!OS) for the Rest of Us
Posted in "Articles, Flash, Flex, Web APIs" at 4:44 pm on October 29, 2008 by Alaric Cole | 2 commentsIn the last article, I hinted at Yahoo!’s Open Strategy, and mentioned that there were a few tools available for Flash and Flex developers: http://developer.yahoo.com/flash/yos. We’ve polished it up and it’s ready for release. So head on over and start developing!
To read more about Y!OS, check this out.
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
With a Little App from my Friends
Posted in "Articles, Flash, Flex, General, Web APIs" at 5:59 am on September 23, 2008 by Alaric Cole | 3 comments
No doubt you’ve heard a little something about Yahoo!’s new open strategy. If you attended Open Hack Day, you would’ve even been able to use the new Social APIs, which allow you to build powerful social applications on our Yahoo! Applications Platform (YAP).
Not to let down the Flash folks, we’ve created some nice AS3 APIs that let you easily integrate social data and create a Flash or Flex application easily in YAP. There’s even a great Yahoo! theme for Flex applications, to give you a standard look and feel right from the start.
If you’re itching to see what this is all about, it’s currently available as a preview release at http://developer.yahoo.com/flash/yos. While you won’t be able to actually use the services (sorry, coming soon), you can get a head start on learning the system and even begin developing your apps, as the code and documentation are all there for the taking. There’s even lots of source code for example applications, so you can be one step ahead of your friends.[Edit: it's now released!]
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!
Yahoo! Music API: Listen
Posted in "Flash, Flex, General, Web APIs" at 5:00 am on September 8, 2008 by Alaric Cole | 3 commentsThe Yahoo! Music API is up and running. You can browse similar artists, gather more info than you ever wanted to know about a particular artist, get lists such as the most popular artists, and get user recommendations and ratings, to name a few. There’s also an easy-to-integrate Flash video player to let you embed music videos on your site.
The API has a liberal Flash policy file, so Flash and Flex developers can use it in their applications worry-free. Time to hone those E4X skills.
Note: The proper version of Flash Player is not installed or JavaScript is not enabled. Unable to display SWF content.
The above example shows the top 25 artists in a Flex BubbleChart. The y axis shows popularity, with the most popular artists on top. The x axis shows the change since the last time the chart was taken, and the size of the bubbles is determined by the track count of the artist on Yahoo! Music.
Hover your mouse over the bubbles for more info. Click here for the source. (Note that this example also covers custom data functions for using complex XML in Flex charts, if you are so inclined.)
Share: on Yahoo! My Web | on del.icio.us | digg it! | reddit!

Copyright © 2007 Yahoo! Inc. All rights reserved. Privacy Policy - Terms of Service
Powered by WordPress on Yahoo! Web Hosting.