Jump to content

Xpressionist 3.5 and custom functions


Recommended Posts

Hi.

Can you write custom functions in the latest XP? If so what is the correct syntax?

I always get errors when trying to write a function like in javascript, for example, and I'm beginning to think I'm missing something really obvious somewhere?

If not, how do people organize and reuse code? multiple instances of XP? Is the custom channel functionality in XP (which I've never used) something that could be useful here?

Thanks

Link to post
Share on other sites

Hi.

Can you write custom functions in the latest XP? If so what is the correct syntax?

I always get errors when trying to write a function like in javascript, for example, and I'm beginning to think I'm missing something really obvious somewhere?

If not, how do people organize and reuse code? multiple instances of XP? Is the custom channel functionality in XP (which I've never used) something that could be useful here?

Thanks

I do not have xp open, but iirc, you need to organize your code to not use functions... unless you do it craftily... I use nulls as containers for storing variables and data.

Let me know what you are trying to do, and I am happy to help create the code.

Cj

Link to post
Share on other sites

Thanks Cj. No "function(){}" syntax then. Good to know. I thought I was doing something wrong... because, what scripting environment doesn't allow for custom functions?

What I'm trying to do:

I'm trying to reuse code I wrote in flash (actionscript 2) for a cartoon bug animation that came out nicely. To get the same moves and that same 2D animation feel that I liked, I was thinking I cpuld do it in EIAS 8 and XP, just not cartoon like this time.

In flash (this was years ago) I wrote a simple function to animate the various parts of one bug. the function controlled the movements, placement and colors of the bug. Just a few expressions, or lines of code. I then reused this function, and passed it parameters to basically animate the rest of the bugs, there were a lot of them, and the result was nice and random, all the bugs behaving differently.

of course trying to write functions gave me errors. I have also tried using "for" loops but I also get errors when I combine it with custom variables. The for loops was in an old version of XP though, EIAS 5.5 XP I think, and this was for another project, similar though, and I ended up using an instance of XP for each "bug" and it was just a nightmare to keep track of.

Using nulls (I sometimes use the XP group itself) to store values is something I've done also. But what if you plan on doing something a bit more involved with maybe a few dozen objects?

Link to post
Share on other sites

I have taken code from flash and rewritten it to XP with no issues...

can you please provide a snippet of code you are having issues with... there are a lot of directions I could recommend, but it is nearly impossible without knowing some level of detail. I am not trying to steal code, just provide help.

custom variables might be solved with nulls... as nulls can store data through frames. One difference between Flash & Xp is that you can declare a variable in flash, and read it the next frame. Not so with XP... so if you store data in a null, you can have access to it by using the [frame-1] reference.

Cj

Link to post
Share on other sites

Thanks so much again for offering to help.

If XP supported custom functions I'd write something like this:

function bugMove(whatBug, movement_X, movement_Y, amplitude, rate){

"Bug_"+ whatBug.XPosition = movement_X;

"Bug_"+ whatBug.YPosition = movement_Y;

"Bug_"+ whatBug.ZPosition = amplitude*cos(rate*time);

}

bugMove("01", 35,27, 120, 80);

bugMove("02", 20,34, 100, 50);

What approach would you take here? cause imagine a few dozen bugs, maybe a hundred of them. Just think of the headache writing all the code for every single one of them...

Link to post
Share on other sites

thanks. For loops work yes but I could never get them to work with what I wanted, like I wrote above, although, this was in the XP that came with v 5.5

with the for loop we have passed 1 variable, the counter variable, x (whatBug). There are still 4 variables (movement_X, movement_Y, amplitude, rate) that need to be passed so, is this where you would use a container null? I assume you would make a new null for each bug and fill the x y and z position with data?

Link to post
Share on other sites

thanks. For loops work yes but I could never get them to work with what I wanted, like I wrote above, although, this was in the XP that came with v 5.5

with the for loop we have passed 1 variable, the counter variable, x (whatBug). There are still 4 variables (movement_X, movement_Y, amplitude, rate) that need to be passed so, is this where you would use a container null? I assume you would make a new null for each bug and fill the x y and z position with data?

Yes... the x,y,a & rate are numbers calculated from changes.... and you need the amp/rate from the previous frame... have a look at this project I did a number of years ago which recreates a rope.

http://www.cjberg.com/EI/rope.html'>http://www.cjberg.com/EI/rope.html

(and others http://www.cjberg.com/EI/)

Cj

Link to post
Share on other sites

I'm getting some file not found errors but that's fine. I have some good info to go by. I found your comment about referring to variables [frame -1] also very interesting: I had no idea about this and I'm reading the manual info on it. Declaring variables (or string variables with the $ sign) and referring to them seems to be kind of awkward and convoluted in XP so I need to understand these concept first I think. I will post here on this thread if I run into other issues> I haven't started the project yet.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...