AS3 :: Instantiate Sound Clips Dynamically
May 18, 2010How can i call and instantiate soundclips in my library dynamically.[code]
View 1 RepliesHow can i call and instantiate soundclips in my library dynamically.[code]
View 1 RepliesSo I've been working on a Flash-based web portfolio for my sound design work, and I'm creating a gallery of images/sound clips which load dynamically (that way I don't need to recompress the swf file every time I add/remove a production). I'm having trouble with checking to see if files exist; for example, I want to check if a sound file exists, and if it does, set the alpha property of a symbol to 100%, and if it doesn't, set the alpha property of that symbol to 25%.
The code I'm using works fine when I test the file locally, but as soon as I upload the file and test it, the movie responds as if a file exists even when it doesn't, and I can't figure out why.
[Code]...
I'm building a shared library of sounds, but am having trouble referencing them in code in the swf that needs them. First I built the built the library and clicked 'export for runtime sharing'. Second I built another swf, went to file > open external library, and dragged and dropped the sounds I need into the new library. Third, I tried to reference it in as3 the way I would normally:
[Code]...
i'm trying to create a dynamically named Vector. i have a critical project deadline tomorrow, and this small problem is holding back continued development i've adapted my code from this example [URL]...yet am getting an error message (see below). here is what i have:
[Code]...
I made a Post-It note movie clip that is draggable. I want to create a whole pad of notes, or at least simulate this. I thought the best way to do this would be to add another Post-It whenever the startDrag() is triggered.
I first tried creating the Post-It with symbols but didn't think I could dynamically create new ones this way. I then created a class and added it to the stage[code]...
For loop generates clips containing clips. I need to access a specific clip (look_back) within the parent clip generated by the loop. Not sure how to do this.[code]
View 1 RepliesUsing org.as3commons.reflect I can look-up the class name, and instantiate a class at runtime.I also have (non-working) code which invokes a method. However, I really want to set a property value. I'm not sure if properties are realized as methods internally in Flex.I have a Metadata class which stores 3 pieces of information: name, value, and type (all are strings).I want to be able to loop through an Array of Metadata objects and set the corresponding properties on the instantiated class.[code]I realize that I have to declare a dummy variable of the type I was to instantiate, or use the -inculde compiler directive. An unfortunate drawback of Flex.Also, right now there's code to account for typecasting the value to it's specified type.
View 1 RepliesFor a game I'm attempting to develop, I am writing a resource pool class in order to recycle objects without calling the "new" operator. I would like to be able to specify the size of the pool, and I would like it to be strongly typed.
Because of these considerations, I think that a Vector would be my best choice. However, as Vector is a final class, I can't extend it. So, I figured I'd use composition instead of inheritance, in this case.
The problem I'm seeing is this - I want to instantiate the class with two arguments: size and class type, and I'm not sure how to pass a type as an argument.
Here's what I tried:
public final class ObjPool
{
private var objects:Vector.<*>;
public function ObjPool(poolsize:uint, type:Class)
[Code].....
Is there any AS3 library or code-snippet that can create altered versions of a Sound object on-the-fly (at runtime)? Either based on:
An existing Sound object; A ByteArray object;
For example, say you have a "dry" sound of a gun-shot. You could:
[Code]...
Does anyone know of a way to dynamically read the sound levels of a loaded MP3 to help produce dynamic sound visualization in Flash?
View 5 RepliesI have a 355 frame timeline with a sound-clip explaining there are two demonstrations, the first will follow automatically but if the user wants to see the second demo first then to click on the link. When the swf file runs, at frame 350 Demo1 (the first demo) starts automatically as expected. If the link is clicked, the main sound clip stops and the second demo starts but the sound clips for both demos play together.How can I ensure that only the relevant sound clip runs?[code]
View 7 RepliesI was wondering if somebody could point me in the right direction to be able to load in a random sound clip (from a set of 5 or more mp3s) when the user rolls over a button. I can't seem to find a way to do this.
View 14 Repliesreferencing sound from a nested clip.In my first frame on the root level I have this function:
function snd(iSnd:Sound):void {
var sndV:SoundChannel = iSnd.play(0, 0, sndTrans);
}
On the second frame of a nested clip I have this:
MovieClip(this.root).snd(MovieClip(this.root).loca tionSound);
I don't get any errors, but my sound doesn't play either. The function works fine when I am referencing it from the root level, but unfortunately I can't do that with this particular instance.
My game is initialized by calling the newBall function below. Every 10 seconds a new ball is created to increase the difficulty by calling the same function. The function works and creates the new ball movie clip, however the previous ball object gets destroyed for some reason. I have an array called ballArr that is supposed to keep track of all of the ball movie clips. I thought that by concatenating the name of the instance with an incrementing number that it wouldn't overwrite the existing object... what am I doing wrong?
Code:
function newBall() {
var ballNum = ballArr.length + 1;
var ball = this.attachMovie("ball_mc", "i" + string(ballNum), 0, {
[code]....
I have done a bit of searching for this and have come up short. I have seen a few others post this question but never seen an answer... So here I am hoping I can find it here!Ok, so my problem is that I need to call MC's from the library dynamically depending on a number of previous user chosen options... and the names are all fairly similar but with a number or word difference...So here is my problem...I need to be able to call a clip such as the following
ActionScript Code:
var1+"mc_name"+var2+"mc_name"
I have a site made in Dremweaver with tons of sound clips with HTML tags and now I am recreating whole site in Flash and now I need to make list of those clips and I want when a user click on some clip that it start download it.
View 3 RepliesI have a dynamic text box in one movie clip, and a button in another movie clip. I need for that button to display a text file in the text box (in the other movie clip) when it is released.There really isn't any way to join these clips, given the design of my site. Here is the code I have for my old design, when the button and the box were in the same clip:
on (release) {
loadText = new loadVars();
loadText.load("journal/2004-09-12.txt");
[code].....
I have an Array Object called extData_arr, that contains data read from a database. Using this data, I'd like to populate my subMenu MovieClips appropriately. I can elaborate on the format of this array if required but basically the problem is this. Now this line seems to work and displays correctly as I expect
status.text = status.text + n + " : " + i + "
";//tracing
but for some reason, on the following line where I try to create empty Clips, flash just doesn't recognize the value of i and therefore refuses to create the clips. Does anyone know why?
[Code]...
I want to target ALL the 20 clips attached as below, at the same time, when I press the button "blue". However, my code can target only ONE of the clips at any time. I have tried attaching the clips to a separate dynamic clip and then targeting it but problems with the registration point (0,0) of that clip means I cannot achieve the result I want:
Code:
for(i=0;i<20;i++){
mc = this.attachMovie("red","red2"+i,i);
var scaleFactor:Number = Math.random() * 80 + 20;
mc._x = Math.random()*500;
mc._y = Math.random()*400;
mc._xscale = scaleFactor;
mc._yscale = scaleFactor;
blue.onRelease = function(){
new Tween(mc,"_xscale",Strong.easeOut,mc._xscale,200,3,true);
new Tween(mc,"_yscale",Strong.easeOut,mc._yscale,200,3,true);
}}
As part of a preloader, I've placed a blank movie clip on the stage and attached the following code:
Code:
onClipEvent (load) {
for (i=0; i<50; i++) {
ranx = Math.round(Math.random()*1000)+1;
[Code]....
The bats generate fine, but I can't get them to move about.
I'm trying to make a flash widget that loads thumbnails from an xml document and have each thumbnail link to a different web page. So far everything works fine but I don't like using _root incase the widget gets loaded into another swf. In my expereice _lockroot dosen't always work.the line highlieted in red will only work if targeted through root as opposed to all my othere reference to ["placeHolder"+i] which use this.["placeHolder"+i]. I've tried _parent, this._parent and adding lots of other _parents. Nothing will work this is the file structure _root.placeHolder'N'.tn_mc. how I can substitute _root for a relative path.
widget_xml = new XML();
widget_xml.ignoreWhite = true;
widget_xml.load('flashWidget.xml');//path to document
[code].....
I was just wondering if this is possible, and if anyone knows how it could be done
What i intend to do is have a number of movie clips which load a photo from XML.As well as the photo i want something in the XML code that tells the movie clip where to place itself on the scene. For example it could contain a number from 1-8 and the scene will be split into eight sections across the X axis. So if it has the number 3 it will go in the 3rd section across anywhere on the Y axis.
I have an array containing names of movie clips. I would like to loop through the array, and add the movie clips to the stage.
I have the following code, but obviously this doesn't work.
HTML Code:
var mcArray = [];
mcArray .push( "mc1" );
mcArray .push( "mc1" );
[Code]....
I currently have an dragable button that is locked to only move left and right within a small bar, and want to have that button playing one sound going left, and another sound going right.
View 3 RepliesI'm trying to control my mp3 sound clips with keyboard commands and have managed to get this to work with internal sound clips:
//************************************************** *************
var note2:b = new b();
btn2.addEventListener(MouseEvent.MOUSE_DOWN,playNo te2);
function playNote2(event:Event){
[code]....
Trying to add a set of movie clips to the stage in a loop. I need to be able to reference them on a mouseDown function - but the projHolder var in the mouse event is coming up undefined. Any ideas how to accomplish something like this?
for (var i=0; i <intWorkCount; i++) {
var projHolder:MovieClip = new MovieClip();
projHolder.name = 'projHolder' + (i);
[code]...
Is it possible to create movie clips dynamically and add frames to them? Because say I have a game and there are NPCs, I'm not going to want to create say 50 different MovieClips manually, is there a way to do this through code?
View 5 RepliesI'm creating a photo slide show that has the ability to go full screen. I have some elements which are always on the stage and some elements which I am adding from the library and/or creating in the code. When I issue the resize event, my stage movieclips are still on the stage and can be repositioned but the elements I created dynamically (most notably the thumbnails which I want to reposition) are gone.
View 1 RepliesI am trying to perform the following:
1. Create a series of movie clips on the stage
2. Give each one a specific name (i.e. movieClip1_mc)
3. Load an image into each one
4. Add three unique listeners to them (MOUSE_OVER, MOUSE_OFF and CLICK)
Afterwards I want to create one single function that will handle all the above boxes depending on which box is clicked.
Obviously the 1st part is simple enough and I have no problem there. Without relying on the "multiple movie clip" parts, I can easily handle the next three - just can't get it to work when working with multiple dynamic movie clips. Where I get stuck will always be giving each one a name and then moving forward. One big issue I continuously face is creating one dynamic function that will handle based on which movie clip the user interacts with.
I am having trouble clearing out a shell movie clip that has other mcs dynamically placed inside it. Something like this;
var myShell:shell_mc = new shell_mc;addChild(myShell);//
//---obviously these buttons are on stage already---buildBtn_mc.addEventListener(MouseEvent.CLICK, buildFunction);clearBtn_mc.addEventListener(MouseEvent.CLICK,
[Code]....