Home  | Login  | Register  | Help  | Play 

RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul

 
Logged in as: Guest
  Printable Version
All Forums >> [Gaming Community] >> [Legends and Lore] >> Artists of Legend >> Art Academy >> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul
Page 16 of 18«<1415161718>»
Forum Login
Message << Older Topic   Newer Topic >>
4/7/2009 0:45:53   
golden rod
Member

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.
DF MQ  Post #: 376
4/7/2009 2:13:22   
Davosaur
Member
 

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

< Message edited by Davyo -- 4/9/2009 19:04:34 >
Post #: 377
4/8/2009 11:36:31   
Vampire and Human
Member

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{

< Message edited by BeefStew -- 4/8/2009 11:38:29 >
AQ  Post #: 378
4/9/2009 18:45:01   
MegaPoster404
Member

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
DF MQ  Post #: 379
4/9/2009 19:39:54   
MetalMewtwo
Member

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.
AQ  Post #: 380
4/9/2009 19:48:38   
somebody621
Member

Honestly, the best way to do pause is with a state machine. Look it up on google, I'm too lazy to explain.
Post #: 381
4/10/2009 17:03:10   
MegaPoster404
Member

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
DF MQ  Post #: 382
4/10/2009 20:51:21   
Vampire and Human
Member

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!

< Message edited by BeefStew -- 4/10/2009 20:52:50 >
AQ  Post #: 383
4/10/2009 20:57:42   
Nicky
Member

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

< Message edited by Nicky -- 4/10/2009 20:59:42 >
AQ DF  Post #: 384
4/11/2009 11:04:05   
MegaPoster404
Member

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?
DF MQ  Post #: 385
4/11/2009 11:59:52   
Vampire and Human
Member

@Nicky: That's because I didn't put in any code yet , 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

< Message edited by BeefStew -- 4/11/2009 12:04:10 >


_____________________________

OM NOM NOM'd by a Charmander!
Limits are 500px wide by 100 px tall.
Filesize at max can be 50kb.

I am a proudly eaten sig. I take pride in my half-digested-ness thank you very much!

The Mods shall not have me beat! Not again! Not this time!
AQ  Post #: 386
4/11/2009 12:48:12   
MetalMewtwo
Member

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.
AQ  Post #: 387
4/11/2009 17:00:52   
somebody621
Member

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.
Post #: 388
4/12/2009 0:40:57   
Nicky
Member

BeefStew- Ah, whoops. Must have overlooked that bit where you didn't have any code there :P. Tired... [x
AQ DF  Post #: 389
4/12/2009 11:43:33   
Vampire and Human
Member

@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
AQ  Post #: 390
4/14/2009 0:31:00   
somebody621
Member

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

//do some stuff

var endTimer:int = getTimer();

timeElapsed = endTimer - beginningTimer or whatever
Post #: 391
4/14/2009 1:18:24   
EragonZZZZ
Member


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.
AQ  Post #: 392
4/19/2009 12:08:05   
Predatoree
Member

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.
AQ  Post #: 393
4/19/2009 13:27:49   
Vampire and Human
Member

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

< Message edited by BeefStew -- 4/19/2009 13:28:01 >
AQ  Post #: 394
4/19/2009 15:31:11   
Predatoree
Member

I like the Great Extensions, but the Newground tutorial pack is already on the front page. :P
AQ  Post #: 395
5/8/2009 14:58:05   
Vampire and Human
Member

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...
AQ  Post #: 396
5/8/2009 16:12:46   
EragonZZZZ
Member

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?
AQ  Post #: 397
5/8/2009 16:14:37   
Vampire and Human
Member

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!

< Message edited by BeefStew -- 5/8/2009 16:18:27 >
AQ  Post #: 398
5/9/2009 23:13:36   
golden rod
Member

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);
}
}


< Message edited by golden rod -- 5/9/2009 23:16:12 >
DF MQ  Post #: 399
5/10/2009 7:32:17   
Vampire and Human
Member

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
AQ  Post #: 400
Page:   <<   < prev  14 15 [16] 17 18   next >   >>
All Forums >> [Gaming Community] >> [Legends and Lore] >> Artists of Legend >> Art Academy >> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul
Page 16 of 18«<1415161718>»
Jump to:






Icon Legend
New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts




Forum Content Copyright © 2018 Artix Entertainment, LLC.

"AdventureQuest", "DragonFable", "MechQuest", "EpicDuel", "BattleOn.com", "AdventureQuest Worlds", "Artix Entertainment"
and all game character names are either trademarks or registered trademarks of Artix Entertainment, LLC. All rights are reserved.
PRIVACY POLICY


Forum Software © ASPPlayground.NET Advanced Edition