Hi
I’m not so good in flash and i have small request.
I have purchased this item http://activeden.net/item/bubbles-flow-sound-visualization/80653 from activeden.
This is an MP3 sound visualization… plays only mp3 and i want to convert this someway in a shoutcast visualization.
This is Main.as
package
{
import flash.display.MovieClip;
/**
* Main FLA class.
*/
public class Main extends MovieClip
{
public function Main():void
{
var box:ProjectorBox = new ProjectorBox(
590, //bubbles flow width
300, //bubbles flow height
0, //flow direction (0 = bottom->top 90 = left->right 180 = top->bottom 270 = right->left)
20, //cells count
30, //default cell radius
10, //cell speed multipier
1.16, //sound impact (0 = no sound impact on speed higher value = higher impact to speed)
2, //blur quality (1 = low 2 = medium 3 = high)
1, //blur strength ratio (1 = default higher ratio = stronger blur)
0.8, //maximum cell alpha level (from 0 to 1)
0.5, //level of alpha modification by camera focus (0 = no alpha changese 1=max alpha changes)
0.04 //speed of focus change
);
addChild(new SimpleProjector(box, 'sample.mp3', 10));
}
}
}
And this is SimpleProject.as
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.ContextMenuEvent;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
/**
* Class that create bubbles animation
* @author Łukasz Zieliński
*/
public class SimpleProjector extends MovieClip
{
private var _cells:Array = [];
private var _focus:Number = 10;
private var _focusCouner:Number = 0;
private var _desiredFocus:Number = 10;
private var _box:ProjectorBox;
private var _soundChannel:SoundChannel;
/**
* Create bubbles animation
* @param box object that holds parameters of bubbles animation.
* @param soundURL MP3 file URL
* @param loops number of loops to play
*/
public function SimpleProjector(box:ProjectorBox, soundURL:String = null, loops:Number = 0)
{
_box = box;
rotation = _box.rotation;
if (_box.rotation == 90 || _box.rotation == 270) {
y = _box.width / 2;
x = _box.height / 2;
}
else {
x = _box.width / 2;
y = _box.height / 2;
}
for (var i:int = 0; i < _box.cellsCount; i++)
{
var cell:Cell = new Cell(_box);
_cells.push(cell);
addChild(cell);
}
addMask();
mouseEnabled = false;
mouseChildren = false;
addEventListener(Event.ENTER_FRAME, projectCells);
addEventListener(Event.ENTER_FRAME, changeFocus);
if (soundURL) {
var sound:Sound = new Sound(new URLRequest(soundURL));
_soundChannel = sound.play(0, loops);
addEventListener(Event.ENTER_FRAME, processSoundAmplitude);
}
}
/**
* Here i check amplitude of sound and apply it ot speed of bubbles.
*/
private function processSoundAmplitude(e:Event):void
{
if (_soundChannel.position == 0) return;
var amp:Number = 0.5 * (_soundChannel.leftPeak + _soundChannel.rightPeak);
_box.cellSpeedMultipier = amp * _box.cellSpeedSoundModification + 1 - _box.cellSpeedSoundModification;
}
/**
* For every frame, update the virtual camera focus.
*/
private function changeFocus(e:Event):void
{
_focusCouner += _box.focusSpeed;
focus = Math.sin(_focusCouner) * 5 + 10;
}
/**
* Add rect mask to animation.
*/
private function addMask():void
{
var m:Sprite = new Sprite();
m.graphics.beginFill(0);
m.graphics.drawRect( -_box.width / 2, -_box.height / 2, _box.width, _box.height);
m.graphics.endFill();
addChild(m);
mask = m;
}
/**
* Makes one cell projection.
*/
private function projectOneCell(cell:Cell):void {
var scale:Number = _box.CAMERA_LEN / cell.spaceZ;
cell.x = cell.spaceX * scale;
cell.y = -cell.spaceY * scale;
cell.scaleX = scale;
cell.scaleY = scale;
}
/**
* Makes all cells projection.
*/
private function projectCells(e:Event):void
{
for each(var cell:Cell in _cells) {
projectOneCell(cell);
var blurLevel:Number = Math.abs(cell.spaceZ - _focus);
if (_box.blurLevel > 0) {
cell.filters = [new BlurFilter(blurLevel * _box.blurLevel, blurLevel * _box.blurLevel, _box.blurQuality)];
}
else {
cell.filters = [];
}
cell.alpha = 1 - _box.alphaModification * blurLevel / _box.CAMERA_LEN;
cell.alpha *= _box.alphaLevel;
}
_focus += (_desiredFocus - _focus) * 0.1;
}
/**
* Virtual camera focus.
*/
public function get focus():Number { return _focus; }
/**
* Virtual camera focus.
*/
public function set focus(value:Number):void
{
_desiredFocus = value;
_focus = _desiredFocus;
}
/**
* Desired virtual camera focus (it smoothly changes focus).
*/
public function get desiredFocus():Number { return _desiredFocus; }
/**
* Desired virtual camera focus (it smoothly changes focus).
*/
public function set desiredFocus(value:Number):void
{
_desiredFocus = value;
}
}
}
There are 2 other .as files but i don’t think they are needed.
So. What do i must change in this codes to make this stream my shoutcast radio and not mp3 files.
I hope this is something simple.
Thanks