Actionscript help for a noob?

A place for tutorials on how to get the most out of Flash

Re: Actionscript help for a noob?

Postby OwnerOfSuccuby » Sat Aug 24, 2013 7:01 am

How would I go about collision? I'm very into concise coding. I would like it to be as simple as possible. For example, I just wanna make an invisible hit box for krystal and put it on a enterFrame event. And when that hit box touches another, a code occurs. Is there a way or a better way to do that?


Just check hitTest - of your object and Krystal.

Some kind like if (Krystal.hitTest(MyBox) {do some thing}

In your box object (it have to be MovieClip obkect and named MyBox in our example - write: this.visible=false;)

So you will see colision boxies and when you will play it it will become invisible.

hitTest Example:

The following example uses hitTest() to determine if the circle_mc movie clip overlaps or intersects the square_mc movie clip when the user releases the mouse button:

Code: Select All Code
square_mc.onPress = function() {
    this.startDrag();
};
square_mc.onRelease = function() {
    this.stopDrag();
    if (this.hitTest(circle_mc)) {
    trace("you hit the circle");
    }
};
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Actionscript help for a noob?

Postby Terrantor!!! » Sat Aug 24, 2013 7:11 am

Awesome!!! Thanks
User avatar
Terrantor!!!
 
Joined: Thu Aug 23, 2012 10:36 am

Re: Actionscript help for a noob?

Postby hat973 » Fri Sep 13, 2013 7:51 pm

question what script would i have to use for a out fit change in game like your wearing a shirt with a star in one thing and you decide to put on a diffrent one with 2 stars
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby BlueLight » Fri Sep 13, 2013 10:48 pm

I think you just put the shirt on a frame in a layer, then you switch frames depending on what shirt you want.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Actionscript help for a noob?

Postby Terrantor!!! » Sun Sep 15, 2013 6:14 pm

You can put the designs on separate frames, too. That way you can change the t-shirt color/type and add filters to the designs!!
User avatar
Terrantor!!!
 
Joined: Thu Aug 23, 2012 10:36 am

Re: Actionscript help for a noob?

Postby hat973 » Sat Sep 21, 2013 11:21 pm

heres one thats bothering me im trying to find out how to do weapon health or in commin words how much the weapon can handle tell it brakes
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby BlueLight » Sun Sep 22, 2013 6:49 am




This is off topic
hat973 Wrote:... or in commin words how much the weapon can handle tell it brakes

Must not make sex joke.



This is on topic.

well since you didn't really say how you want weapon damage to work i'll go with a basic system. Now this is java so you'll have to figure out how to translate this on your own.
I suggest you have at least these 3 methods for a working damage system.
public class weapon {
private int weaponHealth = 100
private int maxWeaponHealth = 100


public int getWeaponHealth(){
return weaponHealth; //or you could use "return this.weaponHealth;" but really they're the same thing. One is just making sure you get the right variable.
}

public void setWeaponHealth(int HP){
//these 2 if statements makes sure the value never gets above or below 0 and the max HP.
if(HP>maxWeaponHealth){HP=maxweaponHealth;}
if(HP<0){HP = 0;}
//now your HP will be set to a value between 0 and 100.
weaponHealth = HP;
}

public void changeWeaponHealth(boolean add, int HP){
if(add ==false ) {HP = -1*HP;}
setWeaponHealth(getWeaponHealth + HP);
}
}


When ever you want to change how much heath the things has, use the changeWeaponHealth(boolean add,int HP); method unless you need to change a variable to a set number like 55.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Actionscript help for a noob?

Postby hat973 » Sun Sep 22, 2013 7:11 am

what about the damage it deals
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby BlueLight » Sun Sep 22, 2013 7:24 am

hat973 Wrote:what about the damage it deals

Sorry your on your own. Just to many ways of doing this and none are really the right way. If its a basic gun concept, then i'd add a int value to the gun, share that value with the bullet and remove that much hp from the target if it hits.

I'm normally dealing with 6 different stats all doing different things like increasing likely to hit, increasing damage, but also decreasing counter attack damage.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: Actionscript help for a noob?

Postby hat973 » Mon Oct 14, 2013 10:38 pm

heres one that intrust me how would script someone to detect the player is close like in the legend of krystal game where she walks up to a lizered and a button pops up
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby OwnerOfSuccuby » Wed Oct 16, 2013 5:40 pm

If on enter frame for example some Area hittest Krystal - then make some button visible.

Try to look how do hittest works.

Or on enter frame or timer that checks each time if Krystal.x value is in some range then make some button visible.
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Actionscript help for a noob?

Postby hat973 » Sat Oct 26, 2013 4:27 am

Terrantor!!! Wrote:I got a question.
Why is there a pause before movement in this clip? For example it seems the entire movie clip plays before her x-coordinate begins to change.
Spoiler (click to show/hide):

kryrig.swf


what i lurned from KaTsu O_O he did this easy way of animating first you make to frames one of the modle standing still and the other of her walking u turn the standing modle into a simbol same as the walking then in the simbol of a simbol of the idle then u put a frame on there with her walking then make a 2nd layer add 2 sepret frames oneover both idle and walking mark the blank frame over idle with walking u can do that in the properties thing then on the blank frame over idle put the action stop (); on it then go out of that put a action on a blank frame on a new layer out side the syimbole speed = 10; lastly click on the idle frame and put the movment screept on it I put it down but i dont have it writen down at the moment
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby hat973 » Mon Oct 28, 2013 10:33 pm

qustin say u have 3-4 animation ones a plane walking animation and the others have you holding a weapon or something how would scripting the weapons and the players to work together so when the player picks up a item it playes the animation of them holding it
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby GoRepeat » Thu Oct 31, 2013 3:49 pm

hat973 Wrote:qustin say u have 3-4 animation ones a plane walking animation and the others have you holding a weapon or something how would scripting the weapons and the players to work together so when the player picks up a item it playes the animation of them holding it


In flash the easiest way to do this is to have embedded movie clips that represent the different weapons then have a stage variable control which one is used.

So you have your walking animation, inside of it you have your hand movie clip, inside of that you can have your weapon movie clip, and inside of that you might have 10-12 frames for each of the different weapons. Then you have some variable (or better yet an array) that controls the weapon frame being shown (1- sword, 2-axe, etc etc). Alternately, if you wanted different attack animations for each weapon then you would pull the embed back a few levels and use the variable to conditionally control which animation is played.
Picarto LiveStream: https://picarto.tv/GoRepeat
Other Stuff: Click Here
User avatar
GoRepeat
Moderator
 
Joined: Wed Jul 21, 2010 2:26 am
Location: Behind the Looking Glass

Re: Actionscript help for a noob?

Postby hat973 » Thu Nov 07, 2013 7:14 am

Hey how would i program a button to play a peace of animation then replace the avi in question like clothed avi click button strip animation replace avi with nude avi but if say you where in a room with a door the nude avi can only go threw how do i do that same as a door only the clothed avi can go threw
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby TigerBus » Thu Nov 07, 2013 8:12 am

add an if else statements to the buttons function and give the clothed or stripped a boolean var saying witch is selected
Tiger Bus Signing Off!
User avatar
TigerBus
 
Joined: Fri Oct 18, 2013 8:55 pm
Location: Western Canada

Re: Actionscript help for a noob?

Postby hat973 » Thu Nov 07, 2013 8:30 am

TigerBus Wrote:add an if else statements to the buttons function and give the clothed or stripped a boolean var saying witch is selected



uh i dont understand i need a more clear experince
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby hat973 » Thu Jan 23, 2014 6:17 am

Code: Select All Code
package
{
   import flash.display.*;
   import flash.events.*;

   public class Player extends MovieClip
   {
      var parentMC:MovieClip;
      var playerMC:MovieClip;

      public function Character(mcParent:MovieClip)
      {
         parentMC = mcParent;
         playerMC = null;
      }
      public function AddCharacter(xPos:Number, yPos:Number, charName:String)
      {
         playerMC = new Player();
         parentMC.addChild(Player);
         playerMC.x = xPos;
         playerMC.y = yPos;
         playerMC.name = charName;
      }
   }
}




this code is driving me batty i double and tripled checked it but the thing keeps saying it wants a RIGHT bracer on line 25 so i give it what it wants then check it onece more it passes the writing part then i do a ctrl+enter and it tells me it wants a Right bracer on line 25 >.< help
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby hat973 » Sat Jun 14, 2014 9:29 am

Okay its been a while since iv asked a question on this subject
im fallowing a If and if else statment but i want to add a bug like if a person enters the wrong code and is alirted to it the player gets hit by one animion cause i have in the code else if code is wrong it pops up Wrong in he txt input box
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: Actionscript help for a noob?

Postby BlueLight » Sat Jun 14, 2014 10:45 am

hat973 Wrote:
Code: Select All Code
package
{
   import flash.display.*;
   import flash.events.*;

   public class Player extends MovieClip
   {
      var parentMC:MovieClip;
      var playerMC:MovieClip;

      public function Character(mcParent:MovieClip)
      {
         parentMC = mcParent;
         playerMC = null;
      }
      public function AddCharacter(xPos:Number, yPos:Number, charName:String)
      {
         playerMC = new Player();
         parentMC.addChild(Player);
         playerMC.x = xPos;
         playerMC.y = yPos;
         playerMC.name = charName;
      }
   }
}




this code is driving me batty i double and tripled checked it but the thing keeps saying it wants a RIGHT bracer on line 25 so i give it what it wants then check it onece more it passes the writing part then i do a ctrl+enter and it tells me it wants a Right bracer on line 25 >.< help


Not a actionscript man myself but i put the code into Notepad++. It seems Package isn't a key word in the syntax according to Notepad++ so that might be the cause but as i said i don't program in AS.

hat973 Wrote:Okay its been a while since iv asked a question on this subject
im fallowing a If and if else statment but i want to add a bug like if a person enters the wrong code and is alirted to it the player gets hit by one animion cause i have in the code else if code is wrong it pops up Wrong in he txt input box

Not trying to be rude, but can you please use something like word when asking a technical question or double check it before posting. I'm literally not sure what your asking.

Okay something about you causing a bug using a if else statement but you want to cause this bug.
More over, this bug is to detect a error in code?
Well what you could do is to surround a block of code with a try statement and then follow it with a catch statement that surrounds your debug code.
This however wont trigger the catch statement unless a exception is thrown inside of the try catch statement.

Example and bit of explanation for AS3
http://stackoverflow.com/questions/3455 ... rrors-in-w

EDIT
Maybe restating the question would help.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

PreviousNext

Return to Tutorials



Who is online

Users browsing this forum: No registered users