revolving objects

This is a discussion on "revolving objects" within the Flash & Multimedia Forum section. This forum, and the thread "revolving objects are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices




Closed Thread
 
LinkBack Thread Tools
  #1  
Old Sep 8th, 2003, 12:52
New Member
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
revolving objects

I've tried a couple of forums now with no success. Im no expert but at the same time im sure this is achievable...cos I've seen stuff like this before?!
I have a bit of script which is revolving an object around a central point. All i want is it to be interactive...so that when i move the mouse to the right side of the screen for example (ie. "_xmouse > 250") it orbits right and if i move left it roates left. It would be even cooler if it acted with acceleration... so it moved faster and then obviously slower as you moved the mouse towards the center of the stage. It's just a case of using the variable "speed" and the _xpositon i guess??. But i dont know how cos Im no pro. any help would be hugely appreciated.
Thanks...

This is the script I have so far...

onClipEvent(load){
y=100;
speed=5;
radius=100;
xcenter=250;
ycenter=200;
zcenter=100;
angle=0;
fl=150;
}

onClipEvent(enterFrame){
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;
angle+=speed;
if(angle>359){
angle-=360;
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Sep 8th, 2003, 17:59
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, It took me a little bit of thinking, but I think you'll like the solution as it only requires 2 new lines of code and the deletion of another!

And it does speed up further away from the object:

Code: Select all
<textarea cols=70 rows=20>
onClipEvent (load) {
    multiplier = 0.05;
    y = 100;
    radius = 100;
    xcenter = 250;
    ycenter = 200;
    zcenter = 100;
    angle = 0;
    fl = 150;
}
onClipEvent (enterFrame) {
    speed = _xmouse*multiplier;
    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;
    angle += speed;
    if (angle>359) {
        angle -= 360;
    }
}
</textarea>
You can change the multiplication factor (how much more the object speeds up) at the top - It's the very first variable.
All I did was multiply the mouse x co-ordinate by this number. 0.05 seems about right to me. 0.1 is ridiculously fast and 0.01 is sluggish.

Hope this is exactly what you wanted
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Sep 9th, 2003, 10:34
New Member
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
your an absolute star! thankyou very much...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Sep 9th, 2003, 10:55
New Member
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Just had a play around ..and its almost what i wanted. I appreciate your help but i realised that what i actually want in the long run is probably going to be more difficult. What this will do eventually is have 4 objects all rotating together. I do this by changing the angle variable on each object. So i divided 360 by 4 to give them equal distances apart. So I have 90, 180, 270 and 360. This works as i had it before but with the new code they will understandably all move into the same position once the mouse enters the center of the screen thus covering each other.
So now im confused as to how i would keep them seperate and at the same time have each of them a button so you can click on them individually.
I know im proably asking a bit to much but just thought you might might be able to shed some light on the matter?!
Anyway..thanks again Sirkent. You've been a great help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old Sep 9th, 2003, 11:25
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Could you post your new code so I can have a headstart on this one? I've been very busy at the moment so I can't quite be bothered to get as far as you - But i'd be happy to try and figure out what the problem is.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
Old Sep 9th, 2003, 11:56
New Member
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
cool.
sorry when i said new code i meant your new code. Basicly if you just have four objects on the stage with the original code i had on each one, but change the angle on each one. ie.
angle = 90
angle =180
angle =270
angle =360.
notice how this works...they all move together but are seperated. i want to acheive this but with your new code! as it is they all move to the same position overlapping each other?
does this make sense...?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Closed Thread

Tags
revolving, objects

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to move the objects in HTML? virenparmar Website Planning 1 Jun 2nd, 2008 08:47
Moving Objects (Not sure if this goes here) Stormraven JavaScript Forum 9 May 11th, 2008 21:59
Sending objects to the client QuikFrozen ASP.NET Forum 5 Apr 18th, 2007 14:20
XML to dataset, bussiness objects johndahl ASP.NET Forum 0 Apr 28th, 2006 05:46
Internet Explorer & objects... HELP! brittny Web Page Design 7 Jul 6th, 2005 23:29


All times are GMT. The time now is 21:50.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved