Deceleration Rotating Wheel.
Hi Guys,
Here's something I am planning.
I'm doing a Roulette Game and need some assistance with the wheel. Most of the graphics are ready for the game and the wheel is rotating fine etc.
What I am trying to do is get a rotating roulette wheel that gradually slows down so that it looks realistic. Of course the wheel will stop at a random place and do what it is supposed to but has anyone had to do any deceleration effects with a circle before.....
Thanks in advance
Gavin
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-04-2002, 08:17 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Rotating Wheel
Is there a way of rotating a wheel through 360 degrees without manipulating each frame to create the animation. When I use Transform and Rotate 90 degrees (4 times to make 360) the image rotates 180 degrees in one direction and then 180 degrees back. I have achieved a simular effect but I did it by creating a lot of different images and playing them one after the other. I'm hoping there's a more effecient way. Thanks for any help.
Andy
Rotating Picture Wheel
Hey everybody!
I'm trying to create a wheel of pictures that slowly rotates and on mouse-over the wheel stops and the image enlarges. Then on rollout it shrinks and the rotation continues.
I can get the wheel to spin and then stop on rollover and continue on rollout but when I add actionscript to enlarge the image on rollover then the image stops but the wheel pretends to continue and won't restart on rollout.
Can anyone help?
My actionscript looks something like (minus all the ; such symbols)
onRollover
stop ()
Image1._xscale = 200
on Rollout
play ()
Image1._xscale = 100
Rotating 'wheel' Menu
Hi flashkit peeps,
I'm after an open source interface, I'm sure I've seen something like it on here somewhere, but I can't find it.
I'm after something like this:
where when you mouse left or right the items rotate round in a circular direction (this screen grab is from http://www.red2design.co.uk/ )
Can anyone help?
Rotating Wheel Menu
Hello,
I was wondering if anyone knew how to make a rotating wheel menu? I'm making a website for a bike courrier service and I was envisioning the menu to be an actual bicycle wheel. When you click on a menu choice, the menu would rotate to the point where the menu choice would be in a designated spot for the active window. While the wheel was rotating, the sound of a rotating bike wheel would be playing. Anyone have any idea how to do something like this? Please let me know.
Thanks.
Rotating Or Spinning Wheel Menu
I want to make a menu similar to the one used on this site: http://www.renaissance-movie.com/.
That's my personal goal for the day. I would love any tips, suggestions, or resources. Anyone?
I know it's going to use _rotation. The rest is not so clear.
Thanks for any help!
Rotating Thumbnail Image Menu Wheel
Can anyone help? I'm searching for a tutorial how to make a rotating thumbnail image menu wheel similar to this one:
http://www.nickgeorghiou.com/nick.html
Thanks!
[F8] Help With Spinning Game Wheel... Wheel Of Fortune-style
Hi everyone,
I'm working on a game with a Wheel of Fortune-style wheel... spin it and it lands on a category.
I have a spinning wheel which works when you drag it with the mouse to "flick it" around... but I actually need it to work with a single keypress. I've attached the files to show where I am. I got the keypress working at the most basic level, but it's buggy and has some weird stuff going on...
- It always lands on almost the same 2-3 spots (alternating)
- It changes direction mid-spin and goes a little wacky, though once it slows down it's okay
- I have nothing in place to recognize which category it landed on
Any help resolving these ANY of these issues would be great. Thanks!!
Help With Spinning Game Wheel... Wheel Of Fortune-style
Hi everyone,
I'm working on a game with a Wheel of Fortune-style wheel... spin it and it lands on a category.
I have a spinning wheel which works when you drag it with the mouse to "flick it" around... but I actually need it to work with a single keypress. I've attached the files to show where I am. I got the keypress working at the most basic level, but it's buggy and has some weird stuff going on...
- It always lands on almost the same 2-3 spots (alternating)
- It changes direction mid-spin and goes a little wacky, though once it slows down it's okay
- I have nothing in place to recognize which category it landed on
Any help resolving these ANY of these issues would be great. Thanks!!
Deceleration
Hi, I have the following code in a movie clip on the main timeline. The clip accelerates to a certain speed and the the speed sort of equals out and continues. I would like the movie clip to accelerate and equal it's speed out at about 3/4 width of the stage, and then decelerate at a random speed.
Does anyone know what code I could use for this?
Any help would be appreciated..
Thanks..
onClipEvent (load) {
startX = 30;
endX = 500;
speed = ((20+Math.floor(Math.random())*20)/10)+math.random;
accel = (random(10))/100;
t = 0;
}
onClipEvent (enterFrame) {
if (this._x<endX) {
this._x = startX+speed*t+accel*t*t/2;
_level0.trail1._width = this._X;
} else {
stop ();
}
Deceleration Script
hi
i have a deceleration script that moves and slows down a moving MC when a button press. what i want though is for the MC to move and slow down while bouncing back and forth automatically. it should be pretty simple but i haven't gotten it to work yet..can anyone help? this is one the MC that moves:
onClipEvent (load) {
xDest = this._x;
}
onClipEvent (enterFrame) {
if (this._x != xDest) {
this._x += (xDest-this._x)*.12;
}
}
and this is on the button:
on (release) {
if (_root.ball.xDest == -50) {
_root.ball.xDest = +50;
} else {
_root.ball.xDest = -50;
}
}
i can send you a sample FLA if you want too, thanks for your help!
Deceleration 'float'
hi
i havea deceration script that the MC acts like a slingshot......it slows down and then speeds up in the other direction. what i want is it to 'float' kinda where it slows down and then slowly starts moving in the other direction and gradually speeds up then slows again and reverses slowly...like in a cycle. here is my 'slingshot' code on the MC right now:
onClipEvent (load) {
xDest = this._x;
xNext = this._x;
}
onClipEvent (enterFrame) {
if (this.dbf == 1) {
if (this._x != xDest) {
this._x += (xDest-this._x)*.05;
}
if (this._x>xDest-10) {
xDest = xNext-200;
}
if (this._x<xDest+10) {
xDest = xNext+200;
}
}
}
and this is the code on the button that starts it( where 'ball' is the name of the MC):
on (release) {
if (ball.dbf == 1) {
ball.dbf = 0;
} else {
ball.dbf = 1;
}
}
if anyone can tell me how i can make the MC look like its floating rather than shooting off let me know, thanks for your help!
Movement With Deceleration, Help Please
Using the following code, I am trying to slide pictures across the screen. Unfortunately at the moment they just jump to the desired location. Could anyone help me out trying to apply a motion to my slides? its been bugging me for ages now but im having trouble finding the solution(pointing me to a tutorial would be great)
Thanks.
Code:
//SS = slide section (the section not covered up by another image on the screen
//IW = image width the with of the image in focus
numberOfImages = 6;
IW = 560;
screenWidth = 700;
SS = ((screenWidth-IW)/(numberOfImages-1));
function movePics(Pic) {
if (Pic == 1) {
trace(Pic);
this.Pic1._x = 0;
this.button1._x = 0;
this.button1._width = IW;
this.Pic2._x = IW;
this.button2._x = IW;
this.button2._width = SS;
this.Pic3._x = (IW+SS);
this.button3._x = (IW+SS);
this.button3._width = SS;
} else if (Pic == 2) {
trace(Pic);
this.Pic1._x = (SS-IW);
this.button1._x = 0;
this.button1._width = SS;
this.Pic2._x = SS;
this.button2._x = SS;
this.button2._width = IW;
this.Pic3._x = (IW+SS);
this.button3._x = (IW+SS);
this.button3._width = SS;
} else if (Pic == 3) {
trace(Pic);
trace(IW);
trace(SS);
this.Pic1._x = (SS-IW);
this.button1._x = 0;
this.button1._width = SS;
this.Pic2._x = SS;
this.button2._x = SS;
this.button2._width = SS;
this.Pic3._x = (2*SS);
this.button3._x = (2*SS);
this.button3._width = IW;
}
}
Acceleration/deceleration
Hey i was wondering if someone can help me.
i have a Movie clip that i want to come across the stage, and stop at a certain point. i understand its just a standard tweening. but i wanted to use actionscript and add a acceleration/decceration effect to it. therefore having total control of where the MC is going, but still maintaining the accel/deceleration effect.
help would be greatly appreciated.
i am not that actionscript savvy, so can you please explain pretty much everything.
thanks. pdg95
Acceleration/deceleration
Hey i was wondering if someone can help me.
i have a Movie clip that i want to come across the stage, and stop at a certain point. i understand its just a standard tweening. but i wanted to use actionscript and add a acceleration/decceration effect to it. therefore having total control of where the MC is going, but still maintaining the accel/deceleration effect.
help would be greatly appreciated.
i am not that actionscript savvy, so can you please explain pretty much everything.
thanks. pdg95
Deceleration / Easing
Hi,
I am trying to find out a nice simple way to make an object decelerate / ease into position.
I have seen that there are loads of different ways of doing it but i wondered if there is a good simple function that can do the job??
any ideas?
Paul Sully
UK
http://www.sullyworld.co.uk
Deceleration / Easing
Hi,
I am trying to find out a nice simple way to make an object decelerate / ease into position.
I have seen that there are loads of different ways of doing it but i wondered if there is a good simple function that can do the job??
any ideas?
Paul Sully
UK
http://www.sullyworld.co.uk
Deceleration Function
Any one knows how can i make a funtion that takes a any given value go to cero smoothly...
Thanks in advance
Adding Deceleration/friction
hiya all.
dg kindly worte a short script for me the other day that moves a movie clip to where the mouse has been clicked on screen, see below:
onClipEvent (load) {
speed = 350;
move = false;
}
onClipEvent (mouseDown) {
if (!this.hitTest(_root._xmouse, _root._ymouse)) {
targetx = _root._xmouse;
targety = _root._ymouse;
x_distance = targetx-this._x;
y_distance = targety-this._y;
distance = Math.sqrt(Math.abs(x_distance*x_distance+y_distanc e*y_distance));
move = true;
time = distance/speed;
updateAfterEvent();
}
}
onClipEvent (enterFrame) {
if (move == true) {
this._x += (x_distance/time)/40;
this._y += (y_distance/time)/40;
if (Math.abs(targetx-this._x)<=4.5 && Math.abs(targety-this._y)<=4.5) {
move = false;
}
}
}
how can i change or add to this script so that as the movie clip reaches it's target it slows down??
any help much appreciated.
Acceleration/deceleration And Actionscript
hi, thanks to be there!
I need to make a move with a piece:
circle a x=30 y= 300
must going to: x 30 y=0
I need to use actionscript...
Must accelerate during the move and decelerate when it's came to the target...
HOW?
Thanks!
Ben
Deceleration Solution Loading Too Soon
I have this deceleration script plugged in to two mc's. on the mc being controlled (in this case moved) I have:
onClipEvent (load) {
_x=-94.6;
finalX=137.5;
_y=148.8;
finalY=148.8;
}
onClipEvent(enterFrame){
_x += (finalX - _x)/5;
_y += (finalY - _y)/5;
}
Then on my mc that acts as a button to control the above mc, I have:
on (release) {
_root.mc_b.finalX = 137.5;
_root.mc_b.finalY = 148.8;
The problem is that the mc moves when the movie is loaded, rather than on the release of my mc w/ button. I just want one mc to tell another (on release) to move (look animated) to a desired x, y coordinate.
I must be placing something wrong in the above script. Can anyone help????
Thank you, Thank you
Friction/deceleration Question...
howdy all...
hoping someone can help me out with this scrolling action...i'm trying to add friction to the drag, and deceleration to onRelease. i have tried several different things, but nothing seems to work correctly. any tips would be much appreciated. thanks!
left = line._x - (line._width/2);
right = line._x + (line._width/2);
tb = line._y;
difference = Math.abs(right-left);
tFrames = this._totalframes;
step = Math.round(difference/tFrames);
slider._x = left;
slider.onPress=function(){
startDrag(this,true,left,tb,right,tb);
runMe();
}
slider.onRelease=function(){
stopDrag();
delete slider.onCurrentFrame;
}
slider.onReleaseOutside=function(){
stopDrag();
delete slider.onCurrentFrame;
}
function runMe(){
slider.onEnterFrame=function(){
xPos = slider._x;
toGo = parseInt((xPos-left)/step);
gotoAndStop(toGo);
}
}
stop();
The Best Way? (deceleration: OnEnterFrame / Functions)
Hey guys, thanks for taking the time to help out.
Ok, so I'm sure all of you have seen the simple decelleration script...
code: this._height = this._height+((_root.targetH-this._height)*.2);
... if not it's pretty easy to understand. Anyway, I'm putting together a project which requires multiple MC's to share this same code but with different properties (instead of _height, it would be _y). As well, the movements have to be controlled by button onPress events.
Now, I am wondering how the best way to go about this would be.
I have tried this before by placing the above code in an onEnterFrame event of every MC that requires it, but after three or four of these bad boys get on the stage at once, performance is severy affected because of all the endless loops.
My other alternative would be to throw the code into a function. Even still performance decreases because it's still being called endlessly.
Is there an easier way to do this that doesnt affect CPU performance as much? Maybe a way to only cycle through the script until the MC has reached it's target properties?
Any help would be greatly appreciated...
Thanks!
How Do I Resize A Rectangle With Deceleration?
How do I resize a rectanlge with deceleration?
I've seen it on many websites... but can't figure out how to do it.
http://www.evb.com/ shows exactly what I want.
Each time you click a link... the square rectangle resizes to a new dimension... in doing so... the existing rectangel travels to the new dimension with a deceleration.
I've seen other places where you have an object and have two frames controlling it. There are two variables controlling the size of the object. Despite many tries... I can't do it.
Any help would be appreciated.
Thanks.
Jam
Deceleration And Spring Effect?
does anybody know how to make a decelerating spring effect? what i want is to have a ball that goes to a target using the spring effect (ie it goes a bit further than the target and springs back a bit before a few times decreasing each time the distance - giving a spring effect) - but what i also want is that as it goes to the first position where it 'springs' back for the ball to decelerate!
I can do the spring - i can do the deceleration - but I dont know how to do the 2 together -
// my spring effect -
onClipEvent (load) {
this._y = 200;
this._x = 100;
targetX = 300;
mover = 0;
loop = 0;
}
onClipEvent (enterFrame) {
if (_root.go == 1) {
mover = mover+(targetX-this._x)/2;
mover=mover *.6;
this._x = this._x+mover;
loop=loop+1;
_root.where=_x;
}
}
// my deceleration
onClipEvent (load) {
movedx = 0;
targetX = 300;
}
onClipEvent (enterFrame) {
distX = targetX-this._x;
totalDistance = Math.sqrt(distX*distX);
this._x += distX*speed;
if (totalDistance<1) {
this._x = targetX;
}
}
Any help much appreciated!
Frame Rate Deceleration
greetings, I am in need of a button that, when pressed once, decelerates the fps from 16 to 8, then, when clicked for the second time, reaccelerates it back to 16. I have already asked some actionscripters, but their replies and explanations on making such a button did no more then litterally mess up the rest of the animation's actions. Here is attached an .fla of my attempt on making such a slow-mo button
http://www.geocities.com/kirillfessenko/slowmo.fla
(note that the fla is in flash mx (not professional) format)
If you export the swf from the fla, notice that the button that decelerates the fps (on the left) only works during the first loop. All the other buttons refuse to function. What's more is that, after every loop, the frame rate actually accelerates for some reason.
Can anybody help? if so, I am, in advance, deeply grateful
Horizontal Scrolling A MC With Deceleration?
I'm trying to create a scrolling effect much like the one viewable here:
http://www.humaniz.com/work/
Which scrolls left/right depending on the mouse position. I found some (old, old) code that kind of does the trick. After determining that the mouse _y position is correct, it kicks into this looping frame to move the large movieclip:
Code:
mouseposition = getProperty("/myself", _x);
iconsposition = getProperty("/icons", _x);
if (Number(mouseposition)>=400 and Number(iconsposition)>Number(-220)) {
setProperty("/icons", _x, iconsposition-(0.1*(mouseposition-400)));
}
if (Number(mouseposition)<300 and Number(iconsposition)<1034) {
setProperty("/icons", _x, Number(iconsposition)+Number((0.1*(300-mouseposition))));
}
However the code is kinda ancient, and doesn't decelerate when it reaches either end of the movieclip it's scrolling.
Is there an elegant way to handle this?
Single Vector Deceleration
Hello,
I think this is one of those dead simple problems, yet I can’t seem to figure out what is going on...
I’m trying to get an object/ball to start at some speed, smoothly decelerate, and stop exactly as some specified distance.
The formula I’m using is from 1d kinematics:
V(f)^2 = V(i)^2 + 2ad
V(f) is 0, since I want it to stop moving, acceleration I have set to -1, and distance I have set to 100.
V(i) = squareRoot(-2 * a * d);
Yet when I run it, my object starts at 0px, and stops at 92.95px and I can't figure out why it never reaches whatever my distance is set as.
Attach Code
ballClip.onPress = function():Void {
this._x = 0;
this.acceleration = -1;
this.distance = 100;
// vf * vf = vi * vi + 2ad
// vf = 0;
// vi = squareRoot(-2ad)
this.velocity = Math.sqrt(-2 * this.acceleration * this.distance);
this.xPos = this._x;
this.onEnterFrame = function():Void {
this.velocity += this.acceleration;
if(this.velocity > 0){
this.xPos += this.velocity;
this._x = this.xPos;
} else {
delete this.onEnterFrame;
trace(this._name +" x: "+ this._x);
}
}
}
ballClip.onPress();
Adding Deceleration To Scroller
I'm using the thumbnail gallery tutorial from this site, and I was wondering how I could add deceleration to the horizontal scroller. Here is the scroller part of the code from the flash file:
PHP Code:
function thumbNailScroller() {// thumbnail code! this.createEmptyMovieClip("tscroller", 1000);scroll_speed = 40;tscroller.onEnterFrame = function() {if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {thumbnail_mc._x -= scroll_speed;} else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {thumbnail_mc._x += scroll_speed;}} else {delete tscroller.onEnterFrame;}};}
Scaling A MC With Acceleration/deceleration
hello all,
I'm having trouble altering some code that was designed to move a MC from one x-coordinate to a new x-coordinate, with acceleration/deceleration. the alterations i'm trying to make are to take an existing MC, a simple box, and change its size by scaling, while still maintaining the acceleration/deceleration as the MC changes it's size. so far, the MC changes its size with the easing in/out, but i can't get the proper size to happen with the variables i'm passing to the function. here's what I have...
----In the first frame of Main:
function scaleTo(x, y) {
whitebox.newX = x;
whitebox.newY = y;
}
-----On the MC (in Main) named whitebox:
onClipEvent(load) {
var d = 2;
var speedX = 0;
var speedY = 0;
var newX = _xscale;
var newY = _yscale;
}
onClipEvent(enterFrame) {
speedX = (_xscale-newX)/d;
speedY = (_yscale-newY)/d;
_xscale = speedX;
_yscale = speedY;
}
-----On a Button (in Main) to trigger the action of the scaling:
on (press){
scaleTo(500, 300);
}
So that's what I have. Three seperate pieces of code. Are there any gurus out there that think they can crank out a simple modification that would make this MC scale to the proper x and y values set by the Button? any help would be much appreciated!!
Thanks everyone....
M14
Help With Mouse Activated Acceleration And Deceleration
Hi guys,
Does anybody know of any source code that i could look at to make a series of images browsable like in http://www.bumbleandbumble.com
Bascially so when hit a thumb nail is hit the images spin through and settle on the relevant image?
Any help much appreciated.
Thanks
Neil
Move Clip With Acceleration / Deceleration
hi there!
i want to move a clip from lets say position y1 to y2. i want it to accelerate from y1 half the way and then decelerate until it is at the y2 coordinate. (so it is slow at the beginning, fast in the middle and slows down at the end).
what the hell is the formular for this? (sorry, but i was always missing in math-lessions...)
thanks for helping me out!
MX Movie Clip Movement With Deceleration
I have movieclip1. When I mouseDown, I want to move movieclip2 to a specific _x position with deceleration.
I am using setProperty (_x) of clip2 on mouseDown of clip1, and clip2 moves just fine, but how do I get the deceleration to work?
Thanks for any help,
kovalik
Object Scroller With Acceleration / Deceleration
Hello! I'm very (EXTREMELY) new to action script and in need of serious help...
I was trying to create an "object scroller with acceleration / deceleration"; a sliding thumbnail gallery. But I don't want the horizontal row of thumbnails to repeat, as in this tutorial:The Infinite Menu tutorial (on Kirupa.com). Rather I just want it to ease out to the end of the strip of images on either side.
Any help out there?
Object Scroller With Acceleration / Deceleration
Hello! I'm very (EXTREMELY) new to action script and in need of serious help...
I was trying to create an "object scroller with acceleration / deceleration"; a sliding thumbnail gallery. But I don't want the horizontal row of thumbnails to repeat, as in this tutorial:The Infinite Menu tutorial (on Kirupa.com). Rather I just want it to ease out to the end of the strip of images on either side.
Any help out there?
Easing [acceleration/deceleration] PanO Image
Hi:
Okay, I edited out all of my confusing commentary
Can somebody please analyze the script below, and tell me why it runs choppy???
It appears that it is too processor intensive at times, but I don't understand why that is.
Actions on the clip:
onClipEvent (load) {
_x=0;
_y=150;
speed=0;
targetSpeed=0;
}
onClipEvent (enterFrame) {
_x+=Math.round(speed/3);
if (speed < targetSpeed) {
speed+=Math.round(10/8);
}else if (speed > targetSpeed) {
speed-=Math.round(10/8);
}
if (_x < 0) {
_x=762;
}else if (_x > 762){
_x=0;
}
}
Actions on the invisible hotspots/buttons [4 in all, each with different values]:
on (rollOver) {
_root.image1.targetSpeed=25;
}
on (rollOut) {
_root.image1.targetSpeed=0;
}
Here is an example [no preloader, but only 55k]:
http://www.ekigroup.com/360/hudsonPano.html
BTW, if I just use a simple _x+=15, etc., there is no choppyness. The frame rate is 24fps.
Thanks,
James
He is risen!!!
[MX04] Deceleration/acceleration In Movie Clip
Hello I was wondering how to add deceleration to a movie clip. I already have acceleration.
onClipEvent(load){
speed=0
maxspeed=5
acceleration=.5
}
onClipEvent (enterFrame) {
this._y+=speed
if (Key.isDown (Key.DOWN))
{
if(speed<maxspeed){
speed+=acceleration
}
}
else if (Key.isDown (Key.UP))
{
if(speed>-maxspeed){
speed-=acceleration
}
}
}
This doesn't decellerate though. Any help is appreciated.
Problems With Frame Rate Deceleration Script
Greetings, I have an animation in which I inserted a button. This button I've scripted to lower the fps of my animation when clicked once, then to raise it back up when clicked twice. The script for this button is as follows:
ActionScript Code:
on (release) {
if(_root.FPS == _root.normalFPS){
_root.changeFPS(_root.slowMoFPS);
} else if (_root.FPS == _root.slowMoFPS){
_root.changeFPS(_root.normalFPS);
}
}
additionaly, one has to give the following command to the frame on which the button is located:
ActionScript Code:
stop();
// Defines default FPS
var normalFPS = 24;
// Defines slow mo FPS
var slowMoFPS = 12;
// Defines animation interval
var animation = null;
// Defines current FPS
var FPS = normalFPS;
// Makes a next frame function
function animate() {
nextFrame();
}
// Makes the function to change FPS's
function changeFPS(f) {
if (animation != null) {
clearInterval(animation);
}
animation = setInterval(animate, 1000/f);
FPS = f;
}
changeFPS(normalFPS);
The button functions perfectly, all seems to work well, apart from the fact that the sound doesn't play, for reasons unknown. I noticed that when it's synced in event, it does work, but I need it to be in stream. Here's a link to the file, can you explain why it doesn't work?
http://www.geocities.com/kirillfessenko/slowmo.fla
I am, in advance, deeply grateful for all the help you'll have to offer
Problem: Sprite Acceleration/deceleration Using Timer
I'm writing a simple space game (it looks like Asteroids right now) that, at this early point, only shows a little spaceship, and has one bit of functionality: You press the spacebar to make it go, and let up on the spacebar to make it stop. It only goes straight.
I have used timers and keyboard events to make this work. It's easy to get the ship to go and stop, but now I want to add that first bit of realism by having the ship decelerate when you lift the spacebar, rather than just stopping on a dime.
What I've developed so far has shown me that this deceleration either doesn't work in a timer function (I'm a newbie and may not be using the correct lingo here), or I somehow have to do something to sync frame rate with timer delay or something along those lines. Right now, with the code I have (shown below), the trace indicates that the ship is indeed "slowing down" until it stops, but because of the timer, that happens pretty much instantly.
Can anyone advise me about how to make the ship slow down in a realistic fashion? (That would of course also show me how to make it speed up realistically too.)
Comments about my coding style are welcome. I am not a developer by trade.
Here's the code. This is ALL in frame one of a FLA. No custom classes. Frame rate is 50.
Code:
var ship:Sprite = new Sprite();
ship.graphics.lineStyle(2,0xFFFFFF);
ship.graphics.beginFill(0x000066);
ship.graphics.lineTo(40, 20);
ship.graphics.lineTo(0, 40);
ship.graphics.lineTo(10, 20);
ship.graphics.lineTo(0, 0);
ship.graphics.endFill();
var flame:Sprite = new Sprite();
flame.graphics.lineStyle(2, 0xFFFFFF);
flame.graphics.beginFill(0x000066);
flame.graphics.moveTo(6, 12);
flame.graphics.lineTo(10, 20);
flame.graphics.lineTo(6, 28);
flame.graphics.lineTo(-2, 20);
flame.graphics.lineTo(6, 12);
flame.graphics.endFill();
addChild(ship);
ship.addChild(flame);
var speed:Number = 1;
var i:Number;
ship.x = stage.stageWidth/2 - ship.width/2;
ship.y = stage.stageHeight/2 - ship.height/2;
var shipGoTimer:Timer = new Timer(10);
shipGoTimer.addEventListener(TimerEvent.TIMER, shipGo);
var shipStopTimer:Timer = new Timer(10);
shipStopTimer.addEventListener(TimerEvent.TIMER, shipStop);
stage.addEventListener(KeyboardEvent.KEY_DOWN, sbDown);// press spacebar to move
stage.addEventListener(KeyboardEvent.KEY_UP, sbUp);
function sbDown(event:KeyboardEvent):void {
if (event.charCode == 32) {//spacebar
shipGoTimer.start();
shipStopTimer.stop();
}
}
function sbUp(event:KeyboardEvent):void {
if (event.charCode == 32) {
i = 0;
shipGoTimer.stop();
shipStopTimer.start();
}
}
function shipGo(event:TimerEvent):void {
ship.x += speed;
// if ship goes beyond right bound
if ((ship.x - ship.width/2) > stage.stageWidth) {
ship.x = -ship.width * 0.9;
}
}
function shipStop(event:TimerEvent):void {
while (i < speed) {
ship.x += speed - i;
trace("i = " + i + ", ship.x = " + ship.x);
if ((ship.x - ship.width/2) > stage.stageWidth) {
ship.x = -ship.width * 0.9;
}
i += .01;
}
}
I Can Scroll Text & Trace The Mouse Wheel But Not Move The Text With The Mouse Wheel
Can u help me scroll some loaded text with the mouse wheel?
This code is great but I just cant get the mouse wheel to scroll. I have set up the mouse wheel trace but need help from here on please
Code:
scrollmcMaxY = tmask._height-scrollmc._height;
scrollmc.onRollOver = function() {
this.gotoAndPlay("over");
if (this._y>=22 && this._y<=scrollmcMaxY-22) {
this.arrowup._visible = true;
this.arrowdown._visible = true;
} else if (this._y<22) {
this.arrowup._visible = false;
this.arrowdown._visible = true;
} else {
this.arrowup._visible = true;
this.arrowdown._visible = false;
}
// end else if
};
scrollmc.onRollOut = function() {
this.gotoAndPlay("out");
};
scrollmc.onPress = function() {
this.gotoAndPlay("press");
endy = _ymouse-this._y;
this.onMouseMove = function() {
if (_ymouse>=endy && _ymouse<=scrollmcMaxY+endy) {
this._y = _ymouse-endy;
} else if (_ymouse<endy) {
this._y = 0;
} else {
this._y = scrollmcMaxY;
}
// end else if
ratio = (chpTexteHauteur-tmask._height)/scrollmcMaxY;
this.onEnterFrame = function() {
var _loc2 = -this._y*ratio;
chpTexte._y = chpTexte._y+int(_loc2-chpTexte._y)*2.000000E-001;
};
};
};
scrollmc.onRelease = function() {
delete this.onMouseMove;
delete this.onEnterFrame;
};
scrollmc.onReleaseOutside = function() {
this.gotoAndPlay("out");
delete this.onMouseMove;
delete this.onEnterFrame;
};
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(wheelNum:Number)
{
if (wheelNum> 0)
{
trace("towards computer");
}
else if (wheelNum< 0)
{
trace("away from computer");
}
}
Mouse.addListener(mouseListener);
"Wheel Of Fortune" Wheel
I need to create a "Wheel Of Fortune" style wheel, where if a person clicks a button it spins, slows down, and then stops at a random location. Not sure where to start though, please help!
Rotating Boxes-non-rotating Box/text
i have a rotating menu(boxes in circular motion). when a box is rolled over, all stop, but the text box that should appear in the middle between them, is not appearing where it should. it seems to be following the animation of its parent box.....any ideas?
jas
Moon Rotating Around Rotating Earth
I've got my earth revolving around the sun. I can't get the moon to revolve around the earth while it is revolving around the sun. Has anyone done this before, or is willing to help out?
Thanks
Rotating Menu With Non-Rotating Labels
I have a rotating menu that sets the selected button to the 3:00 position once clicked. I need the labels for the buttons to stay in the upright position as they rotate with the button. I have attached an image the help explain what I am trying to do. Anyone know of an action script that would keep the labels upright?
THIRD WHEEL
is there an actionscript that enables the use of the scrolling wheel on the mouse?
thanks.
Mouse Wheel ?
I use a lot of scroll bar in my flash site, I want to know more about the mouse wheel use in flash, I have found a tips but i think it's incompled (onClipEvent (enterFrame) {
rButton = Key.isToggled(4);
if (rButton != old) {
trace ("scroll-whell detected");
old = rButton;}
Please Help!!!
Wheel Of Fortune
Hello!
I'm making "Wheel of Fortune". Making the wheel spin was no problem (of course) and make it stop random. But how (!) do i find out where it stops? I have different pictures on the wheel and want something special to happen when it stops on a dog... i can make the same thing happen every time, but want different tings to happen on different pictures. HOW?
-Roger
Scratch Wheel
I am trying to develop a scratch wheel in flash, does anyone know where I could find a tute for this type of thing- I want it to manipulate a sound file....
J
|