View Full Version : rotate a movie
big20oz
02-25-2004, 10:49 AM
Hey guys I am just trying to rotate a simple star that is a movie.
I created a star and converted it to a movie called star
Then a circle which became button1
the code attached to the button is as follows
on (press) {
star._rotation = 30;
}
How come when I press this button the star movies doesn't rotate?
ge_flash
02-25-2004, 11:01 AM
you schould try this:
on (press) {
_root.star._rotation = 30;
}
big20oz
02-25-2004, 11:15 AM
what does the .root do?
big20oz
02-25-2004, 11:17 AM
that doesn't work either
AnubisibunA
02-25-2004, 11:19 AM
EDIT: - I noticed you just posted... you are calling the 'instance name' of your star movieclip with the code
on (press) {
_root.star._rotation = 30;
}
NOT the movieclip's name in your library. Make sure you give the star movieclip on the stage the InstanceName of "star"
that's probably your problem.
----------------------------------------[ original post ]----------
would be too much code to paste the different things you can do with rotating... so check out these pages for some help
h!!p://www.flashingthenet.com/tutorial_actionscript_rotation.htm
h!!p://mdp.artcenter.edu/~vanallen/scripting/2003fa/scripting_wk05b.html
h!!p://www.dancingimage.com/dev/CAA/3D%20Rotation%20Tutorial.htm
h!!p://www.bluesfear.com/tutorials/FLASasmotion.php
ge_flash
02-25-2004, 11:23 AM
_root define the path at Root
big20oz
02-25-2004, 11:33 AM
yeah I have all that set up right, its just not working any other sujestions?
ge_flash
02-25-2004, 11:37 AM
Can you ulpload the FLA ?
big20oz
02-25-2004, 11:39 AM
yeah give me a minute, anyone got any sujestions for a free webhost?
divarch
02-25-2004, 11:42 AM
If you are putting the code directly on the star, as you are, then:
on(press){
this._rotation=30;//though I think you want '+=30' instead
}
//this will work as 'on release' until you include 'onEnterFrame'
As already posted check the tutes!
big20oz
02-25-2004, 11:43 AM
its actually on a button
divarch
02-25-2004, 11:48 AM
Originally posted by big20oz
its actually on a button
What is? Code? No matter..
big20oz
02-25-2004, 11:50 AM
yeah the code is on the button, when you press the button the star beside it should rotate. I would think very simple but its not working.
big20oz
02-25-2004, 11:53 AM
http://us.f1f.yahoofs.com/bc/6ee0dd02/bc/flash/star.fla?bfjVNPABvGSTbhln
big20oz
02-25-2004, 11:54 AM
there is the .fla I am sure I am just doing something dumb but I am new so don't be to harsh.
AnubisibunA
02-25-2004, 11:55 AM
h!!p://mdp.artcenter.edu/~vanallen/scripting/2003fa/downloads/enterframe_flag_state.zip
from one of the links I posted... it seems like exactly what you want...
divarch
02-25-2004, 11:55 AM
Please name the INSTANCE!
It works, try it!
big20oz
02-25-2004, 11:58 AM
nope I don't want it to do that I want it just to turn one rotation of whatever degrees I want.
ge_flash
02-25-2004, 11:59 AM
divarch is right
INSTANCE!
big20oz
02-25-2004, 12:00 PM
Divarch, unless I am missing something the instances are named. I high light the movie and in the poperties box it states
Instance of: star
I must be missing something
ge_flash
02-25-2004, 12:02 PM
press Button.
big20oz
02-25-2004, 12:04 PM
I was looking right beside that boy at the instance of label...I get it now sorry I was being a moron and thanks for the help guys!
big20oz
02-25-2004, 12:30 PM
now how so I make it that when I hit that button the star spins a set # of times? A while loop comes to mind. Am I correct here?
divarch
02-25-2004, 12:35 PM
No loops are run in a single frame, but you could make a function for your rotation and use 'setInterval' instead.
Please search the forum with 'interval' keyword.
big20oz
02-25-2004, 12:35 PM
on (release) {
x=0;
while(x<100) {
_root.star._rotation+i +=10;
x++;
}
}
here is the code I am trying
divarch
02-25-2004, 12:41 PM
Originally posted by big20oz
on (release) {
x=0;//put this outside the button
while(x<100) {
_root.star._rotation+i +=10;//what is i for? x++;
}
}
here is the code I am trying
divarch
02-25-2004, 12:43 PM
If you sitck with the loops, try this:
var x=0;
on (release) {
while(x<100) {
_root.star._rotation=x*10;
x++;
}
}
big20oz
02-25-2004, 12:48 PM
I am trying with the fuction so I made a fuction on the 1 frame 1st layer doing this
function runMe()
{
while(x<100){
_root.star._rotation += 10;
x++;
}
}
then on the button I added this code.
on (press) {
setInterval(runMe, 2500)
}
Am I barking up the right tree?
divarch
02-25-2004, 12:50 PM
Yep, the loop won't work, or it will give you more trouble, see to deal with the 'interval'.
I am busy right now, but will come back to it later today.
Cheers
ge_flash
02-26-2004, 03:52 AM
I prefer this way:
MovieClip.prototype.setRotation = function(degree) {
this.onEnterFrame = function() {
if (this._rotation<degree) {
this._rotation += 1;
} else {
delete this.onEnterFrame;
}
};
};
_root.star.setRotation(90);
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.