View Full Version : Feel free to call me a moron
Nittenakios
04-30-2004, 08:12 PM
I have followed the 3D rotation tutorial on the bit-101 site, and have a nice little animation of spinning balls. So far, so good. Now, I'd like to add a section of code that affects the speed of rotation, and allows for negative (anti-clockwise) rotation also. I would like it to be dependant upon mouse position, as in the moveable slideshow tutorial on this site, which I have attempted, massivly badly, to implement.
Could someone please give me some advice before I defenestrate my PC?
Thanks,
Frustrated in Malta
vosgien
05-01-2004, 02:54 AM
feel free to call me a moron
OK - you're a moron - no, only joking, suprise is that no one did it before me !
In order for someone to answer your Q you need to post the code or ( better still) post an fla so that people can see what you have done and maybe help improve on it
Cheers
Vosgien
Nittenakios
05-01-2004, 04:20 AM
I hope this helps. I have been thinking about this overnight, but I have still made no headway! Any help is much appreciated.
Thanks,
Malta is now an EU member, don't all rush at once...
vosgien
05-01-2004, 06:23 AM
Hi,
To alter direction according to the mouse position, in frame 2 of your ball mc's change this line:
angle+=speed;
to this :
if(_root._xmouse > 275)
{
speed = 10;
angle+=speed;
}
else if(_root._xmouse < 275)
{
speed = 5;
angle-=speed;
}
Now, you could copy and paste this ten times, but if you look at the attached fla, you will find one ball in the library, and some code on the main timeline, which uses an array of the angles, this is used to load in ten balls ( there are ten angles) and the code in frame1 of the ball mc
angle=//whatever angle each ball is
//is changed like this
angle = _name;
This way you have only one lot of code to alter
Hope that helps
Vosgien
Nittenakios
05-01-2004, 11:20 AM
Vosgien, thanks very much!
It works very well, now all I have to do is to work out how to make the speed proportional to the mouse position, so that it slows to a stop when the mouse is in the centre, and speeds up as the mouse movesto the left or right.
Thanks for attaching ring2.fla as an example, but I am afraid that I cannot open it- Flash says "unexpected file format", I am guessing that this is because you use MX and I use an elderly copy of Flash 5? Or my copy of Flash needs to go to the old folks home...
Would there be any chance of you posting the code that you used on the main timeline to generate the array?
Many thanks for your help,
Nittenakios
vosgien
05-01-2004, 11:34 AM
Hi,
If you are using F5, you need one ball in the library, give it a linkage identifier of ball, put this code on fr1 of the main timeline :
ballArr = new Array();
ballArr = ["0","36","72","108","144","180","216","252","288","324","360"];
for (i=0; i<ballArr.length; i++) {
attachMovie("ball", ballArr[i], i);
}
and in frame 1 of ball change
//from
angle = 0;
//to
angle=_name
this will make life easier for you
It is Saturday evening here and I have a life beyond Flash, which means I am going out for the evening, if you work out how to relate the speed to the mouse pos, post here, and if I don't see a post by tomorrow sometime I will look again for you
Cheers
Vosgian
Nittenakios
05-01-2004, 11:38 AM
Vosgien, again, thanks!
I'm working on the relative speed thing now..
Have a good time tonight, I think I can hear beer calling my name about now as well.....
N
vosgien
05-01-2004, 11:43 AM
Hi,
If you are in the UK it is most certainly beer o'clock
Cheers
Vosgien
Nittenakios
05-01-2004, 11:49 AM
I'm in Malta, just under Sicily, and the bells are chiming "drink Drink Drink" as Itype this..:D
In the first frame
nMaxRate= 5;
In the second frame
z=Math.sin(angle*Math.PI/180)*radius+zcenter;
scale=fl/(fl+z);
x=Math.cos(angle*Math.PI/180)*radius;
_x=x*scale+xcenter;
_y=y*scale+ycenter;
_xscale= _yscale = scale*100;
_alpha=scale*100;
if(_root._xmouse > nScreenWidth/2)
{
speed = (nMaxRate - _root._xmouse * nMaxRate/(nScreenWidth/2));
angle+=speed;
}
else if(_root._xmouse < nScreenWidth/2)
{
speed = (_root._xmouse * nMaxRate/(nScreenWidth/2)- nMaxRate);
angle-=speed;
}
if(angle>359){
angle-=360;
}
Now the speed is proportional, I just need to work on tidying it all up!
N
Nittenakios
05-01-2004, 03:39 PM
The idea of reducing this to an array is very neat, very efficient, but I want this to form the basis of a navigation system (eventually). To this end, I believe that I have to identify each ball individually, with an invisible button, so that they may be selected and perform different duties. Being new to Flash, this assumption of mine may well be wrong. Can anyone steer me toward the truth?
N
Nittenakios
05-01-2004, 05:08 PM
Currently Flash decides the value of _xmouse and decides what to do with it. Now this works very well, in terms of close to the <or> ScreenWidth thing, IF screenwidth is 400.. But, I want more. I would like my circle of balls (heretoafter known as cballs) to be a nav system. Specifically for a much larger screen. So, the prob is, with the screen bigger, when you move the mouse to the right, the balls circle fast enough to be Kimi Raikonen JUST before his engine blows (Illmor engineering has never been the same since the plane crash).
Anyone with any ideas is more than welcome,
N
Thank Deity Of Choice/Good fortune for this Forum
Nittenakios
05-03-2004, 07:57 AM
I just upgraded from Flash 5 to MX 2004 pro, and my movie no longer works when I test it, but does when I drag the icon into IE....What have I done wrong?
N
vosgien
05-03-2004, 08:19 AM
Hi,
Only got the notification of your last post, which is why I didn't respond before. Unfortunately I work in MX and 2004 is something I know very little about, so I am not going to be much help, tho' I believe the principle are the same !
I did the same tute when I worked in Flash 5, and to counter the stage thingy, I did this, I made my three frame movie clip, and did not use the stage variable at all, I then put that clip into a second clip, there were in fact 5 or six different clips ( with different words in) in frame one of the _parent clip - does that make sense, so my frame one code looked like this
y = 0;
radius = 80;
ycentre = 10;
xcentre=10;
zcentre=75;
angle=0
fl=30;
// if you then add this :
this.onrelease = function()
{
//code here
}
/*you will make your clip a button, no need
for invisible ones*/
btw- I noticed in your original that you had the ball in three seperate key frames, you need three frames for your code and if you put the ball on another layer, you only need the one key frame extended by three.
Also, I defined my speed variable on the _root which gave me greater ability to manipulate.
Hope some of that helps, but as to why it will not work in MX Pro - sorry I cannot say
Cheers
Vosgien
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.