4 Replies Latest reply on May 1, 2008 9:32 AM by Rothrock

# Rotation Problem

• ###### 1. Re: Rotation Problem
yengec;

I have not read through your code, but I think that a good start to solving your problem would be to simplify your code; in doing so you will be able to focus in on the problem areas of your code;

try "commenting out" everything; then, one line of code at a time, un-comment-out your code;

I am sure you get the idea; this is how I, for instance, debug a large chunk of code that is producing an error somewhere within it;

I hope that this helps;

• ###### 2. Re: Rotation Problem
I also would add that i do not understand the use of 'Strings' here in lue of numbers?
• ###### 3. Re: Rotation Problem
Fla Source Code
• ###### 4. Re: Rotation Problem
Your code is a style that was introduced in Flash 5 and was replaced by dot notation in Flash 6. Very few people here (or anywhere really) understand it. I used it a bit in 2001, but quickly adopted Flash 6 dot notation and can barely remember where to begin. So some of what I tell you now might not be right.

The :/ means a varaible so you can just replace the first bit of:

/:trigger = Number(eval("/:trigger")) + Number(eval("/:trigger"));
if (Number(eval("/:trigger")) > 100)
{
/:trigger = "100";
}
else if (Number(eval("/:trigger")) < Number(-100))
{
/:trigger = "-100";
} // end else if

with the following code.

trigger *=2
if(trigger>100){
triger=100;
} else if (trigger<-100){
triger=-100
}

I don't know what value trigger starts with or is initialized to so that may cause problems. I just don't now.

In the next bit I'm pretty sure that "/a" means a movieclip instance called a. And instead of getProperty() we use a dot properties so all of those can be handled like this:

newRotationX=_xmouse-a._x
newRotationY=_ymouse-a._y;

I'm with clbeech here. I don't understand why you keep giving everything string values and then having to cast or eval them back to numbers. So in the next bit get rid of the casting Number() bit and assign number values instead of strings.

if(rotationX>41){
rotationX=41;
}...

And so on. That allso applies for the loop:

for (i = 1; i <= objects; i ++)

I think with the temp variables in the next bit you are trying to reference clips and variable inside clips.

set("/a/my" + i + ":tempY", (eval("/a/my" + i + ":Y")) * (eval("/library/:cos" + rotationX)) + (eval("/a/my" + i + ":Z")) * (eval("/library/:sin" + rotationX)));

So I think this should become.

a["my"+i].tempY=(a["my"+i].Y*Math.cos(rotationX))+(a["my"+i].Z*Math.sin(rotationX));

I think that is right. There are now built in trig functions. But they use radians, so you will need to convert your degrees to radians. Or perhaps you could use.

a["my"+i]*library["sin"+rotationX] etc.

The following lines are pretty much the same until we get down to the setProperties() part. Again we don't use that just a dot.

a._yscale=depthZ

And so on. And finally tell target is gone so we just tell things directly.

a.gotoAndStop(Type)

or maybe that is

a.gotoAndStop(a.Type)

It really is a mess and you've got a lot of work cut out for you.