The Armor Games website will be down for maintenance on Monday 10/7/2024
starting at 10:00 AM Pacific time. We apologize for the inconvenience.

ForumsProgramming Forumso im making a little flash game and cant get my music on it

28 13439
took95
offline
took95
438 posts
Nomad

i am making this game on flash cs5, i have the coding down for the gameplay, and i even have discovered how to get all sorts of things, BUT its silent. i want help with this, i cant find any good places to getmusic for games, as a matter of a fact, i cant find ANY. either way here is a link to the swf. file if you just want to check it out and see my progress:

and here is the flash file if you want to tweak it and change it how you want:


i want to get a couple of songs up with this, i was thinking ofputting some music from my mp3 player or musin library and neither work, if you can help me with this, i would settle with a site for getting music. Also, if this changes anything(and i think it does) my default music playeris VLC media player, but i have windows media player also, the music DOES work, i have tried converting songs to files that are compatible with flash, but with all my research and messing with stuff, i cant find out what to do....please help me, the best way to contact me, thats not thru AG(which i am sad to say i cant always get to) is at my hotmail, tristan.alexander@hotmail.com
if you have advice about how i should do something or change something email me.

(also this isnt a game for AG, not yet:P, but i am turning it in for a "talent show" for my online school(insight) flash animation class because i did the entire years work in 3 days, and wanted to make games. So keep that in mind when you look over this.)

PS. I dont care what you do with this, as i said this is my class assignment, it is DEFINATELY a begginer game, but if you change stuff, or share it, or even say YOU made it, I dont care, just help me with the music please.

PSS. i was putting in teleporters with the "restart" format, the coding that maks it so when you touch a point, you are sent to another, so if there is hanging code anywhere that is why.

PSSS. just for your info, these are the codes i used, i have them all copied down on text documents:

FOR CHARACTER "GRAVITY"

onClipEvent (load) {
var ground:MovieClip = _root.ground;
var grav:Number = 0;
var gravity:Number = 2;
var speed:Number = 15;
var maxJump:Number = -20;
var touchingGround:Boolean = false;
}
onClipEvent (enterFrame) {
_y += grav;
grav += gravity;
while (ground.hitTest(_x, _y, true)) {
_y -= gravity;
grav = 0;
}
if (ground.hitTest(_x, _y+5, true)) {
touchingGround = true;
} else {
touchingGround = false;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
}
if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (Key.isDown(Key.UP) && touchingGround) {
grav = maxJump;
}
if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {
_x -= speed;
}
if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {
_x += speed;
}
if (ground.hitTest(_x, _y-(height), true)) {
grav = 3;
}
}

FOR THE VIRTUAL CAMERA(VCAM)

onClipEvent (enterFrame) {
_y += (_root.char._y-_y)/4;
_x += (_root.char._x-_x)/4;
}


FOR THE RETURN TO A POINT

onClipEvent (enterFrame) {
if (_root.char.hitTest(this)) {
_root.char._x = charX
_root.char._y = charY
}
}

FOR MAKING THE HP TIMELINE PROGRESS(DAMAGE)

onClipEvent(enterFrame) {
if(_root.char.hitTest(this)) {
_root.vcam.hp.nextFrame();
}
}

THE "PLAY AGAIN?" BUTTON

on(release) {
_root.gotoAndStop("game"
}


WHEN HP REACHES FINAL FRAME GAMEOVER IS TRIGGERED

_root.gotoAndStop("gameover"


ALSO I WOULD REALLY LIKE TO HAVE MULTIPLE LEVELS, IF SOMEONE CAN HELPME WITH THAT I WOULD BE VERY GRATEFUL
  • 28 Replies
beech
offline
beech
107 posts
Nomad

ok took, here you go -

first the sound issue - to place a Sound file in the Library use: File>Import>Import to Library - browse to the file, and presto, the sound will show up in the Library panel - then do the right-click, prefs, and add a Linkage ID (or if running CS4 or later double click in the linkage id column and just type it in)

second, the animation issue - what you need here is second condition in your controls that determines if the animation is on the correct frame, use that result to determine if the playhead needs to be moved or not, like so:

if( _currentFrame != x ) gotoAndStop("right"

where "x" is the frame number of the frame labeled 'right' - in AS3 we have a new property called currentLabel, which allows you to use the label name - but in AS2 we do not, so you'll need to use the frame number.

but you will also need another condition to put the character 'back' into the normal static position:

if(!Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.UP) && touchingGround ) {

gotoAndStop('normal';//<-whatever that label name may be

}

there is a thread here at AG with a basic example i made a little while back that shows this type of thing in action.

took95
offline
took95
438 posts
Nomad

ok so the music thing still didnt work,but my flash is odd so idk, but the coding worked, i dont know why but it did so thank you!!!! but now i have more problems,:P, differnt thing though, so to make this simple and not explin everything i have done on this new one(btw these are all my assignments but my teacher is ok with me getting help since we just need to learn it all:P) but so what i need is,basically, a pacman ghost AI in as2. i need it to randomly pick a direction when it hits a wall and continuemoving so here is my coding:

onClipEvent (load) {
goLeft = function ()
{
_x = _x - 4;
};
goRight = function ()
{
_x = _x + 4;
};
goUp = function ()
{
_y = _y - 4;
};
goDown = function ()
{
_y = _y + 4;
};
getDir = function ()
{
dirVar = Math.floor(Math.random() * 4);
if (dirVar == 0)
{
goDir = goUp;
}
if (dirVar == 1)
{
goDir = goDown;
}
if (dirVar == 2)
{
goDir = goRight;
}
if (dirVar == 3)
{
goDir = goLeft;
}
};
getDir();
}
//Move enemy
onClipEvent (enterFrame) {
goDir();
if (_root.maze.walls.hitTest(_x, getBounds(_root).yMin, true))
{
this._y += 4;
getDir();
}
if (_root.maze.walls.hitTest(_x, getBounds(_root).yMax, true))
{
this._y -= 4;
getDir();
}
if (_root.maze.walls.hitTest(getBounds(_root).xMin, _y, true))
{
this._x += 4;
getDir;
}
if (_root.maze.walls.hitTest(getBounds(_root).xMax, _y, true))
{
this._x -= 4;
getDir;
}
}

now when i run this, it can run into walls and it can turn if it hits a wal above/right/or below it(for the most part) and it cant get up when it hits a left. right now i have it in a little box it can bounce around, and it will move randomly at the corners except the bottom left, it always sticks there....

thanks for the help beech!! i finnaly go that to work, i was sooo happy to have that fixed

beech
offline
beech
107 posts
Nomad

you're welcome took

ok so - i'm not certain what the issue could be with your Sound problem, i'll need more information on how you tried to do it.

code: ok, well first off, i'm going to recommend that you remove all of your code from what is called 'object attachment' - that is where you place code directly 'on' the object - this can cause a lot of headaches and is consider not to be a 'best practice' - instead you should place all code either on the timeline, or far better, in Class files. now, AS2 wasn't quite intended for lots of heavy Class use, although it does operate in that manner, where AS3 is more Class *based* so i would recommend beginning the transition to AS3 style coding and leave AS2 behind.

that being said - i have created a basic demo for you to learn from - it is in AS3. read through the code found in the two Class files: Game and Ghost - it will show you some of the basic methods to instantiate instances, and control them with a single process loop - as well as checking the bounds. but there also are some construction techniques in the Ghost instance itself that will demonstrate a bit on how to construct a character so that it can be dynamically propagated and controlled

once you have become familiar with the system, post back with questions, i'm sure you will have some

HERE is the file

gaboloth
offline
gaboloth
1,612 posts
Peasant

Hey beech, that reminded me of a question that I have had for a while, in as2 is it better to code in external as files or on frames?

beech
offline
beech
107 posts
Nomad

there are some difficulties with scoping issues in AS2 when working with classes, but it's still very doable and really better - it's just that you sometimes have to carry a few references around with you, depending on the task.

the timeline is acceptable, but usually for small, quick snippets - if you do anything large-ish you'll want to use Classes and better structured OOP or you'll get lost fast.

but object attachment is really not good structure, limited, and very hard to debug - and has been deprecated in 3 for these and other reasons.

jakeup
offline
jakeup
138 posts
Nomad

I have a problem getting audio onto a flash file. I tried importing it but it said "one or more files were not imported because there were problems reading them" .

jakeup
offline
jakeup
138 posts
Nomad

Ok i imported it now I just need to know how to get the file to play from the beggining of the game to the end of it. bassicly like make it go on for the whole game.

beech
offline
beech
107 posts
Nomad

previously in this thread there have been examples of different methods of how to loop a sound

took95
offline
took95
438 posts
Nomad

ok, so i am really confused:P, classes are not my thing, so i am really unsure of what youre coding is and how i am supposed to use it, i opened youre flash and there is absolutely no code on it, its all in the other things. so i can see what the code is, but i dont know how you have the ghosts, whrere are they?, and how does flash make them.....
so beech, thank you for the time trying to help me but i dont understand i will stick to my level of flash i suppose, because this is too much for me.....

Darkroot
offline
Darkroot
2,763 posts
Peasant

They are in the library and he created them with the class. The class has all the code. Just open one of the classes in flash if you want to see the code. The code isn't very complex and the class doesn't make it any harder to understand.

took95
offline
took95
438 posts
Nomad

yeah, my flash is odd for some reason, and i made a game and i need to figure this other question out soon, im sharing this game tommorow, so does anyone know how(im learning as3 now, but i need this in as2) to make it so that it will create an object through out the game. so to be specific, in my game i have a survival mode and i need it to keep creating my zombies as you live, and if i understand it enough i also want to make it so that when you reach a certain point it creates the zombies your about to fight in adventure mode, but i can getthis by making allthe zombies in the places i want them, then by putting an empty frame and make it so that once the char hits another point "create" the zombie by putting it on the next frame, but this is hard and alot, so PLEASE help....tahnk you, i am seriously learning as3, but as i said, i currently know as2, so i appreciate the help im trying to convince me to use as3, but i need this in as2. THANK YOU!!!

PixelSmash
offline
PixelSmash
566 posts
Nomad

Well my AS2 is rusty beyond comprehension, but if you have a specific zombie movieclip, you should be able to keep spawning these by using a timer set to a specific or random time... I hope this helps, since I can't give you any AS2 code for it, as3 would be perfectly fine. Good luck!

took95
offline
took95
438 posts
Nomad

well a timer may help, and so would a hitTest at a certain point, my prob is getting it to draw it from the library to the stage, but im still trying to learn as3 in my free time, which as soon as i started became less and less:P, and im confused, but the class im doing all this for is AS2 so i need this in that then ill learn it in as3..

sorry for taking so long to get back to this, i havent been on the forums in awhile, just barely started gettingback to AG...again...

Showing 16-28 of 28