ActionScript 3.0 :: Attaching Sounds To Movie Clips In An Array
Jul 22, 2009
Bit of a problem with trying to attach a sound to a series of movie clips stored in an array. I miss attachSound from AS2, it was so cool. Background first. I'm making a simple pairs game where the aim is to match the 2 cards that have the same sound attachted to it. I'm storing my card movie clips in an array to build the grid (obviously lol) and I have 18 audio files in my library with the class names s0 - s17. Code breakdown below. Apologies if this doesn't appear in code format,[code]I have two issues.
1 - how would I add a sound to each movie clip in the for loop in preparation for adding another function which is called when the user clicks the movie clip and the sound plays?
2 - the grid is 36 tiles long , so to make the whole pairs game work I need to attach each sound twice, and then again I will create another function which will then shuffle them randomly.
View 0 Replies
Similar Posts:
Feb 25, 2010
ive got these clips on stage and add event listeners in an array :
[Code].....
but i want to have nothing on stage and attach the same clip from the library a certain amount of times and have them put themselves into the array, is this possible?
View 4 Replies
Jun 5, 2011
As most of you don't know, I've been creating an rpg game. And, after several tries of art making, etc, I have finally moved back into coding the game. And now, I'm stuck on the equipment system idea. At first, I thought I would just place a bunch of goToAndStop's for each movie clip to go to a frame that has that certain armor piece. This was my first idea for an equipment system. However, after doing some research, and realizing how much lines of code could be saved, I started looking into simply adding and removing movie clips from the character as my new equipment system idea. Now.... on to the problem.
Basic want/ overall achievement wanted: Create an equipment system, which will basically attach movie clips (items) onto characters, which themselves will already be attached movie clips on the stage.
Problem: What is the exact code to do this? And Is there a better way to do this for an equipment system (a less laggy or more efficient way perhaps that I'm not seeing; Check the code below to get a better idea of what I'm talking about)?
Part of the code (or basic idea of code; see comments for extra details
code:
//Don't worry I have an OnEnterFrame function here;
//attachedObj= the character; figure= the MC name of the character;
attachedObj = attachMovie("figure", "figure"+1, 1);
[Code].....
View 2 Replies
Feb 9, 2010
I'm trying to create a simple platform game and decided to use movie clips for each move ment.I created a movie clip for the character jump called jump_mc and want to simply attach it to the UP keypress so it plays and removes everytime i press up on the keyboard. I've scoured the net but can only find movie clips attached to buttons.
View 2 Replies
Sep 24, 2010
The product is a maze game, where you have to navigate through the dark with a flashlight. Now, whenever I walk into a wall, my character stops, however the "flashlight" (a filter that reveals the texture beneath a mask) floats through the walls as if they didn't exist.
What I am asking, is if there is any way I can make the two movie clips attach to each other in any way, and not separate from each other. I tried applying the "player" hitTest code to the "filter" and "mask", however this caused the flashlight graphic to glitch and get out of position
View 3 Replies
Oct 11, 2005
i cant get it to work,i want 2 attach a ovie clip to another,so when one moves i wan the other to move too.this is what i have to attach it
_root.two._x = _root.one._x;
it works, but once one of the thing moves, it dotn go with it.
View 2 Replies
Jun 20, 2006
I'm trying to attach several movie clips into another movie clip. I can add the movie clips successfully . However, the movie clips start from the middle of the main movie clip that I used as the background layer for the other movie clips. Is there any way to make it located to the top left? Here is the code I used:
Code:
Layer_Movie.attachMovie("NumberTop","num",depth,{ _x: scol + (col * 32), _y: scol - 32 });
scol and srow are the attributes that represents the starting locations from the left and top. (I used 10 for the variables scol and srow the movie should be located 10 pixels away from the top and left) 32 is the height and also width of the movie clip to be added.
(I know sometimes actionscript is not so powerful to implement such kind of processes. Since I have not time to wait for the another version of actionscript
View 6 Replies
Jul 25, 2010
Firstly, I want to be able to push the space bar on my keyboard during a swf, and for a movie clip to appear on the stage. This is what I have so far:
Code:
onClipEvent(enterFrame){
if(Key.isDown(Key.SPACE)){
_root.attachMovie("Explosion", "Explosion"+i, _root.getNextHighestDepth());
_root["Explosion"+i]._x = _x;
_root["Explosion"+i]._y = _y-20;
}}
but its not working....
Secondly, I want A movie clip to spawn in the middle of the stage, then randomly travel outwards to the edge of the stage, then dissapear. And this needs to happen over and over, with the same movie clip travelling to a different place each time. This is what I have so far :
Code:
onClipEvent(load){
timer = 0;
i = 0;
a = 0;
b = 0;
[Code] .....
View 4 Replies
Nov 18, 2009
I want to attach a Movie Clip of a laser I made to a class. Currently I have no animation because that's the least of my problems.
The Laser is meant to fire when I press spacebar but instead i get an Error 1009 Below i have included my Code dealing with the Laser and Shooting By the way nothing crashes its just the laser will not spawn on the stage.
This is the Code on the Stage dealing with the Laser
function shoot(X:Number,Y:Number, A:Number):void
{
var b:Laser = new Laser(X, Y, A);
addChild(b);
[Code].....
View 1 Replies
Feb 24, 2004
I'm trying to make a portfolio page where each of my thumbnails loads with the 'fading grid' effect. I've made all the thumbnails movie clips with the appropriate script, and they all work fine. I've also set them to be exported for actionscript, each with a number as their name, i.e. "1" "2" and so on.
I was then planning on using the following bit of code to load these movies into my portfolio clip, to save me having to do it at author-time.
[Code]....
But for some reason, instead of loading two movies, each one 10 to the right of the previous movie, it just loads them on top of each other. Is it something to do with the stage not updating?
View 3 Replies
Jul 20, 2005
I've been trying to figger this one out. How do you create a delay effect when dynamically attaching mc's to another mc, the stage, whatever.
say you're building an xml driven menu which is essentially a stack of mc's attached to another. how do you make them appear to fade in one by one, starting at the top and working toward the bottom? (i can create the effect, just not sure how to script it).
it's gotta be fairly straightforward since i see it lots of places. I tried creating it with frames but that doesn't work since the mc's get attached so quickly.
View 7 Replies
Nov 17, 2009
I have a project in which I have a dozen movie clips on the screen each of which are started by a separate button. Each of the movie clips has a sound in its first frame.When I test the swf file all of the sounds from the first frame of each movie clip play simultaneously for about a quarter of a second. I'm not sure why because all the movies are stopped upon initialization. I've tried SoundMixer.stopAll() and I've tried setting volume to zero with SoundMixer.soundTransform = new SoundTransform(0) for each movie but nothing seems to stop the movie clips from producing that initial, short burst of sound.
View 1 Replies
Apr 13, 2003
I have seven loops in total. I imported them into the library. i've put each of them in a seperate movie clip with the names loop1,loop2,.In those movie clips, the first (key)frame contains the action stop(); . The second frame is a keyframe too and from here on the sound starts. And of course they loop.Okay, now the buttons to control the movie (Prev, Stop, Play, Next) work fine, but let me explain the system i used. I used a var loopnumber and everytime you click Next or Prev, it '+'es 1 or '-'es 1. I also set a variable number_to_play = "_root.loop"+loopnumber, so you would get _root.loop--number--, where --number-- is 1,2,3,4,5,6 or 7. To actually play the sound, i used tellTarget(number_to_play) {gotoAndPlay(2)}.That's why i added stop(); to the first frame of those clips.how can i make a volume slider for those sounds inside my movie clips ? I've checked this forum already for questions like this but they don't use the system I use.
View 4 Replies
May 12, 2009
I am working on a game that involves a play head (called playHead) moving along the screen and when it encounters various movie clips it triggers a sound to be played. It is all going well except that the sound seems to want to play more than once, so there is a staggered wierd sound. Is is possible to make the sound only play once and also it needs to play until the the sound has finished. (the sounds are all very short).Here is the code:
onClipEvent(enterFrame){ if (this.hitTest(_root.playHead)){ _root.sound15.stop(); _root.sound15.attachSound("over"); _root.sound15.start(); } }
View 5 Replies
Dec 7, 2010
i am making a sidescroller and i'm working on the collision and the way my teacher suggested was to give all the movie clips an instance name (which i did), but i'm not too sure on how to put them into an array for collision detection
the movie clips are within a movie clip simply named levelOne (and lvlOne_mc for as) which is exported for action script. the pieces within are well named and have an instance name (for example the first platform instance name is Pf01) but i don't know how to set up the array so i can set up collision detection between the character and the objects
View 1 Replies
Jan 18, 2011
I have some movieClips in my libaray called p1, p2 etc with export settings of the same name.I have the names stored in an array.I cant work out how to do this dynamically:
ActionScript Code:
private var myImages:Array = [p1, p2, p3, p4, p5];
private function changeImage(newImg:Number):void {
[code].....
View 7 Replies
Aug 28, 2009
If I've got an array that contains mc names like this:
PHP Code:
var homeArray = new Array("home1_mc",
"home2_mc",
"home3_mc",
[code]....
How do I do the equivalent of this:
PHP Code:
var i:MovieClip = homeArray[0];
var image1:MovieClip = addChild(new i);
View 2 Replies
Sep 23, 2009
How to put movie clips into an array? I am trying to have several instances of a clip in an array, but can't get it working.
View 3 Replies
Feb 24, 2007
its possible to have an array of movie clips? what i've been trying to do is to make a variable equal a random number between 0 and 10 and that variable is put in as the array number and it then loads that 1 movie clip chosen randomly from the array of movie clips.
View 4 Replies
May 16, 2005
I put all my Movie Clips on an array and I can't access it very good
[Code]...
It removes the last movie clip and other actions that I applied to those mvoie clip the last movie clip is always selected.Of course j is initialized with array.lenght How can I access it in a different way?}
View 7 Replies
Nov 9, 2009
In the following code, the on1,on2,on3,on4,on5 are instance names given to 5 buttons. all five of the buttons ARE SUCCESFULLY responding to the Press1 function below.
Code:
var ONarray:Array=new Array("on1","on2","on3","on4","on5");
for (var i:uint; i < ONarray.length; i++) {
var ON:MovieClip=getChildByName(ONarray[i]) as MovieClip;
[Code]....
View 25 Replies
Jun 15, 2010
I have a movie the attaches movie clip linkages to an array with buttons, the idea is to attach the clip to the stage and when you attach another clip ,the one one the stage moves down in the y position 25 px to allow the next movie to go in its space.I cant seem to get the movie to drop down and all the clips stay at the same y coordinate.I have tried using a variable to update the y value also to hard code the y value nothing seems to work below
var warnArray = [""];
mybtn.onRelease = function() {
warnArray.unshift("movie1");
[code]....
View 9 Replies
May 22, 2009
I've got an array with four movie clips that I would like to move onto the screen separately (the first one, then the second, etc). Is there a way to do that?
This is the code I have to move the whole array onto the screen:
arrCSnav:Array = [cs1_Button, cs2_Button, cs3_Button, cs4_Button]
for(i=0;i<arrCSnav.length;i++) {
var enterTween:Tween = new GCSafeTween(arrCSnav[i], "x", Strong.easeOut, arrCSnav[i].x,arrCSnav[i].x+180,12,false);
}
View 3 Replies
Nov 2, 2011
i stored 8 mc's in an array an i put them on the stage. now I want to apply to these mc's a blur effect. My problem is that i don't know how to apply for every mc the blur effect by clicking on it. So for example I have all the mc's on the stage and if I click on one of them the clicked one should have the blur effect and so on. How to apply the filter to the mc's?
View 2 Replies
May 22, 2010
in my program the user can create multible movie clips so i stored them in an array. now the problem is i need to find the ._x of all of them. so i have tried to create a for loop that will go through at a certain amount of times (pending on the number of created movie clips)
Code:
for(z=1;z<=_root.howmany;z++)
trace(array_name[z]._x);
}
it doesn't work?
the array is storing the string of the movie clip
(like; _root.moive1, _root.mave2,etc)
but when i try to access it, it doesn't work? what am i doign wrong and/or what should i do?
View 1 Replies
May 1, 2002
Does anybody know how to go about creating an array of movie clips? Can it be done? I can't find it in any of my books.
View 7 Replies
Apr 20, 2010
In AS3 I have an array of Movie Clips:
Code:
var page_array:Array = new Array();
page_array = [home_mc, about_mc, contact_mc];
I want to set properties in those memory clips, e. g.
[Code]...
View 2 Replies
May 11, 2010
In this code I created an array and am placing instances on the stage when I click on buttons relating each movie clip.
[Code]...
View 3 Replies
Nov 10, 2003
[URL] -heres a intresting portfolio site at the bottum they have 3 columns i want to do they same thing where they select from the first list they select from the secong list then the description shows up and loads a swfs which of these two methods would be easier to use
1.use a array or list
2. use movie clips
View 4 Replies
Jul 12, 2002
Does anyone know of a way to use the attachMovie() function to attach movie clips into the root timeline from the library of a movie that has been loaded into the root movie?I want to place a series of movie clips into a smaller movie that is loaded into the root timeline when needed and be able to script the linked movie clips in the library for use in my root timeline
View 1 Replies