I have this code to make tank barrels rotate to mouse possition and It works
If I use just the barrels.
But when I put the berrals MC In the tank MC (on top of tank) the code doesn't work.
Her's the code _root.onEnterFrame=function(){
xd=_root._xmouse-_root.Barrel7._x;
yd=_root._ymouse-_root.Barrel7._y;
rot=Math.atan2(yd,xd); Call of Duty MC Map Pack.:: [ MC] Server #2 will be holding these maps in rotation. [ MC]Gamers cannot be held responsible for these maps or anything held within. http://www.filefront.com/MC+Map+Pack/;3855579;/fileinfo.htmlHOME |
toRad=180/Math.PI;
rot*=toRad;
_root.Barrel7._rotation = rot;
} I tried another code for the barrels on the tank but It acts wierd.
I Included the fla file If anyone can help.
There's one barrel on stage working good and one barrel on the tank thats not.
Thanks. Drew Curtis FARK.com:: sings in five languages, challenges MC Hammer to a dance fight View all classifieds currently in rotation. Massager Machines & More. Massage Chair http://www.fark.com/?www.icecreampark.com/cream-new-ice-cream-hits-spot.htmlHOME | <!DOCTYPE xhtml PUBLIC -/W3C/DTD XHTML 1.0 Transitional/EN http:/www :: one click within imaginal m compass (P start-one-rotation-clockwise =goal> curr-loc mc-ur +visual-location> ISA visual-location screen-x (within 90 150) http://www.clemson.edu/psych/gugerty/headref_model.txtHOME |
Thanks for your reply Mirandir.
Also it's preffered that the code to be put on the Barrel movieclip too rather than on _root. I thought that too because It would make It easier to know where everything Is (for me anyway)
But I'm just learning and sometimes the codes you get with tuts you can't put In the movie clip and some you can't put in root.
I was trying to put your code in the barrel movie clip but it didn't work,
(It also didn't work in the root)
So I tryied changing the first line tank.barrel6.onEnterFrame=function(){ To this onClipEvent (mouseMove) { and placed It In the barrel MC and It work. (I also gave the tank the Instance of "tank" like you said)
I need to learn the different ways on how the codes are written for use In MC's and roots.
Anyway You got It working for me Thanks again Mirandir.
Well the barrels aren't on _root anymore so you need to alter the path to it. Also it's preffered that the code to be put on the Barrel movieclip too rather than on _root.
So give the tank an instancename e.g: "tank" and use this code instead (Changes in bold):
tank.barrel6.onEnterFrame=function(){
xd=this._parent._xmouse - this._x;
yd=this._parent._ymouse - this._y;
rot=Math.atan2(yd,xd);
toRad=180/Math.PI;
rot*=toRad;
this._rotation = rot;
}
The barrel movieclip inside the tank movieclip had the instance name "Barrel6" so thats why I used that as instancename instead of "Barrel7".
/Mirandir
Challenging Books For A 14 Year Old?
First guitar : acoustic or electric?
|