Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 8:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Simultaneous Actions
PostPosted: October 26th, 2004, 12:12 pm 
Hi,

If I have OpusScript e.g.

Object1.Show();
Object2.Show();

// but I want them to show simultaneously, how is the script written?


Steve :?


Top
   
 
 Post subject:
PostPosted: October 26th, 2004, 12:33 pm 
Offline

Joined: October 25th, 2004, 3:09 pm
Posts: 32
I have done this before by using fork. First create a function like this

function DisplayObject()
{
this.Show();
}

then to show the objects

fork(DisplayObject, Object1);
fork(DisplayObject, Object2);


For this message Tony Coleman has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 27th, 2004, 2:51 am 
Offline

Joined: October 26th, 2004, 1:26 pm
Posts: 262
Tony Coleman wrote:
I have done this before by using fork. First create a function like this

function DisplayObject()
{
this.Show();
}

then to show the objects

fork(DisplayObject, Object1);
fork(DisplayObject, Object2);


-------

Hi Tony,

Thanks for this example as after reading the Script HELP file, it made things easier to understand.

I noticed that a Script Object is required. So I wanted to create a script action on a button and not have the Script Object show the objects as the page displayed.

What I did was this...

// SCRIPT OBJECT //

function DisplayObject()
{
this.Show();
}

function ShowBoth()
{
fork(DisplayObject, Object1);
fork(DisplayObject, Object2);
}


// Then on the button for the script action I entered:

ShowBoth()

// This seemed to work fine.

After experimenting with 'fork' I realised that 'this' could not be used for other functions, so after testing various examples I found that instead of using this.Show() I could use...

function DisplayObject()
{
Object1.Show();
Object2.Show();
}
function ShowBoth()
{
fork(DisplayObject, Object1);
fork(DisplayObject, Object2);
}

// I hope I've got this all right! :D

_________________
Cheers,
Steve


For this message Steve H has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 27th, 2004, 12:39 pm 
Offline

Joined: October 25th, 2004, 3:09 pm
Posts: 32
Quote:
function DisplayObject()
{
Object1.Show();
Object2.Show();
}
function ShowBoth()
{
fork(DisplayObject, Object1);
fork(DisplayObject, Object2);
}


With the code above you are telling both object to show twice. The first fork will start showing Object1 then when that has finished show Object2. But the second fork calls show for Object1 but as it has started showing it returns straight away and starts showing Object2. This does work but is doing more work than it really needs to. Also you don't need to pass the objects as the parameter to fork so you could just do this.
fork(DisplayObject);
fork(DisplayObject);
The reason I passed it in my example is that the object pass is then the this object.

Quote:
I realised that 'this' could not be used for other functions


I am not sure what you were trying to do here and why this could not be used. Have you got an example?

Tony


For this message Tony Coleman has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Simultaneous Actions
PostPosted: October 28th, 2004, 1:00 am 
Offline

Joined: October 26th, 2004, 1:26 pm
Posts: 262
<< I am not sure what you were trying to do here and why this could not be used. Have you got an example? >>


Hi Tony,

I know 'this' could be used for Show(), but thought it could not be used for e.g. animations.

I looked in the HELP file and saw how 'this' was not used in the script example for Show() and Hide() together, so tried applying that method to other variations. Please bear in mind I am only experimenting, and thought the discussion of "Simutaneous Actions" (fork in script) could be perhaps a discussion to kick off on this new forum. (plus I need to learn) :D

Have a look in the following on why I did not use the 'this' keyword...

function DisplayPath()
{
Star1.FollowPath(Path1, 4, false, false, 0, 100)
}
function DisplayRotate()
{
Star1.Rotate(360,4)
}
function ShowAnimations()
{
fork(DisplayPath)
fork(DisplayRotate)
}

// The function called on an action on a button was:
// ShowAnimations()


Now I know you're going to say 'fork' is not needed, as I could simply make the default wait command from 'true' to 'false' on the FollowPath(), but I was simply experimenting and trying to learn setting out OpusScripting using 'fork'.

I guess I could simply have done the following on a script action...

Star1.FollowPath(Path1, 4, false, false, 0, 100, false);
Star1.Rotate(360,4)

// and not even needed to call a function.

_________________
Cheers,
Steve


For this message Steve H has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 28th, 2004, 11:51 am 
Offline

Joined: October 25th, 2004, 3:09 pm
Posts: 32
Quote:
Have a look in the following on why I did not use the 'this' keyword...

function DisplayPath()
{
Star1.FollowPath(Path1, 4, false, false, 0, 100)
}
function DisplayRotate()
{
Star1.Rotate(360,4)
}
function ShowAnimations()
{
fork(DisplayPath)
fork(DisplayRotate)
}


You could have used 'this' if you wrote the code like this

function DisplayPath()
{
this.FollowPath(Path1, 4, false, false, 0, 100)
}
function DisplayRotate()
{
this.Rotate(360,4)
}
function ShowAnimations()
{
fork(DisplayPath, Star1)
fork(DisplayRotate, Star1)
}

This way you could reuse the DisplayPath() and DisplayRotate() functions again but with different objects e.g.

fork(DisplayPath, Square1)
fork(DisplayRotate, Square1)

Tony


For this message Tony Coleman has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 29th, 2004, 4:45 am 
Offline

Joined: October 26th, 2004, 1:26 pm
Posts: 262
[quote="Tony Coleman"][/quote]
You could have used 'this' if you wrote the code like this

function DisplayPath()
{
this.FollowPath(Path1, 4, false, false, 0, 100)
}
function DisplayRotate()
{
this.Rotate(360,4)
}
function ShowAnimations()
{
fork(DisplayPath, Star1)
fork(DisplayRotate, Star1)
}

This way you could reuse the DisplayPath() and DisplayRotate() functions again but with different objects e.g.

fork(DisplayPath, Square1)
fork(DisplayRotate, Square1)

------------

Thanks for this Tony,

I found that I could combine actions in your fork example at the end...

{
fork(DisplayPath, Square1)
fork(DisplayRotate, Square1)
fork(DisplayPath, Star1)
fork(DisplayRotate, Star1)
}

// then even the following worked..

{
fork(DisplayPath, Square1)
fork(DisplayRotate, Square1)
wait(1)
fork(DisplayPath, Star1)
fork(DisplayRotate, Star1)
}

// I experimented thus more...

{
fork(DisplayPath, Square1)
fork(DisplayRotate, Square1)
fork(DisplayPath, Star1)
if (MyVariable = 0)
{ fork(DisplayRotate, Star1) }
}


Thanks for all your help. :D

_________________
Cheers,
Steve


For this message Steve H has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 20 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group