all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

two different _rotations?


two different _rotations? lreadl
4/3/2005 11:29:03 PM
flash actionscript:
I created a new flash document, then created a new symbol with the identifier
'arrow', which is simply a MovieClip containing one frame with a picture of an
arrow pointing to the right. Then I entered the following ActionScript in the
first frame of the new flash document: var arrow1:MovieClip =
this.attachMovie('arrow', 'arrow1', 0, [_x=0, _y=0, _rotation = 0]);
this.onEnterFrame = function():Void {arrow1._x++;}; When I did publish
preview, this produced an arrow pointing to the right, and moving directly to
the right. Then I revised the ActionScript such that it assigned a value of 45
to _rotation in the init object, as follows: var arrow1:MovieClip =
this.attachMovie('arrow', 'arrow1', 0, [_x=0, _y=0, _rotation = 45]);
this.onEnterFrame = function():Void {arrow1._x++;}; This produced an arrow
pointing to 45 degrees down and to the right, and moving 45 degrees down and to
the right. Then I revised the ActionScript as follows: var arrow1:MovieClip =
this.attachMovie('arrow', 'arrow1', 0, [_x=0, _y=0, _rotation = 0]);
arrow1._rotation = 45; this.onEnterFrame = function():Void {arrow1._x++;};
This produced an arrow pointing to 45 degrees down and to the right, but moving
directly to the right. Apparently, if you change _rotation in the init object,
the whole (_x, _y) coordinate system of the clip you're attaching is rotated,
while if you change _rotation later, only the picture itself is rotated. Am I
missing something here? This seems like a really bad way to do it. If flash
is going to allow me to change the picture independently of the coordinate
system, there should be two different properties, one for the picture, and one
for the coordinate system, instead of the same property under different
circumstances changing both. Is there a way to rotate only the picture and
leave the coordinate system unchanged using the init object? Is there a way to
rotate the coordinate system outside the init object?
Re: two different _rotations? lreadl
4/4/2005 3:35:44 AM
Ok, new question. Why did nobody answer the above question? Does no one know
the answer? Is it a stupid question no will deign to answer? Is my post not
concise enough for people to read? If you're not going to answer the above
question, please tell me what I did wrong. Should I not even come here?
Somebody please reply, even if it's only two words. I hate having no idea
what's going on.
Re: two different _rotations? kglad
4/4/2005 4:05:18 AM
properties set using the initObject reset the default properties of the
movieclip assigned those properties. it goes beyond _rotation and includes
many other movieclip properties.

for example, after all your attachMovie() statements, including the 2nd,
arrow1._rotation=0. if you use:

var arrow1:MovieClip = this.attachMovie("arrow", "arrow1", 0, [_x=100, _y=0,
_rotation = 45,_alpha=5,_xscale=22]);
trace(arrow1._x);
trace(arrow1._rotation);
trace(arrow1._alpha);
trace(arrow1._xscale);

you'll find them all the be the default numbers.
Re: two different _rotations? robin_southgate
4/4/2005 11:21:02 AM
I think your terminology of using square brackets is incorrect. Therefore your
_rotation value is actually being applied to 'this' and not 'arrow1'. To use
the initobject I have always used the shorthand object declaration: {_x:0,
_y:0, _rotation:45} - that would then apply the object values to arrow1
correctly.
Re: two different _rotations? Rothrock
4/4/2005 11:36:31 AM
lreadl the only thing you did wrong was be too impatient. Sometimes it might
take more than a few hours to answer a question. Everyone here is a volunteer
and sometimes you might have to wait a whole day before you get an answer. As
to the question, I was really startled by that. I would not have thought that
was how it worked ? and agree that seems to be a bad idea, but I'm sure that a
use can be made of it ? it certainly makes going off at a 45 degree angle much
easier! It would seem your choices are to use the init object or not. If you
use it you will have to take it into account.
Re: two different _rotations? Rothrock
4/4/2005 11:42:43 AM
Good catch robin_southgate! I hadn't noticed that and that explains it all. I
hardly ever use the init object, but when I do I use the curly bracket
notation, so that would explain why I had never noticed this.
Re: two different _rotations? lreadl
4/4/2005 7:29:58 PM
Re: two different _rotations? Jeckyl
4/4/2005 9:26:45 PM
[quoted text, click to view]

The problem is the above.

The above is the same as

_x=0;
_y=0;
_rotation = 0;
this.attachMovie('arrow', 'arrow1', 0, [0,0,0]);

that is, you are evaluating the assignments and then passing an array in the
last parameter of the attachMovie instead of an object

what you need is to pass an object like this

this.attachMovie('arrow', 'arrow1', 0, { _x:0, _y:0, _rotation:0} );

the above creates an object with _x, _y and _rotation values and passes that
to the attachMovie to set up the corresponding variables in the new
movieclip.

Jeckyl


AddThis Social Bookmark Button