Need some help? Why not ask..
User avatar
QwertyFail
Black Mist
Black Mist
 
Posts: 1206
Joined: Tue Jun 22, 2010 3:58 am

ActionScript 3 Help!

by QwertyFail Sun May 29, 2011 8:18 pm

I recently got my hands on Flash CS5, and ever since I've been struggling with AS3...

I've read the manuals that came with it explaining AS3, so I you guys don't have to explain what variables or instances are...

So this is where I'm at:

I've already created some basic walking and idle animations for the character that you control, and I also have the basic function down for left and right movement, but for some reason I'm having a difficult time defining the variable.

So if anyone could help me with making a character that could jump and move left to right gradually, that would be very helpful and awesome for me. :D
Image
User avatar
Omar
Black Mist
Black Mist
 
Posts: 705
Joined: Mon Mar 01, 2010 1:39 am
Location: Mexico City

Re: ActionScript 3 Help!

by Omar Tue May 31, 2011 7:01 pm

QwertyFail wrote:I recently got my hands on Flash CS5, and ever since I've been struggling with AS3...

I've read the manuals that came with it explaining AS3, so I you guys don't have to explain what variables or instances are...

So this is where I'm at:

I've already created some basic walking and idle animations for the character that you control, and I also have the basic function down for left and right movement, but for some reason I'm having a difficult time defining the variable.

So if anyone could help me with making a character that could jump and move left to right gradually, that would be very helpful and awesome for me. :D

Damn i only know ActionScript 2, if it was Action Script 1 or 2 i would help. i do know some basic stuff. lets say im not a total expert in Action ScriptIng but moving the characteris enough.
User avatar
QwertyFail
Black Mist
Black Mist
 
Posts: 1206
Joined: Tue Jun 22, 2010 3:58 am

Re: ActionScript 3 Help!

by QwertyFail Tue May 31, 2011 7:17 pm

Omar wrote:Damn i only know ActionScript 2, if it was Action Script 1 or 2 i would help. i do know some basic stuff. lets say im not a total expert in Action ScriptIng but moving the characteris enough.

Same here, I've been tinkering with ActionScript 2, and I seem to have a knack for it. In ActionScript 3 you have to create your own variables, functions, classes, etc. These were preset in both ActionScript 1 and 2. I don't know why they had to make it so complicated for ActionScript 3 though, because they could have just created another program for creating your own codes where you could just import them into ActionScript 3 in a simplified manner and use them from there, while also having preset codes already there for you.

-- Fri Jun 03, 2011 11:04 am --

Alright I have another really stupid question: How to hell do you set the origin point of a MovieClip to the center of it?

This problem has been bugging me for a very long time now... :evil:
Image
User avatar
Omar
Black Mist
Black Mist
 
Posts: 705
Joined: Mon Mar 01, 2010 1:39 am
Location: Mexico City

Re: ActionScript 3 Help!

by Omar Sat Jun 04, 2011 1:53 am

Can you be more specific?
Flash isn't so hard, you can buy a book for flash cs5.
Book actually help me do stuff that i didn't know in flash, Flash is very powerful and it will always be like that.
User avatar
QwertyFail
Black Mist
Black Mist
 
Posts: 1206
Joined: Tue Jun 22, 2010 3:58 am

Re: ActionScript 3 Help!

by QwertyFail Sat Jun 04, 2011 2:54 pm

Omar wrote:Can you be more specific?
Flash isn't so hard, you can buy a book for flash cs5.
Book actually help me do stuff that i didn't know in flash, Flash is very powerful and it will always be like that.

When you create a new symbol, you will see a cross-hair that I believe is the origin of the "Edit Symbol Stage" appear in the "center" of it. I need to know how to center it up towards the middle of the "Edit Symbol Stage" because in my Flash CS5 it is located all the way towards the right of the "Edit Symbol Stage", and this has been annoying me for quite some time now...
Image
User avatar
Daniel Sun
Site Admin
Site Admin
 
Posts: 1345
Joined: Thu Feb 18, 2010 8:44 am
Location: Australia

Re: ActionScript 3 Help!

by Daniel Sun Sun Jun 05, 2011 3:54 am

I'd say use as2 for now. It's far easier. Tom Fulp uses as2.
User avatar
QwertyFail
Black Mist
Black Mist
 
Posts: 1206
Joined: Tue Jun 22, 2010 3:58 am

Re: ActionScript 3 Help!

by QwertyFail Sun Jun 05, 2011 4:21 am

Daniel Sun wrote:I'd say use as2 for now. It's far easier. Tom Fulp uses as2.

Haha, but you're right, AS2 is a HELL of a lot easier than AS3...

-- Tue Jun 21, 2011 11:39 am --

QwertyFail wrote:
Omar wrote:Can you be more specific?
Flash isn't so hard, you can buy a book for flash cs5.
Book actually help me do stuff that i didn't know in flash, Flash is very powerful and it will always be like that.

When you create a new symbol, you will see a cross-hair that I believe is the origin of the "Edit Symbol Stage" appear in the "center" of it. I need to know how to center it up towards the middle of the "Edit Symbol Stage" because in my Flash CS5 it is located all the way towards the right of the "Edit Symbol Stage", and this has been annoying me for quite some time now...

Random Post: I fixed it, problem solved!

-- Tue Jul 05, 2011 5:06 pm --

Since there's no better place to ask for help on ActionScript 3.0, I'm just going to ask for it here...

So I've played around a little with ActionScript 2.0 for a while and decided to translate my code into ActionScript 3.0. Everything worked alright except for the vCam I created for the character in my game. Whenever I turn the vCam off, the code works just fine, but when I turn it on it makes my character all jumpy with its collision. If anyone knows what's wrong with my code, then please teach me how to solve it! I've looked through all my ActionScript tutorial books and I still can't find the answer to this!

Code: Select all
import flash.events.Event;
import flash.events.KeyboardEvent;

var leftKeyDown:Boolean = false;
var rightKeyDown:Boolean = false;
var upKeyDown:Boolean = false;
var downKeyDown:Boolean = false;
var xSpeed:Number = 0;
var ySpeed:Number = 0;
var mainSpeed:Number = 0.5;
var frictionPower:Number = 0.8;
var gravityPower:Number = 1;
var terminalVelocity:Number = 20;
var vCamX:Number = 0;
var vCamSpeed:Number = 1.5;
var vCamFriction:Number = 0.85;

stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeysDown);
stage.addEventListener(KeyboardEvent.KEY_UP, checkKeysUp);
stage.addEventListener(Event.ENTER_FRAME, hitTest);
stage.addEventListener(Event.ENTER_FRAME, Main);

function Main(event:Event)
{
   moveCharacter();
   dynamicMovement();
   vCamMovement();
   vCamDynamic();
}

function checkKeysDown(event:KeyboardEvent)
{
   if (event.keyCode == 37)
   {
      leftKeyDown = true;
   }
   if (event.keyCode == 38)
   {
      upKeyDown = true;
   }
   if (event.keyCode == 39)
   {
      rightKeyDown = true;
   }
   if (event.keyCode == 40)
   {
      downKeyDown = true;
   }
}

function checkKeysUp(event:KeyboardEvent)
{
   if (event.keyCode == 37)
   {
      leftKeyDown = false;
   }
   if (event.keyCode == 38)
   {
      upKeyDown = false;
   }
   if (event.keyCode == 39)
   {
      rightKeyDown = false;
   }
   if (event.keyCode == 40)
   {
      downKeyDown = false;
   }
}

function moveCharacter()
{
   if (leftKeyDown)
   {
      xSpeed -=  mainSpeed;
   }
   if (rightKeyDown)
   {
      xSpeed +=  mainSpeed;
   }
   if (upKeyDown)
   {
      ySpeed -=  6.5;
   }
   if (upKeyDown && leftKeyDown)
   {
      ySpeed -=  0;
      xSpeed -=  3;
   }
   if (upKeyDown && rightKeyDown)
   {
      ySpeed -=  0;
      xSpeed +=  3;
   }
}

function dynamicMovement()
{
   mcMain.x +=  xSpeed;
   xSpeed *=  frictionPower;

   if (xSpeed > 3)
   {
      xSpeed = 3;
   }

   mcMain.y +=  ySpeed;
   ySpeed +=  gravityPower;

   if (ySpeed > terminalVelocity)
   {
      ySpeed = terminalVelocity;
   }
}

wallCollision.visible = false;

function hitTest(event:Event)
{
   while (wallCollision.hitTestPoint(mcMain.x,mcMain.y,true))
   {
      mcMain.y--;
   }
   if (! wallCollision.hitTestPoint(mcMain.x,mcMain.y + 1,true))
   {
      upKeyDown = false;
   }
   if (wallCollision.hitTestPoint(mcMain.x,mcMain.y + 1,true))
   {
      ySpeed = 0;
   }
}

function vCamMovement()
{
   if (leftKeyDown)
   {
      vCamX -=  vCamSpeed;
   }
   if (rightKeyDown)
   {
      vCamX +=  vCamSpeed;
   }
   if (vCamX > 7)
   {
      vCamX = 7;
   }
   if (vCamX < -7)
   {
      vCamX = -7;
   }
}

function vCamDynamic()
{
   vCam.x = mcMain.x;
   vCam.y = mcMain.y;
   vCam.x +=  vCamX;
   vCamX *=  vCamFriction;
}


-- Sun Jul 10, 2011 3:58 pm --

Solved!

*GLaDOS voice* By myself...
Image
Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest