Jump to content

need help with advanced codes flash as2


chattydash

Recommended Posts

i am useing as2 not swiching i like as2 and know the basics for it ok

 

i need some thing more advanced i know the basics i am trying to make a character select screen for sprites also i am trying to code a two key function to make my sprite fly faster by holding shift and prestin A or D i just need the codes for shift and how to edit the frame speed with out editing every frame speed

 

so yeh i need help on codeing a select screen and codes for keys to make my sprites fly faster i have done this stuff sort of in the past but this is more advanced so can naypony help me i am useing sprites i could past the codes i am already useing if that helps later if needed i have them animated and i have the movie clips done just need codes to work with also this is not a full game it is a test to make my skill better and to learn more ok any over info needed just ask and i will see if i know it or if i can give you that info ok just can you help with my problem

 

thanks chattydash

Edited by chattydash
  • Brohoof 1

img-1291563-1-AyOlSVD.gif

 

sorry for the spelling problem i try my best its so hard to wright write with my mouth

 

credit goes to Gone ϟ Airbourne for the epic sig

Link to comment
Share on other sites

i am trying to code a two key function to make my sprite fly faster by holding shift and prestin A or D

 

If I understand what you're saying, you would like to accomplish something like this?

 

(Quick example I made) http://www.swfcabin.com/open/1363350906

 

It would be easier to help if you supplied some code.

  • Brohoof 2

Sig.png

~ Sometimes when it's windy, I stand outside and wait to be carried away ~

Link to comment
Share on other sites

WAYT WAT ARE YOU DOING. SRSLY. Donut use Actionscript 2 bro. I'm telling you right now, if you want to get serious about game design and programming, grab some FlashDevelop and learn AS3. It saves your life. On the other hand, if you're just programming small games to show to your friends and whatnot, this is somewhat okay. Actionscript 3 is just so much more organized and easy to use. I would beglad to help if you could describe the problem a bit better. ;)



Hey you! Hey! Do you have Flash? Wanna animate ponies?


HERE'S A THING I DID A LONG TIME AGO!



Pony Puppets for any version of Flash!


:squee:

Link to comment
Share on other sites

(edited)

 @Swick @NeverPony

 

 

If I understand what you're saying, you would like to accomplish something like this?

 

(Quick example I made) http://www.swfcabin.com/open/1363350906

 

It would be easier to help if you supplied some code.

yes just what i want i will get the codes and the frames the sprites are on too this will help

 

 

onClipEvent (enterFrame) {
 if (Key.isDown(37)) {//left
  this.gotoAndStop(2)
  _root.direction = "left"
  if(this.hitTest(_root.left)){
   this._x += 8
   }
  this._x -= 8
 } else {
  
  if (Key.isDown(39)) {//right
   this.gotoAndStop(4)
   _root.direction = "right"
   if(this.hitTest(_root.right)){
   this._x -= 8
   }
   this._x += 8
   } else {
         if (Key.isDown(65)) {//fly left
  this.gotoAndStop(6)
  _root.direction = "left"
  if(this.hitTest(_root.left)){
   this._x += 8
   }
  this._x -= 8
     }else{
      
      if (Key.isDown(68)) {//fly right
   this.gotoAndStop(8)
   _root.direction = "right"
   if(this.hitTest(_root.right)){
   this._x -= 8
   }
   this._x += 8
   } else {
      
      
     if(_root.direction == "right"){
      this.gotoAndStop(3)
     }
     if(_root.direction == "left"){
      this.gotoAndStop(1)
      
      if(_root.direction == "right"){
      this.gotoAndStop(7)
     }
     if(_root.direction == "left"){
      this.gotoAndStop(5)
      }}}}}}}

 

the frames the fast flying are on are 10 for left and 12 for right and still (not moving) is 9 for left and 11 for right oh! do not forget hit tests for this too i will get the hit test codes too

 

onClipEvent(enterFrame){
 if(this.hitTest(_root.rainbow)){
 if(Key.isDown(39)){
 _root.rainbow._x = _root.rainbow._x - 8
 }
 if(Key.isDown(37)){
 _root.rainbow._x = _root.rainbow._x + 8
 }
  if(Key.isDown(68)){
 _root.rainbow._x = _root.rainbow._x - 8
 }
 if(Key.isDown(65)){
 _root.rainbow._x = _root.rainbow._x + 8
 }
}
}

 

i could if i get these codes right make here run too just use the same key lay out then hit test it is well but stick to the fly one and i will need to know the hittest is well thanks

Edited by chattydash

img-1291563-1-AyOlSVD.gif

 

sorry for the spelling problem i try my best its so hard to wright write with my mouth

 

credit goes to Gone ϟ Airbourne for the epic sig

Link to comment
Share on other sites

I'm not completely sure what you're asking for, but here's some code I wrote up:

 

 

onClipEvent (load) {
    var speed:Number = 8;
    var rSpeed:Number = 12;
    var moving:Boolean = false;
    var running:Boolean = false;
    var flying:Boolean = false;
}
onClipEvent (enterFrame) {
    
    if (Key.isDown(16)) {
        running = true;
    } else {
        running = false;
    }
    
    if (Key.isDown(37)) {
        //Walking Left
        this._xscale = 100;
        if (running == false) {
            if(flying == false)
            {
            this.gotoAndStop(2);
            }
            this._x -= speed;
        } else {
            if(flying == false)
            {
            this.gotoAndStop(3);
            }
            this._x -= rSpeed;
        }
        moving = true;
    } else if (Key.isDown(39)) {
        //Walking Right
        this.gotoAndStop(2);
        this._xscale = -100;
        if (running == false) {
            if(flying == false)
            {
            this.gotoAndStop(2);
            }
            this._x += speed;
        } else {
            if(flying == false)
            {
            this.gotoAndStop(3);
            }
            this._x += rSpeed;
        }
        moving = true;
    }
    if (Key.isDown(38)) {
        //Flying Left
        flying = true;
        if (running == false) {
            this.gotoAndStop(4)
        } else {
            this.gotoAndStop(5)
        }
        this._y -= speed;
        moving = true;
    } else if (Key.isDown(40)) {
        //Flying Right
        flying = true;
        if (running == false) {
            this.gotoAndStop(4)
        } else {
            this.gotoAndStop(5)
        }
        this._y += speed;
        moving = true;
    }
    if (!Key.isDown(37) && !Key.isDown(38) && !Key.isDown(39) && !Key.isDown(40)) {
        moving = false;
    }
    if (moving == false) {
        this.gotoAndStop(1);
    }
    
    if (!Key.isDown(38) && !Key.isDown(40))
    {
        flying = false;
    }
    
}
 

 

 

 

Frame 1: Idle

Frame 2: Walk

Frame 3: Run

Frame 4: Fly

Frame 5: Fast Fly



Hey you! Hey! Do you have Flash? Wanna animate ponies?


HERE'S A THING I DID A LONG TIME AGO!



Pony Puppets for any version of Flash!


:squee:

Link to comment
Share on other sites

(edited)

@Swick

 

no just the shift key to move left to right

 

i have a mc with 16 frames all the even frames have movements on them and all the odd frames have it idle and it is left,left,right,right ect.. so  

 

frame1 stand left    -    frame2 walk left  

frame3 stand right  -    frame4 walk right

frame5 stand left    -    frame6 fly left  

frame7 stand right  -   frame8 fly right 

frame9 stand left    -    frame10 flyfast left   

frame11 stand right  -  frame12 flyfast right 

frame13 stand left    -  frame14 dash left  

frame15 stand right  - frame16 dash right

 

    this is what the standing frames are for


     if(_root.direction == "right"){
this.gotoAndStop(3)
}
if(_root.direction == "left"){
this.gotoAndStop(1)

if(_root.direction == "right"){
this.gotoAndStop(7)
}
if(_root.direction == "left"){
this.gotoAndStop(5)
}}}}}}}

 

ok is this in as3 or 2 i am useing 2 so change the fames to the numbers i have and thefirst bit of code is the vars ok you have done the code but the left and right are the same code when they should be diffrent i will see if i can work with this plus do i have to put these vars on the MC iswell as the varable frame not in the mc

Edited by chattydash

img-1291563-1-AyOlSVD.gif

 

sorry for the spelling problem i try my best its so hard to wright write with my mouth

 

credit goes to Gone ϟ Airbourne for the epic sig

Link to comment
Share on other sites

Code is the spawn of Satan. It's a shame it's so useful though. I haven't used Flash's code since high school and even then that was the basics. Sorry for being no help.

happy.png

Link to comment
Share on other sites

Why do you have 'stand left' and 'stand right' repeated four times on different frames? On top of that, there is no reason to have an individual left and right frame. You can simply flip the movieclip when needed by using the xscale property.

 

if(_root.direction == "right"){

this.gotoAndStop(3)
}
if(_root.direction == "left"){
this.gotoAndStop(1)

if(_root.direction == "right"){
this.gotoAndStop(7)
}
if(_root.direction == "left"){
this.gotoAndStop(5)
}

 

Also, what is going on here. You have the same if statements twice, meaning only the latter frame will be used in either of these circumstances.

 

Updated example with a bit of animation added: http://www.swfcabin.com/open/1363808642

There are only three frames in this sample.

 

Example code

 

var speed = 1;

var xSpeed = 0;
var ySpeed = 0;
var xSpeedCap;
var ySpeedCap;
var pScale = player._xscale;
 
player.stop();
 
_root.onEnterFrame = function()
{    
 //////////////
//Speed Caps//
//////////////
 
if(Key.isDown(16)) //Shift
{
xSpeedCap = 10;
ySpeedCap = 10;
}
else
{
xSpeedCap = 3;
ySpeedCap = 3;
}
 
if(xSpeed > xSpeedCap)
{
xSpeed = xSpeedCap;
}
if(xSpeed < -xSpeedCap)
{
xSpeed = -xSpeedCap;
}
if(ySpeed > ySpeedCap)
{
ySpeed = ySpeedCap;
}
if(ySpeed < -ySpeedCap)
{
ySpeed = -ySpeedCap;
}
 
 ////////////
//Movement//
////////////
if(!Key.isDown(68) && !Key.isDown(65))
{
player.gotoAndStop(1);
}
 
if(Key.isDown(68)  ) //Right
    {
player._xscale = pScale;
xSpeed += speed;
player.gotoAndStop(2);
if(Key.isDown(16))
{
player.gotoAndStop(3);
}
    }
else{d.gotoAndStop(1);}
 
    if(Key.isDown(65) ) //Left
    {  
player._xscale = -pScale;
xSpeed -= speed; 
player.gotoAndStop(2);
if(Key.isDown(16))
{
player.gotoAndStop(3);
}
    }
  else{a.gotoAndStop(1);}
 
    if(Key.isDown(87)) //Up
    {    
ySpeed -= speed;   
    }
   else{w.gotoAndStop(1);}
   
    if(Key.isDown(83)) //Down
   {  
ySpeed += speed;
    }
 
//Friction
if(!Key.isDown(65) && !Key.isDown(68) || Key.isDown(65) && Key.isDown(68))
{
player.gotoAndStop(1);
xSpeed *= 0.7;
if(xSpeed < 0.01 && xSpeed > -0.01)
{
xSpeed = 0;
}
}
if(!Key.isDown(87) && !Key.isDown(83) || Key.isDown(87) && Key.isDown(83))
{
ySpeed *= .7;
if(ySpeed < 0.01 && ySpeed > -0.01)
{
ySpeed = 0;
}
}
 
player._x += xSpeed;
player._y += ySpeed;

}

 


Sig.png

~ Sometimes when it's windy, I stand outside and wait to be carried away ~

Link to comment
Share on other sites

(edited)

if think you have miss understod me i do not what the xscale function is a side scroler so it is only going left to right not up and down i shoul of made this clear plus those codes are use to stop the image jumping back e.g i move right with out these codes it jumps back to left my starting frame this is so it stays right or left and it is in diffrent movements ok i will show you what it is heres the link: http://www.swfcabin.com/open/1363939877

Edited by chattydash

img-1291563-1-AyOlSVD.gif

 

sorry for the spelling problem i try my best its so hard to wright write with my mouth

 

credit goes to Gone ϟ Airbourne for the epic sig

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...