Wasnt sure if this counted as Actionscript or what so I just put it in this section. Im working on a Typography ptoject for college and usually I would use google for flash stuff but I need something specific and well...google is like a mindless monkey matching similar words.
I really need to know how to make things ( a ball for example) bounce directly up and down to an audio file, I know it can be done because Ive seen it before but there wasnt a source file or any of the code. I would prefer to get this done before friday,
Im using CS4 if that has any options for this without AS then I havent found them so any help would be much appreciated.
EDIT: also I would like to know if there was a way to make something similar to the Scope visualisation from Windows Media Player.
Flash CS4 - Need quick help
Flash CS4 - Need quick help
This isnt just a gimp mask...This is an S&M gimp mask...
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Flash CS4 - Need quick help
I have a Flash development book on Safari Books Online that outlines how to make the bars that go up and down with the music levels (can't remember what you call those things), so I would figure that would at least be a start on making a ball bounce with the music. I am about to go to bed tonight, but I will try to go through it tomorrow and get you some code snippets to get started with.
The indelible lord of tl;dr
Re: Flash CS4 - Need quick help
Thatd be great, thanks 
This isnt just a gimp mask...This is an S&M gimp mask...
Re: Flash CS4 - Need quick help
You still able to get that code for me?
This isnt just a gimp mask...This is an S&M gimp mask...
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Flash CS4 - Need quick help
Oh crap! Sorry, I forgot about that. Let me check real quick, and I will see if I can get it. BRB
The indelible lord of tl;dr
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Flash CS4 - Need quick help
Ok, I found it, but it takes a bit of preface because the book builds on a single project all the way through. Near the beginning of the book, you create a stereo visualization widget by creating a multicolored gradient bar, and then putting a mask over it to make the gradient bar into about 10 or 12 changing color bars that go up and down with the music. So when this code snippet talks about a mask, that is the mask it is talking about and hopefully could act as a beginning to experimenting with the "peak event". Here is the snippet:
The top loads an MP3 and begins playing it, the bottom portion controls the on/off toggle of the MP3, while the commented portion controls the stereo visualizer. In the section "soundControl.lPeak.barMask.scaleX = channel.leftPeak * 4", soundControl is the widget that was made earlier in the book, while lPeak.barMask are components within that widget (lPeak and rPeak were the left and right visualizers, and the barMask was the mask). I am assuming that channel.leftPeak or rightPeak are the functions you are looking for to experiment with.
Note however that I didn't go through the whole book before shifting gears to PHP, so I don't know in-depth how this code works beyond the normal logic that is evident to all programmers. So if anything is missing, I can try to find it for you. The book is "Learning Flash CS4 Professional" 1st Edition by Rich Shupe in case you wanted to check it out.
Code: Select all
1 var snd:Sound = new Sound();
2 snd.load(new URLRequest("assets/song.mp3"));
3
4 var channel:SoundChannel = new SoundChannel();
5 channel = snd.play();
6 ///////////////VISIALIZATION STARTS BELOW/////////
7 this.addEventListener(Event.ENTER_FRAME, onSoundPlayback);
8 function onSoundPlayback(evt:Event):void {
9 soundControl.lPeak.barMask.scaleX = channel.leftPeak * 4;
10 soundControl.rPeak.barMask.scaleX = channel.rightPeak * 4;
11 }
12
13 soundControl.addEventListener(MouseEvent.CLICK, onSoundToggle);
14 function onSoundToggle(evt:MouseEvent):void {
15 if (channel.leftPeak > 0) {
16 channel.stop();
17 } else {
18 channel = snd.play();
19 }
20 }Note however that I didn't go through the whole book before shifting gears to PHP, so I don't know in-depth how this code works beyond the normal logic that is evident to all programmers. So if anything is missing, I can try to find it for you. The book is "Learning Flash CS4 Professional" 1st Edition by Rich Shupe in case you wanted to check it out.
The indelible lord of tl;dr
Re: Flash CS4 - Need quick help
Thats perfect thanks
got the line moving randomly to the beat of the music, had it all made ready for the code lol Thanks for the help, might actually get a good mark for this project, dont think Il ever come back to Kinetic Typography in flash willingly though. I love using flash but lining all the words up to the audio is a nightmare! lol seems to look and sound fine though, thanks again 
This isnt just a gimp mask...This is an S&M gimp mask...
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm