14,574 Forum Posts by "Denvish"
At 2/22/09 05:28 PM, sir5000 wrote: Coo-ee, fellow Flashimators,
I need all of your help with some ActionScript 2.0 programming. I'm trying to make my flash animation loop, but how do I do that? What commands do I use and how do I use them?
Put this on the last frame of the animation
gotoAndPlay(1);
It'd also help if you also posted some other basic helpful ActionScript commands.
Check out the Basic and Useful Links sections of AS: Main and/or AS3: Main (depending on which version you plan to use) to learn more about Actionscript.
At 2/22/09 04:43 PM, Kirk-Cocaine wrote: Fuck, you can do that? I feel like such a fool for manually turning off all the shortcuts now. Why the fuck isn't it set to off as default. FUCK.
lol, I wasn't aware of that either. We all learn something new every day :) I IZ FEWL TOO
At 2/22/09 04:37 PM, jmtb02 wrote: Might be a conflict with the IDE.
Check it published to browser, or in external Flash Player to confirm. The whole preview swf/keyboard shortcuts conflict thing is a major flaw in CS3+ IMO, it should have been possible for Flash to automatically turn off the shortcuts while in preview mode.
At 2/22/09 03:53 PM, LeechmasterB wrote: Don't listen to the guys. ^^
That simple... the flash renderer can render bitmaps far quicker then vector graphics.
Agreed. For large detailed/scrolling backgrounds in particular, pngs/bmps are far less CPU intensive, because there's little rendering involved. Vectors are generally fine for the smaller stuff. If you have no reason to use exclusively one or the other, then use bitmaps for the backgrounds/layouts and vectors for the sprites etc.
This has got to be one of the funniest threads I've seen in a long time
At 2/22/09 04:20 PM, InnerChild548 wrote: How do I make it so when my player touches the switch (this.) it plays the movieclip (door).
onClipEvent(enterFrame){
if(this.hitTest(_root.player)){
_root.door.play();
}
}
Make sure the door MC has the Instance Name door
At 2/22/09 02:34 PM, GodlyKira wrote: removeMovieClip only removes an mc attached dynamically, but there is the visible property
this._visible = false
Alternatively apply swapDepths to the MC and then it can be removed with AS
on(rollOver){
this.swapDepths(789);
this.removeMovieClip();
}
At 2/22/09 01:54 PM, TheGoldenMonk wrote: Oh sorry, I needed AS2. I appreciate the response though.
Converted to AS2, kind of:
player.onEnterFrame=function{
this.x += this.vX;
this.y += this.vY;
if ( this.hitTest(_root.barrier ) ){
this.vX*=-1;
this.vY*=-1;
}
}
vX is horizontal speed, vY is vertical speed. Ideally though you'll need separate if{} sections to handle bounce in each direction, as that will reverse both vX and vY - you'll probably be wanting to reverse vY only if hitting top/bottom, and vX when hitting left/right.
Well I'm not sure how it works with two this.onEnterFrame
Also, I think a mask has to be a fill rather than a line - not sure how relevant that is
Your other choice of course is just to add another createEmptyMovieClip at a higher depth and draw the lines in that
Guessing either your instance names are wrong, or using 'screen' as an instance name causes conflicts with the 'screen' Object or the 'Screen' component mentioned in the AS2 reference help
Best bet is a key listener. These actions on a frame on the main timeline:
kl=new Object();
kl.onKeyDown=function(){
if(Key.getCode()==32){ //SPACEBAR
//DO STUFF
}
}
kl.onKeyUp=function(){
if (Key.getCode()==32){ //SPACEBAR
//DO STUFF
}
}
Key.addListener(kl);
If you need to know the keycodes for left, right etc, you can use this thingy
At 2/20/09 12:42 PM, GodlyKira wrote: or chr(Key.getCode()); its already built into flash, only thing you would need an array or an object for would be saving the keycode, to refer later in th control function
Well I never knew that - thanks for the info. Although it doesn't seem to work for characters except numbers and letters, not picking up # or SHIFT etc
Oh, forgot to mention, you're better off handling mouseDowns separately with onMouseDown and/or a mouse Listener. The keycode 1 for mouse click won't work on MACs apparently, so it's not advised if your game is to be distributed.
Just as an experiment, parsed out the keycodes listed on this page into an array, just use chArr[Key.getCode()]; to show which key was pressed.
Seems to work OK
chArr=["","","","","","","","","Backspace","Tab","","","","Enter","","","Shift","Control","","Pause/Break","Caps Lock","","","","","","","Esc","","","","","Spacebar","Page Up","Page Down","End","Home","Left Arrow","Up Arrow","Right Arrow","Down Arrow","","","","","Insert","Delete","","0","1","2","3","4","5","6","7","8","9","","","","","","","","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","","","","","","Numpad 0","Numpad 1","Numpad 2","Numpad 3","Numpad 4","Numpad 5","Numpad 6","Numpad 7","Numpad 8","Numpad 9","Multiply","Add","","Subtract","Decimal","Divide","F1","F2","F3","F4","F5","F6","F7","F8","F9","","F11","F12","F13","F14","F15","","","","","","","","","","","","","","","","","","Num Lock","ScrLk","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",";","=",",","-",".","/","`","","","","","","","","","","","","","","","","","","","","","","","","","","","[","\\","]","#","`"];
kl=new Object();
kl.onKeyDown=function(){
_root[TextBoxName].text=chArr[Key.getCode()];
}
Key.addListener(kl);
You need to set up a listener
var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta) {
trace("MouseWheelTrig");
}
Mouse.addListener(mouseListener);
Main problem is setting espeed to zero on attack - it doesn't get reset to 3 until the hero is out of 'follow' range.
Rearranged your loops slightly with else if and also for efficiency you only need to calculate the hypotenuse once per enterFrame
onClipEvent (load) {
espeed = 3;
scale = _xscale;
active = true;
}
onClipEvent (enterFrame) {
distance = 300;
tx = this._x;
ty = this._y;
sx = _root.mcHero._x;
sy = _root.mcHero._y;
dd = Math.sqrt((sx-tx)*(sx-tx)+(sy-ty)*(sy-ty))
if (dd<distance) {
if (dd<distance-150) {
this.gotoAndStop(3);
} else if ((tx<sx) && active) {
this.gotoAndStop(2);
_xscale = -scale;
this._x += espeed;
} else if ((tx>sx) && active) {
this.gotoAndStop(2);
_xscale = scale;
this._x -= espeed;
}
} else {
this.gotoAndStop(1);
espeed = 3;
}
}
At 2/18/09 01:59 PM, Petwoip wrote: The stage has a bunch of movie clips scattered around, and they each have different symbol names and instance names. Is there any conceivable way to create a loop that detects each movie clip on the stage and moves them all by 10 pixels to the right?
for(var i in _root){
if(_root[i]._x!=undefined){
_root[i]._x+=10;
}
}
beginGradientFill is the command you need, but I can't be any more help than that I'm afraid because I never really got my head around the whole matrix thing. There are code samples in the AS2 help files.
At 2/18/09 12:42 AM, TheNamesDarkly wrote: Yeah I'm Making A New Flash And I'm Wondering How To Make Like A Timer That Counts Up And Also Counts The Frames Displayed So Far. So Any Suggestions On How To Make This?
Dissect this for one method.
For the frame counter, you could alternatively just have _root._currentframe as the var on a dynamic textbox
At 2/17/09 06:09 PM, DevAwesome wrote: How can you give pixels REALLY good quality?
You can't, really. Flash uses vector art, is inifinitely up-sizeable with no loss of quality. bmps/jpegs/pngs/gifs all use pixels, which will just be expanded as squares when the graphics are magnified. Your best bet when using pixel art is to expand it as much as possible using an external graphics program before importing to Flash, but this will also increase both the fla and swf sizes
At 2/17/09 04:16 PM, Corky52 wrote:At 2/17/09 02:31 PM, Dacheater wrote: What about the Eat My Fucking shit flashes that have got all 3 portal awards?Turd of the week: have lowest scoring flash of the week.
Underdog: biggest gap in between Review average and the score of the submission.
The RCP needs to have the highest review average of the week and at least 30 reviews.
Basically, any semi-organised group inside or outside of NG can achieve these awards, as has been proved over and over again by SS, LL, KK, etc. IF a Flash gets a daily or weekly award, that might actually MEAN something, as in: the author has some Flash skills, so the several thousand worldwide voters actually supported the game/movie, or rather thought it was worthy of a 2+ score.
It's not hard to make something the lowest-scoring Flash of the week. It's not hard, after that, to get a group to review it high once it's off the 'latest 50' list. And the same applies to RCP - once it's off the radar, people ain't gonna notice the sudden review rating rise. This is the flaw in the NG system.
At 2/17/09 12:27 PM, Johnny wrote: AI algorithms, especially pathfinding can be difficult to implement, but you're on the right track.
It just has to be an x/y coordinate... and it only has to be at intervals LESS than the width/height of the objects in the way. If the walls are 20 pixels thick, checking a line of sight ever 19px will work fine. Obviously, it will be on an angle, so you'll have to get the smallest distance overall... or just do an arbitrary check every 5 pixels or so.... then change the zombie's state from canSee = true, to canSee = false if he cannot see the player and include that boolean into a statement.
if(canSee){
//eat his face code
}
Appreciate you supporting my aged status, but the topic starter still wants the zombie to seek the nearest door when !canSee. That's the complex bit - which, as I said, is why even apparently simple AI is NOT simple. I admit, my solution would end up with zombies stuck in room corners, but the only other solution is to use tile-based or rotation-based/shapeflag hitTest pathfinding (ps in this scenario I'd go for the later as more efficient/easier to implement), which is a whole new ball game.
At 2/17/09 12:30 PM, LeechmasterB wrote: 3. So whenever there is a wall the zombie will ignore the player?
PS I did NOT say that
Also, that Flash file has only been on NG for 1 day, chances are your review will be removed within a week
Flash authors will automatically get more leniency on NG, regardless of their author comments. Review mods have no control over the submissions themselves, just the reviews. The only way that authors will get remonstrated is if they submit an 'abusive' submission, and that's generally judged on the flash file, not the comments. Sucks, but that's just the way it works.
At 2/17/09 12:30 PM, LeechmasterB wrote:At 2/17/09 12:00 PM, Denvish wrote: Your asking for some pretty complex AI there. You have the right approach though. Run a (probably shapeFlag) hitTest on the wall, calculate the angle between zombie and player (you're already doing that).
<rant>
You got to be shitting me!
1. That AI is not complex at all!
Yes it is, whatever your theoretical head may think. Any AI is complex coding, particularly to someone who is stumped by this kind of problem.
2. No its exactly the wrong aproach (invisible movieclips and shapeflag hittest? wtf) ever heard about math? It can be done way simpler and less performance intensive.
Approach* I never mentioned invisible MCs, also please explain your reasoning, preferably with code samples. Otherwise I call bullshit.
</rant>
When you can prove yourself by making a living out of coding Flash games, then feel free to diss my advice. Until then, STFU you tit.
Not a problem I've seen, but I'm still on AS2. On the whole, when you attach a MovieClip, you'll be telling it to stop(), or gotoAndStop(frame/random(_totalframes)+1 ); anyway, so this shouldn't really affect.
http://www.newgrounds.com/bbs/topic/8166 29
http://www.newgrounds.com/bbs/topic/8166 30
At 2/17/09 11:58 AM, bl00db47h wrote:At 2/17/09 11:37 AM, popsicle-of-doom wrote: Doesn't it not matter only the swf matters.Yah, but I tried exporting it. I made it an .avi file and it was huge.
avi files are huge by nature
At 2/17/09 11:48 AM, 4urentertainment wrote: Using my recently learned trigonometry, I was able to do this:
Click here (move with arrow keys)
It's simple, yet effective. I'm trying to do zombie AI. And this would work pretty well, that is, if there were no walls.
So my question is, how do I go about making him see the walls and get past them to the player?
I though about having a big, invisible line going from his face, like twice his length, and if that line hitTests a wall, then the zombie will ignore the player, and seek the closest door/turn then once he's there, get back to chasing the player. But that doesn't sound too practical. Any suggestions?
Your asking for some pretty complex AI there. You have the right approach though. Run a (probably shapeFlag) hitTest on the wall, calculate the angle between zombie and player (you're already doing that). If this enables the zombie to move up or down the wall (basically you'll need to convert angle back to xvel and yvel) then adjust _x or _y accordingly. Once the hitTest is no longer true, then just move the zombie as normal

