# Flash 5, move character help

**URL:** <https://forum.kirupa.com/t/flash-5-move-character-help/7280>\
**Category:** Uncategorized\
**Created:** [October 27, 2002, 11:22am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280 "2002-10-27T11:22:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![thestick](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@thestick](https://forum.kirupa.com/u/thestick)\
**Post date:** [October 27, 2002, 11:22am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/1 "2002-10-27T11:22:37Z")

</div>

i have only just started, could someone give me some code to make one stickman move left and right, i have walking and still animations, just need the code, i’ve tried to code it myself but it failed my attemp at code was this -  
stop();

function initGame() {

```
// create the stickman 
attachMovie( "stickman", "stickmanstill",1) ;
stickman._x = 275;
stickman._y = 300;

```

}

function moveStickman(){}  
// check for arrow keys  
if (Key.isDown(Key.RIGHT)) {  
dx = 10;

```
} else if (Key.isDown(Key.LEFT)) {
	dx = -10;
	
} else {
	// no movement
	dx = 0;
}

// move the stickman and limit that movement
stickman._x += dx;
if (stickman._x &lt; 30) stickman._x = 30;
if (stickman._x &gt; 520) stickman._x = 520;

// make the stickman run or stand still
if ((dx != 0) and (stickman._currentFrame == 1)) {
	stickman.gotoAndPlay("stickman");
} else if ((dx == 0) and (stickman._currentFrame != 1)) {
	stickman.gotoAndPlay("stickmanstill");
}

```

stickman= running  
stickmanstill=standing still

thanx

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 27, 2002, 10:20pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/2 "2002-10-27T22:20:13Z")

</div>

does anyone knoe the code to make it work coz i’m a real newbie with actionscript and i really need to get this dun, otherewise could someone tell me a link to a site which has a tutorial on it for this sort of thing?  
:pirate:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 28, 2002, 1:03pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/3 "2002-10-28T13:03:05Z")

</div>

Well, what is that code doing, Thestick? I mean, what’s the problem?

pom 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 28, 2002, 1:07pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/4 "2002-10-28T13:07:37Z")

</div>

One thing I noticed: you attached the stickman clip under the name stickmanstill, so that’s how you have to call it when you want to move it. Not just stickman.

pom :cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 28, 2002, 1:19pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/5 "2002-10-28T13:19:52Z")

</div>

my problem is that for some reason when i export the movie all i see is my motion stickman walkng while staying still in the very top left corner. n e ideas? just trying it again give me a sec …

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 28, 2002, 1:32pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/6 "2002-10-28T13:32:20Z")

</div>

Did you try to replace stickman by stickmanstill in your code?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 28, 2002, 1:46pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/7 "2002-10-28T13:46:57Z")

</div>

i’m doing that in a while, i’m at work so i can’t i’ll tell u whether it worked at 8:00 PM

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 28, 2002, 2:17pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/8 "2002-10-28T14:17:52Z")

</div>

Well, it’s 10:20 pm here… 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 28, 2002, 7:46pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/9 "2002-10-28T19:46:11Z")

</div>

could u check why this won’t work plz i’ve tried most things i know and i still don’t know why it doesn’t work  
(flash 5)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 4:54am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/10 "2002-10-29T04:54:16Z")

</div>

i didnt really check the FLA but… on this line…

function moveStickman(){}

the function declaration… arent the curley brackets supposed to be open here and closed after all the code for that function has been written?? so it would be

function moveStickman(){

code

}

cuz it seems like the function wont do anything when called… if there is no code in it… but im not too hot on functions in flash so im probably wrong

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 8:31am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/11 "2002-10-29T08:31:37Z")

</div>

That was the problem… 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 8:53am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/12 "2002-10-29T08:53:22Z")

</div>

i just changed that line and now when i export the movie it comes only shows up as a white screen and not anything else

do u have any ideas?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 8:57am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/13 "2002-10-29T08:57:32Z")

</div>

You have to put the closing bracket at the end of the block!!!

> Statement block must be terminated by ‘}’  
> function movestickman() {

Looks pretty clear, doesn’t it? :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 9:00am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/14 "2002-10-29T09:00:25Z")

</div>

sorry about that i accidently posted the undedited version, read my previous reply which i have just updated to get the relevent flash file  
sorry  
:x

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 9:07am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/15 "2002-10-29T09:07:29Z")

</div>

Put a } at the end of your function…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 9:09am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/16 "2002-10-29T09:09:58Z")

</div>

Something else, you’re trying to attach stickman, but there’s no clip called like that in the library. Two of them are called stickmanstill.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 9:19am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/17 "2002-10-29T09:19:36Z")

</div>

stop();

function initGame() {

}   
// create the stickman  
attachMovie( “stickman”, “stickmanstill”,20) ;  
stickman.\_x = 275;  
stickman.\_y = 300;  
}

function movestickman() {

}  
// check for arrow keys  
if (Key.isDown(Key.RIGHT)) {  
dx = 10;

```
} else if (Key.isDown(Key.LEFT)) {
	dx = -10;
	
} else {
	// no movement
	dx = 0;
}

// move the stickman and limit that movement
stickmanstill._x += dx;
if (stickmanstill._x &lt; 30) stickmanstill._x = 30;
if (stickmanstill._x &gt; 520) stickmanstill._x = 520;

// make the stickman run or stand still
if ((dx != 0) and (stickmanstill._currentFrame == 1)) {
	stickmanstill.gotoAndPlay("stickman");
} else if ((dx == 0) and (stickmanstill._currentFrame != 1)) {
	stickmanstill.gotoAndPlay("stickmanstill");
}

```

this is the code i have got from your help, i would greatly appreciate it if you could tell me what I need to change and why, sorry for being such a pain.[SIZE=1]stop();[/SIZE] [FONT=arial]stop();[/FONT] [FONT=arial]stop();[/FONT]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 9:27am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/18 "2002-10-29T09:27:06Z")

</div>

i’ve changed the linkage properties and now when i load it up i get a walking stickman animation (stickman) and this in the output box

Generator is not enabled for this movie. C:\My Documents\jack\stickdude.swf

um, how do i enable the generator  
?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 29, 2002, 9:35am UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/19 "2002-10-29T09:35:11Z")

</div>

Hang on!! 😛

This will make it through the compilation:

```auto
stop();

function initGame() {
	// create the stickman 
	attachMovie( "stickman", "stickmanstill",20) ;
	stickman._x = 275;
	stickman._y = 300;
}

function movestickman() {
	// check for arrow keys
	if (Key.isDown(Key.RIGHT)) {
		dx = 10;
	} else if (Key.isDown(Key.LEFT)) {
		dx = -10;
	} else {
		// no movement
		dx = 0;
	}
	// move the stickman and limit that movement
	stickmanstill._x += dx;
	if (stickmanstill._x < 30) stickmanstill._x = 30;
	if (stickmanstill._x > 520) stickmanstill._x = 520;

	// make the stickman run or stand still
	if ((dx != 0) and (stickmanstill._currentFrame == 1)) {
		stickmanstill.gotoAndPlay("stickman");
	} else if ((dx == 0) and (stickmanstill._currentFrame != 1)) {
		stickmanstill.gotoAndPlay("stickmanstill");
	}
}

```

Then you need to change your linkage names.

pom 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 10, 2002, 1:32pm UTC](https://forum.kirupa.com/t/flash-5-move-character-help/7280/20 "2002-11-10T13:32:17Z")

</div>

thanx for the code it works now, but one minor problem the stickman starts at the top of the screen and even when i change the “y” properties it won’t move down, could you tell me how i can make it move please?

[Next page](https://forum.kirupa.com/t/flash-5-move-character-help/7280.md?page=2)
