Added: 2 years ago
From: oppcell
Views: 72,245
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (233)

Sign In or Sign Up now to post a comment!
  • hero.gotoAndStop('still');

    var Key:KeyObject = new KeyObject(stage);

    stage.addEventListener(Event.E­NTER_FRAME, onenter);

    function onenter(e:Event) :void{ if (Key.isDown(Key.RIGHT)){ hero.x+=2; hero.scaleX=1; hero.gotoAndStop('walking'); } if (Key.isDown(Key.LEFT)){ hero.x-=2; hero.scaleX=-1; hero.gotoAndStop('walking'); }else{ hero.gotoAndStop('still'); }

    }

  • Hang on, where does the KeyObject script we downloaded go?

  • You should like Josh of the howstuffworks podcast haha.

  • Thank you, sir. You were entirely helpful.

  • thx so much!! but where the second part?

  • wow actionscript stole my strawberry tart

  • I can never succeed with these tutorials. I find them hard to follow. I have done everything to what you said and it saying things like. goToAndStop is not a function (player1.goToandStop("stand"); it wont alow it. And I also dont know how import KeyObject is done from the flash file. I ave it in same directtory.........

  • thanks honey

  • thank you

  • what did he do between when he said something about the red flaigs and the content layer?

  • Line 3. Type was not found or was not a compile-time constant: Key Object

    Line 3 Call to a possibly undefined function.

    I have no clue what is wrong. I seem to have typed the exact same code as in the video

  • Having troubles. Can't get him to stop twitching. Under "output" it says:

    ArgumentError: Error #2109: Frame label still not found in scene still. at flash.display::MovieClip/gotoA­ndStop() at heroplay_fla::MainTimeline/fra­me1()

    Can anyone help?

  • The class or interface 'KeyObject' could not be loaded. i get this error all the time

  • THANK YOU, YOU ACTUALLY MAKE THE TUTORIAL AS IF YOU'RE TRYING TO TEACH SOMETHING TO SOMEONE WHO DOESN'T ALREADY KNOW EVERYTHING ABOUT THE SUBJECT

  • libary.

  • this helped me out so much. cant thank you enough.

  • can u make a tutorial ? when a hero is jumping and sitting? :)

  • great ^^

  • do you know what the difference between actionscript 3.0 and javascript?

    i really wonder about that...

  • @jessin8D java script has less colours

  • Comment removed

  • I would do animations for walking left or right instead of pictures but good tutorial.

  • Comment removed

  • good job man :D

  • I dont get how you make the animation appear on the library : /

  • LOL 0:57 sounds likes "save link ass"

  • "Now we have bouf our frames."

    Black man for sure. Lol.

  • Thanks. Great tut

  • How do I get rid of the chopiness when he moves?

  • @daftmarzo Its choppy because there are not enough frames to make the animation smooth, 24 frames per second of something moving is normal and smooth, This sprite sheet looks alot less than 24 frames per second, and thats why its choppy because the interval of movement per second is incredibly slow and makes it obvious.

    The more frames per second the smoother it is

  • It says that it doesn't recognize KeyObject

  • Very confusing, you lost my subscription

  • Thanks for some ideas.

  • how can you make my character play the walking animation while walking? it did before, but after the else stuff, it stopped, and only shows the 1st frame of the walking animation. I have no errors, any help?

  • Thanks so much for this! Took me forever to find a tutorial like this, this is exactly what I need to start my street fighter style game :D

  • YOUR PLAN DOESN"T WORKZ FOR MEH

    D:

  • Great video. Worked perfectly for me.

  • Comment removed

  • Comment removed

  • i get this error: 1120: Access of undefined property hero.

    Please help me, i'm totally new to flash so what can i do?

  • @ruig you can check if you labled your hero 'hero' under properties

  • To all that gets the hero stuck on the first pose when he's supposed to be walking: After hours of googling I finally found a forumpost with the solution! YouTube won't let me post a link, but Google this: "[AS3] movieclip doesn't play when holding arrow keys down" and you should find the same forumpost I did, with the solution. GL.

  • hey where do i need to put the thing i downloaded from senocular? please i need immediate response.

  • I have an error that says :

    ERROR: tmp_hero.as, Line 23: Type was not found or was not a compile-time constant: Event.

    How do I fix that?

  • What if your running animation has 5 frames and you want it to action through them as you walk left or right.

    =]

  • @dragonvl Nevermind I added this: instead of leaving gotoAndPlay(walking animation); if(player.currentLabel == 'still') { player.gotoAndStop('running'); }

  • @dragonvl I think that you should just flip thouse anims you've made. Hope it helps :)

  • Comment removed

  • fucking windows 98 :D

  • Is the keyobject file available in FlashDevelop?

  • YOUR MY HERO

  • Why do we have to go get another ones code to this. Why not just do it ourselves, with the as3 code?

  • after fixin' the problem it is still moving by an error in line 17

  • dude plz you have to help me i cant fix the senocular problem i got macromedia flash 8.

    plz dude im beggin you.

  • Comment removed

  • You don't explain what layers everything is occurring in, yet you go into great detail about opening and closing parenthesis...c'mon man

  • Why didnt you explain anything about the content layer and as3. You didnt have anything about it in this tutorial! Its very annoying. Please someone explain because my character does not move. Still, great tutorials! Thanks

  • i still don't understand how the Key Object download has anything to do with my AS3 file. How is my document communicating with the key object? I erased that small snippet at the begging of keyobject to stop it from twitching and saved it and it still twitches when i play it. and where did you get the action script layer from? it like magically appeared when you pan back down.

  • I apreciate the help but if you are going to make toutorials please don't skip steps or have things already on the screen. its mad annoying to have to guess where you got to certain stages.

  • thank you man, had to make a mini flash games for my studies and your tutorials are saving my life^^

  • u are such a life-saver~~^^ subscribed!

    keep on the work!

  • downloaded KeyObject.as in same folder, deleted the bit you said but still get error 'Type was not found or was not a compile-time constant:KeyObject' i'm using a mac but i'm sure that is not the problem.

  • Hey men this works whit actionscrip2.0? i only got flash 8 i got years searching for a tutorial whit this but for 2.0

  • I like this, but where's the guns and the enemies?

  • that was great very informative

  • The Character doesn't have animation when i press a arrow key help

  • Finished the tut, i say great tutorial. But when i move with the finished product my character has no animation only the first frame of the animation. Any ideas?

  • Character not moving while walking?

    SIMPLE FIX:

    replace the code gotoAndPlay under the key.isdown code with gotoAndStop and your character will walk correctly.

    Here is the code to copy paste if you're still confused:

    function onenter(e:Event):void{ if(Key.isDown(Key.LEFT)){ hero.x-=5; hero.scaleX=1; hero.gotoAndStop('walking'); }else if(Key.isDown(Key.RIGHT)){ hero.x+=5; hero.scaleX=-1; hero.gotoAndStop('walking'); }else{ hero.gotoAndStop('still'); }

    }

  • perfect! thank you man

  • Thanks So Much, This Really Helped Me Understand AS3

  • can somebody PM my the codes

  • Thanks oppcell... very clear and you make it look totally easy!

    Great job, mate.

  • @Jerkish2120 @MrB4rbz, the problem is that as long as you hold the key down, it will continuously "gotoAndStop" on your "walking" movie clip; which will keep starting the movie clip from the beginning, making it appear frozen.

    ================

    SOLUTION:

    if(hero.currentLabel != 'walking'){

    hero.gotoAndStop('walking');

    }

    ==============

    This checks to see if it is already running the "walking" frame. If so, it won't keep starting it over from the beginning.

  • when i type

    var Key:KeyObject = new KeyObject(stage); the 'stage' doesn't highlight in blue?

  • @Jerkish2120 I experienced the same problem. Then i looked in the library and noticed, that my walking animation was only a graphic, but it has to be a movie clip, i thought. Then i recreated the walking animation as movie clip, inserted it again and everything worked!

    Sorry for my bad english and i hope i could help! ;)

  • I've tried this tutorial in CS3, CS4 and CS5 and started from scratch several times - but the character doesnt walk when you move him - he just freezes. On the vid though he walks fine. Any ideas any one?

  • dood can u help me im trying to add buttons instead of keyboard keys so i can make an ipphone app

  • ive got the same problem as Jerkish2120 and MrB4rbz. no errors are found but it only shows the first from of the walk cycle. anyone figured out how to fix this?

  • please reply to this: how come when i put the }else if statement the feedback says that 'else' is unexpected?

  • DUDE, your going way to fast.

    --where can i find a AS3 Layer?  or should i just name is that way?

    -- How do i go into the 'Actions - Frame'

  • can you make characters more advanced than this? to look like a real people?

  • Whenever I press right, My hero teleports to the left, then starts walking to the right...? The same thing happens when I press left, only he teleports to the right....

  • very nice, but i have one problem:

    when my hero walk, he only slide over the sreen without moving his feet

    i think something with the walking movieclip is wrong, but i don't find the mistake

    can anybody help me?

  • @SandroAUT : My character moves but doesn't animate either. Did you resolve this?

  • HELP !!!

    I need the code for objects ( like a block ) with gravity !!

    I you now please send me the code !!!

  • I figured out why it wasn't playing the full walking animation or whatever if you guys couldn't figure it out, in the main time line the actions layer and the content layer need to be only 1 frame. Awesome tutorial helped me a lot

  • when my hero is supposed to be walking, he just stays on the first pose.....

  • @Jerkish2120 i think i figured it out!! i ended up having to use cs4 and publish with Flash Player 10. the exact same code published with Flash Player 9 does that first-frame-of-animation-non-a­nimated thing.. BUT then i published with Flash Player 10, and it worked!! phew! finally!

  • @kentoster Do you know any other way to get around this, because im using cs3 and i can't publish with Flash Player 10

  • this was really helpful

  • how do I increase the size of my chars? the bounding boxes around them are all slightly different sizes.

    Doest increasing the size matter now or can it be done later?

  • how you have a make as3 Layer?

  • Where do you save your key action script?

    or can i save it anywhere

  • hey, great vid

    i have a problem though

    i DIDN'T download the package at the start (so that's probably why) but the problem with mine is the animations within the symbols with the main 'hero' symbol are not playing - any clues?

    also, i used bones for my animation (but when it didn't work i converted the armature layer into a normal one)

  • @GregTheGrogan - i'm also using different code so do i still need to download the package for it to work

  • Thx theussification, BUT i just fixed this error, then, when i play the movie, i get the same error, BUT when i try to check errors, it says there are no errors, also, i did fix the KeyObject, but it didnt work in anyway, if you'd please help me?

  • i loveeee this tut

    You really helped me ;p

    tank you so much :)

  • hopefully you will look at my video..and join the rest of us.

  • Comment removed

  • Comment removed

  • i love your tutorials but now i have an problem .. there stand : rigthbrace before end of the programm necessary.. what i shoud do ?

    when i push Ctrl + Enter ..

    die figur just move the moves still and walking but but does not move there ..

  • I get a different error: (Destricption:1158:Syntax error: missing left brace ({)...) (Source:function onenter (e:Enter):void(

    I've never done this before so i dont know if im supposed to put in something different instead on onenter, like you just used it cause it was a tutorial, or you have to use it to get it working, Please help me

  • @pureownage779 ,

    You get this error because at the onenter function you typed:

    function onenter (e:Enter):void(

    It should be:

    function onenter (e:Enter):void{

  • ok so my recent posts wer supposed to be replies but it glitched and put all my comments on the top :P so sorry if they seem out of place

  • I dunno why this gave me so much trouble before. Seems so easy now. Thanks!

    Good tut. Stay awesome.

    [p.s. I had to import it in the .fla like "import KeyObject" to make it work, but when I made it my document class it didn't work... any ideas?]

  • LOL thanks for this tutorial. I was messing around and added kirby.rotationZ-=9 when left is pushed. It looked fucked up. 5 stars, keep teaching us bro.

  • Tutorial was awesome, worked perfectly and am messing around with Z Axis/Y Axis. Onto rotation!

  • I'm trying to do this with an animated 'still' and get the errors:

    1119: Access of possibly undefined property x through a reference with static type Class.

    1119: Access of possibly undefined property scaleX through a reference with static type Class.

    1061: Call to a possibly undefined method gotoAndStop through a reference with static type Class.

    Any tips on how to solve this would be greatly appreciated.

  • i try doing the same thing with a y-coordinate but the animation won't work.

  • Comment removed

  • A great tuturial but could u also show us how to make a back ground and lvls? =DD

  • could i please get this script for as2?

    thank you kindly

  • @vamuseupload

    there are tons more videos on as2 then as3.

  • i dont doubt that there are but i need this particular script for as2 because the project im working on needs it, thanx

  • @vamuseupload This entire tutorial is just making the as3 work like as2. All it is is the key.isdown working in as3. just use key.isdown code. The other as in the tut isn't really hard to figure out, I think the only thing as3 specific is the scaleX...

    Not that hard to figure out. [and Bioshock was an awesome game]

  • the background of my hero is black how come?...

  • @zizikelizike

    u can right click it , and select "break apart" or press ctrl+b . and then erase the black

  • thx

  • how do you get the Keyobject package into the same directory as your game

  • awesome man

    this was very helpful

  • You are a brilliant teacher :)

  • 4:52 skips how do you get to that part?

  • Perfect ! Just the little touch i was missing. Loved It. Thanks a bunch ! :)

    Keep it up !

  • thanx!!!!!!!!!!!!!! i so needed that

  • The SWF was working fine and the person moved perfectly. When I closed Flash, the next time I opened this file, I get this error: 1046: Type was not found or was not a compile-time constant: KeyObject.

    Help Please?

    Great video though, I learned a lot.

  • I get this error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.

    at caveman_fla::MainTimeline/onEn­ter()

    Any help?

  • awesome awesome awesome

  • wow :) Thanks a lot. Good lesson

  • Perfect! Thanks so much man!

  • My window doesint let me show it UP! MY INTERNET IS NOT WORKING! HELP ME WHERE DO I SEACH THE ONE WHO CREATE IT! PLZ!

    AND U KNOW I ALWAYS USE MOZILLA FIREFOX!

  • How can I make it so that the character follows my mouse. For example: If I had "birds eye view" character, how could I make him turn towards where my mouse is pointing? Kind of like endless war 4

  • Comment removed

  • I downloaded those sprites or whatever you call them. but they all have a black background and when i convert them to a symbol like you do the black background stays with them!

  • @cricketownz It should be a bitmap, go to modify, go to bitmap, and go to trace.

  • if your want to use wasd you dont just type "(Key.A)" a stands for a number in flash terms ask google for the flash letter codes

  • thanks

  • Comment removed

  • Cool...

  • part of teaching is responding to questions.

  • How do i make it so that it moves with the WASD keys and not the arrows?

    When i type if (Key.isDown(Key.A)) for example nothing happens. pls reply

  • whats if and Key for the ifKey.isDown thing?

  • Comment removed

  • omg it works ! :D

    I did it an other way than you do,

    but it works :D thank you verry mutch :D

  • Comment removed

  • thx :D it is very helpful :D

  • I had same problem. I posted about it two months ago and he hasn't been answering for this problem.

  • btw I love when people say 'I did everything right, but got an error.' lol

  • I know, it's hilarious! " Let's see here, well if you got an error it must be complicated to figure you did something wrong! " lawl :P

  • Comment removed

  • jerkish2120 - that's exactly the problem I had as well...whats up? Please clarify for us would ya! Thanks! otherwise very cool

  • very helpful! thanks

  • You just need to add a new layer and call it "as3" every action should be written in that layer.

    P.S: the new layer shortcut is right below the layers display :)

  • How did you take out the black background around the man?

  • Just go to paint and paint the background of white, then add that graphic to the library and follow the tutorial :)

  • actually even better, make sure its a PNG format, the background is invisible when put onto flash

  • Dude i did evrything right but i get

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: The class or interface 'KeyObject' could not be loaded. var Key:KeyObject=new KeyObject(stage)

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 4: The class or interface 'Event' could not be loaded. function onenter(e:Event):void{

    Total ActionScript Errors: 2 Reported Errors: 2

    pls help

  • you might need to make sure that the KeyObject file is in the same folder as your flash file, also make sure that it is directed at your game, to do that, open it up, and at the top right corner of all the text should be a dropdown box, click it and make sure its selected on your game, this can also be prevented by making specific folders for your games

  • 3:40

  • great videos

  • cool, i'm going 2 download a cs4 free trial

  • How did you open that programming thing out when you switched to the as3 layer?

  • F9 key in case you havent figured it out in 5 months

  • never mind i kind of found out xD

  • where do i write the

    hero.gotoAndStop('still');

    var Key:KeyObject = new KeyObject(stage);

    stage.addEventListener(Event.E­NTER_FRAME,onenter);

    function onenter(e:Event):void{

    if (Key.isDown(Key.RIGHT)) {

    hero.x+=5;

    }

    }

  • I get two errors:

    1046: Type was not found or was not a compile-time constant: KeyObject.

    (Line 3)

    1180: Call to a possibly undefined method KeyObject.

    (Line 3)

    Please help me

  • when i got the 1046 error it was for hero, i fixed it by not exporting it for action script

  • Hey i get an error that says "1046 type was not found or was not a compile-time constant: KeyObject" could someone help me?

  • nvm that i fixed it. now i have a new problem. my guy moves like hes suppossed to, but he doesn't walk. he goes to the first walking pose but not the second when i press a key.

    could someone help?

  • Make sure you have your class folder defined. To do so, go into your properties menu and go to Edit>Preferences...>ActionScri­pt>ActionScript 3.0 settings

    Then, just add the directory of your class folder

    If it is deeper into your class folder, you must also add in an import statement for it to, for example, if you had it in your com/senocular/utils folder:

    import com.senocular.utils.*;

    hope that helps

  • Hey! men like in a class room I got a question is that important to keep all the images or bitmap there

  • you didn't show us how to make that content layer thing. because of that im stuck

  • just make a new layer. name it content. Thats all

  • well i did that anyway but it still doesnt work because you said save it in the same directory as the key object as and i dont understand what that means

  • i have a problem when i try to write my own character movement code when you hold a keypress it gets stuck on the walking animation as it keeps entering the frame over and over if you hold the key down. can anyone help me??

  • when i try to put the "walking" movie clip in the "hero", it come up with a popup saying "You cannot place a symbol inside itself!"

    How do i fix this?

  • you are obviosly trying to put the item inside itself, just make another movie clip and put both in there, walking and standing, also make sure they are in separate frames

  • 1084: Syntax error: expecting rightparen before semicolon.hero.gotoAndStop('st­ill');

    how t ofixthis€?

  • i folloed but the hero moves at the start on the spot and does not move left and right

  • i followed exactly the steps but when i test movie the hero moves in the still position and it does not response to the arrow keys?