RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (Full Version)

All Forums >> [Gaming Community] >> [Legends and Lore] >> Artists of Legend >> Art Academy



Message


golden rod -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/7/2009 0:45:53)

what would be the code for pressing p on the keyboard to make something pause and then pressing p again to make it start again.




Davosaur -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/7/2009 2:13:22)

well i cant say for exactly but if you want to search for it theres a whole numbering system for letters i forget how the code is but its like (Key.isDown(80)) something like that ill try to find the chart

heres the keycodes:

q 81
w 87
e 69
r 82
t 84
y 89
u 85
i 73
o 79
p 80
a 65
s 83
d 68
f 70
g 71
h 72
j 74
k 75
l 76
z 90
x 88
c 67
v 86
b 66
n 78
m 77

VVV thanks never coded in awhile :P VVV




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/8/2009 11:36:31)

Also, when you code it, if it's in AS2 (I don't know about AS3) then instead of (Key.isDown(Key......)){ You just do (Key.isDown(80)){ You don't include the "Key." in the second parenthesis.


Btw, golden rod, a good trick to making a pause in a game, is just take your ENTIRE code, and surround it with the code for "if(!Paused)...." Then just make "P" pause the game. So then, if paused is false, the game will run normally, if it's true.... Whatever :D, just use else{




MegaPoster404 -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/9/2009 18:45:01)

okay, I'm trying to make a game where a car rolls and follows the mouse. It's following the mouse, but it doesn't start at the mouse. I thought I got the code for going to the mouse right, but it's not working. Here's the whole code on the movie clip:

onClipEvent (load) {
	startDrag(this);
	this.gotoAndPlay("walk");
	this._x = _xmouse;
	this._y = _ymouse;
}
on (mouseMove) {
	this._x = _xmouse;
	this._y = _ymouse;
}


I'm using AS2 in flash CS4




MetalMewtwo -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/9/2009 19:39:54)

This code should work:

onClipEvent (mouseMove) {
this.gotoAndPlay("walk");
xcoordinate = _root._xmouse;
ycoordinate = _root._ymouse;
this._x = xcoordinate;
this._y = ycoordinate;
}

The code you used, i dont know why it does what it does, but theres a way to get around it. First i made minor variables to get the x and y coordinates myself. Then flash will use those coordinates to reposition the movieclip, each time you move the mouse.

So i guess using "_xmouse" can be unreliable sometimes.




somebody621 -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/9/2009 19:48:38)

Honestly, the best way to do pause is with a state machine. Look it up on google, I'm too lazy to explain.




MegaPoster404 -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/10/2009 17:03:10)

Thanks, MetalMewtwo. It's working now.

Also, could someone tell me how to do a hit test? I'd like it that when object A hits object B, object A plays it's death animation, and a value C goes down by 2




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/10/2009 20:51:21)

it's simple, really. Just give Object B an instance name of whatever, lets say "objB" Then, on Object A, put in onClipEvent(enterFrame){

then, just do:

if(_root.objB.hitTest(this)){ //"this" being Object A, and the word before hitTest is Object B. Btw, I think you need to put _root., not sure. Usually u put root for something not part of the MC, like a variable defined on the frame (unless it's global)
//put your code here

}
}

//end it with 2 thingys!




Nicky -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/10/2009 20:57:42)

Is this what you're thinking, MegaPoster? (Arrow keys to move the dot- A)

Code I used on "A":

onClipEvent (load) {
	C = 20;//Set C to 20
	dying = false;//Set it so that it knows that you're not dying.
}

onClipEvent (enterFrame) {
	if (dying == false) {//These actions only work if the dying animation hasn't played or is playing. 
		if (Key.isDown(Key.UP)) {//Moves the character. (Until the hittest line)
			this._y -= 15;
		}
		if (Key.isDown(Key.DOWN)) {
			this._y += 15;
		}
		if (Key.isDown(Key.LEFT)) {
			this._x -= 15;
		}
		if (Key.isDown(Key.RIGHT)) {
			this._x += 15;
		}
		if (this.hitTest(_root.B)) {//If this is hitting _root.B ("B")
			dying = true;//You are dying, therefore, after these actions are completed they won't be repeated again. (You can't move, etc.)
			this.play();//Death animation plays (inside the "A" MC)
			C -= 2;//C variable goes down by 2. If you leave out the "dying" code, C would repeatedly go down by 2 while "A" is touching "B".
		}
	}
}


Probably not the best way to do it, just putting it out there :P.

Beefstew: I found that without a variable to stop the actions that C would go down continuously while A is still touching B.... Might be just me though, who knows. :P




MegaPoster404 -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/11/2009 11:04:05)

Hmm.... I'll try that, Nicky. A few more things.

1. I'm trying to make a move area so you don't drive on the sky. I'll try it with coordinates, if that would work, but I want to know why the following code isn't working:

quote:


on (rollOver) {
startDrag(root.AssaultCart);
}
on (rollOut) {
root.AssaultCart.stopDrag();
}


2. How do you make a timer?




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/11/2009 11:59:52)

@Nicky: That's because I didn't put in any code yet [:D], lol. I had just made the if, you were right to put in something else, I just excluded that part, since he might have a different code :D.

@MegaPoster404: That's because that's for buttons.... And rollOver means something happens when the mouse rollsover the button, and rollout means once its off. Just use _x and _y coordiantes, like whoever originally suggested it said.

Also, just use variables... (For the timer)

-BeefStew




MetalMewtwo -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/11/2009 12:48:12)

2.For making a timer... Im guessing you dont know how to add a variable name to a dynamic textbox.

-First make a textbox
-then go to the properties of the textbox
-in there, where it saids "static", change it to "dynamic"
-next, at the bottom right corner of the properties section, there should be a place for you to type in a "var:" name. If you dont see it, at the bottom right corner, you should see a little triangle/arrow, click it. Now you should see it.
-in that "var:" space, type in "_root.timer"

-Now at the top, change your framerate to 30 frames per second
-then you click on the stage/timeline and add in this code...

var timer = 0;
var framecounter = 0;
onEnterFrame = function () {
_root.framecounter++;
if (_root.framecounter == 30) {
_root.timer++;
_root.framecounter=0;
}
};


and heres how it should look like:
http://megaswf.com/view/0a5f56ac35a79fafb1cc1657152fe0b5.html

This code only increases by 1 for every one second. In flash's world, 1 second is based on its frames, so 1 second in our world would mean 30 seconds in flash's world. Therefore we use another timer to count the number of frames passed so far, after 30 frames, we tell flash that 1 second in our world has passed.

If your not using 30 frames per second, remember to change that "30" to whatever your framerate is.




somebody621 -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/11/2009 17:00:52)

MegaPoster - getTimer() returns the time in milliseconds since the flash movie begins. You could store the beginning time, then subtract the current time to find the time elapsed.




Nicky -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/12/2009 0:40:57)

BeefStew- Ah, whoops. Must have overlooked that bit where you didn't have any code there :P. Tired... [x




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/12/2009 11:43:33)

@somebody621: But I thought that always just returns the time from the START of the movie? Plus, it can't be changed, so... Yeah... I'm sure he just wants to make something that he can start and stop whenever he wants :D. I think... Oh well, lol.

-BeefStew




somebody621 -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/14/2009 0:31:00)

You can set it so that
var beginningTimer:int = getTimer();

//do some stuff

var endTimer:int = getTimer();

timeElapsed = endTimer - beginningTimer or whatever




EragonZZZZ -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/14/2009 1:18:24)


quote:

var timer = 0; 
var framecounter = 0; 
onEnterFrame = function () { 
_root.framecounter++; 
if (_root.framecounter == 30) { 
_root.timer++; 
_root.framecounter=0; 
} 
}; 


This functions as a proper timer so long as there is absolutely no lag; otherwise, as the framerate changes so does the definition of what is "one second". A fine solution, but getTimer() may be a tad better.




Predatoree -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (4/19/2009 12:08:05)

Ooh yay I'm on the first post! :D And by the way, finding the converter wasn't that hard, I just searched "PNG to SWF Converter" in Google.




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (4/19/2009 13:27:49)

Lol, now I'm Jealous, XD!

I have A LOT to contribute, :P

Here's a GREAT site for extensions, if any of you know what they are. You download them, use your Flash Extension Manager, and they make Flash easier :D! Like a mod, sort of. But legal. These are free, expensive ones are found at http://adobe.com:

Great Extensions

And GREAT tutorials as well at:

http://www.newgrounds.com/collection/flashtutorials

-BeefStew




Predatoree -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (4/19/2009 15:31:11)

I like the Great Extensions, but the Newground tutorial pack is already on the front page. :P




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (5/8/2009 14:58:05)

Hey, I've never really tried the SharedObject method for saving stuff.. I'm assuming though that I won't be able to test it, since it'll be saved as a cookie, so te plain .swf from flash won't really do much, correct? I'm not really sure, all I know is I keep getting undefined variables...




EragonZZZZ -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (5/8/2009 16:12:46)

Answered your PM but I might as well answer it here, too.

SharedObjects are saved in their own folder in Application Data. They are not cookies. You should be able to test properly right from the .fla file.

Are you remembering to .flush() after you modify .data?




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (5/8/2009 16:14:37)

Yep :D, I remembered... Just had to define some variables better :s. Got it working again :D, though not to efficiently...

Hmm, I always thought it was cookies... Oh well, works better this way when it comes to making sure they don't try and get rid of it on accident :p!




golden rod -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (5/9/2009 23:13:36)

k so first off i'm using flash 8 pro.

now my question is how do i make like a registry system. and once that is made what changes do i make to my log in system's code?
this is the code for the log in system right now
quote:

stop();
var user_input = "";
var pass_input = "";
login_button. onRelease = function () {
if (user_input == "User1"
&& pass_input == "mypassword") {
gotoAndStop(2);
}
else{
gotoAndStop(3);
}
}




Vampire and Human -> RE: Flash Q&A Thread 5 - Flash Sold Its Shares In Your Soul... Recession (5/10/2009 7:32:17)

Umm... That's not really how it works. It's FAAAAAAR more complicated. And can sometimes (if not always) involve 2 or more different languages (usually MySQL and PHP).

http://www.sephiroth.it/tutorials/flashPHP/authentication/index.php




Page: <<   < prev  14 15 [16] 17 18   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition
0.1367188