A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Music Player with Options - Shared Objects

  1. #1
    Junior Member
    Join Date
    Jan 2005
    Posts
    22

    Music Player with Options - Shared Objects

    I have been attempting to create a music player on my website in which you can choose the song you want to listen to you. Also I am making it so once you choose that song it will store it in a SOL file so when you launch the site again it will start playing the song you chose last time. Here's what I have for my first frame:

    Code:
    local_data = SharedObject.getLocal("user_data");
    stored_user_name = local_data.data.user_name;
    test.text = stored_user_name;
    if (stored_user_name=1) {
    	mysound = new Sound();
    	mysound.attachSound("The Used - Blue and Yellow");
    	mysound.start();
    }
    if (stored_user_name=2) {
    	itsound = new Sound();
    	itsound.attachSound("Greenday - Holiday");
    	itsound.start();
    }
    I have two buttons at the bottom for choosing the song. Button one:
    Code:
    on (release) {
     local_data.data.user_name = 1;
     local_data.flush ()
    }
    And button two:
    Code:
    on (release) {
     local_data.data.user_name = 2
     local_data.flush ()
    }
    Lastly I have a dynamic text field named "test" which displays the number chosen.

    What happens is when I start the flash, it plays both songs. Also if I were to click button two, the text field wont change to a 2 until the page is refreshed(since the number is stored in memory of the computer). So why won't it play one or the other? Did I make a mistake in the code?

    In case you didn't notice, I use numbers to represent what song is supposed to be played. When they hit button 1, the number one is stored in memory and then it checks the if statement. If the number is 1, it plays the first song.
    Last edited by gamerkd15; 01-26-2007 at 11:58 PM.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Your if statements are wrong. Change to this:

    if (stored_user_name==1) {
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Jan 2005
    Posts
    22
    Thanks it works now. I guess in actionscript you never use the =?

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    In if statements you always have to use the ==
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center