A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11249 Flash Movies | 9 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: kyo
» Title: building estructure
» Description: explosion of building estructure made by swift3D
» More by kyo


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6393 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Webdancer's Web Site
» Comments: Webdancer's, an artistic adventure in 3d graphicsbr>


Random Links | Add your own Flash Related Links
Flash Tutorials 1197 Tutorials 7 New Tutorials Added!
What's New | Top100

» Let Photos Show Your Happy Family this Christmas and Upload YouTube
» PowerPoint show to DVD slide show--- PPS to DVD
» How to burn FLV to DVD for Mac
» How to Create Christmas Flash Greeting Ecard with photos and music
» Getting Started In Flash
» How to convert FLV video to MP3 audio for Mac OS
» Join flv videos together with just a few clicks
» How to convert flv file to avi for mac os x
» How to Create Christmas Flash Greeting eCard without programming skills
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Senior Web Designer
Aquent
US-GA-Atlanta

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Audio

Categories Flash MX Audio Player
Author: Tim Murray | Website: http://www.gmg.com.au |

 
Page 12
«prev ... 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... next»

Adding a thumb dragger to the slider

Time to add a button to our slider that we can drag back and forth to position the playhead. To do this, we will need a button to drag. So create a button named "dragger", create a layer above the highlight layer and name it "dragger" as well, and put your new dragger button on that layer. Give it an Instance Name of "draggerBTN". We will need this to access our dragger in code to find out where it is and to move it.

For starters, we will just make it move along the slider as the sound plays. When we have that working, we will add code to let us control the sound playback by dragging the slider.

To keep the next bit of math simple when we work out where to put our dragger when the sound is playing, we need to align the registration point of the dragger with the top left of our highlight, like this:

When it is aligned, double-click on the dragger button to edit the graphics and put it where you want it. Make sure that you move all of your keyframed graphics when you do this!

Now that we have done our alignment visually, we won't have to compensate by doing weird coding! Using this approach, we don't need to add corrections to our formulas to compensate for where the registration point is for the dragger. We get rid of a lot of "+4.5" and "-5" sort of things from the code that never make sense when you go back and try to modify it later.

Flash is a visual tool: try to work visually as much as you can and only add code as a last resort.

The code we need is basically the same as the code that we used for the progress bar. We have to go up from the mover movie clip to where our sound is, work out what the current frame is as a fraction of the total frames, and calculate where that position is along our 170 wide progress bar. Once we have that value, we need to go up to our draggerBTN and move it to that position.

Time to add another function to our functions layer:

function setDraggerPosition() {
 var targetPosition = 170 * _parent._parent._currentframe / _parent._parent._totalframes;
 draggerBTN._x = targetPosition;
}

Now we need to create a dummy movie that won't be seen and will simply hold a bit of onEnterFrame code that will call our setDraggerPosition function to move our dragger as the sound is playing. So go back up to the progress-bar movie clip and create a layer named "movieMover", draw in a rectangle, convert the rectangle to a symbol (F8) named "mover".

This code needs to go on the mover movie clip to call the setDraggerPosition function:

onClipEvent (enterFrame) {
 _parent.setDraggerPosition();
}

I don't really want the mover movie clip to be visible, so let's set its Alpha to 0% in the Properties panel and we're done.

Test the movie (Ctrl+Enter). When you hit play, the slider should move across as the sound plays. We haven't got any code on the dragger yet to handle dragging: we're going to do that next! But we have a little problem when we get to the end of the sound: it loops back to the start again and continues playing. If you want to, this may be fixed by replacing the setDraggerPosition function with this code:

function setDraggerPosition() {
 var targetPosition = 170 * _parent._parent._currentframe / _parent._parent._totalframes;
 draggerBTN._x = targetPosition;
 if (_parent._parent._currentframe == _parent._parent._totalframes) {
 _parent._parent.gotoAndStop(1);
 _parent.playBTN._visible = true;
 }
}

The "if" statement checks to see if the playhead is at the end of the sound. When it gets there we put it back to the beginning and stop playing. We also show the Play button again for the visitor.

As an exercise, you could add a Loop button toggle that works similarly to the Play/Pause button. When the Loop button is active, the movie would loop continuously; when the Loop button is inactive, the sound playhead would return to the beginning of the sound and stop.

Save now.

«prev ... 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... next»

» Level Advanced

Added: : 2004-02-17
Rating: 8.35 Votes: 62
Hits: 2769
» Author
Tim is a co-director of the Glasson Murray Group, providing quality graphic design, illustration, 3D visualisation, interactive environments, virtual reality, multimedia and website services.
» Download
Download the files used in this tutorial.
Download (2157 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES