Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 7:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: drawing a sine wave
PostPosted: September 26th, 2006, 1:14 pm 
Offline

Joined: March 14th, 2006, 11:55 am
Posts: 8
Location: Belfast
Has anyone out there got any scripting ideas on drawing sine waves. I eventually want to use opus to construct a simulation for a Physics principle:- superposition of waves which adds the amplitudes of individual waves to give a more complex wave.

_________________
A.Ashby


For this message alastair ashby. has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 26th, 2006, 1:44 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
Could you create the sine wave in Flash and then use a browser object or something else to display the Flash file from within Opus?

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


For this message bwpatric has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 26th, 2006, 8:42 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
While you can draw a static sine wave in Opus, you can't get a dynamic or travelling wave working at an acceptable speed.
This is because Opus cannot draw native curves -- you have to make up a composite curve from a series of short straight lines spaced end on end.

Paul


For this message Paul has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Sine wave
PostPosted: September 27th, 2006, 3:10 pm 
Offline

Joined: March 14th, 2006, 11:55 am
Posts: 8
Location: Belfast
Thanks for taking the time to reply. I am currently trying to learn a little flash to enable me to draw moving sine waves but it is slow going. Any help would be appreciated.

_________________
A.Ashby


For this message alastair ashby. has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: September 27th, 2006, 4:03 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
Here's some ActionScript that might be of interest to you.

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(EndX, 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();
};

It creates a wave. Perhaps it can point you further to a solution? Modifying things can change the wave's peaks, speed, etc. You can do this in SwishMax if that is easier to use. It's a lot cheaper.


You do not have the required permissions to view the files attached to this post.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


For this message bwpatric has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 7th, 2007, 9:10 pm 
Offline

Joined: March 14th, 2006, 11:55 am
Posts: 8
Location: Belfast
Have not been online for a while but could you tell me how to adapt this for swishmax as I have so far been unsuccessful.

_________________
A.Ashby


For this message alastair ashby. has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 8th, 2007, 1:47 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
Take a look at this. I haven't played much with it, just came across some code and tried it out to see if it would work.


You do not have the required permissions to view the files attached to this post.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


For this message bwpatric has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 8th, 2007, 3:35 pm 
Offline

Joined: March 14th, 2006, 11:55 am
Posts: 8
Location: Belfast
Thanks for replying so promptly. I tried this in Swishmax but unfortunately all that happens is that the outline of a rectangle is drawn in red/black dotted line on a green background.

_________________
A.Ashby


For this message alastair ashby. has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 8th, 2007, 4:32 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
Are you testing it in a browser or external player? It doesn't do anything if you just try to play within SM.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


For this message bwpatric has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 8th, 2007, 4:35 pm 
Offline

Joined: November 3rd, 2004, 2:11 pm
Posts: 323
I can display the SWF in Opus in both DocView and the Browser object. Everything works like it should.

_________________
Opus Pro XE 9.1 Win7 64-bit Core i3 8MB RAM


For this message bwpatric has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: March 9th, 2007, 9:13 pm 
Offline

Joined: March 14th, 2006, 11:55 am
Posts: 8
Location: Belfast
Sorry to be a pest but I have tried what you suggested. If I run the file in SM in browser it does not quite run as it should , the sine wave is very erratic. When I try to run it in Opus nothing happens. I obviously am doing something wrong. I did type your code into flash and it worked perfectly but I am trying to use SM as the learning curve for Flash is too steep. I really want to do some wave simulations for Physics which is why I want to persevere with this.

_________________
A.Ashby


For this message alastair ashby. has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 9th, 2007, 11:37 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
It does work, and erratic is probably the wrong word, it's just too fast at the existing fps setting.
I've altered the variable "WaveSpeed" to make it more visually smooth at 24fps.
If you use the browser object you first load a web page that links to the
flash file.
Opus browser >> html file >> swf file.
Then it works -- see attached -- you will have to change the file path inside the browser object to the html file.

It might help you to go over the browser and docview objects in the help file.

Paul


For this message Paul has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 10th, 2007, 7:11 pm 
Offline

Joined: March 14th, 2006, 11:55 am
Posts: 8
Location: Belfast
Many thanks, got it to work. Am grateful for your efforts. If I want to adapt the code I take it that I load it into SM and then output it as a swf file. I take it that I can change your code slightly?

_________________
A.Ashby


For this message alastair ashby. has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: March 10th, 2007, 8:14 pm 
Offline

Joined: November 11th, 2004, 4:05 am
Posts: 636
Location: Christchurch, NZ
just load a copy of the swi file into swishMax, do what you like then do a file export as swf.
It pays to work on copies of source files like the ones with the swi extension and keep original ones as backups.
That way you can't stuff something up; most of us learnt this the hard way.

cheers
Paul


For this message Paul has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: July 11th, 2007, 10:38 pm 
Offline

Joined: October 25th, 2004, 1:21 pm
Posts: 424
Location: West Lancs, UK
Opus: 7
OS: Xp, Win7
bwpatric wrote:
Here's some ActionScript that might be of interest to you.


Can you explain to me how to use this script?

I've created a script object containing the script...

if I then preview the page, I get the message

Script 1[1] (3, 0) : Undefined identifier 'Stage'

Sorry to be stupid, but the wave is exactly what I'm after!

Thanks, Linda

_________________
Linda Rossiter, Rossiter & Co

Pro 8, Pro 7, Pro 6, Pro 05.5XE, Pro 04XE, XE2.8, ILM 4.5 on Win7 Professional


For this message Linda has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group