-
Senior Member
Well, I have fixed the fla for you. Only first 3 songs currently + some code in the prev/next/contract/expand buttons.
But you should listen to hp3, if you want to do your life easier, you could use only 2 frames and change songs to be loaded through the list in the array or something (I would try that way). Then again, if you are not very comfortable with arrays and changing variables dynamically, you could continue with this.
-
when you are developing an application in Flash, I think it is best to attept to keep all code in frame 1 as much as possible. Spreading code across frames is typical for presentations, but for applications you generally run into problems when the code is all over the place. Mind you, this is a rule of thumb, not a requirement.
when making a sound application using sound objects, you usually declare the sound object once, then assign new sounds to it through loadSound or attachSound. It is unneccessary and not a good plan to re-create a sound object just to play a sound.
so in your case create a sound object once in frame 1 (see below) and reuse it.
you have buttons in the interface to select prev/next tracks
when you click a button it should:
determine previous or next track
load a new mp3,
You could do all this with 2 functions.
Think of all of your sound urls and names as a list stored in an array. Prev and Next buttons just move through the array.
For the expand and contract, you dont need to change frames either. You can show and hide the contracted version using the _visible property.
Below is the basic concept of your application, but coded within one frame. You may need to modify some target paths depending upon whether your buttons are within mcs or not.
Code:
/*
create 1 mc for contracted player
create 1 mc for expanded player
put all code and mcs in frame 1
*/
expandedmc._visible = false; // default to hiding expanded mc
mp3Player = new Sound();
// list mp3 urls
mp3URLS = new Array("url1.mp3",url2.mp3","url3.mp3"...);
count; // declare global variable
// load next sound
function getNext(){
mp3Player.stop(); // stop current sound
count = (count <= 0) ? mp3URLS.length - 1 : count - 1;
mp3Player.loadSound(mp3URLS[count],true); //stream the mp3
}
// load previous sound
function getPrev(){
mp3Player.stop(); // stop current sound
count = (count == mp3URLS.length - 1) ? count = 0 : count + 1;
mp3Player.loadSound(mp3URLS[count],true); //stream the mp3
}
// assign functions to button events
nextButton.onRelease = getNext;
prevButton.onRelease = getPrev;
// assign expand/contract interface code to button events
expandButton.onRelease = function () {expandedmc._visible = true}
contractButton.onRelease = function() {expandedmc._visible = false}
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|