RE: Flash Q&A thread 3 (Full Version)

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



Message


EragonZZZZ -> RE: Flash Q&A thread 3 (3/19/2007 21:29:27)

whats wrong with onEnterFrame?




petermaxo -> RE: Flash Q&A thread 3 (3/19/2007 21:51:07)

does anyone know what is wrong with my code? what I mean by the last frame is, say you had a movie clip with 7 frames in it, and a movie clip with 18 frames in it, and either one of them could be attatched to a scene. you want the scene to change exactly when whichever clip is attatched enters the last frame, i.e., the 7th or 15th.




flsg -> RE: Flash Q&A thread 3 (3/20/2007 17:47:38)

well, you could just put a code in the 7th or the 15th frame lol
EragonZZZZ: because it's hard to maintain and you can have errors like petermaxo did before(erasing the previous onEnterFrame of the same clip)
if you don't have a note everywhere, even the best programmers could do the same error




petermaxo -> RE: Flash Q&A thread 3 (3/20/2007 18:18:33)

I mean if I wanted 1 scene, and wanted it to end on either the 15th or 7th (or 13th, or 2764th...) depending on what movie was loaded. also, can someone PLEASE tell me something wrong with the code posted above




EragonZZZZ -> RE: Flash Q&A thread 3 (3/20/2007 22:38:54)

Ah, flsg. Thou maketh a good point!

What do YOU use instead (when putting code on the timeline just doesn't work out)?





petermaxo -> RE: Flash Q&A thread 3 (3/21/2007 17:26:14)

*ahem* does anyone hear me?




Grie Velorn -> RE: Flash Q&A thread 3 (3/21/2007 23:50:54)

hey does anyone know why i get this error when i try to use LLB's battle system?
**Error** Scene=Scene 1, layer=Setup, frame=2:Line 1: ')' expected
if (_root HP<=0 {




petermaxo -> RE: Flash Q&A thread 3 (3/22/2007 7:11:53)

it's supposed to be: if(_root.hp <= 0){




Grie Velorn -> RE: Flash Q&A thread 3 (3/22/2007 22:23:19)

okay thanks ill try that
EDIT: thanks it worked




swenn -> RE: Flash Q&A thread 3 (3/23/2007 16:39:24)

Alright I got some Q;(flash 8 prof.)
I use this code for movement:

onClipEvent (load) {
	step = 5;
	movieWidth = 180;
	movieHeight = 180;	
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.RIGHT) && this._x<movieWidth) {
	this._x += step;
	} else if (Key.isDown(Key.LEFT) && this._x>20) {
		this._x -= step;
	} else if (Key.isDown(Key.UP) && this._y>20) {
		this._y -= step;
	} else if (Key.isDown(Key.DOWN) && this._y<movieHeight) {
		this._y += step;
	
	
	}
	
}


Now
how do i get it to show my walking animations? and my idle animation to the last direction moved when no key is pressed?



And:
how do I get to duplicate an movieclip at random point of the stage at random times?




flsg -> RE: Flash Q&A thread 3 (3/23/2007 17:32:46)

eragon: what do you mean?
Grie Velorn: also, even if flash is super weak at debugging, you can just read the infos of the bug XD
"')' expected" what do YOU think it is?
swenn: here's the simple way: just put a this.gotoAndPlay(frameNumberOrName) before the end of if statement
for the movie duplication:

I'm too lazy to write the good code, so I'll just show you the simple way:
_root.onEnterFrame=function(){
if(random(99)>90){
_root.attachMovie("linkageName", "newName", depth)
_root["newName"]._x=random(Stage.width)
_root["newName"]._y=random(Stage.height)

}
}




petermaxo -> RE: Flash Q&A thread 3 (3/23/2007 21:19:11)

do you have any problems in my code for me to fix?




Grie Velorn -> RE: Flash Q&A thread 3 (3/23/2007 23:52:27)

@flsg:I dont have any action script know how at all only stop and gotoandplay and thats it so dont bug me about stuff like that cause i have no clue what to do but draw in it sorry if i sounded rude




swenn -> RE: Flash Q&A thread 3 (3/24/2007 3:40:38)

_root.onEnterFrame=function(){ 
if(random(99)>90){ 
_root.attachMovie("linkageName", "newName", depth) 
_root["newName"]._x=random(Stage.width) 
_root["newName"]._y=random(Stage.height) 

} 
} 

Can you please explain me the code flsg, so I understand what it does?




petermaxo -> RE: Flash Q&A thread 3 (3/24/2007 7:53:10)

quote:

I have a string of code trying to attatch a movie clip to the _root. and make it play. Here is the (somewhat shortened) code:

_root.onEnterFrame = function(){
if(back == 1){
_root.attachMovie("grassback", "back", 1,{_x:225,_y:200})
}if(ename == "green slime"){
_root.attachMovie("greenslimeattack", "enemy", 2,{_x:400,_y:200})
}_root.enemy.play()
}

sometimes, the movie clip 'greenslimeattack' won't play, or it will be delayed. does anyone know what's wrong?


Just thought I'd repost this in case everyone forgot what my problem is.




flsg -> RE: Flash Q&A thread 3 (3/24/2007 15:05:07)

swenn: I was using the simple way, so it might seems unorganised:
each time a frame passes, you make a random number between 0 and 99 and check if it's bigger than 90
if it's the case, attach the mc in the library where the linkage name is "insertNameHere". Then, give it a new name and a depth(for more informations check the help document about attachMovie). Then, use the new name and acces the mc and change it's x and y positions to a random number(the default positions is 0,0 when you attach a clip)

petermaxo: first of all, check if you can acces back on _root, which means see if the variable is on _root.
second: you put _root.enemy.play() after the if(), and I think your intention was to put it IN the if()




petermaxo -> RE: Flash Q&A thread 3 (3/24/2007 18:08:57)

1. didn't help.
2. I am simplifying the code by putting it at the end. instead of:
if(_global.ename == "lava slime"){
_root.attachMovie("lavaslimeattack", "enemy", 2,{_x:400,_y:200})
_root.enemy.play()
}if(_global.ename == "fire slime"){
_root.attachMovie("fireslimeattack", "enemy", 2,{_x:400,_y:200})
_root.enemy.play()
}...
I only need:
if(_global.ename == "lava slime"){
_root.attachMovie("lavaslimeattack", "enemy", 2,{_x:400,_y:200})
}if(_global.ename == "fire slime"){
_root.attachMovie("fireslimeattack", "enemy", 2,{_x:400,_y:200})
}...
_root.enemy.play()


Edit: I realized what was wrong- I finally realized why everyone was complaining about my use of onEnterFrame. I deleted it and it worked fine. The reason the movie clip wouldn't play was that it was being continueously loaded and never made it past the first frame.




Myhos -> RE: Flash Q&A thread 3 (3/25/2007 18:55:38)

quote:

ORIGINAL: swenn

Alright I got some Q;(flash 8 prof.)
I use this code for movement:

onClipEvent (load) {
	step = 5;
	movieWidth = 180;
	movieHeight = 180;	
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.RIGHT) && this._x<movieWidth) {
	this._x += step;
	} else if (Key.isDown(Key.LEFT) && this._x>20) {
		this._x -= step;
	} else if (Key.isDown(Key.UP) && this._y>20) {
		this._y -= step;
	} else if (Key.isDown(Key.DOWN) && this._y<movieHeight) {
		this._y += step;
	}
}

Now
how do i get it to show my walking animations? and my idle animation to the last direction moved when no key is pressed?

And:
how do I get to duplicate an movieclip at random point of the stage at random times?

Alright I would of hoped that your doing this code on the frame but you aren't...anyhow the object that this code has been assigned has to be a movie clip, next go inside of the movie clip and create a new layer (lets say layer 1 has your drawing or what ever) name the new layer A&L now add a label (in the properties window) make the label" still " (don't put in the " or the spaces)now add a stop command( stop(); ) on the frame (on layer A&L) next create a new key frame for both layers. On the A&L layer name it " right " (don't put in the " or the spaces). Now make your code have this:

if (Key.isDown(Key.RIGHT) && this._x<movieWidth) {
this._x += step;
gotoAndPlay(right); PS you MIGHT need to have it "right"

now put your right movement animation on layer 1 frame 2 (right).

In case i didn't make any sense to you, take a look at kirupa's tut: http://www.kirupa.com/developer/mx2004/platform_game.htm




petermaxo -> RE: Flash Q&A thread 3 (3/27/2007 18:09:14)

whenever I try to run this code, the output says

**Error** Scene=map, layer=Layer 1, frame=1:Line 9: ']' or ',' expected
_root.attatchMovie("plain", "space1_1plain", 1, [_x:0, _y:0]);
can anyone tell me where the problem is?




lil boi blue -> RE: Flash Q&A thread 3 (3/27/2007 21:46:47)

i think its the space btw the ',' and the '1',
idk much about actionascript but i always thought words like AND, OR, IF, ELSE were better than using commas and periods




Myhos -> RE: Flash Q&A thread 3 (3/27/2007 22:08:40)

well for and your normally use &&, anyhow the space won't make a difference, anyhow, try using = instead of :




petermaxo -> RE: Flash Q&A thread 3 (3/28/2007 15:41:12)

never mind, I accidentally was using "[]" instead of "{}". the code reads thus:

_global.space1_1 = "plain"

if(_global.space1_1 == "plain"){
_root.attatchMovie("plain", "space1_1plain", 1, {_x:0, _y:0});
}

when I run the movie, nothing happens.




flsg -> RE: Flash Q&A thread 3 (3/28/2007 20:12:33)

quote:



Edit: I realized what was wrong- I finally realized why everyone was complaining about my use of onEnterFrame. I deleted it and it worked fine. The reason the movie clip wouldn't play was that it was being continueously loaded and never made it past the first frame.

actually, I am the only one who's "complaining", so you should thank me (lol joke[:D])

for the code, you wrote "attatch" while it should be "attach"




petermaxo -> RE: Flash Q&A thread 3 (3/29/2007 6:33:33)

oops, the stupid error fairy strikes again[:D] thanks

Edit: Man! These bugs are popping up faster than mushroms! If I have code attached to a frame in a movie clip:

this.onEnterFrame = function(){
_global.action = "hit"
}

and on a scene:

if(_global.ename == "green slime"){
_root.attachMovie("greenslimeattack", "enemy", 3,{_x:400,_y:300})
}root.enemy.play()
_root.onEnterFrame = function(){
if(_global.action == "hit"){
_root.attachMovie("playerhit", "player", 2, {_x:200,_y:300})
}if(_global.action == "attackcomplete"){
gotoAndStop("battle")
}
}

What could go wrong that would make the variable 'action' not change. It is defined in a previous scene.




Myhos -> RE: Flash Q&A thread 3 (3/29/2007 10:15:06)

Just an idea but you should start on a smaller flash project,action script can be your friend, or it can be a pain in the ass. Instead of going against the huge boss (in this case a flash rpg) you should level up a little by making smaller games. Besides the fact that it can be usually completed sooner (so faster gratification) you'll be able to understand code better.

also for your bugs, do you mean it just doesn't work or it does wacky things? if its the latter, i found that printing out the code can be a huge help.




Page: <<   < prev  2 3 [4] 5 6   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition
0.1386719