I need help with my code

This is a discussion on "I need help with my code" within the Flash & Multimedia Forum section. This forum, and the thread "I need help with my code are both part of the Design Your Website category.



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

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 19th, 2007, 16:28
New Member
Join Date: Jul 2007
Location: California
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
I need help with my code

Hello, I'm new here and I'm fairly new to Flash actionscript, but I really want to know more. Anyhow, my issue here is that I have an object that is able to move around in 8 directions (North, Northwest, west, etc.) and accelerates. My problem is when it stops moving, the speed doesn't go back down to the base speed but instead stays at the max speed. Would anyone here be able to help me with this? On the stage is nothing but the object and the animation portions are just for the frames to look right when it is moving. My code is below:

Code: Select all
onClipEvent (load)
{
basicSpeed = 3 //the speed I would like it to start at
addonSpeed = 0.25 //the rate at which it accelerates too:
maxSpeed = 12 //which is the top speed
var trueSpeed // this is the variable that is used to measure the movements
left = true //to say if character is facing left or right. for animation
var testSpeed = basicSpeed // basically setting up my behind the scenes variable to start at basicSpeed
var moving = false //to say whether or not the object is in movement
}
 
onClipEvent (enterFrame)
{
function routine() //this just wants to tell if the object is moving or not, and if not, start another function
{
if (moving = false)
{
slow_down()
}
}
routine ()
function accelerate() //to increase speed
{
if (testSpeed != maxSpeed)
{
testSpeed += addonSpeed;
}
 
trueSpeed = testSpeed;
}
function slow_down() //to slow down, but it doesn't look like it is working.
{
if (testSpeed > 3)
{
testSpeed -= addonSpeed
trueSpeed -= addonSpeed
}
}
if (Key.isDown (Key.RIGHT)) //rightwards movement
{
moving = true
if (left) //animation
{
left = false
this._xscale = -_xscale
}
accelerate() //movement
this._x += trueSpeed 
}
if (Key.isDown (Key.LEFT))
{
moving = true
if (!left) //animation
{
left = true
this._xscale = -_xscale
}
accelerate() //movement
this._x -= trueSpeed
}
if (Key.isDown (Key.UP))
{
moving = true // movement
accelerate()
this._y -= trueSpeed 
this.gotoAndStop(1) //animation
}
if (Key.isDown (Key.DOWN))
{
moving = true //movement
accelerate()
this._y += trueSpeed 
this.gotoAndStop(2) //animation
}
}

Last edited by Sgaspar11; Jul 19th, 2007 at 17:21.
Reply With Quote

  #2 (permalink)  
Old Jul 19th, 2007, 17:19
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: I need help with my code

Ok, not bad for just learning actionscript.

Edit: Nevermind, just need to get your slowdown function working...quick meeting then I'll take a look in more detail.
Last Blog Entry: Yay!? (Oct 8th, 2007)

Last edited by Sgaspar11; Jul 19th, 2007 at 17:58.
Reply With Quote
  #3 (permalink)  
Old Jul 31st, 2007, 05:26
New Member
Join Date: Jul 2007
Location: California
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: I need help with my code

Well, it has been a little while. Could anyone help me? I'm not sure what that thing is I need to do with my slowdown function.
Reply With Quote
  #4 (permalink)  
Old Jul 31st, 2007, 15:24
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: I need help with my code

Yeah I've been really busy lately, and been goofing around with it a little bit but I am struggling with it as well. (I always have touble reading other people's code, it's sort of like having your own secret recipe that no one else gets) I'll ask my programmer guru buddy.

Cheers,

Scott
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
Reply

Tags
code, game, help

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
code help please lcsaeteurn JavaScript Forum 1 Apr 30th, 2008 02:06
code behind code doesnt work skat ASP.NET Forum 4 Feb 18th, 2008 10:05
live search code and styleswitcher code hebel JavaScript Forum 0 May 12th, 2007 06:16
Can somebody give me the code to hide the source code? renren JavaScript Forum 7 Mar 7th, 2006 12:27
code chedderhawk Introduce Yourself 2 Jul 14th, 2005 09:27


All times are GMT. The time now is 22:29.


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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43