RE: Flash Q&A thread 2 ** checked everyday (Full Version)

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



Message


Darklord517 -> RE: Flash Q&A thread 2 ** checked everyday (3/28/2006 11:07:35)

How would you make it so that if a guy hits a coin for example the amount of money which is a dynamic text box with a variable of gold goes from 50 to 100?




somebody621 -> RE: Flash Q&A thread 2 ** checked everyday (3/28/2006 11:47:24)

//if the movie clip with the instance name char on the main timeline collides with the movie clip with instance name coin on the main timeline
if(_root.char.hitTest(_root.coin, true){
//add 50 to the variable money, located on the main timeline.
_root.money + = 50;
//delete the money move clip.
removeMovieClip(_root.money);
//end the code
}
a simple way using hitTests. Seriously. Try to figure out your own code these days. People just take the code for granted.




Darklord517 -> RE: Flash Q&A thread 2 ** checked everyday (3/28/2006 12:27:21)

Thanks somebody i was stuck on that code for a long while i tried about 20 different codes i made myself but thanx anyway, BTW i do use my own AS its just tat when i puzzle over something for too long i get really leary.




steelsoldier -> RE: Flash Q&A thread 2 ** checked everyday (3/28/2006 16:16:47)

Thanks to this tutorial i can now do flash movies!!!!
http://img393.imageshack.us/my.php?image=untitled46me.swf
2 days try and i did this stupid flash lol




flsg -> RE: Flash Q&A thread 2 ** checked everyday (3/28/2006 16:44:50)

steelsoldier: it's good, but you could perhaps try some motion in Flash
Somebody: thanks a lot!!!




mathus the seconth -> RE: Flash Q&A thread 2 ** checked everyday (3/28/2006 18:14:03)

how do u loop sounds?




flsg -> RE: Flash Q&A thread 2 ** checked everyday (3/28/2006 20:35:42)

mathus the seconth:
//declare an new Sound Object
var mySound=new Sound()
mySound.attachSound(libraryLinkageOfTheSound)
mySound.start(howManyTimes,0)




somebody621 -> RE: Flash Q&A thread 2 ** checked everyday (3/29/2006 14:34:10)

Made a little code to test the FPS of an movie. My movies keep lagging.
Here goes.
Type this code on the first frame of an MC's timeline. It's heavily commented, so beware!
The comments are there for a reason, and figure out what the code is doing before you copy and paste(I hate copy and pasters).

//set the FPS.  Movie only runs through this code once.  It's just to set it
var FPS=1;
//set a variable i.  This will be used to see how many times the getFPS function has run
var i=1;
//the movies framespeed that you set in the properties panel.  You can change this around.  All it's there for is to test the lag of the movie.
var j=24;
//on every frame
onEnterFrame=function(){
	//make a variable FPS increase by one.  If you have Flash 5 or lower, put FPS+=1.
	FPS++
	//see how how many frames have passed.  Delete this code if you want.
	trace(FPS);
}
//define a function that runs on a set interval, defined at the end.  It requires no arguments or parameters
getFPS = setInterval (function(){
	//the actual framespeed is the amount of frames passed divided by how many times this code has run, since it runs every second.  FPS=frames per second.
	actualFPS=FPS/i;
	//test the lag of the movie.  All this is is subracting the framespeed the movie is going from the framespeed the movie should be going.
	actualLag=j-actualFPS;
	//the framespeed rounded to the nearest whole number
	approxFPS=Math.round(actualFPS);
	approxLag=Math.round(actualLag);
	/*make variable i increase.  i represents the amount of times this code has run.  You could also
	delete the actualFPS = FPS/i line, and put FPS=1 right here, but that would be less accurate.  Also, for 
	flash versions 5 and lower put i+=1.*/
	i++
//run this code every second.
},1000);
//code made by somebody621
	

Make two dynamic textboxes, one with the variable name approxLag, and the other with the variable name approxFPS.
You can change these to other variables in the code, but I don't like huge irrational numbers. Label them with static textboxes next to them.

Ideas:You could turn this into a componant for other movies. Then you wouldn't have to dig inside the movie clip to set the variable j, just type into the component.




flsg -> RE: Flash Q&A thread 2 ** checked everyday (3/29/2006 16:36:00)

cool code! Never though we could use setInterval on differents lines lol
just a little comment: since you're not gonna to use getFPS, write simply: setInterval(......)
well, if you need to clear it later then you'll need it lol




somebody621 -> RE: Flash Q&A thread 2 ** checked everyday (3/30/2006 9:24:59)

You can still us clearInterval for my code. setInterval also requires the function name. setInterval(function name, time, and parameters)




flsg -> RE: Flash Q&A thread 2 ** checked everyday (3/30/2006 16:59:25)

what I'm saying is that it can be a temp function with only one line, like this:
setInterval(function (){trace("hi"), 1000}
but I didn't know we could use:
setInterval(function(){
//code here...
}
, 1000)




somebody621 -> RE: Flash Q&A thread 2 ** checked everyday (3/30/2006 18:30:44)

Made a little light generator. The inspiration is from a project on Ultrashock test actionscript projects. Basicly, my version defines a random value for each particles y position and uses the Pythagorean theorem to find the x position so that it snaps to a circle defined within my actionscript, then divides that y by two. Every frame, the points of light go up and their alpha decreases. The depth of the points is defined by the y position when the points are first made. There still are a couple of depth sorting problems, but here it is!

I've heard that the random operator is deprecated. What do we use instead? Also, what does int do?

EDIT: Depth Problems Fixed!




Crimson dragon -> RE: Flash Q&A thread 2 ** checked everyday (3/31/2006 15:22:52)

lol i need help again.
ive been doin alright up to now, im alright at action script now (thanks kirupa and flsg!)
....ok ive made a shop in a game, how would i make it so wen i press the "buy" button i lose the amount of gold it is.
Ive tried many codes for this plz help.
thanks =)




Darklord517 -> RE: Flash Q&A thread 2 ** checked everyday (3/31/2006 15:28:37)

well that depends on the amount of gold you already have im not sure how to do it in AS but i now what you have to do.

Somebody, flsg, Zoltan, LBB please right this in AS.

First you have to find out how much gold you already have, this should be a variable. Then when you click buy it should be
on (release){
_root.gold = "" - 50;
}

The words in bold should be changed to what you have.

Is this correct flash gurus?




Crimson dragon -> RE: Flash Q&A thread 2 ** checked everyday (3/31/2006 15:33:22)

thanks for telling me that but i already hav my gold var etc.
all i need 2 know is how 2 lose gold wen i buy it lol
EDIT-actually thank you very much darklord that helped a lot!
EDITEDIT-Darklord thanks a lot a lot! it works!!!!!!!!! Whooooo!
EDITEDITEDIT-ok so it isnt working that well. i went with 70 gold and 60 was took off and that is fine. but i go back with 200 gold and wen i press buy it takes my gold 2 70 and then takes 60 off leaveing me with 10 again. so can anybody help in making the amount of gold in the "" vary 2 how much u actually have (if all that makes sence)




flsg -> RE: Flash Q&A thread 2 ** checked everyday (3/31/2006 16:34:24)

somebody621L int() is like Math.round(), but doesn't round the number
ex:
int(3.1)//return 3
Math.round(3.1)//return 3
int(3.5)//return 3
Math.round(3.5)//return 4

darklord517: I don't know, but I have my own better way:
//code on the frame...
//_global.gold repleace _root.gold since you can access it easily from anywhere
_global.gold:Number=0
//code on the button
on(Release){
  _global.gold-=50
  //_root.tf is a dynamic TextField
  _root.tf.text=_global.gold
}




somebody621 -> RE: Flash Q&A thread 2 ** checked everyday (3/31/2006 18:59:13)

I have my even better way. lol
//define the amount of gold you have
user.gold = 500;
//define a function
//gold is the money you should lose in this function
function loseGold(gold){
//if your gold is higher than the gold needed
if(gold < user.gold){
//user's gold is decreased by gold. Thanks flsg for pointing out my error.
user.gold -= gold;
}
}
//when the mouse button is released over your button
mybutton.onRelease = function(){
//lose 50 gold
loseGold(50);
}
You must have declared the gold value twice. Get rid of one.
nvm, I see what you have wrong. You wouldn't use _root.gold = ""-50, but declare gold earlier and use _root.gold -= 50;




flsg -> RE: Flash Q&A thread 2 ** checked everyday (3/31/2006 21:50:53)

lol, you even build a function for this[8D]
anyway, you forgot the "=" in user.gold - gold
edit: does anyone know a good site about Java+Flash?




lil boi blue -> RE: Flash Q&A thread 2 ** checked everyday (4/1/2006 22:41:02)

check this out, i've decided that since you guys have been here for awhile, we will call ourselves....the flazh possay
Lil boi blue
flsg
Zoltan
somebody621




flsg -> RE: Flash Q&A thread 2 ** checked everyday (4/2/2006 0:30:02)

lol...Flash possay...what does possay means? Sorry I'm not very good at English

darklord517: I forgot to say that your code doesn't work because of _root.gold-=""-gold
you can put a trace() statement after _root.gold=""-gold, like this:
trace(_root.gold)

you'll see that in the output screen(when you play your movie in Flash), you can see the Number NaN(yes, NaN is a number in Flash)
let me explain:
"" is a string, gold is a number
when we do the operation ""-gold, Flash first convert the string into a number, than it calculate the return value
"" converted into number is NaN(legal numeric value, Not a Number)
NaN-gold(a number)=NaN
understand now?[;)]
P.S. "1" convert into number is 1, "2" is 2, "3.123412" is 3.123412...


does someone know a good site to host a webpage?(ASP+JSP+Access)




lil boi blue -> RE: Flash Q&A thread 2 ** checked everyday (4/2/2006 0:39:50)

http://dictionary.reference.com/search?r=2&q=posse its really spelled posse but i just did it possay for purnunciation perposes

(paw-say) its a group of people called to help a police chief but in slang it can refer to a group of people called together or something like that

www.google.com !! just search it free webpage hoster, i know bravenet, freewebs, and 712 or something like that

flsg.bravenet.org thats how they do it




Darklord517 -> RE: Flash Q&A thread 2 ** checked everyday (4/2/2006 1:06:39)

Oh thnks now my own thing will work lol.




mathus the seconth -> RE: Flash Q&A thread 2 ** checked everyday (4/2/2006 1:58:16)

can anyone help me with the game im making? all the scripts ppl give me dont work. its a shooting game, like the one zoltan made, i have a bg, a gun with a crosshair, an enemy, and a bullet. the scripts on the gun are:

//gun replaces cursor.
onClipEvent (load) {
	
startDrag("", true);
	Mouse.hide();
}
//I made this section myself:
//when you press, the bullethole x & y = the gun x & y.
onClipEvent(mouseDown) {
	_root.bullethole._y = _root.gun._y;
	_root.bullethole._x = _root.gun._x;
}


thats just about it.
now i need u to teach me how to make scorecount, reload, and hittest between the bullet and the enemy (if u can of course) ill upload a file of what i have later.

EDIT: here is what i have so far.

timebomb

(turn up the volume music by me, thanks to http://www.ctcmix.com, i found this site on a cereal box lol long time ago.)

u should try this hoster: http://www.badongo.com/, it can take 1 gig files!!!!, thats AMAZING.

EDIT EDIT: I fixed the script,
Before --->
on (press) {


After --->
onClipEvent(mouseDown) {


it makes it go much smoother.




lil boi blue -> RE: Flash Q&A thread 2 ** checked everyday (4/2/2006 3:05:57)

as many know im a graphics guy but here is a site thats pretty good, if you go to tutorials, it has a game section, VERY unorganized though www.flashkit.com and the search thing doesn't work too well




mathus the seconth -> RE: Flash Q&A thread 2 ** checked everyday (4/2/2006 13:08:17)

lbb, can u so graphics for my game? whatever u think looks bad in my game (which there is alot) can you draw it better? in the end of the game ill give u credit for graphic design in the credits.




Page: <<   < prev  6 7 [8] 9 10   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition
0.140625