Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsI have looked around for a while, and messed around with various methods of doing this, but in the end i couldn't figure it out. So basically does anyone know of a way to detect what frame a certain MC is on? What i am planning on doing with this is having an if statement detect if it is on a certain frame, and if it is, it will perform a certain action.
Thanks KhanhCPham, like they say practice makes perfect. I'll start practicing immediately thanks man.
So I am attempting to improve my animation, and in the process I have found that a huge part of my animation that I need help with is the human anatomy part. I can draw a perfect human body from the front or back, but that's it. I haven't been able to find any good tutorials on the internet about how to draw a human in any pose. That's what I mainly need help with. A basic way to draw a human in any position and have it look decent. What I do when I am animating is I draw just stick figures as my animation, and when I am finished I go back in and I draw over them, using them as guides. I run into the constant problem of not knowing how to draw the human anatomy, the way that I would like it to be. If anyone has a guide that would help me out, that has really helped them in the past, if you could get that to me, that would be awesome. Thanks.
And another glitch that happens in flash, is that whenever I bring the pen's cursor onto the stage for flash, it immediately scrolls all the way up. None of these glitches happen in flash with a regular mouse.
So I just recently bought a Bamboo Capture: Pen & Touch, and I just finished installing the drivers fully, doing the tutorials, and all that jazz, and I start up Flash, so that I could use it with Flash, and I get a peculiar glitch when I am trying to write. The glitch is that whenever I am trying to do anything on the Flash interface it writes for a half second, then brings down the right click drop menu. I have been looking for ways to fix it for the past hour, and have found nothing, so I have resorted to asking you guys. As I said I haven't tested it on any other program yet. This glitch does not happen when I am writing in non adobe applications, such as chrome, or the Bamboo application.
Alright I guess i'll look into tweenLite, but the reason I don't really want to use it is because I want everything I do in AS to be me, and not some other program.
At 9/30/12 09:46 PM, MSGhero wrote:There is more to this code of course, but i was just pasting the essential bit. I am wondering how do i make it so that the health bar has smooth movement when it is being decreased. Not choppy. I looked into it for about an hour, but couldn't figure it out.Look up TweenLite. It's baller at making things smooth (on phone, can't link)
With all due respect, I'd like to learn how to do this in AS3, and not using something else like this tweenlite instrument.
Hey guys hows it going, so i have this script.
function healthbarscale(e:Event):void
{
healthbarmc.healthbar.scaleX = healthCurrent/healthTotal;
}
There is more to this code of course, but i was just pasting the essential bit. I am wondering how do i make it so that the health bar has smooth movement when it is being decreased. Not choppy. I looked into it for about an hour, but couldn't figure it out.
At 9/29/12 03:19 PM, MSGhero wrote: At 9/29/12 02:41 PM, jaksmillie wrote:Is there a way without creating and array of all enemies, or naming every enemy individually in a script that I can simply identify the MC as an enemy, and so that everytime the damage MC hits an enemy of the enemy class, it does damage to it?
You'd have to use an array without making things way too complicated. Why don't you want to use one though?
Yea but so that means, if i had, theoretically, 1000 enemies, I would have to include all of them in the enemy array?
Yea so, the title may be a little misleading, but i couldnt fit all of it in 35 characters. Basically I want to have it so that a function, will affect multiple MC's but I dont have to name every MC is the script. Basically I want it so that I have a script that identifies whenever I do damage to an enemy their health goes down, I have that script already, however I want it to affect multiple types of enemies. For instance if there is zombie1 and zombie2 standing next to each other I want damage to be done to both of them with my damage MC, without having to name them individually in my script. Is there a way without creating and array of all enemies, or naming every enemy individually in a script that I can simply identify the MC as an enemy, and so that everytime the damage MC hits an enemy of the enemy class, it does damage to it?
Thanks guys, so I should never put AS inside of a movieclip? Alright that makes sense, i'm just used to doing it because I used to know a bit of AS2, and i would put script inside of movieclips a lot. I'll try putting the script in the stage instead.
I have a stage with a movieclip on it, and inside the movieclip once it performs its animation, in the last frame it performs this code.
stage.addEventListener(Event.ENTER_FRAME, deletethis);
function deletethis(e:Event):void{
MovieClip(this).parent.removeChild(this);
}
It works, and the movieclip gets deleted once it gets to the appropriate frame, however I get this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::slash_1/deletethis()"
I am still learning AS3 and I have tried to fix this with different solutions however I cannot figure it out. Can someone point out what I am doing wrong and explain it to me please.
thanks mate
I have a movieclip that I have created, and I would like to insert it into a frame via AS3. I would also like to delete it. What are the commands for creating and deleting movieClips.
At 9/27/12 09:36 PM, Khronosis wrote: If you want to determine the distance between two points, you'll want to refresh yourself on grade 9 trigonometry and employ the Pythagorean Theorem
Essentially, "a^2 + b^2 = c^2", where "a" and "b" will be "x2 - x1" and "y2 - y1", respectively. Solve for "c" and you'll get the distance between the two points. Then you can compare it against your predetermined radius.
I wrote a small example a while ago for a similar question, here: http://www.newgrounds.com/dump/item/5a8c696a710eb3a6433a585e 627cfb0f
The colored triangle represents the imaginary triangle created when using the Pythagorean Theorem, with red and green being "a" and "b", and the blue hypotenuse being "c", the desired distance.
Thanks mate. Figured it out, and I knew it had something to do with an equation however i just wasn't sure which equation to use. Anyways first good answer i have had in a while.
At 9/27/12 08:00 AM, Ssilver7 wrote: The problem could be as simple as not calling Math correctly as I have noticed in your post you are using lower case.
healthCurrent = Math.round(healthCurrent *0.8);
The above should be what you're after.
Thank you, but i managed to figure it out by myself. cheers mate.
I am currently trying to make a command in my game where, when a button is pressed a movieClip will follow the mouse around, and when the movieClip gets out of a certain radius it will gotoAndStop(); on a different frame of the movieclip. I know how to do everything accept the radius part. I have been looking at Math commands for the past hour and I just have no clue what to use, if I even use Math at all. Could someone lead me in the right direction of what command to use. To summarize what I need help with is a command that I can use to set a radius for a movieClip.
At 9/26/12 08:24 PM, ProfessorFlash wrote:At 9/26/12 08:08 PM, jaksmillie wrote: Hey guys I have this script here that I have been working on, and for the past hour I have been trying to figure out how to make it that so everytime I multiply the 'healthCurrent' variable by .8, then if the output contains decimals, well it gets rid of the decimals and rounds it to the nearest number. I have tried using math.roundHow did you fail in using Math.round? It does exactly what you want and couldn't be simpler to use. Your current code doesn't contain any rounding so I can only tell you what you know; use Math.round.
Im sorry if this comes off as dickish, but thank you for successfully not answering my question. I clearly stated that I didn't know how to use math.round. replies like that get under my skin man.
Hey guys I have this script here that I have been working on, and for the past hour I have been trying to figure out how to make it that so everytime I multiply the 'healthCurrent' variable by .8, then if the output contains decimals, well it gets rid of the decimals and rounds it to the nearest number. I have tried using math.round, and a few other methods, but have not been able to make it work.
var healthTotal:Number = 500;
var healthCurrent = healthTotal;
stage.addEventListener(Event.ENTER_FRAME, textchange);
healthMinus50.addEventListener(MouseEvent.MOUSE_UP, healthminus50);
rawr.addEventListener(MouseEvent.MOUSE_UP, cntHp20Pcnt);
stage.addEventListener(Event.ENTER_FRAME, LOOP);
reset.addEventListener(MouseEvent.MOUSE_UP, reset1);
function textchange(e:Event):void{
mctext.text = String(healthCurrent + "/" + healthTotal);
mctext.embedFonts = false;
}
function healthminus50(e:MouseEvent):void{
healthCurrent -= 50;
}
function cntHp20Pcnt(e:MouseEvent):void{
healthCurrent *= .8;
}
function LOOP(e:Event):void{
if(healthCurrent <= 0){
healthCurrent = 0;
}
}
function reset1(e:MouseEvent):void{
healthCurrent = 500;
}
Here is a link to the file itself I made, in case you really want to see the file. http://www.newgrounds.com/dump/item/080d9cceb2c464843175b158 8050ecb1
I have a question about dynamic text that has most likely a simple solution, however that solution eludes me. How do I set a dynamic text field to a variable? This script is what i have so far, and i want to set the healthTotal variable so that it displays on the dynamic text field, mctext.
import flash.events.Event;
var healthTotal:int = 500;
var healthCurrent = healthTotal;
stage.addEventListener(Event.ENTER_FRAME, textchange);
function textchange(e:Event):void{
mctext.text = healthTotal;
mctext.embedFonts = false;
}
At 9/25/12 11:52 PM, MSGhero wrote:
:Just use math to see if there's a collision, and move colliding things away from each other so they aren't colliding any more.
And you just say use math like I know what it is. Like I said I am fresh out of the womb in terms of learning AS3 and i would love an explanation of how math could be used to detect collision between the two objects.
At 9/25/12 11:52 PM, MSGhero wrote: And there's nothing in your code that actually handles collisions, so there's nothing we can do to specifically help you. Just use math to see if there's a collision, and move colliding things away from each other so they aren't colliding any more.
Yea... I know that there is no Collision script in there, however, you did misinterpret what I asked for. I was asking for something like a kick start to help me off in the right direction. I never said I did have any collision scripts, i was just showing my script, and asking how i would implement a collision script in there so that I could get the results that I want.
Yes i am posting again about the same thing, but for a different reason.
--
I am currently learning AS3 from scratch, everything of course, and in doing so i just do not want to copy and paste other peoples work into my game because then i have no clue what it does, and I am left not knowing whats going on in my game, which isn't good. I have three questions.
1. Is there a dictionary of all terminology in AS3 that I can refer to because, as i stated, I am learning flash and I have not found a decent dictionary of all AS3 terms. For instance I have no idea what an ! or && means. It would be helpful knowing all those little terms :).
2. How do you use code tags? (sorry, last post that i will not use code tags in.)
3. Can someone help me with adding a collision function to my script. I would really appreciate it if someone wouldn't just link me to some tutorial, but rather explain it in to me in a way that involves my script.
--
import flash.events.KeyboardEvent;
import flash.events.Event;
//stops from moving.
stop();
//Below. Tells that the var is naturally set to FALSE.
var rightPressed:Boolean = false;
var leftPressed:Boolean = false;
var upPressed:Boolean = false;
var downPressed:Boolean = false;
//Below. A variable to tell the character Movement speed.
var baseCharacterMovement:int = 2;
//Below. Speeds set for each direction to deal with collisions.
var baseCharacterMovementRight:int = 2;
var baseCharacterMovementLeft:int = 2;
var baseCharacterMovementUp:int = 2;
var baseCharacterMovementDown:int = 2;
//Below. Activates the functions for the keys being pressed and released.
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
//Below. Activates the functions whenever the frame is entered.
stage.addEventListener(Event.ENTER_FRAME, LOOP);
//Below. The two functions below are the functions that recognize which keys are being pressed.
function keyDownHandler(e:KeyboardEvent):void
{
if(e.keyCode == Keyboard.RIGHT){
rightPressed = true;
}
else if(e.keyCode == Keyboard.LEFT){
leftPressed = true;
}
else if(e.keyCode == Keyboard.UP){
upPressed = true;
}
else if(e.keyCode == Keyboard.DOWN){
downPressed = true;
}
}
function keyUpHandler(e:KeyboardEvent):void
{
if(e.keyCode == Keyboard.RIGHT){
rightPressed = false;
}
else if(e.keyCode == Keyboard.LEFT){
leftPressed = false;
}
else if(e.keyCode == Keyboard.UP){
upPressed = false;
}
else if(e.keyCode == Keyboard.DOWN){
downPressed = false;
}
}
//Below. This function is the function that performs the actual movement of the specified object.
function LOOP(e:Event):void
{
if(rightPressed){
Char.x += baseCharacterMovementRight;
}
else if(leftPressed){
Char.x -= baseCharacterMovementLeft;
}
if(upPressed){
Char.y -= baseCharacterMovementUp;
}
else if(downPressed){
Char.y += baseCharacterMovementDown;
}
}
<script src="https://gist.github.com/3780244.js?file=AS2 bad collision script"></script>
forgot this
I am just trying to create a simple collision script that will stop the "char" object when it hits the "back" object, however i am encountering a very odd problem.
onClipEvent(load){
var charSpeed:Number = 2;
var back:MovieClip = _root.back;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
_x += charSpeed;
}
if(Key.isDown(Key.LEFT)){
_x -= charSpeed;
}
if(Key.isDown(Key.UP)){
_y -= charSpeed;
}
if(Key.isDown(Key.DOWN)){
_y += charSpeed;
}
if(back.hitTest(_x+(_width/2),_y+(_height/2),true)){
_x -= charSpeed;
}
if(back.hitTest(_x-(_width/2),_y+(_height/2),true)){
_x += charSpeed;
}
if(back.hitTest(_x,_y+(_height),true)){
_y += charSpeed;
}
if(back.hitTest(_x,_y,true)){
_y -= charSpeed;
}
}
Here is the file. I honestly cant figure this out.
http://www.newgrounds.com/dump/item/a571d76d75bb9ef743661562 54dde4d5
I am new to AS3 and am trying to gain an understanding of its features, but i simply cant figure out the way to make it so that an object cannot go past another object. I managed to do this however, the problem I am encountering is that when my object hits the wall of the other object, it stops, but if you hit the same directional key in the direction that you hit the wall, the object will simply go through the wall. here is the script. I think that I did something wrong, or unorthodox method using the script.
import flash.events.Event;
import flash.events.KeyboardEvent;
//characters general movement speed.
var charMovement:int = 2;
var leftBumping:Boolean = false;
var rightBumping:Boolean = false;
var upBumping:Boolean = false;
var downBumping:Boolean = false;
var leftBumpPoint:Point = new Point(-19.25, -19.25);
var rightBumpPoint:Point = new Point(19.25, -19.25);
var upBumpPoint:Point = new Point(0, -38.5);
var downBumpPoint:Point = new Point(0, 0);
var rightPressed:Boolean = false;
var leftPressed:Boolean = false;
var upPressed:Boolean = false;
var downPressed:Boolean = false;
stage.addEventListener(Event.ENTER_FRAME, LOOP);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
function keyDownHandler(e:KeyboardEvent):void{
if(e.keyCode == Keyboard.LEFT){
leftPressed = true;
}
else if(e.keyCode == Keyboard.RIGHT){
rightPressed = true;
}
else if(e.keyCode == Keyboard.UP){
upPressed = true;
}
else if(e.keyCode == Keyboard.DOWN){
downPressed = true;
}
}
function keyUpHandler(e:KeyboardEvent):void{
if(e.keyCode == Keyboard.LEFT){
leftPressed = false;
}
else if(e.keyCode == Keyboard.RIGHT){
rightPressed = false;
}
else if(e.keyCode == Keyboard.UP){
upPressed = false;
}
else if(e.keyCode == Keyboard.DOWN){
downPressed = false;
}
}
function LOOP(e:Event):void{
if(leftPressed){
char.x -= charMovement;
}
if(rightPressed){
char.x += charMovement;
}
if(upPressed){
char.y -= charMovement;
}
if(downPressed){
char.y += charMovement;
}
{
if(world.hitTestPoint(char.x + leftBumpPoint.x, char.y + leftBumpPoint.y, true)){
trace("leftBumping");
leftBumping = true;
} else {
leftBumping = false;
}
if(world.hitTestPoint(char.x + rightBumpPoint.x, char.y + rightBumpPoint.y, true)){
trace("rightBumping");
rightBumping = true;
} else {
rightBumping = false;
}
if(world.hitTestPoint(char.x + upBumpPoint.x, char.y + upBumpPoint.y, true)){
trace("upBumping");
upBumping = true;
} else {
upBumping = false;
}
if(world.hitTestPoint(char.x + downBumpPoint.x, char.y + downBumpPoint.y, true)){
trace("downBumping");
downBumping = true;
} else {
downBumping = false;
}
if(leftBumping){
leftPressed = false;
}
}
if(rightBumping){
rightPressed = false;
}
if(upBumping){
upPressed = false;
}
if(downBumping){
downPressed = false;
}
}
how do i make it so that you can gotoAndStop on a different frame outside of the move clip?
At 5/23/09 01:16 AM, Wylo wrote: Which browser?
safari
Whenever I pull up the flash settings in a game i am playing to adjust a setting, I try to click on the flash settings box, but it is un-responsive meaning that when i click nothing happens. I cannot even click the X button to get rid of the screen. My computer type is mac. Can anyone help me with this problem.
in the video currently on the front page this one