Game Coding
I am trying to make an action game for my site, and so far, i cant even get my character to shoot. I have no idea whats wrong with my code, so can someone please help? I have the game attached.
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-25-2005, 01:15 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Coding A Game.. Pls. Help..
guys.. i've been creating two small (very small) games..
1. Drag and Drop (photo fit):
The user will be given a face to look at.. after some time he needs to assamble the face he saw.. this will be by dragging and droping..once it is the correct face, he will go to a new page which says 'well done'.. that's it.. now i've done the design part and a bit scared about the coding section... can anyone pleaseee help me by sending me similar type tutorials / sample fla's / examples / links.. thankzz..
2. Quiz:
This is a straight forward objective type questions.. the user will not be allowed to the next question until he gets the first one right.. please send me similar type tutorials / sample fla's / examples / links..
Jeswin
Help With Game Coding
In a game I am making, when the player bumps into a wall, I want the timeline to jump to the Game Over scene.
The code is in a movie clip that is placed on the main stage, and is:
Code:
onClipEvent(enterFrame) {
if (this.hitTest(_root.b4)) {
_root.gotoAndPlay("game over", 1);
}
}
If I take out the "_root.gotoAndPlay("game over", 1);" and replace it with a trace command (just to see if it works) it works fine.
What code should I use so it jumps to the Game Over scene?
[F8] I Need Some Game Coding Help
Hey guys, I've been using flash for a few years now, but I've never had any formal education with it. Most of my animation/drawing techniques are good, but I'm not too knowledgeable with actionscript. My school has asked me to make a game in flash, and i need some help with the coding. One thing i need is coding to make a text box display how many milliseconds have passed after a certain frame (a score), and i also need a button code to rewind my timeline X amount of frames on release of a button. If anyone can give me any assistance it would be much appreciated!
Game Coding
I have a requirement to write a pacman type game, but this seems quite
complicated.
Could you kindly point me towards any tutorials on moving something around a
grid and recognising walls. And also any tutorials for enemies following you
around.
Thanks for any pointers
Coding A Game
I don't know if this is supposed to be here, or under "tutorials". But anyhoo, i'll just post it here...
I want to make a game, similar to pacman. Now, I know how to move the player using keypresses, that's easy, but how do i stop it when it hits a wall?
I was thinking of making the "levels" as one big jpg or something, and then make another invisible layer on top of that gfx to make the walls, so I have one overal wall to hit into...
Also, I want "pickups" to appear randomly in the maze as u pick up other stuff...
Does anyone have some tips/pointers to start out this project?
Any help would be greatly appreciated...
Newbie Game Coding
yo guys, im new here, im lookin at game codin for flash, wanting to make an interactive space invaders type game to start then when im good at all the coding i can get into more advanced rpg type stuff. first things first, i wanna know how to get a guy to move left, right, and shoot using arrow keys and space bar, if neone has a good tutorial can ya post the URL or if its easier just to tell me post it here, thanx
Problem While Coding A Game
I'm trying to make a pong game, and I already got the concept but now I'm trying to add items, and I want to know how to make them appear randomly throughout the game. I made this but it doesn't seem to work:
http://www.filedropper.com/pong
Can someone help please? Thanks in advance.
I Need Help With Coding For A Game I'm Making
I'm creating a game with two ships that fly around trying to shoot one another. It is two player with one ship using One ship uses the arrow keys to fly, that one works. The other, which uses the "A", "W", "S", and "D" does not work.
Here is the code for the ship that uses the arrow keys:
ship2.onEnterFrame = function() {
Key.isDown(Key.UP) ? (this.speed = +7.5) : Key.isDown(Key.DOWN) ? (this.speed = -3.75) : null;
Key.isDown(Key.LEFT) ? this._rotation -= 12.5 : Key.isDown(Key.RIGHT) ? this._rotation += 12.5 : null;
this._x<=0 ? this._x=1100 : this._x>=1100 ? this._x=0 : null;
this._y<=0 ? this._y=800 : this._y>=800 ? this._y=0 : null;
this.speed *= .94, this.roto=this._rotation*(Math.PI/180);
this._x += Math.sin(this.roto)*this.speed;
this._y -= Math.cos(this.roto)*this.speed;
updateAfterEvent();
};
This is the code for the A,S,W,D ship:
ship1.onEnterFrame = function() {
Key.isDown(Key.119) ? (this.speed = +12.5) : Key.isDown(Key.115) ? (this.speed = -6.25) : null;
Key.isDown(Key.97) ? this._rotation -= 7.5 : Key.isDown(Key.100) ? this._rotation += 7.5 : null;
this._x<=0 ? this._x=1100 : this._x>=1100 ? this._x=0 : null;
this._y<=0 ? this._y=800 : this._y>=800 ? this._y=0 : null;
this.speed *= .94, this.roto=this._rotation*(Math.PI/180);
this._x += Math.sin(this.roto)*this.speed;
this._y -= Math.cos(this.roto)*this.speed;
updateAfterEvent();
};
I believe the numbers are the correct ascii numbers, but I am unsure. Any help you could offer will be greatly appreciated.
Thank you!
Coding For A Flash Game
Hi i'm trying to make a game in flash for a mobile phone.
it's pretty simplistic game but not too sure how to code, any help would be great. the file attached is a basic outline of the
game.
Game Coding.. Pls. Heeeelpp..
guys.. i've been creating two small (very small) games..
1. Drag and Drop (photo fit):
The user will be given a face to look at.. after some time he needs to assamble the face he saw.. this will be by dragging and droping..once it is the correct face, he will go to a new page which says 'well done'.. that's it.. now i've done the design part and a bit scared about the coding section... can anyone pleaseee help me by sending me similar type tutorials / sample fla's / examples / links.. thankzz..
2. Quiz:
This is a straight forward objective type questions.. the user will not be allowed to the next question until he gets the first one right.. please send me similar type tutorials / sample fla's / examples / links..
Jeswin
Game Coding In Flash 8 Professional - HELP
I'm relatively new to flash but am a quick learner. Have been using the program to a reduced level of its full potential for about 3 months.
I have decided that, despite my limited knowledge, I would like to code a game in flash. A kind of a challenge. Deal Or No Deal UK being my game of choice.
At the risk you do not know of the game, I will explain breifly below. If you know it, then skip past all the red text.
There are 22 boxes with 22 different amounts of money in each of them, ranging from 1p to £250,000. A player has to choose a box to begin the game with. This box is only recognisable by its number, between 1 and 22, inclusive.
The player then participates in several rounds of selection. The player would choose a box to be opened and the amount of money inside this box would be eliminated from the board upon which the remaining amounts are shown.
The first round would consist of choosing 5 boxes. The values within the 5 chosen boxes are eliminated from the aforementioned game screen, and after the boxes have been chosen and opened, an offer by a "banker" would be given via telephone.
The offer is based on the players' previous gameplay as well as the reamining amounts but I feel for this flash game, a mean or average value could be easier to use. (Mean calculated by adding up all remaining values and dividing the total by the number of remaining boxes)
The next 5 rounds consist of just 3 boxes being chosen and eliminated. The bankers' offer comes after each of these "choice sections" of the game. The bankers' offer will be different each time based on which boxes are left. If the player has eliminated a lot of the higher valued boxes, the offer will be lower. The banker is trying to offer an amount to buy the box that the player selected at the start, off them. If the player has eliminated a high value, for example £250,000, the banker knows this value cannot be in their box.
After each round the player will have to decide whether they will "deal" or "no deal" and either accept the offer the banker is giving, or turn the offer down hoping they can eliminate the lower values remaining, thereby increasing the offer the banker gives them next round.
If they deal before the game is over, they continue on the game to find out what they COULD have won had they said no deal to the offer they accepted.
Having said "no deal" to the last offer, and once the player is down to their own box, one remaining box to choose from, and two possible values left on the game board for the contents of the boxes, they must open their own box and accept the value within it.
Sometimes the banker will offer them a "swap" in which case they can choose which of the two boxes they want to have as their own if they "feel" that the larger of the two remaining values resides in the other box. Perhaps a 1 in 4 chance of a swap being offered would be suitable for the flash game?
I have desinged the first scene which introduces Noel Edmonds (presenter of the show on Channel 4) and the game setup. I am putting each "choice section" on a different layer. For each box selection required in a specific round, there are that many frames. For example, round one requires 5 box choices so there are 5 frames on the layer and I have put a stop(); command on each of the frames planning a gotoAndStop(); command to move onto the next frame when the box has been chosen.
I will design a box for each of the numbers, 1 to 22 and save them as seperate files. The problem I need is to be aware whether this is the right way to go about things or if there is an easier way to design and code the game.
I also need help with setting up an array so that each of the values can be put as an arrary item. Then I will need some sort of random selection and elimination code so that when a box graphic is clicked, a random value from the array is shown then eliminated.
I also need to know a mean calculation code.
So I need:
To know if I'm going about this in the right way
If not, perhaps some tips would be in order?
To know how to put the game together - The design bit is fine for me, just the coding goes over my head - I never know where to start and where to put the finished code
How to set up an array and get a randomisation and elimination thing set up - If this is the right way to go about it
How to code a mean calculation.
Thanks for your time everyone!
Finally Released My Game, But I Need Your Help With Coding Stuff
Ok so i released my game today, you can play it at Geopersia.com
Well if you see the game you can tell its a tile game, but there is one big problem and its the depth one, i am using duplicateMovieClip() i am incrementing the new movie clip by 1 and its depth by _root.getNextHighestDepth(), so i have been trying every form of hitTest() to try to figure out a way so that the tiles cant go under/over each other, i want it to look 2D...
there are almost an infinite possibilities of tiles, all with different names and everything, what should i do?
I dont think there is an answer to this but if you can help i would greatly appreciate it.
p.s. also snapping objects would be great, but i think thats really impossible with how this game is set up.
p.s.s i also have used sharedObjects but i have no idea on how to use it with duplicateMovieClip, but i do have an idea can i save the whole picture using sharedObjects and the person can load that picture
like it saves everything in a shared object i think there is a exportBitmap something like that. Saving is one of the biggest parts of my game
AS3 Forum Game (group Coding Experiment)
Quote:
Tom Fulp: Here's a cool idea: An AS3 Code Collab! If this collab is a success, the end result will be a Flash submission made entirely from AS3 code, put together by a whole bunch of programmers who add a few lines at a time. Check it out and MAKE IT HAPPEN!
Its kind of like a little AS3 exercise and game. If you'd like to participate head over to this newgrounds forum post ^_^
http://www.newgrounds.com/bbs/topic/966360
Hard Coding Vaule In A Game - Faster?
Hi,
can someone tell me if hard coding the values is faster, as opposed to ref a var every time you want to check, for example, if a ball hits a boundary?
I have tried it both ways and the movie goes a lot faster with the hard coded value in. Is this normally the case with hard coded values? Want to know because every thing i read tells me hard coding is bad, but if your game runs much faster with hard coded values. Then should,nt hard coding be more recommednded?
Confused..
Coding A Simple "Guessing Game", Any Help Is Highly Appreciated
Hello, I made this very straight-forward guessing game (if you guess 3 the output window pops up and says "nice guess") My challenge is this:
Add to it so that the user is told if the guess is too high or too low. Make the range of the possible guesses a random number between 1 and 1000. You can use this code to generate a random # between 1 and 1000. Put it in the first frame of the timeline:
SecretNumber=Math.round(Math.random()*999+1);
The .fla file is attached, Thanks for any help in advance I'll be here the entire time!
Kelly M.
Trouble With "MEMORY GAME" Coding
I am trying to do a memorygame, the 1 where u click on two and if they match they stay open else they will go blind again, till u solve it.
Now, I am having trouble finding a way to assign the 8 diffrent pictures, to two random bricks out of 16.
i tried all kind of stuffs, closest was the for loop that slice the array holding the bricknumbers, and pushing the imagearray.
anywayz, more complicated to tell you, than it really is, hopefully.
Give me an example idea, and do it in 5.0 AS because i dont use MX so far.
Needs EXPERT Help: 1. Save Game For Replay, 2. Reset Game
I'm rather new to Action Script, but doing not bad. I have searched the Board, found a link to a tutorial on ActionScript[Org], titled: "save a local copy of file". But that was yet not clear enough for me.
2 Questions at the moment (files attached):
1. Save Game for Replay: How can I save the set to a file in the Same Folder so it could reload for further play from that point on?
2. Reset Game: How can I Reset the Game for a NEW Attemp? I need to remove all Actors at once, to start a new game, without closing this SWF and reopenning it.
If you'd be so kind as to explain very clearly, and add Action Script, taking into consideration that I still get confused by trying to deal with Arrays and so. I promise to study your lesson carefully - this GameTest attached is the fruit of this week studies.
THANKS A LOT
Nit Kalish
Flash Game Help The Game Runs Too Slow In A Browser
lo there!
I'am so frustrated!
I have made a plattformgame in flash, and after I had published it I tested it (local) when it was embedded in a browser, and it hacks and laggs! But when I play it in the flash player it works just fine.
What should I do?
I removed all the heavy graphics, lowerd the fps to 30fps and removed all the code so now its just the bassis left (gravity, collision, key checking etc. and yes u should bounce on the walls giving a wall jump effect).
Anyone please! I am in big need of help!
Is it my code? Did I publish it wrong?
here are the links:
http://smh03.lbs.se/smh03niklas/prof...ofilbollen.swf
http://smh03.lbs.se/smh03niklas/prof...ofilbollen.fla
http://smh03.lbs.se/smh03niklas/prof...filbollen.html
//Qui
How To Disply Time In Game And How To Stop After The Game..
Hi all,
i need help on drag and drop game...
i have done the drag and drop function, for this game timer has to be shown, after user finishes the drag & match, it should give finish alert and time taken for this game (please tell me also how to stop time after he finish the game) is to be sent to some external file or some database...
can it be done?
i have attached the .fla file also..
[F8] Game Studio Needs Flash Game Programmer
Hi -
I've been working on cartoon Flash interfaces for awhile. Now my clients want games, so I'm looking for one or two Flash game actionscripters who can help out and maybe start a studio. Since it's a startup, I'm looking for someone who's good, but not yet making millions - hoping we can do that ourselves eventually. Someone dependable, easy-going and easy to get along with. Would be great to find someone relatively local, but not absolutely necessary.
We'll be creating custom Flash games for an existing client.
Hoping to check out people's games first.
J.
[F8] How Can I Make A Game With Levels And A Game That Restarts?
I know this sounds stupid, but I just can't figure it out. I need to make a platform game. I'm fine with making a points system and a scrolling background and it functions but I don't know how to get the player to touch an object, or reach a goal and then transport to another level...I don't want to make the user have to click something to go to a new level.
Also, when the character hits an enemy, I can make it die, but I don't know how to make a button or something appear saying 'Game Over - Try again', so they can pretty much restart the level.
Hopefully someone can help me.
Regards,
Andrea
Help With A Game.. Game Is Running Slow In Browser..
I am working on this game for work and for now all i have is placeholder art for the most part and nothing very heavy on the graphics end yet my game is running very slow.. i bumped the FPS to 60 since at 30 i was getting image tearing or a double vision effect.. the upped FPS fixed that but the game is still running very slow. To give you an idea of what's going on i have different intervals running so different things can happen at different times.. there are 2 constant onEnterframes for the 2 enemies flying around the screen.. there is 1 for the main loop, 1 for the character, 1 for whenever tickets generate which removes itself and deletes the enterframe when they disappear, 1 for the wrecks that occur on level 2 which also remove themselves and delete enterframes for themselves, and 1 for a holder that handles all the money flying in which removes themselves as they collide with the player or leave the screen. All enterframes that run during gameplay delete themselves at the end of each level and re-initialize at the beginning of the next.
I can't figure it out.. please take a look at the fla and html files attached. Could it be just the sheer size of the game screen.. should i make it about half the size?? I appreciate any help and thank you.
Also the game's scripted animations seem to be running a little choppy if you watch their movement closely like there is a little glitchy jump every second or so.. is this fixable?
AS Help Needed In Game(i Will Give Credit In Game If You Help)
ok so basicly this is my game so far
23.swf
my probelm is that i want to make my charcter a flame and the tips of his head will move depending on the direction you are going.
So here is basicly this what its like
Moving left-Flames bend to right
Moving left and down-Flames bend at an angle between the left and down
Moving Down-Shorter Flames
Moving Up-Stretched Flames
etc...
ill put borders on after i get the flames down
Coding In The MC
well it seems that I can not figure out how to open the Movie Clips in order to implement the code.
the original MC is called birthday and it has several layers in top of the static layer, where all the MC objects are distribute in layers in other to fade them in and out. however, I can not open the MC to implement the code and call through instances the objects to appear and desapear
__________________
mariusvam@hotmail.com
Coding...
I'm new to Flash MX- i dabbled in Flash 3 but as I now see things have progressed way to much and I'm learing the program all over... I'm trying to find out how to enter code for a frame action. Its to set up a preloading movie clip. Can anyone help? Thanks!
Coding ?
I need a simple code that would allow a image of a card deck to pull up a movie named roleofteacheryesterday
thanks
Coding
This may sound really stupid but how do you achallly put in code. Because i want to make an inventory systom , ive got the code but i dont know where to put it?
Coding Help
I got a sample of some code to move and object up and down , using 'K' and 'M'. All the code makes sense except the variable moveY.
I Have no Idea what it's doing , where it was declared and initialised and how it actually works.
Could someone please explain the Logic of $moveY.
onClipEvent (enterFrame) {
if (Key.isDown(75) && _y>65) {
if (movey>=0) {
moveY =-1;
}else if (moveY>-4) {
moveY*=1.2;
}
keypressed = true;
_y += moveY;
}
if (Key.isDown(77) && _y<250) {
if (movey<=0) {
moveY =1;
}else if (moveY<4) {
moveY*=1.2;
}
keypressed = true;
_y += moveY;
}
if (!keypressed) moveY = 0;
}
Coding Help
how do I make it where You have a picture of a guy and you press a direction button like up, and that picture moves???
Like in a game.
Need Some Help With My Coding...
I have some scrolling buttons that when i click on them, i want them to display a couple of pictures and also some information that describes the pictures. The information will be brought into the textfield from an external file. I have this code inserted on my button. Any help will be apperciated.
[Here's my Code]
---------------------------------------------------------------------
on (release) {
images1.play()
//Load the textfile containing all text for this website
siteData = new LoadVars();
siteData.load("text1.txt");
siteData.onLoad = function(success) {
if (success) {
textbox.text = siteData.myFirstvar;
//trace(siteData.myFirstvar);
//trace(siteData.mySecondvar);
} else {
trace("file NOT found");
}
};
}
---------------------------------------------------------------------
Thanks,
Tony
Help With Coding
Hi,
on my website i want to make a counter that counts down till saturday 11 pm, from saturday 11 pm till sunday 8 am i want to display "party in progress" and at 8 am the counter has to reset and count back down till saturday 11 pm.
Can somebody help me with the coding please ?
thx very much
How Would I Go About Coding This?
the following code doesn't work because each clip duplicates itself, along with the code, ad infinitum, causing a flash error message:
onClipEvent (load) {
this.duplicateMovieClip("script3", 1);
script3._x = this._x + this._width - 1;
}
the above was a failed test!
what i really need to do is make a script that will position a series of mcs next to each other (as in: mc._x = this._x + this._width - 1 so that each of them can then be populated using loadmovie.
also, two of the 11 mcs i am loading are different widths to all the others. how would i go about coding this?
no doubt this is easy if you actually understand actionscript!
any help would be much appreciated!
Swf To Swf Coding
I have a Btn that works great. It's inside a MC inside an swf. I've made a menu that has 10 empty movie clips that pulls the Btn in and everything works great. I just can't seem to coding the Btns. It's a Btn inside a MC inside a SWF being pulled into a MC inside my main time line. I'm trying to make this menu so I can change out the Btns and everything works. Here's my code:
_level0.mc1.mc.btn.onRelease = function() {
getURL("Page","_Blank");
}
I've also tried:
tellTarget (_level0.mc1.mc.btn) {
onRelease = function() {
getURL("Page","_Blank");
}
Anybody have any ideas??? Please???
Just Bad Coding? Please Help
Code:
_root.fromEsp =_root.config.firstChild.childNodes[i].firstChild.toString();//grabs xml data contains a path to a file
trace("location+asset= "+_root.fromEsp)//debug
var assetName = _root.fromEsp.split("\");//split array into back slashes
_root.fileName = assetName.pop();//get file name by "popping" array
pathFile="C:\test\"+_root.fileName //rebuild new path by concat...
gotoAndPlay("calc")//proceed
Hello code kings and queens Im stuck on this one and really need your help.
Im grabbing the path from xml which points to a file.
after the above code I hope to end up with
• the full original filepath "_root.fromEsp"
• the name of file "assetName"
• a rebuilt path which includes the name of file."pathFile"
My problem:
The above works well. BUT if _root.fromEsp is a
path to a movie file (wmf,avi,mpg etc) , trace (on line 2) returns the filename of my movie without the full path???
Really bugging me! if "_root.fromEsp" is a path to a jpeg or swf there is no problem.
hope this makes sense.
Thanks for your time
Cheers
Help With Some Coding Please
Hello, i am a "graphical guy" and new in flash.
Now i wanted to trie some effect in flash that needs a bit coding but i'm a newbie so i wanted to ask if some-one of you could be so kind to help.
this is what i'm trying to achieve:
http://www15.brinkster.com/morreke/howto.jpg [copy and paste url please]
anybody ?
thx
Help With Some Coding...
Ok here it goes...Im ive got a button and when that button is clicked it is to load text into a dynamic text box...every thing is set up correctly but the coding i think is wrong take a look and tell me what you think...
Quote:
on (release) {
= new loadVars();
loadText.load("TEXT1.txt");
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.myNews;
}
};
}
Help With Coding. Thanks
Can anyone teach me or share the coding like the one in the website below? i mean the pictures which can see 360% degree
http://www.sydneyoperahouse.com/sect...ur/vrtour2.asp
Thanks... i need that in my project..
Help With Coding
hei,
just got help from you guys - but i don´t manage to get it right.... (---see attached file)
(the grey rectangle should start fading in when i reach the red square (hit area), not already when you cross the edges of the grey square)
can anyone tell me what i am doing wrong?
taking what you already have, do the following:
1. Inside your movie clip, turn the red box into a movie clip instance and then name it "redSquare" in your properties box.
2. Remove your current functions (all but the stop()) from your first frame of your fading movie clip timeline.
3. Give your fading movie clip placed on _root the name greyBox
4. Assign the following actions to the "redSquare" mc inside the "greyBox" mc:
code:
onClipEvent(enterFrame){
this.onEnterFrame = function(){
if(rewind == true){
_root.greyBox.prevFrame();
}
}
this.onRollOver = function(){
rewind = false;
_root.greyBox.play();
}
this.onRollOut = function(){
rewind = true;
}
this.onRelease = function(){
_root.gotoAndPlay(34);
}
}
This should work for you. It did for me.
Help Coding
PHP Code:
//--------------------------------------------------------------------------
// location of the playlist if no html parameter is found
// change "playlist.xml" if you want another filename ..
//--------------------------------------------------------------------------
_root.playlist == undefined ? playlist = "mp3player.xml" : playlist=_root.playlist;
//--------------------------------------------------------------------------
// below here it's all code and code ..
//--------------------------------------------------------------------------
// stage variables
Stage.showMenu = false;
Stage.scaleMode = "noScale";
stop();
// player variables
volume = 90;
current_song = 1;
top.equalizer._visible=0;
// playlist loading
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = loadData;
data_xml.load(playlist);
// parsing all xml data into flash
function loadData(success) {
if (success) {
// showdisplay and playlist toggles
showDisplay = this.firstChild.attributes.showDisplay;
if (showDisplay == "yes") {
top.easeY(toppos);
topup = false;
display_btn._rotation+=180; }
showPlaylist = this.firstChild.attributes.showPlaylist;
if (showPlaylist == "yes") {
bot.easeY(botpos);
botup = false;
list_btn._rotation+=180; }
// getting all titles and filenames
aPath = new Array();
songTitel = new Array();
audioTracks = new Array();
audioTracks.shuffle();
audioTracks = this.firstChild.childNodes;
song_total = audioTracks.length;
for (var i = 0; i<song_total; i++) {
aPath.push(audioTracks[i].attributes.path);
songTitel.push(audioTracks[i].attributes.title);
// buiding playlist buttons
bot.playlist.btn.duplicateMovieClip("btn"+i, i);
bot.playlist["btn"+i]._y = bot.playlist.btn._y+i*int(bot.playlist.btn._height) +i;
bot.playlist["btn"+i].txt = checkDigits(i+1)+". "+songTitel[i];
bot.playlist["btn"+i].hit.onPress = function() {
listClick(this._parent.getDepth()+1); };
}
//checking autostart mode
autoStart = this.firstChild.attributes.autoStart;
if (autoStart == "yes") {
playSong();
play_btn._visible = 0;
} else if (autoStart == "no") {
play_btn._visible = 1;
pause_btn._visible = 0;
} else if (autoStart == "random") {
current_song = random(song_total)+1;
playSong();
play_btn._visible = 0;
} else {
current_song = int(this.firstChild.attributes.autoStart);
playSong();
play_btn._visible = 0; } }
// done ! all loaded succesfully. purging trash
delete audioTracks;
delete data_xml;}
// list button
function listClick(prm) {
delete pausepos;
current_song = prm;
MySound.stop();
playSong(); }
// list scroller
bot.list_bg.onEnterFrame = function() {
if (hitTest( _root._xmouse, _root._ymouse, true) && this._parent.playlist._height > this._height ) {
ymin = this._y+this._height - this._parent.playlist._height;
ymax = this._y+3;
conv = (this._ymouse -15)*1.3/this._height;
conv > 1 ? conv = 1 : null;
conv < 0 ? conv = 0 : null;
this._parent.playlist.easeY (ymax - conv*(ymax-ymin)); } };
bot.playlist.setMask(bot.list_bg);
// play function
function playSong() {
AudioPath = aPath[current_song-1];
// checking for pause > start from there
if (pausePos>0) {
top.equalizer._visible = 1;
MySound.start(pausePos, 0);
pausePos = 0;
// startup new sound
} else {
MySound = new Sound();
MySound.setVolume(volume);
MySound.loadSound(AudioPath, true);
MySound.onSoundComplete = function() {
top.equalizer._visible = 0;
if (autoStart == "random") {
current_song = random(song_total)+1;
} else {
current_song == song_total ? current_song = 1 : current_song++;
}
playSong(); };
// check loading bar
top.track_load.onEnterFrame = function() {
total = this._parent._parent.MySound.getBytesTotal();
geladen = this._parent._parent.MySound.getBytesLoaded();
if (geladen != total) {
this._parent.load_display = Math.round((geladen*100/total))+"% Loaded";
this._xscale = Math.round((geladen*100/total));
} else {
this._xscale = 100;
top.equalizer._visible = 1;
delete this.onEnterFrame;
delete this._parent.load_display; } }; }
// switch paly/pause buttons
play_btn._visible = 0;
pause_btn._visible = 1; }
// play button
play_btn.onRelease = function() {
playSong(); };
// pause button
pause_btn.onRelease = function() {
this._visible = 0;
play_btn._visible = 1;
pausePos = MySound.position/1000;
MySound.stop();
top.equalizer._visible=0; };
// next button
next_btn.onRelease = function() {
delete pausepos;
current_song == song_total ? current_song = 1: current_song++;
MySound.stop();
playSong(); };
// previous button
prev_btn.onRelease = function() {
delete pausepos;
current_song == 1 ? current_song = song_total: current_song--;
MySound.stop();
playSong(); };
// display toggle button
top.setMask(top_mask);
toppos = top._y;
top._y = int(toppos + top_mask._height - 29);
topup = true;
display_btn.onPress = function() {
if(topup == true) {
top.easeY(toppos);
topup = false; }
else {
top.easeY(int(toppos + top_mask._height -27));
topup = true; }
this._rotation += 180; };
// playlist toggle button
bot.setMask(bot_mask);
botpos = bot._y;
bot._y = botpos - bot.list_bg._height -6;
botup = true;
list_btn.onPress = function() {
if(botup == true) {
bot.easeY(botpos);
botup = false; }
else {
bot.easeY(botpos - bot.list_bg._height -6);
botup = true; }
this._rotation += 180; };
// drag button functionality
drag_btn.onPress = function() {
startDrag(this._parent); };
drag_btn.onRelease = drag_btn.onReleaseOutside=function () {
stopDrag(); };
// copyright button
copy.onPress = function() {
getURL("http://www.jeroenwijering.com/?item=Flash+Mp3+Player","_blank"); }
// updating time display
this.onEnterFrame = function() {
dur = int(MySound.duration/1000);
pos = int(MySound.position/1000);
playTime = {};
playTime.minutes = int((pos)/60);
playTime.seconds = int((pos)%60);
playTime.total = checkDigits(playTime.minutes)+":"+checkDigits(playTime.seconds);
trackTime = {};
trackTime.minutes = int(dur/60);
trackTime.seconds = int(dur%60);
trackTime.total = checkDigits(trackTime.minutes)+":"+checkDigits(trackTime.seconds);
if (top.load_display == undefined) {
top.display = playTime.total+" / "+trackTime.total;
} else {
top.display = top.load_display; }
if (top.trackDrag != true) {
prozent = pos*100/dur;
top.track_play._xscale = prozent; } };
// prefixing a 0 to the time
function checkDigits(toCheck) {
return (toCheck<10) ? toCheck="0"+toCheck : toCheck; }
// track progress slider functions
top.track_back.onPress = function() {
this._parent.trackDrag = true;
this._parent.track_play.onEnterFrame = function() {
perc = (this._parent._xmouse-this._parent.track_back._x)/this._parent.track_back._width;
max = this._parent.track_load._width/this._parent.track_back._width;
perc > max ? perc = max: null;
perc < 0.01 ? perc = 0.01: null;
this._width = this._parent.track_back._width*perc;
this._parent._parent.pausePos = (perc*this._parent._parent.MySound.duration/1000); }; };
top.track_back.onRelease = top.track_back.onReleaseOutside = function () {
delete this._parent.track_play.onEnterFrame;
this._parent.trackDrag = false;
MySound.stop();
playSong(); };
// volume slider functions
vol_back.onPress = function() {
vol_front.onEnterFrame = function() {
perc = (_xmouse-vol_back._x)/vol_back._width;
perc > 0.95 ? perc = 1: null;
perc < 0.05 ? perc = 0: null;
this._width = vol_back._width*perc;
volume = Math.round(perc*100);
MySound.setVolume(volume);
top.equalizer._yscale = volume; }; };
vol_back.onRelease = vol_back.onReleaseOutside=function () {
delete vol_front.onEnterFrame; };
vol_front.setMask(vol_mask);
// drawing equalizer in actionscript
top.equalizer.setMask(top.eq_mask);
top.equalizer.onEnterFrame = function() {
i++;
this.createEmptyMovieClip("graph"+i, i);
with(this["graph"+i]) {
_x = 0;
_y = 0;
beginFill(0x666666, 50);
moveTo(0,0);
for (j=0; j< 36; j++) {
z = random(12)+8;
lineTo(j*6,-1);
lineTo(j*6,-z);
lineTo(j*6+4,-z);
lineTo(j*6+4,-1);
lineTo(j*6,-1); }
lineTo(j*6,0);
lineTo(0,0);
endFill(); }
i >= 3 ? i=0: null; };
// scrolling the display song title
function scrollTitle() {
top.title.txt.autoSize = true;
if (songTitel[current_song-1].length > 20) {
top.title.txt.text = songTitel[current_song-1]+" "+songTitel[current_song-1];
top.title._x+top.title._width/2 +4< top.title_mask._x ? top.title._x = top.title_mask._x : top.title._x--; }
else {
top.title.txt.text = songTitel[current_song-1];
top.title._x = top.title_mask._x-3; } }
top.title.setMask(top.title_mask);
setInterval(scrollTitle, 40);
// easing display and playlist movement
MovieClip.prototype.easeY = function(t) {
this.onEnterFrame = function() {
this._y = int(t-(t-this._y)/1.5);
if (this._y>t-1 && this._y<t+1) {
delete this.onEnterFrame; } }; };
That's a code from my .fla file. How would i make it so that instead of the variables showing in the .xml file, they are defined in the [html]<object></object>[/html] code? i understand that this will make the variables visible in view source and i am fine with that.....
CE Coding
Hello!
I found this fla in the movies section, I was modifying it when I found out, that when I was changing the actionscript code, the Central European coding wasn't detected, the letters š, č, ž were not displayed in the swf. I used the Arial CE font and it didn't help either.
Please help
theredtitan from Slovenia
Help With Coding
here is what i have:
a movie clip calld "plastic"
a movie clip calld "arrow"
a movie clip calld "target"
a move clip calld "foot"
a button call "button"
at first frame i have this codes
Mouse.hide();
arrow._visible = false;
aim = 0;
the button is placed inside the foot movieclip
and the foot movieclip folows the mouse
the target movieclip is placed inside the arrow moviecilp
the arrow movieclip has the following code apllyd to it
onClipEvent(load){
X = this._x;
Y = this._y;
}
onClipEvent(mouseMove){
Xm = _root._xmouse;
Ym = _root._ymouse;
Xdiff = Xm - X;
Ydiff = -(Ym - Y);
radAngle = Math.atan(Ydiff/Xdiff);
if (Xdiff < 0){
corrFactor = 270;
}
else{
corrFactor = 90;
}
this._rotation = -radAngle*360/(2*Math.PI) + corrFactor;
updateAfterEvent();
}
the button has the following code
on (release) {
if (_root.aim == 0) {
_root.arrow._x = this._x;
_root.arrow._y = this._y;
_root.arrow._visible = true;
_root.aim = 1;
}
}
the foot movieclip has the following code
onClipEvent (enterFrame) {
if (_root.aim == 1) {
if (_root.arrow.target._x>_root.plastic._x) {
_root.plastic._x += 10;
}
if (_root.arrow.target._x<_root.plastic._x) {
_root.plastic._x -= 10;
}
if (_root.arrow.target._y>_root.plastic._y) {
_root.plastic._y += 10;
}
if (_root.arrow.target._y<_root.plastic._y) {
_root.plastic._y -= 10;
}
}
}
what i was trying to do is to tell the plastic to go to the target
but it goes some place else not relly sure were
plz help me solve this
M:I:Coding?
I can't possibly describe this but I can't seem to get :
Code:
on (release) {
gotoAndStop("mainXrave", 1);
}
This to WORK! its set on a button in a scene but it isn't working!
-In the scene-
A customised cursor, controlled by this._x = _xmouse, and etc
A weird aurora thing as a Movieclip I got using tutorials, 3 frames and just duplicates itself for the efect.
And the not-so-working-well BUTTON.
So what could possibly stop such a easy code not work?
Thanks
Tongxn
AM:I:CODING?!?
Help With Coding Please
Hi everyone, I have been trying to alter this script for a while to better suit my needs but I have not been able to do what I hope to achieve. This is the scrpit for a SIMON game that randomly creates a patter (well I think most people know this) I am trying to use its randomness and other functions without the random string getting longer ( I want it to keep playing new patternes of 3 sounds every time)
There is a variable "step"
and a variable "count"
that seem to control the lenght of the pattern the script creates but I cant think of how to make it do what I said above.
Could anyone take a look and see please?
Code:
var dim = 50; //Alpha of pieces when clicked
aPieces = new Array(); //Array of pieces
aMoveList = new Array(); //Array of moves made
var ID;
var count = 0; //Number of moves made
var first;
var soSound0 = new Sound(this); //Creates a new Sound
soSound0.attachSound("simonSound1.mp3"); //Attaches simonSound1.mp3 to that sound
var soSound1 = new Sound(this);
soSound1.attachSound("simonSound2.mp3");
var soSound2 = new Sound(this);
soSound2.attachSound("simonSound3.mp3");
var soSound3 = new Sound(this);
soSound3.attachSound("simonSound4.mp3");
var step = 0;
for (var i = 1; i < 5; i++) //Adds the four movie clip quadrants to aPieces
{
aPieces.push(this["m" + i]);
this["m" + i].value = i - 1;
}
function buildPieces()
{
for (var i = 0; i < aPieces.length; i++)
{
aPieces[i].onPress = function() //When the piece is pressed it dims
{
this._alpha = dim;
};
aPieces[i].onRollOut = function() //When you roll your mouse off of the piece it undims
{
this._alpha = 100;
};
aPieces[i].onRelease = function() //When you release your mouse
{
this._alpha = 100; //Set transparency to 100%
_root["soSound" + this.value].start(0); //Play the piece sound
if (aMoveList[step] != this.value) //If the piece you pressed does not equal the piece you were supposed to press
{
failure(); //failure method
return;
}
step++; //Add one to the amount of steps to do
if (step == aMoveList.length)
{
nextLevel(); //Go to the next level
}
};
}
}
function failure()
{
tMainText.text = "Game Over.";
killPieces();
mStart._alpha = 100; //Set start button transparency back to 100%
aMoveList = new Array(); //Delete array of moves
mStart.onRelease = function() //Recreate the start button
{
startGame();
}
}
function killPieces()
{
for (var i = 0; i < aPieces.length; i++) //Deletes all the functions of the pieces so you cant interact with them
{
delete aPieces[i].onPress;
delete aPieces[i].onRollOut;
delete aPieces[i].onRelease;
}
}
function lightUp(num)
{
clearInterval(ID);
count--;
if (count == 0) //If no more pieces are left to light up, wait for user to input sequence
{
userTurn();
return;
}
if (count == 1) //If the last piece in the list has just been lit up, pick a random light to light up
{
num = Math.floor(Math.random() * 4);
}
else //Set num to the next light to light up
{
num = aMoveList[aMoveList.length + 1 - count];
}
light(num); //Light up the light
}
function userTurn()
{
step = 0; //Sets the step to 0
buildPieces(); //Lets user interact with pieces
}
function light(num)
{
dimIt(num); //dims the num piece
ID = setInterval(pause, 500, num); //Light up the piece for half of a second
}
function pause(num)
{
clearInterval(ID);
unDim(num);
ID = setInterval(lightUp, 50, num); //Creates a 50ms pause between lighting up pieces
}
function dimIt(num)
{
if (count == 1)
{
aMoveList.push(num);
}
_root["soSound" + num].start(0); //Plays the sound when lighting a piece up
aPieces[num]._alpha = 50;
}
function unDim(num)
{
aPieces[num]._alpha = 100;
}
function startGame()
{
first = Math.floor(Math.random() * 4) //Picks first piece
tMainText.text = ""; //Sets the text field to display nothing
for (var i = 0; i < aPieces.length; i++)
{
aPieces[i]._alpha = 100; //Sets all the pieces to 100% transparency
}
mStart._alpha = 0; //Sets the start button to invisible
delete mStart.onRelease; //Deletes the start button onRelease function
buildPieces();
count = 1;
light(first); //Lights first piece
}
function nextLevel()
{
killPieces(); //Disables interacting with pieces
for (var i = 0; i < aPieces.length; i++)
{
aPieces[i]._alpha = 100; //Sets all pieces to 100% transparency
}
count = aMoveList.length + 1;
var timer = getTimer();
this.onEnterFrame = function()
{
if (timer < getTimer() - 1000) //Wait 1 second before starting sequence display after input
{
delete this.onEnterFrame;
light(first);
}
};
}
mStart.onRelease = function()
{
startGame();
};
Thanks Very Much
Mark
[F8] Gun Coding
1. how do I say in a code that the movieclip 'gun' is inside the movieclip 'arm?
2. I have a very dodgy code here...my 'gun' movieclip is inside the 'arm' movieclip. they point to the mouse using the code attached to them.
the gun fires, the bullet doesn't. the bullet doesn't move anywhere, it stays at its starting point...
heres the code, this lot is all attached to my actions layer:
code: z=10;
bulletSpeed = 30;
var radians:Number = gun._rotation *Math.PI/180;
var vx:Number = Math.cos(radians)
var vy:Number = Math.sin(radians)
onMouseDown = function() {
shoot();
}
function shoot() {
attachMovie('bullet', 'bullet'+ z, z);
rad = gun._rotation*Math.PI/180;
_root['bullet'+z]._y=gun._y+ (25 *Math.sin(rad));
_root['bullet'+z]._x=gun._x+ (25 *Math.cos(rad))
_root['bullet'+z]._rotation=gun._rotation;
var vx3:Number = Math.cos(rad) * bulletSpeed+vx;
var vy3:Number = Math.sin(rad) * bulletSpeed+vy;
_root['bullet'+z].onEnterFrame = bulletMove;
z++
}
function bulletMove():Void
{
this._x += vx3;
this._y += vy3;
}
P.S. is it possible to attach a bullet to another layer when it is fired, so that when it hits its target and stays there, it scrolls along with the background (which is on a different layer)?
Coding Help
Actually this is 2 questions 1 on topic and one out of curiosity.
Now I usually don't have a problem doing a gotoAndPlay but for some reason i'm getting errors.
on (release) {
gotoAndPlay (scene, 1);
}
I'm getting nothing...but errors
And the second question. What are the fundamental differences with Actionscript 2.0 and 3.0 because I making the graphics for an experimental flash RPG and want to know what I should use.
New To Coding
hi there
I bougth this component plugin for my Flash CS3 called WaveNav but I am a beginner in coding.
I was going to use this WaveNav-sample that comes with plugin for my navigation. I have 14 "buttons" I need to navigate on my site but as I said I am a beginner in coding.
Can enyone help me seti it up?
below is the as from the sample:
import com.flashrelief.events.WaveEvent;
//create an array of movie clips to use in the navigation
var wordArr=["home","gallery","videos", "blog","portfolio","resume","about us","contact","legal"]
var tArr = [];
for(var i=0;i<9;i++){
var mc = new TextHolder();
mc.alpha = .65;
mc.tField.autoSize = TextFieldAutoSize.LEFT;
mc.tField.text = wordArr[i];
tArr.push(mc);
}
//assign the array to the component
myWave.items = tArr;
// create events for the links
myWave.addEventListener(WaveEvent.MOUSE_DOWN, goDown);
myWave.addEventListener(WaveEvent.MOUSE_OVER, goOver);
myWave.addEventListener(WaveEvent.MOUSE_OUT, goOut);
//
function goDown(e:WaveEvent){
trace("numer clicked: "+ e.num);
trace("targed movieclip: " + e.targ)
}
function goOver(e:WaveEvent){
var mc = e.targ;
mc.alpha = 1;
}
function goOut(e:WaveEvent){
var mc = e.targ;
mc.alpha = .65;
}
Thanks in advance,
solvin
|