473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

onClipEvent

52
Hello again

I'm having a little problem with this code, the idea is that the cat object follows the main character around and performs certain actions when the character is in range or out of range. on the whole the code is absolutely fine:

Expand|Select|Wrap|Line Numbers
  1. onClipEvent (enterFrame) {
  2.  
  3.     if (Key.isDown(Key.UP)&&((this._y - _root.Cat._y) <25)) {
  4.         this.gotoAndStop("catstill");
  5.     } else if (Key.isDown(Key.RIGHT) &&((this._x - _root.Cat._x)<-200)) {
  6.         this._x += 8;
  7.         this.gotoAndStop("catright");
  8.     } else if (Key.isDown(Key.LEFT) && ((this._x - _root.Cat._x) > 200)){
  9.         this._x -= 8;
  10.         this.gotoAndStop("catleft");
  11.     } else if ((this._y - _root.Cat._y) > 25){
  12.         this.gotoAndStop("catjump");
  13.     } else if ((this._y - _root.Cat._y) <25){
  14.         this.gotoAndStop ("catstill")
  15.     } 
  16.  
  17.     if (((this._x - _root.Cat._x) > 200) && ((!Key.isDown(Key.LEFT)))){
  18.         this._x -= 8;
  19.         this.gotoAndStop("catleft");
  20.     } 
  21.  
  22.     if (((this._x - _root.Cat._x)<-200) && (!Key.isDown(Key.RIGHT))) {
  23.         this._x += 8;
  24.         this.gotoAndStop("catright");
  25.     }
  26. }
Except this bit:
Expand|Select|Wrap|Line Numbers
  1.  
  2. if (((this._x - _root.Cat._x) > 200) && ((!Key.isDown(Key.LEFT)))){
  3.         this._x -= 8;
  4.         this.gotoAndStop("catleft");
  5.     } 
  6.  
  7. if (((this._x - _root.Cat._x)<-200) && (!Key.isDown(Key.RIGHT))) {
  8.         this._x += 8;
  9.         this.gotoAndStop("catright");
  10.     }
I would like for the cat to walk at a different rate to the character and (eventually) stop within a range of 200 either side of the character, to give the cat an independent feel.

I know what is going wrong (I think) but being new to AS2 I'm not sure how to put it right. Currently if the cat is outside the 200 range it will continue towards the character until it hits that 200, then it will stop and run some other action/movie. But because of the onClipEvent(enterFrame) (I think this is the culprit) it goes to the first frame of the cat movie on each frame so all I get is a catatonic siding cat instead of the walking cat I would like(hope that I make sense).
Sorry about the code I have left the current version on a different computer so some of this is from memory.

Any help much appreciated.

CHinde
Mar 11 '09 #1
0 2321

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: kyllle | last post by:
My first actionscript and I have two errors when I run it. Basically this code is to control scrolling navigation. Code onClipEvent (load) { _x = 0; _y = 0; spd = 8; } onClipEvent...
1
by: propagandhi101 | last post by:
hey im really new to actionscript and for a school project thats due in three days i encountered an error in the text that i cant figure out ive done everything i can think of so if anyone knows...
1
by: siresoth666 | last post by:
Greeting to everyone, I am a rookie at ASP and this may seem like a very simpleton question to most but I am clueless about it. I copied a code from a tutorial on to Flash its ASP but it does not...
2
by: chinmayagoyal | last post by:
Hello, I have been working on a dragonball z game recently and I have encountered a problem with the sprites.I have traced the bitmap and everything else and even created a movieclip of the sprite.I...
0
by: Dionysusmtl | last post by:
I'm working on a flash portfolio that loads examples of our work (jpgs) into a movie. For example, it started off using an xml list to display certain images but I found it necessary to draw info...
1
by: mikeguy3086 | last post by:
Here is what I'm trying to achieve: I'm making a site that is basically a big slide show which is insignificant, but it has to be really minimalistic. So what I did was make an invisible button...
1
by: deepakNagpal | last post by:
hi, i would like to make a animated ball from one side to another side and viseversa but when i am running this code only once my ball is running but not second time. please help
2
by: patronise | last post by:
I have this bit of code that at the moment moves the flash to the specific scene and frame at the press of any key on the keyboard. However, I want to modify this so that it works with specific a...
1
by: SR90 | last post by:
I'm trying to do this automatic scroll box, with an "up" and "down" arrow. The scroll box will have boxes lined up on top of each other moving continuously throug the scroll area. I need help...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.