| By Danny Patterson | Article Rating: |
|
| August 3, 2005 02:15 PM EDT | Reads: |
39,805 |
The implementation of this history class is also simple. The example above uses two navigation components. The following is the class code for those two components:
// SiteNavigation.as
class SiteNavigation extends MovieClip {
private var buttonOne:MovieClip;
private var buttonTwo:MovieClip;
private var buttonThree:MovieClip;
private var buttonFour:MovieClip;
private var history:History;
function SiteNavigation() {
history = History.getInstance();
buttonOne.onRelease = function() {
if(this._parent.history.addItem('One')) {
this._parent._parent.gotoAndPlay('One');
}
buttonTwo.onRelease = function() {
if(this._parent.history.addItem('Two')) {
this._parent._parent.gotoAndPlay('Two');
}
buttonThree.onRelease = function() {
if(this._parent.history.addItem('Three')) {
this._parent._parent.gotoAndPlay('Three');
}
buttonFour.onRelease = function() {
if(this._parent.history.addItem('Four')) {
this._parent._parent.gotoAndPlay('Four');
}
// HistoryNavigation.as
class HistoryNavigation extends MovieClip {
private var backButton:MovieClip;
private var forwardButton:MovieClip;
private var history:History;
function HistoryNavigation() {
history = History.getInstance();
backButton.onRelease = function() {
this._parent._parent.gotoAndPlay
(this._parent.history.previousItem);
}
forwardButton.onRelease = function() {
this._parent._parent.gotoAndPlay
(this._parent.history.nextItem);
}
Conclusion
The Singleton pattern is both a simple and proven design pattern for restricting instantiation and for providing a global access point. A variation of this class is the Multiton pattern, which also restricts instantiation, but allows for a fixed number of instances.
This article was originally published on Community MX (www.communitymx.com).
Published August 3, 2005 Reads 39,805
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Danny Patterson
Danny Patterson is a Consultant
specializing in Flash and Web technologies. Danny is a Partner and
Author at Community MX (communitymx.com) and a member of Team Macromedia
Flash. He is a Certified Advanced ColdFusion MX, Flash MX and Flash MX
2004 Developer. You can check out his weblog at DannyPatterson.com.
![]() |
SYS-CON Belgium News Desk 08/03/05 01:41:16 PM EDT | |||
Macromedia Flash - How To Use the Singleton Design Pattern. Design patterns are standardized solutions to common programming problems. It's good to use design patterns for two simple reasons. First, it's faster (and many times better) to implement a time-tested design pattern as opposed to developing a custom solution. Second, collaboration with other developers increases when common practices are used. |
||||
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Adobe May Cooperate with Apple to Transplant Flash Player to iPhone
- Ph.D. in Twitter Anyone?
- Eolas Sues the Internet
- Adobe LiveCycle Enterprise Suite 2 for Cloud Computing
- Adobe Betas Target RIAs and Cloud Computing
- Special Report on the Emerging Cloud Computing Trend
- Adobe Cans Another 9% of its Workforce
- My Thoughts on Ulitzer
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Ulitzer Live! New Media Conference & Expo
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Cloud Executives Feature on Cloud Computing Expo Power Panel
- Software Flexibility in the Cloud - Part 4 of 5
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- Is Microsoft as Free as Open Source?
- Adobe Reader Sued
- Adobe Unveils LiveCycle Enterprise Suite 2 for Deployment in the Cloud
- Where Are RIA Technologies Headed in 2008?
- Cover Story: How to Increase the Frame Rates of Your Flash Movies
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Your First Adobe Flex Application with a ColdFusion Backend
- Adobe Flex 2: Advanced DataGrid
- i-Technology Blog: Death-Knell For "Rich Media? Hardly!
- Adobe/Macromedia - Microsoft, Look Out!
- How To Create a Photo Slide Show ...
- Adobe Flex Interface Customization - Themes, Styles, Skins
- Personal Branding Checklist
- Has the Technology Bounceback Begun?
- "Real-World Flex" by Adobe's Christophe Coenraets




































