Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








Animated Sine Wave


Hi I wonder can anyone help.

I want to create a spectrum analyser with several grpahical elements one of them being a sine wave. the analyser is a real one using generater vars from swiftmp3. Havent got in to actionscript too much so Im not sure where the best place to start is. Would this be something totally generated by math continuously or some kind of programmatic animation of bezier curves.

Please help

Pete




FlashKit > Flash Help > Flash ActionScript
Posted on: 08-28-2001, 09:29 AM


View Complete Forum Thread with Replies

Sponsored Links:

Sine Wave
I'm trying to just draw a static sine wave on the stage. How do I do this? I've seen some that map dots to the Math.Sine function, but I'm trying to do it with a line or path...I need to see some code, though. I'm new to Actionscripting, so dots or lines or whatever is fine. Would appreciate the help.

View Replies !    View Related
[F8] Sine Wave Help
I want to create a background like on the psp and ps3 but I cant figure out how to animate the waves. How could i do this?

View Replies !    View Related
Ask Some Help With Sine Wave
i use this .fla
and try to make it changing colours.....
like gradient, changing colours non-stop(look like equalizier)

sorry i'm a newbie pls help

thx for anyone who helping me!!!!!!!!!!!!!!

View Replies !    View Related
Sine Wave Stuff
I'm trying to put together an interactive sine wave generator where the user can input amplitude and frequency values and have an animated sine wave on the screen display the corresponding amplitude and wavelength. So to that end, I'm trying to accomplish any of the following:

Draw a static sine wave (amplitude 1, WL=2Pi) on the screen, ideally without using a bunch of dots mapped to a sine function. Any way to do it with a line/path?

Create the input text to accomplish this.

Animate the sine wave in a box on the stage and have it "loop" easily.

Any help greatly appreciated

View Replies !    View Related
Sine Wave Animation
Hello from Germany

at first sorry for my bad english i hope you can help me anyhow

i am trying to animate some sine waves with actionscript, during my research i have found the great code from hgseib (Link: http://www.seibsprogrammladen.de/fra...ispiele/flash6 -> Zeichnen ...Sinuswelle). The script works very well but it slows down hardly my computer if i animate 3 or more waves in that way. My question: has someone of you any ideas to optimize the script from hgseib or another script wich makes the same?


Code:
var cBogenmass = Math.PI/180;
var cHoch = 106;
var cLinks = 0;
var cRechts = 628;
var cStepps_pro_draw = 230;
var cVorschub = (cRechts-cLinks)/cStepps_pro_draw; //ca. 2.7
var cDreh_pro_time = 2*cBogenmass;//Halbwellen
var cDreh_pro_draw = 1*cBogenmass;//Geschwindigkeit
var cRadius = 50;
// globale
var gDaempfung = 0.99;
var gDrehung = 0;
//

_root.paint_mc = _root.createEmptyMovieClip('welle4', _root.getNextHighestDepth());
_root.paint_mc = _root.createEmptyMovieClip('welle3', _root.getNextHighestDepth());
_root.paint_mc = _root.createEmptyMovieClip('welle2', _root.getNextHighestDepth());
_root.paint_mc = _root.createEmptyMovieClip('welle1', _root.getNextHighestDepth());

_root.attachMovie("balken","balken",_root.getNextHighestDepth());
_root.balken._x = 0;
_root.balken._y = Stage.height - _root.balken._height;



function fSinuswelle(vDrehung,farbe,staerke,nr,cRadius)
{
with (_root["welle"+nr])
{
clear();
var r = cRadius;
var y = cHoch+r*Math.sin(vDrehung);
var x = cLinks;

lineStyle(staerke, farbe, 100);
moveTo(x, y);
for (var vTime = 0; vTime<cStepps_pro_draw; vTime++)
{
vDrehung += cDreh_pro_time;
r *= gDaempfung;
y = cHoch+r*Math.sin(vDrehung);
x += cVorschub;
lineTo(x, y);
}
}
}

_root.onEnterFrame = function() {

gDrehung+= 0.05;
fSinuswelle(gDrehung,0xffffff,3,1,cRadius);
fSinuswelle(gDrehung,0xdddddd,2,2,cRadius+30);
fSinuswelle(gDrehung,0xcccccc,1,3,cRadius+60);
fSinuswelle(gDrehung,0xcccccc,0.5,4,cRadius+90);
};

View Replies !    View Related
Sine Wave Problem
ok, i am trying to create a rightward moving sine wave with a fill underneath it, so it looks like a ripple. my problem is for some reason, i can get it to move leftward, but when i try to invert it, i get the bottom right hand corner up in the middle.

here's my code:

NbrControlPoints = 20;
StartX = 0;
EndX = Stage.width;
BottomY = Stage.height;
WaterLevel = Stage.height/2;
WaveHeight = 30;
WaveSpeed = .0005;

_root.onEnterFrame = function()
{
this.clear();
this.beginFill(0xFE9919, 100);
this.moveTo(StartX, BottomY);
for (x = 0; x < NbrControlPoints; ++x)
{
var r = x/(NbrControlPoints-1);
px = EndX + r*(StartX - EndX);
py = WaterLevel + WaveHeight*Math.sin(r*Math.PI*2 + getTimer()*WaveSpeed);
this.lineTo(px,py);
}
this.lineTo(StartX, BottomY);
this.lineTo(EndX, BottomY);
this.endFill();
}

and i missing something stupid that is making this happen? i've been troubleshooting this for 2 hours and the math is now making my head hurt.

any help would be appriciated.

View Replies !    View Related
Sine Wave To Stop At Target
Hi guys wondered if someone can help me with this problem.
I am trying to get a shape to move in a sine wave path to another target shape. when reached it will stop at the coordinates of the target shape but I don't know how to go about it can anyone help.
thanks in advance

View Replies !    View Related
Harmonic Effects On A Sine Wave
I had posted a portion of this a couple of days ago but thought I would post the rest in case it might be useful. I hope all the code gets attached. It is helpful for demonstrating the effects of harmonic content in a power system on the sine wave. The individual harmonic percentages are expressed as a percentage of the fundamental (sine wave). I am attaching the script in parts because Attach Code will not let me attach it all in one go.

Here are the first 400 lines







Attach Code

//This is designed for MX 2004
//I think the movie works best at about 30 fps
fscommand("allowscale",true);
fscommand("fullscreen",true);

mouse_listener = new Object();
mouse_listener.onMouseDown = function() {
recalculate_THD();
movesliders();
}
Mouse.addListener(mouse_listener);
//update the harmonics array based on the digital input
//redisplay that digital input with the correct number of decimal places
//calculate the sum of the individual harmonics and update the display
//update the THD display value
//
function recalculate_THD() {
total_harmonic_distortion = 0;//initialize this variable
for(var i = 1; i < harmonics.length; i++) {
harmonics[i]["myamount"] = Number(this.sliders["digital" + i].text_holder.harmonic_percent.text)/100;
this.sliders["digital" + i].text_holder.harmonic_percent.text = String(limit_decimals(Number(harmonics[i]["myamount"])*100));
total_harmonic_distortion = total_harmonic_distortion + Number(harmonics[i]["myamount"]) * Number(harmonics[i]["myamount"]);
}
total_harmonic_distortion = Math.round(Math.sqrt(total_harmonic_distortion)*10000)/100;
this.harmonicsdata["harmonics_value"].text = String(total_harmonic_distortion);
}

//resposition the slider buttons according the the harmonic percentages currently contained in the array
function movesliders() {
for(var i = 0;i < harmonics.length; i++) {
this.sliders["button" + i]._y = -harmonics[i]["myamount"]*100;
}
}

function update_digital_input() {
for(var i = 1; i < harmonics.length; i++) {
this.sliders["digital" + i].text_holder.harmonic_percent.text = String(limit_decimals(Number(harmonics[i]["myamount"])*100));
}
}

function sinewaves_defined_enterframe() {
this._parent._parent.sine.sinewave.onEnterFrame = function() {
if(this.i >= this._parent._parent.res*10) {
this.i = 0;
}
var current_x = this.i;
update_xy_array (current_x);
this._parent._y + add_harmonics(current_x) * my_yscale / 100;
this.i++;
}
}

function add_harmonics(i_value) {
my_yvalue = 0;
for(var k = 0; k < harmonics.length; k++) {
my_yvalue = my_yvalue + 100 * Math.sin(2*Math.PI*i_value*Number(harmonics[k]["myorder"])/res)*Number(harmonics[k]["myamount"]);
}
my_yvalue = my_yvalue * 0.8;
return(my_yvalue);
}

function update_xy_array (currentvalue) {
//push the latest value onto the array
calculated_xy_pairs.push({myx:String(currentvalue),myy:String(add_harmonics(currentvalue))});
//if the length of the array is longer thanthe display area is wide, knock off the first element of the array
if(calculated_xy_pairs.length*my_xscale > oscope._width) {
calculated_xy_pairs.shift({myx:String(currentvalue),myy:String(add_harmonics(currentvalue))});
}
//clear the line and redraw it
sine.sinewave.clear();
sine.sinewave.lineStyle(1,0x00FF00,100);
for(var i = 0; i < calculated_xy_pairs.length-1; i++) {
sine.sinewave.moveTo((-calculated_xy_pairs.length+i)*(my_xscale),Number(calculated_xy_pairs[i]["myy"]));
sine.sinewave.lineTo((-calculated_xy_pairs.length+i+1)*(my_xscale),Number(calculated_xy_pairs[i+1]["myy"]));
}
}

function makeslider(mypath,number_of_sliders,color1,color2,linecolor,slotcolor,leftmargin,mylabels) {
var mylabels,slotcolor;
var mypath,number_of_sliders,mywidth,leftside,rightside,topside,bottomside,slider_x,color1,color2,linecolor,leftmargin;
var my_format:TextFormat = new TextFormat();
my_format.color = linecolor;
my_format.font = "Arial";
my_format.size = 14;
my_format.align = "center";

my_digital_format = new TextFormat();
my_digital_format.bold = true;
my_digital_format.align = "right";
my_digital_format.font = "Arial";
my_digital_format.color = 0x000000;
my_digital_format.underline = false;
my_digital_format.size = 14;
my_digital_format.italic = false;

mypath._xscale = 60;
mypath._yscale = 50;

mypath.createEmptyMovieClip("scale",mypath.getNextHighestDepth());
pixels_between_sliders = 40;
leftside = -10-leftmargin;
rightside = -10 + pixels_between_sliders*number_of_sliders;
topside = -125;
bottomside = 55;
slider_x = 0;

with (mypath.scale) {
//left side
colors = [color1, color2];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {matrixType:"box", x:0, y:-120, w:30, h:150, r:(90/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
moveTo(leftside-leftmargin,bottomside-5);
lineTo(leftside-leftmargin,-120);
curveTo(leftside-leftmargin,topside,leftside-leftmargin+5,topside);
lineTo(rightside-5,topside);
curveTo(rightside,topside,rightside,topside+5);
lineTo(rightside,bottomside-5);
curveTo(rightside,bottomside,rightside-5,bottomside);
lineTo(leftside-leftmargin+5,bottomside);
curveTo(leftside-leftmargin,bottomside,leftside-leftmargin,bottomside-5);
endFill();

for(var j = 1; j < number_of_sliders; j++) {
slider_x = slider_x + pixels_between_sliders;
lineStyle(0,linecolor,0);
beginFill(slotcolor,100);
moveTo(slider_x-1,0);
lineTo(slider_x-1,-100);
lineTo(slider_x+1,-100);
lineTo(slider_x+1,0);
lineTo(slider_x-1,0);
endFill();
lineStyle(0,linecolor,100);
moveTo(slider_x-1,0);
lineTo(slider_x-1,-100);
moveTo(slider_x+1,0);
lineTo(slider_x+1,-100);
for(var i = 0; i <= 10; i++) {
lineStyle(1.5,linecolor,100);
moveTo(slider_x+6,-i*10);
lineTo(slider_x+12,-i*10);
}
for(var i = 0; i <= 9; i++) {
lineStyle(1,linecolor,100);
moveTo(slider_x+6,-i*10-5);
lineTo(slider_x+10,-i*10-5);
}
}
}
for(var j = 1; j < number_of_sliders; j++) {
mypath.createTextField("buttonlabel" + j,mypath.getNextHighestDepth(),j*pixels_between_sliders-15,-120,33,23);
mypath["buttonlabel" + j].setNewTextFormat(my_format);
mypath["buttonlabel" + j].selectable = false;
mypath["buttonlabel" + j].text = mylabels[j];
my_format.size = 13;
mypath["buttonlabel" + j].setTextFormat(mypath["buttonlabel" + j].text.length - 2,mypath["buttonlabel" + j].text.length,my_format);
my_format.size = 16;

mypath.createEmptyMovieClip("digital"+j,mypath.getNextHighestDepth());
mypath.createEmptyMovieClip("button"+j,mypath.getNextHighestDepth());

mypath["digital" + j]._x = j*pixels_between_sliders;
mypath["digital" + j]._y = 40;
mypath["button" + j]._x = j*pixels_between_sliders;
with (mypath["digital" + j]) {
//make_a_rectangle(this,0x000000,CAF9CC,100,100,0,-10,10,-5,1);
lineStyle(0,0x000000,100);
beginFill(0xCAF9CC,100);
mywidth = 38;
myheight = 20;
moveTo(-mywidth/2,-myheight/2);
lineTo(-mywidth/2,myheight/2);
lineTo(mywidth/2,myheight/2);
lineTo(mywidth/2,-myheight/2);
lineTo(-mywidth/2,-myheight/2);
createEmptyMovieClip("text_holder",1);
text_holder._x = -4;
text_holder._xscale = 90;
text_holder._yscale = 120;
text_holder.createTextField("harmonic_percent",1,-mywidth/2,-myheight/2,mywidth+6,myheight);
text_holder.harmonic_percent.setNewTextFormat(my_digital_format);
text_holder.harmonic_percent.text = "0.00";
}
with (mypath["button" + j]) {
my_button_number = j;
//left side
colors = [0xEEEEEE, 0x666666];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:8, h:36, r:(90/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
//lineStyle(0,0xFF0000,100);
moveTo(-4,-18);
curveTo(-4,-22,-5.5,-25);
lineTo(-5.5,25);
curveTo(-4,22,-4,18);
curveTo(-6,0,-4,-18);
endFill();
//right side
colors = [0x999999, 0x222222];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {matrixType:"box", x:0, y:0, w:8, h:36, r:(90/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
//lineStyle(0,0xFF0000,100);
moveTo(4,-18);
curveTo(4,-22,5.5,-25);
lineTo(5.5,25);
curveTo(4,22,4,18);
curveTo(6,0,4,-18);
endFill();
//lineStyle(0,0xFF0000,0);
colors = [0x666666, 0xD5D5D5];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {matrixType:"box", x:0, y:-20, w:8, h:36, r:(90/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
moveTo(-4,-18);
lineTo(4,-18);
curveTo(6,0,4,18);
lineTo(-4,18);
curveTo(-6,0,-4,-18);
endFill();
colors = [0x666666, 0xCCCCCC];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {matrixType:"box", x:0, y:-25, w:8, h:4, r:(90/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
lineStyle(0,0xCCCCCC,100);
moveTo(-4,-18);
curveTo(-4,-22,-5.5,-25);
lineStyle(0,0x666666,100);
lineTo(5.5,-25);
lineStyle(0,0xFFFFFF,100);
curveTo(4,-22,4,-18);
lineStyle(0,0x666666,100);
lineTo(-4,-18);
endFill();
colors = [0x999999, 0x000000];
alphas = [100, 100];
ratios = [0, 0xFF];
matrix = {matrixType:"box", x:0, y:21, w:8, h:6, r:(90/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
lineStyle(0,0xFFFFFF,100);
moveTo(-4,18);
curveTo(-4,22,-5.5,25);
lineStyle(0,0x000000,100);
lineTo(5.5,25);
lineStyle(0,0x666666,100);
curveTo(4,22,4,18);
lineStyle(0,0xCCCCCC,100);
lineTo(-4,18);
endFill();
lineStyle(0,0x999999,0);
beginFill(0x333333,100);
moveTo(-4,-1);
lineTo(4,-1);
lineTo(4,1);
lineTo(-4,1);
lineTo(-4,-1);
endFill();
lineStyle(0,0xFFFFFF,100);
moveTo(-4,1);
lineTo(4,1);
lineTo(4,-1);
lineStyle(0,0x999999,100);
moveTo(-4,-18);
lineTo(4,-18);
curveTo(6,0,4,18);
lineTo(-4,18);
curveTo(-6,0,-4,-18);
colors = [0x000000, 0x000000];
alphas = [40, 10];
ratios = [0, 0x66];
matrix = {matrixType:"box", x:0, y:15, w:2, h:60, r:(90/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
lineStyle(0,0xFF0000,0);
moveTo(-5.5,25);
lineTo(5.5,25);
lineTo(5.5,-25);
curveTo(8,-20,10,-6);
curveTo(8,-6,8,2);
lineTo(8,30);
curveTo(7,32,6,32);
lineTo(0,32);
curveTo(-6.5,29,-5.5,25);
endFill();
lineStyle(0,0x666666,80);
moveTo(-5.5,25);
lineTo(5.5,25);
lineTo(5.5,-25);
_xscale = 100;
_yscale = 100;
}
}
my_format.align = "center";
my_format.size = 12;
my_format.color = 0x000000;
mypath.createTextField("percentage",mypath.getNextHighestDepth(),-32,24,55,50);
mypath["percentage"].setNewTextFormat(my_format);
mypath["percentage"].selectable = false;
mypath["percentage"].wordWrap = true;
mypath["percentage"].text = "harmonic
percentage";
text1 = "harmonic";
text2 = "order";
text1_y = -100;
text2_y = -80;
my_format.align = "center";
my_format.bold = true;
my_format.color = 0xFFFFFF;
my_format.size = 14;
for(var i = 0; i < text1.length; i++) {
mypath.createTextField("mylabel1" + i,mypath.getNextHighestDepth(),-20,text1_y,14,20);
mypath["mylabel1" + i].setNewTextFormat(my_format);
mypath["mylabel1" + i].selectable = false;
mypath["mylabel1" + i].text = text1.substring(i, i+1);
text1_y += 12;
}
for(var i = 0; i < text1.length; i++) {
mypath.createTextField("mylabel2" + i,mypath.getNextHighestDepth(),-5,text2_y,14,20);
mypath["mylabel2" + i].setNewTextFormat(my_format);
mypath["mylabel2" + i].selectable = false;
mypath["mylabel2" + i].text = text2.substring(i, i+1);
text2_y += 12;
}
}
//function to make a (filled) rectangle based on four input corners and color info
function make_a_rectangle(mypath,linecolor,fillcolor,linealpha,fillalpha,linewidth,left_x,right_x,top_y,bottom_y) {
mypath.lineStyle(linewidth, linecolor, linealpha);
mypath.beginFill(fillcolor,fillalpha);
mypath.moveTo(left_x,top_y);
mypath.lineTo(right_x,top_y);
mypath.lineTo(right_x,bottom_y);
mypath.lineTo(left_x,bottom_y);
mypath.lineTo(left_x,top_y);
mypath.endFill();
}
function displaydelay(mypath){
mypath.solidbox._visible = 1;
mypath.solidbox._alpha = 0;
mypath.fadingbox._visible = 1;
mypath.myhint._visible = 1;
mypath.fadingbox._alpha = 90;
//after the initial delay has elapsed, now make the fade in
fadedelay = setInterval(gradualfade,10,mypath);
clearInterval(initialdelay);
}
function gradualfade(mypath) {
mypath.solidbox._alpha += 4;
mypath.fadingbox._alpha -= 4;
if(mypath.solidbox._alpha >= 100) {
clearInterval(fadedelay);
}
}
function limit_decimals(myinput) {
return_for_display = String(Math.round(myinput*100)/100);
return_for_display = return_for_display.split("").reverse().join("");
//trace(return_for_display.indexOf("."));
if(return_for_display.indexOf(".") <> -1) {
for(var i=2; i> return_for_display.indexOf("."); i--) {
return_for_display = "0" + return_for_display;
}
} else {
return_for_display = "00." + return_for_display;
}
return_for_display = return_for_display.split("").reverse().join("");
return(return_for_display);
}
//create movie clips to fill
//"sinewave" is nested /in "sine" in a previous version that was required but technically is
//no longer. I went ahead and left it this way because it is so easy to reverse the direction
//of the wave travel this way just by setting the _xscale of its parent ("sine")
this.createEmptyMovieClip("oscope",this.getNextHighestDepth());
this.createEmptyMovieClip("sine",this.getNextHighestDepth());
this.sine.createEmptyMovieClip("sinewave",this.sine.getNextHighestDepth());
this.createEmptyMovieClip("sliders",this.getNextHighestDepth());
this.createEmptyMovieClip("harmonicsdata",this.getNextHighestDepth());
this.createEmptyMovieClip("sine_masker",this.getNextHighestDepth());

mylabels = new Array();
topcolor = 0x990000;
bottomcolor = 0xFFCC00;
linecolor = 0xFFFFFF;
leftmargin = 10;
slotcolor = 0x000000;
sliders._x = 10;
sliders._y = 65;
mylabels = ["1st","5th","7th","11th","13th","17th","19th","23rd","25th","29th","31st","35th","37th","41st","43rd","47th","49th"];
//number_of_buttons = mylabels.length;
makeslider(sliders,mylabels.length,topcolor,bottomcolor,linecolor,slotcolor,leftmargin,mylabels);

harmonics = new Array();
//set initial values for the array. In this case, since there are zero harmonics, the result will be a sine wave
harmonics.push ({myorder:1,myamount:1.0,mysuffix:"st"});
harmonics.push ({myorder:5,myamount:0.0,mysuffix:"th"});
harmonics.push ({myorder:7,myamount:0.0,mysuffix:"th"});
harmonics.push ({myorder:11,myamount:0.0,mysuffix:"th"});
harmonics.push ({myorder:13,myamount:0.0,mysuffix:"th"});

View Replies !    View Related
Sine Wave Picture Effect
how do i make this sine wave picture effect ,wave on the horizontal insted of the vertical
)
( vertical as it is now
)

//// horizontal as i want it to be
http://www.mn001c7645.pwp.blueyonder.co.uk/test.htm

View Replies !    View Related
Sine Wave/blob Effect
Hey everyone,

I have a logo that I made in Fireworks, and it looks decent, but I was wondering if anyone could mimic it with movement. For example, if someone could use actionscript to make it "wiggle" or wave like a flag in the wind, that would be awesome.

Notice how the blue line itself stays at about the same thickness (it barely starts getting thicker), but the shading around it thickens as it goes more and more to the right.

Here's the image (ignore the text):



Thanks for any help / tips
Matt

View Replies !    View Related
Sine Wave Picture Effect
how do i make this sine wave picture effect ,wave on the horizontal insted of the vertical
)
( vertical as it is now
)

//// horizontal as i want it to be
http://www.mn001c7645.pwp.blueyonder.co.uk/test.htm

View Replies !    View Related
[Flash MX] How To Create A Sine Wave
[Flash MX] How to create a sine wave using the curveto() method of the flash drawing API ??

View Replies !    View Related
Need Advice To Create A Sine Wave Dynamically
Is it possible for Flash to draw a line from point A to point B dynamically?

I have to create a sine wave that plots points on the screen. I thought it would be possible to duplicate a movieclip of a dot, and everytime a new position in the sine wave is created, then the movieclip would duplicate and place the dot on the screen at that position. So far, not very hard, but I need a solid line for the sine wave, hence the question, can I draw a line dynamically from point A to point B?

Any help would be much appreciated.

Cheers,

vglcrew

View Replies !    View Related
How Do You Rotate A Graphic Using Math Sine Wave
Hi there I hope someone can help me. I want to make a movie clip graphic rotate using its _rotate property. However I want to make it start rotating slowly from a stopped position and increase to a certain speed then slow down again then do the same thing only rotating in the opposite direction. All I know is the 'sine wave' would be used in the calculation. I know nothing about math - the word itself scares me. Ideally I would like to change a number in the equation that would make the back and forth rotation go faster and I would like another number in the equation to govern the frequency of the spin (so I need two parameters amplitude and frequency). I have no idea how to write this equation or how to attach it to my movie clip graphic. Help on this matter would be appreciated.

At present I'm making a movie clip rotate using:

this._rotation=this._rotation+x; (if I change the value of x as you know the rotation would be faster). I would like to keep the new back and forth rotation as close to this way of rotating the clip as possible.

Cheers

View Replies !    View Related
[FLASH8] Looking For Sine Wave Tutorial/explination
I've found a couple sine wave examples in searching the forum, however I was hoping I might be able to get somewhat of an explanation as to how to create one.

What I'm actually trying to create is a moving sine wave (from left to right) who's amplitude on the left is low, but is about 4x at the other end.

Any assistance would be appreciated.

View Replies !    View Related
Sine Wave Using Script With Changing Amplitude
hello guys .. i got a problem in creation of sine wave. i want to show ripple water effect using sine wave. That's why i require sine wave with decreasing amplitude... so.. plz do help me...

View Replies !    View Related
Use Actionscript To Move Text Along A Sine Wave
So, I've written a function that will take a string, generate a movieclip for each letter in the string and animate the string moving along a sine wave with my defined settings, but I've been unable to figure out how to orient the text to the wave appropriately. I'm defining the _y position of each letter as it moves across the stage as follows:


clip._y = 100 * Math.sin(clip._x) + 240;


Where 100 is the amplitude and 240 is an offset putting the wave in the middle of my stage. Anybody know how to calculate the precise rotation of the clip as it travels along the wave? Thanks for your help!

View Replies !    View Related
How To Slowly Draw An Arc/sine Wave/parabola
If I have coordinates for an origin and a target (and a focal point for the middle of the arc), how might I draw a sine wave or parabola between the two?

I would like the end result to be similar to how it would appear with myMovie.curveTo. Howver, curveTo draws the whole curve instantaneously. I need it to slowly grow, as if plotting the path of a missile.

The nearest I've got just makes a straight line, but apart from the fact it doesn't draw a curve, it's exactly what I need:


Code:


originx = 10; //origin of the arc
originy = 200;

targetx = 300; //target of the arc
targety = 150;

percent = 0; // the line will be drawn slowly, one percent of the total length at a time

this.lineStyle( 1, 0x333333, 99 );
this.moveTo(originx, originy);

this.onEnterFrame = function () { //draw the line

if (percent<100) {
currentx = originx + (((targetx-originx)/100)*percent); //find coords of next spot on straight line
currenty = originy + (((targety-originy)/100)*percent);

this.lineTo(currentx,currenty);

percent ++;

}
}

View Replies !    View Related
How Can I Fill In The Area Below And Above A Sine Wave Curve/line?
I'm trying to create a "Scorched Earth" (eg. Tanks) clone and I'm having trouble creating a nice random 2D landscape (eg. hills, slopes, valleys, etc).

Right now I just combine a couple of sine waves and draw them using movieClip.lineTo(x, y) so what I end up with is a movie clip containing a TON of lines (each x,y value is connected to another x,y using the lineTo function)

So, after I have my nice curve/lines, how do I fill in the area below it with a solid color (eg. green representing grass).

Also, is there a better way to drawing a 2D landscape? I'm wondering if creating 600 lines on a movieClip is bad... (using all those lines make the full line look like a curve...)

You can checkout exactly what I'm talking about right here:
http://www.lagworld.net/canon.swf

Finally, if anybody knows why my movie runs so slow please let me know =) (its running at 60fps in case that has anything to do with it)

View Replies !    View Related
How Can I Made The Ramdom Circles Move In A Sine-wave Form?
I'm trap!!!

I have the MX fla for the ramdon circles movement. I want them to form a sine-wave movement.

I alredy tried Math.sin(X) for it and it wont work.

I would like somebody to help.

View Replies !    View Related
How Can I Made The Ramdom Circles Move In A Sine-wave Form?
I'm trap!!!

I have the MX fla for the ramdon circles movement. I want them to form a sine-wave movement.

I alredy tried Math.sin(X) for it and it wont work.

I would like somebody to help.

View Replies !    View Related
Animated Sound Wave
Is there anyone knows how to animate a vector sound wave? Thanks.

View Replies !    View Related
Help With Animated Cosine Wave
Hi all,

can anyone help me with an effect that i am trying to create.

I want to create a cosine wave that moves accross the screen horizontally. However the wave has circles attached to it that i want to move on the y axis inline with the wave but not on the x axis. i can do both seperatly bu not together.

Any help would be greatly appreciated. Math is not my strong point.

Cheers Rikki

www.flamedia.co.uk

View Replies !    View Related
Animated Wave Converge To One Point
Hi All!

I am really desperate - willing to give compensation, just ask!! If anyone can help. I'm basically a newbie at this, but have a really urgent job on, and realise this is kind of beyond me.

I need to have an animated wave converge to one point, and even better generate from one point also. Is this possible?

I also found this in flashmatics library (http://www.experiments.flashmatics.co.uk/): http://www.flashmatics.co.uk/curvesOpt.html

which dynamically draws waves between two points. I want the two points, but I want the waves to move/flow between them, not to draw themselves.

I will be so grateful if anyone can help me!

This is code for random moving waves, but not between two points:
/*
set up vars
p = number of points along the line; more = smoother curve
sx = start position of the wave
ex end of the wave
by = size of area
wl = the water level
wh = height of waves
ws = speed of wave; negative numbers make it go right
*/
for (var i = 0; i<6; i++) {
this.createEmptyMovieClip("wave"+i, i);
var w:MovieClip = this["wave"+i];
w.p = 50;
w.sx = 0;
w.ex = 800;
w.by = 0;
w.wl = 0;
w.wh = 50;
w.ws = -(0+((random(10)/2)+.1)/2000);
var Ld:String = String(i/2);
if (Ld.length>1) {
w.lh = 1;
} else {
w.lh = 0;
}
w.id = i;
w._alpha = random(45)+25;
w.onEnterFrame = function() {
//begin with a clean canvas
this.clear();
this.lineStyle(this.lh, 0xFF0000);
this.moveTo(this.sx, this.by);
for (x=0; x<this.p; ++x) {
var r:Number = x/(this.p-1);
var px:Number = this.sx+r*(this.ex-this.sx);
var py:Number = 20+this.wl+this.wh*Math.sin(r*r*Math.PI*2+getTimer ()*this.ws);
this.lineTo(px, py);
}
};
}

View Replies !    View Related
Animated Vector Sound Wave
Can anyone tell me how to make a sound wave animated in flash? Thanks.

View Replies !    View Related
Need Sine And Cosine Help
FIrst off i have a piece of code which makes an mc
"bounce" up and down:
_y = -Math.abs(100*Math.sin(_x/75))
I understand the absolute value part and everything else except for the sin part. I understand a little about sine and cosine when using it so make an object move based on its rotation, but i dont understand how this code works. THe x is constantly being increased by another line of code, but if you multiply the sine times the x wouldn't the y just keep going up? I dont understand what makes the ball peak and then come back down.

can anyone help explain this in simple terms and/or show me some links which help explain sine and cosine? THanks in advance.

View Replies !    View Related
Inverse Sine
anyone know if there is an inverse sine function? i have two squares with a line in between them and i have to rotate it so that it correlates with the position of the squares.

anyone have any ideas? thanks, patrick.

View Replies !    View Related
Sine Like Waves
I'd like to know how to make sine like waves (see link), I want them to move and oscilate randomly but with long intervals...Anyone know how> I'm a complete flash newb and just want to make this for an opening to my site...

http://www.cs.odu.edu/~cpoyner/wavering.gif

Thanks

View Replies !    View Related
SINE CURVE?
hi guys..why does the sine curve in the math.sin function start by going down...i am having real problems with that.i am applying that function at the origin and i want it to start the normal way by going in the positive y direction .can i somehow get it to start going upwards ?? Please help!!

View Replies !    View Related
Using Sine For Rotation
I'm trying to do something in DHTML (Javascript), which I'm sure many of you will have done in actionscript.

It's not really the language I'm having problems with, it's the method.

http://www.dannytuppeny.com/spin.asp

It's supposed to be travelling in a circle, but it looks naff. If you view the source, you'll see what I'm trying. If anyone can explain what's wrong, it'd be greatly appreciated.

If you have any questions about it, post here and I'll answer

Thanks,

Danny

View Replies !    View Related
Sine Function
how do i use the math.sin funtion. I have a symbol that i want to go in a wavy motion like a sin graph.

View Replies !    View Related
Sine Conversion
So i'm writing some code and I need to have the sine of an angle in degrees. I can only get it in radians with flash. What can I do?

View Replies !    View Related
Movement Using Sine
Hi
i have created a small animation using motion tweening and i was wondering if the same animation could be recreated using action script
here it is
http://www.mn001c7645.pwp.blueyonder.co.uk/sine.html

View Replies !    View Related
Sine Curves
Hi

I want to be able to input the start screen co-ordinates and the destination co-ordinates and plot a sine curve between them.

So for example. I may wish to start at 100,100 on the screen and end at 150,150. I want to plot a sine curve between these 2 points.

The formula I use to plot a sine curve is

x=x+1;
y=y-sin(degrees)*radius;


The question I have is is it possible to create a formula which plots a sine curve which hits 2 given points.

View Replies !    View Related
Sine And Cosine Help
HELLO! I LL TRY USE Math.sin(x:Number); but the results is wrong.
sees the images and anyone can help me ?
i wanna calculate the sine and co-sine of angle numbers.

tks

View Replies !    View Related
Movement Using Sine
Hi
i have created a small animation using motion tweening and i was wondering if the same animation could be recreated using action script
here it is
http://www.mn001c7645.pwp.blueyonder.co.uk/sine.html

View Replies !    View Related
Sine/Cosine Question
if i have an angle of 140 and i take the cosine and sine of it.

angle = 140;
thesine = Math.sin(angle);
thecosine = Math.cos(angle);

It is returning random numbers sometimes they're both positive or both negative or one of each. Does anyone know why this is happening.

thanks in advance

khamstra

View Replies !    View Related
Many IF Statements Or One Sine Statement?
Hi, for my game i have a rotating man that moves in one of 16 directions. Now would it be better (in performance terms) to use 8 IF statements to control his movement or just one Sine calculation??

Bit of a conumdrum for me...

View Replies !    View Related
Inverse Sine Function
I'm not exactally a newb to flash, but I feel like one right now. I am trying to make a gravity program and in order to calculate angles, I'm trying to do something that requires the inverse sine of something, and I can't find that function in the Math class. Is it just the Math.asin... I'm not sure. Any help would be great.

View Replies !    View Related
[F8] Using Variable In Cosine/sine
I made a couter that raises the value of "step" by 1 each time the frame is loaded. The scene is nothing more than a looping timeline of 13 frames. (the first frame sets "step" to zero). I can see the couter works, in a dynamic textfield.

Now i'm trying to use this variable in a cosine&sine function so that i have a rotating object as a function of time.

The function:

onClipEvent (load) {
_x = 180*Math.cos((2*Math.PI*step)/225)+400;
_y = 180*Math.sin((2*Math.PI*step)/225)+400;
}

But this doesn't seem to work, my object doesn't move, while my counter is happily counting. What am I to do here?

View Replies !    View Related
Sine Curve Animation
Hi, I love the curve animation like this page
http://www.sennheiser.com/sennheiser...f/root/private

then I try to figure out my way...

I guest. I am in a wrong way... in term of flexibility and optimizability
I hope It can be more lively like a rope with the lost of strength....
then I am really in a wrong way of developing the script...


ActionScript Code:
package {

    import flash.display.Sprite;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
    import flash.display.CapsStyle;
    import flash.display.LineScaleMode;

    import flash.text.TextField;

    public class SineAnimation extends Sprite{

        private var tracer:TextField = new TextField();

        public function SineAnimation():void{
            addChild(tracer);


            var moveTimer:Timer=new Timer(10);
            moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
            moveTimer.start();


        }      

        public function drawCurve( phase:Number = 0, waveWidth:Number = 0, amplitude:Number = 100 , sineMcWidth:Number = 0):void{
//      tracer.text=stage.stageWidth.toString();

            if (sineMcWidth == 0)
            {
                sineMcWidth  = stage.stageWidth;
            }
            var offsetY:Number = stage.stageHeight/2;
            var sineCurrentPointX:Number;
            var currentDelta:Number;

            var resultCurve:Sprite = new Sprite;


                graphics.clear();
                graphics.lineStyle(1, 0x990000, 1, false, LineScaleMode.NONE, CapsStyle.SQUARE);
                graphics.moveTo(-20 ,offsetY );


            for( var i:Number = 0; i < sineMcWidth; i++ ) {

                currentDelta = Math.PI * i / 100*waveWidth +  phase ;
                sineCurrentPointX = offsetY + amplitude * Math.sin(currentDelta);
                graphics.lineTo( i , sineCurrentPointX );
       
            }
        }


        public function onTimer( e:TimerEvent  ):void{
   
            drawCurve(e.target.currentCount/100, 0.09);
        }
    }
}

View Replies !    View Related
How To Calculate The Angle Of A Sine (or Cosine)?
i have a problem with something i supposed to remember from the old math from school, but i forgot..

Im fixing a MC wich moves towards a certain point, (lets say, a anti aircraft missile), its dynamic, so it also follows a moving point. (see this thread: http://board.flashkit.com/board/show...32#post1392132 )

That works, i measure the distance (X and Y) to the target point, combine that to total distance, and do some math to get the sine or cosine of the angle between the two point's

All fine, BUT i dont know how to get the angle (in radians or degree's) from the sinei/cosine i calculated.. and i need that to align the moving movieclip to its path(otherwise it looks crap, eg: a missile that moves while pointing right while moving sideways)

I can calculate allmost everything with right-triangles exept this.. so help me please; this seems one of those things that come back all the times when scripting game gfx..

So the question is: how to calculate an angle out of a sine or cosine??

Macaca
[Edited by Macaca on 01-01-2002 at 11:41 AM]

View Replies !    View Related
How To Build Sine Waves With Little Cpu Effort?
Hi, guys...

I am looking for a tutorial or source code that dynamically draws a couple of horizontally moving sine waves. I´ve found some sources, but they seem to be very cpu intensive... Does anyone know how to do it with little cpu effort?

Thanks in advance!

View Replies !    View Related
Move Direction On Angle - Sine And Cosine
Hey, I am having a lot of trouble with this. I have a ball and a platform. Now when I press left and right keys, the platform will rotate, to a max of 30 degrees right and left. The ball is constantly falling, coded at a rate so that it is like gravity...here is the code for it:

code: onClipEvent (load) {
time = 0;
}

onClipEvent (enterFrame) {
//implement gravity into the ball
_y = 1/2*(.2)*Math.pow(time, 2);
time++;
}

Now the code for when the ball hits the platform (it is coded like this because in reality, there are multiple paddles):

code: onClipEvent (enterFrame) {
with (_root.ball) {
//maze boundaries
if (leftPad.row3.hitTest(_x, getBounds(_root).yMax, true)) {
time --;
}
}
}

Now, what I want to do is make is so that, depending on the angle of the platform, the ball's x and y will fall in the correct direction at the correct rate. I figure I will have to use sine and cosine for this, but I am not wholly sure how to get it to work.

All I did so far was calculate the sine and cosine, but I don't know exactly how to impliment it into the movement of my ball...

code: angle = _root.maze._rotation;
//how much the maze has rotated
currentX = Math.cos(angle*Math.PI/180);
currentY = Math.sin(angle*Math.PI/180);
(it is within an onClipEvent handler)

Any help would be greatly appreciated, thanks

View Replies !    View Related
Dynamic Text On Sine Curve Path?
Hi,

This is really a kinda urgent requirement, I hate being urgent on forums since help takes as long as it takes usually, but I'm being pressured at the moment and can't do it.

Basically I need to have text from a dynamic/input textfield to appear in a wavy line pattern automatically. Now I'm pretty sure it can be done fairly easily with the right knowledge but I unfortunately lack that knowledge.

The idea I had was that a string is broken into individual letters and each is placed along a sine curve of a set length/width - the string/characters are repeated if necessary in order that the full width of the curve is covered. Also note that the text need not be rotated to match the lines, only _x and _y values need to be adjusted.

I have to produce a design with dynamic text similar to this (my ascii art skills are crap so please imaging that these are wavy lines rather than zig zags):

/////////////////
/////////////////
/////////////////
/////////////////
/////////////////

Please please please, I need your help - desperately, I have nothing to offer apart from the satisfaction of producing a wavy text pattern and from knowing that you have saved me from a breakdown.

Thanks guys,

Jon

View Replies !    View Related
Dynamic Text On Sine Curve Path?
Hi,

This is really a kinda urgent requirement, I hate being urgent on forums since help takes as long as it takes usually, but I'm being pressured at the moment and can't do it.

Basically I need to have text from a dynamic/input textfield to appear in a wavy line pattern automatically. Now I'm pretty sure it can be done fairly easily with the right knowledge but I unfortunately lack that knowledge.

The idea I had was that a string is broken into individual letters and each is placed along a sine curve of a set length/width - the string/characters are repeated if necessary in order that the full width of the curve is covered. Also note that the text need not be rotated to match the lines, only _x and _y values need to be adjusted.

I have to produce a design with dynamic text similar to this (my ascii art skills are crap so please imaging that these are wavy lines rather than zig zags):

/////////////////
/////////////////
/////////////////
/////////////////
/////////////////

Please please please, I need your help - desperately, I have nothing to offer apart from the satisfaction of producing a wavy text pattern and from knowing that you have saved me from a breakdown.

Thanks guys,

Jon

View Replies !    View Related
Random Sine Waves Drawn As Lines With CurveTo
ello all,

I am trying to acheive something like the attached image with the lines not exactly like sine waves but drawn dynamically with a controllable variable height and to be able to have the lines finish on the same point on the screen (converging to a point)

I have the following from code found on here

Code:
/*
set up vars
p = number of points along the line; more = smoother curve
sx = start position of the wave
ex end of the wave
by = size of area
wl = the water level
wh = height of waves
ws = speed of wave; negative numbers make it go right
*/
for (var i = 0; i<6; i++) {
this.createEmptyMovieClip("wave"+i, i);
var w:MovieClip = this["wave"+i];
w.p = 50;
w.sx = 0;
w.ex = 800;
w.by = 0;
w.wl = 0;
w.wh = 50;
w.ws = -(0+((random(10)/2)+.1)/2000);
var Ld:String = String(i/2);
if (Ld.length>1) {
w.lh = 1;
} else {
w.lh = 0;
}
w.id = i;
w._alpha = random(45)+25;
w.onEnterFrame = function() {
//begin with a clean canvas
this.clear();
this.lineStyle(this.lh, 0xFFFFFF);
this.moveTo(this.sx, this.by);
for (x=0; x<this.p; ++x) {
var r:Number = x/(this.p-1);
var px:Number = this.sx+r*(this.ex-this.sx);
var py:Number = 20+this.wl+this.wh*Math.sin(r*r*Math.PI*2+getTimer ()*this.ws);
this.lineTo(px, py);
}
};
}

this gives a nice consistant wave but not the 'messy' lines as on the attached image. Also is there a way to use curveTo rather than points to give a smoother curve??

Anybody got any pointers as this maths bit is driving me a bit mental!

Thanks guys

View Replies !    View Related
Sine Rules. Inconsistant Output Using Input Text Fields.
I am trying to solve a triangles dimensions using Sine Rules.
I have 3 known fields:
tilt [an angle], slope [an angle] & baseLength [a length].
I want to calculate the length of a side named tiltLength.

The script I'm using is:

on (release) {
thirdAngle = 180 - (tilt + slope);
tiltLength =( baseLength * Math.sin(tilt * Math.PI/180 )) / Math.sin(thirdAngle * Math.PI/180)
play();
}

My problem is that this works great if I input the 3 known variables in frame1.
However if I try to input the angles via input text fields sometimes it works fine, but then at other times I get a negative value, which is impossible.

If I place the same values into frame 1 the answer is correct !!!

Can some kind soul put me out of my agony and suggest whats going wrong?

Egg

View Replies !    View Related
Create Non-animated Equivalent Of Animated Flash 8 Animation
Hi, I'm working with a template that includes Flash. It's bad enough I've never touched Flash before this project, but I have to actually work with someone else's engineering of one (I'm retrofitting a purchased template)! LOL

Anyway, all I want to do is to save a completely non-animated version of the animated version I've managed to perfect. The plan is to use it on sub-pages of our presentation so that people only have to experience the animation when they land on the page. Not when they're navigating around. I've already tried a couple of things including saving an image map version. All that did was present me with an error message that certain components weren't included, which is tentatomount to being non-usuable to me for now.

So, is there a way to tell Flash, "Hey, this looks great, now give me a static version of it with working links and everything!".

Thanks if anyone can help!

Dave

View Replies !    View Related
Animated SWF Is Not Animated When Included In Another Movie As A Clip
I have an SWF that, when run by itself, is an animation of a graphic equalizer display. But when I bring it into a new movie as a movie clip (I want to change the alpha, throw up some text, clear the txt, change the alpha, etc), the animation does not work, and all I get is the static images.

FLA is at http://www.black-diamond.com/flash_src/equalizer.fla if anyone wants to take a look at it. The one I am trying to bring it into is at http://www.black-diamond.com/flash_src/test3333.fla (the corresponding .swf to see what happens is at http://www.black-diamond.com/flash_src/test3333.swf ).

Any suggestions greatly appreciated.

Thanks.

(Reposted because last title wasn't descriptive enough)

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved