Ethic Solutions Free Webmaster Tools
     
Flash Cookies - Remembering User Music Preference Flash Tutorials : FlashAdvisor.com
Flashadvisor logo
:: Desktop Shortcut
:: Flash Help
Advices from Experts

 Submit Here! · Link to Us · Newsletter · Tell a Friend ·

      Add Tutorial |

 

Advertise here










 

Google

Search WWW   
FlashAdvisor.com

 Home > Tutorials  > ActionScript

Flash Cookies - Remembering User Music Preference

Author: Alexander Jones | Email
Website : www.al3xander.com


Advertisement

This article and tutorial discusses the process of setting a cookie in flash to remember a user's music preference. The user selects a song on initial viewing of the site, then when they come back to the site that song will be played. All source code and files are included along with a step by step tutorial.More...Setting cookies in flash to remember a user's music preference is a relatively simple process if you are familiar with Actionscript; however, many sites do not have this feature and it is extremely useful, and often requested.

To begin we need to start a new flash document. Open flash and create the new document. Create a button, this will be for the first song. When finished, place the button in Scene1 on frame 1. Then create another button, or duplicate the other, for the second song. When finished, place the button in Scene 1 on frame 1 next to the other button. Beside each button create a static text field with text containing the song's name for them to select. Then put a text field above the buttons and titles saying 'SELECT A SONG'.


Now we have a basic framework setup. Next you need to add a dynamic text field to the stage, with nothing typed in it, but large enough for the full song title to fit into. Under properties of the dynamic text field you have just created, set the instance name to: "ctext". This textfield will hold the song title the user selects. Beside this dynamic text field create a static textfield, with the text "YOUR SONG CHOICE IS:". Now it is time to finalize our framework. Click on the first button on the stage, and set the instance name to "btn1", then follow this process and set the instance name of the second button to "btn2".

Lastly you need to find two mp3 files you wish to play in this example. Once you have found them, place them in a new folder on your desktop. Then save the .FLA you are working on into the same folder.

Next you need to go to my site to get the actionscript code, to paste into scene 1 frame 1. Direct link to the actionscript is here: http://al3xander.com/?p=7



Add the preceding actionscript in Scene 1 on Frame 1. Then look through the code and change where it says "FIRST SONG TITLE HERE" to the title of your first song, and "FIRST Mp3 FILENAME HERE.mp3" to the mp3 filename of your first song. Then do the same for the second song in the actionscript. Finally save the file and publish it. Now open it in your favorite browser(firefox of course) and select a song. It should play. When you refresh the page the same song you selected at first will be played.

This is a most basic example but the script is tight and customizable. This can be extended a great deal, and is a good framework for beginners to work with. If you can't get things working please leave a comment, or download the sourcecode files on my "Scripts" page.
Download Source File

| 1 |

Rate This Tutorial :
We hope the information helped you. If you have any questions or comments, please don't hesitate to post them on the Forums section
Submit your Tutorial at Click Here
  

Home | About Us | Contact Us | Feedback | Advertise with us

Best viewed in 800x600 resolution with Internet Explorer.

Site Developed and Hosted by  ethicsolutions.com
All rights reserved with FlashAdvisor

Flash is a registered trademark of Adobe Systems, Inc.

36 users online