I was able to get a little farther, I created a class that extends sprite and added in two getters and setters for startX and startY. I'm getting another error now though on the two lines of code below.
Code:
this.getChildByName("myBall_"+i).x = this.getChildByName("myBall_"+i).startX+Math.sin(angleX)*range;
this.getChildByName("myBall_"+i).y = this.getChildByName("myBall_"+i).startY+Math.cos(angleY)*range;
It says that startX and startY are not propertys of type DisplayObject. Why is it considering what I would think would be Sprite as a display object? The full code is below.
Thanks,
Saveth
Code:
package com.crylounge
{
import flash.display.*;
import flash.media.*;
import flash.net.*;
import flash.utils.ByteArray;
import flash.events.*;
import flash.geom.*;
import com.crylounge.ExtendSprite
public class RaveWaveformVisualization extends BaseVisualization
{
private var angleX:Number = 0;
private var angleY:Number = 0;
private var range:Number;
private var xspeed:Number = .1;
private var yspeed:Number = .1;
[Embed(source="/images/AnimateBall.swf")]
[Bindable]
public var AnimateBall:Class;
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);
makeCircles();
}
override protected function drawVisualization(e:Event):void
{
if( !this.visible ) return;
SoundMixer.computeSpectrum(spectrum, true, 2);
var vol:Number = 0;
for (var i:uint = 0; i <256; i++) {
var fft:Number = spectrum.readFloat()*12;
//vol is percieved loudness - generated by combining all 512 'lev' values//
vol += fft;
range = fft*50;//vol*2;
if (this.getChildByName("myBall_"+i)) {
this.getChildByName("myBall_"+i).scaleX = this.getChildByName("myBall_"+i).scaleY = fft;
this.getChildByName("myBall_"+i).x = this.getChildByName("myBall_"+i).startX+Math.sin(angleX)*range;
this.getChildByName("myBall_"+i).y = this.getChildByName("myBall_"+i).startY+Math.cos(angleY)*range;
angleX += xspeed;
angleY += yspeed;
}
}
}
public function makeCircles():void {
for (var j:uint = 0; j <256; j++) {
var eachBall:ExtendSprite = ExtendSprite(new AnimateBall());
eachBall.name = "myBall_"+j;
eachBall.x = 380 - 5;
eachBall.y = j*2+30;
eachBall.startX = eachBall.x;
eachBall.startY = eachBall.y;
this.addChild(eachBall);
this.rotation = 45;
this.x = 300;
this.y = - 180;
}
}
}
}