ActionScript 2.0 :: Can't Create Multiple Movieclips With A For Loop
Nov 12, 2003
i'm having a problem with a for loop. The problem is that it doesn't create multiple movieclips with an unique instance, i think it copies over itself.
for( var i = 1, x = -20; i < 4; i++){
if(this['plaatje' +i] != undefined){
_root.again.createEmptyMovieClip("image", i);
i'm having a problem with a for loop. The problem is that it doesn't create multiple movieclips with an unique instance, i think it copies over itself.
for( var i = 1, x = -20; i < 4; i++){ if(this['plaatje' +i] != undefined){ _root.again.createEmptyMovieClip("image", i); this._root.again.image += _root.again["image" +i];
I have a group of 16 images that I would like to load 1 of each into each movieclip. I want image1 to be inside of visual1, image 2 inside of visual2, and so on. the images are named like, 1960s_(1).png where the 1960 (year) part is coming from the rangeNum variable. The above gives me this error: 1061: Call to a possibly undefined method addChild through a reference with static type int.
I simply want to be able to access 3 already created, but not yet added movieclips using a loop. I've tried a few code combination but can't figure out the syntax.[code]
there is something i just dont get regarding motion with multiple movieclips (from a for loop). I have tried many different approaches, and every time there is either all the clips move in the same direction, other times they only move one direction, other times when i get individual motion for each object they dont move smooth, and seems more too move very slowly across the scene but rapidly back and forth in a small area. I dont have any specific code to show, but does anyone have tips or a place to direct me, cause i dont understand the logic of it, however i want to understand.
Everytime I press a movieClip, i -1(on the output window) should be equal to the number of the movieClip (ex: myClip17, when pressed, should produce in the output window a value of 17 for i-1). Please copy paste this code to a flash document and you'll see what I mean (please don't forget that you have to have linkage in the library for a movieClip symbol that you have to create - it's a circle only with stroke that has w=15 h=15). Every time I click on a number it should appear a circle on it. If the circle is already there it should disappear. But that's not the case. Somehow every movieClip has the order to attach one of the instances of movieclip marca_mc to myClip31.
Basically I have 5 movieclips I want positioned around the stage. So I figure the best way to this is with a for loop. However the way I've coded it doesn't appear to add new movieclips and seems to just move the first movieclip 5 times and it always ends up with an x of 169. Here's my code:
Code: for (i=0; i<5; i++){ var barName:MovieClip = _root.game.attachMovie("butSquare","r1wBar"+i,_root.getNextHighestDepth());
The problem is: everytime I press a movieClip, i -1(on the output window) should be equal to the number of the movieClip (ex: myClip17, when pressed, should produce in the output window a value of 17 for i-1).Please copy paste this code to a flash document and you'll see what I mean (please don't forget that you have to have linkage in the library for a movieClip symbol that you have to create - it's a circle only with stroke that has w=15 h=15).Every time I click on a number it shouldappear a circle on him. If the circle is already there it should disappear. But that's not the case. Somehow every movieClip has the order to attach one of the instances of movieclip marca_mc to myClip31.
Is there a way I can create these clips and add them to an array in a loop ? It doesn't seem to want to work for me.. ?
var p1 = new P1; var p2 = new P2; var p3 = new P3; var p4 = new P4; var p5 = new P5; var p6 = new P6; var p7 = new P7; var p8 = new P8; var p9 = new P9; var p10 = new P10; var p11 = new P11; var p12 = new P12; var p13 = new P13; var p14 = new P14; var p15 = new P15; var p16 = new P16; var p17 = new P17; var p18 = new P18; var p19 = new P19; var p20 = new P20;
I'm trying to make a point and click game for the fun of it. I'm having troubble with the .onPress function. I've made an array of movieclips, and I want to go through them in a loop, and make an onPress function for each of them. What I am trying to do with the code below is to make the debugText tell me what movieclip I pressed:
First of all , how can i change that "stub1.swf" to change its value like stub1.swf, stub2.swf stub3.swf etc. Also, it doesnt seem to create multiple movieclips; it only makes the one.
I want to create some instances of a movieclip thats in my library. [code]This code works. Then I want to startDrag all of them, in the same loop. How to?I'vre tried "k"+i.startDrag(this) but that won't work. Any other good guesses?
I put together this code that builds a container that contains boxes(squares) in an ordered way. Problem is when I rotate the container, the boxes don't stay in their order. (something to do with swapping depths I think) . In fact, they look a bit confusing. Just create a movieClip 24 x 24 and Name it Box. Create another movieClip and name this one Container. Save them in your library. Then just copy this code and compile. You know the routine.
I found lots of links to creating 1 moveclip dynamically but not to create multiple move clips. I am trying to create 10 empty movieclips dynamically, but I cannot seem to get my script to work. This is what I came up with and does not work: var i; for (i=0; i<10; i++) { var myMC["myMC"+i]:MovieClip = new MovieClip(); myMC["myMC"+i].name = "mc"+i; addChild("mc"+i); } Why this does not work/how do I make it work?
I'm trying to create multiple Functions inside a Loop.[code]I essentially want to make 4 Functions called closeButOut1, closeButOut2, closeButOut3 and closeButOut4.This is the error message I get:
-1084: Synax error: expecting identifier before this.
-1084: Syntax error: expecting leftparen before rightbracket.
I wished to create multiple copies of a variable in a loop.such as:
var pots:String = thisString [i]
and then i wish to reference one of these loop generated variables.Now how would you set it up so you could have all those variables of "pots" had their own names so one could reference say: "pots1" "pots2" or "pots17" ? This kind of situation would bee seen in a situation where I would be bringing in many array values and assigning certain parts of them to the variables. such as array[i][name]
I'm attempting to create a graphical representation of the microphone activity in flash for a conference.
I got a movieclip called eqNotch that's just a rectangle and its linkage name is EqNotch.I also have a movieclip where I am writing my as3 on the first frame, its called dynamicBar and linkage name is DynamicBar.
I've successfully written the code for the dynamicBar to create one column of eqNotches and the number of rows is dependent on mic activity.[code]...
How do i word a for loop to make it loop through multiple arrays?I want 1 for loop to loop through multiple arrays in order to move/alter objects.I want to keep the arrays separate.
ActionScript Code: characters = new Array(); characters[0] = male;
i have been building a library that has thumbnails which you click to view the full image. i have built the application it works but i want to change the way the image on the actual thumbnail loads using code instead of manually adding the value to the url loader component.
var myX;var instanceN:String;trace(instanceN);var currentLoad:uint = 0;// current loader and image loadingvar thumbnailURL:String;//Thumbnail URLvar thumbReq:URLRequest;// Thumbnail url requestfor(var k:uint = 0;k < iL_btn.length; k++)[code].....
the loop runs fine without the last line of code which i've commented out.the make up of these thumbnails are a uiLoader component which are each inside there own movieClip.what i wanted this to do was every time the loop runs it currentLoad adds 1 to its value then that value is subbed into instanceN:String and thumbnailURL address that bit works the trace statements read correctly.but my issue is using the instanceN value as the instance name path which then loads the current thumbnailURL value which is the URL address for the thumbnail picture.when i try to load the url address using the commented out code above i got the error .TypeError: Error #1010: A term is undefined and has no properties.the trace statements correct values below
the first value is the currentLoad value.
the second value is the instance name path.
the third is is the URL address for the thumbnail.[code].....
I have 50 images that need to be on stage, which will be embedded into 50 different movie clips. I named the movie clips image1-image50 and the images are in an external folder named 1-50. Every freaking article or tutorial I have found clearly explains how to upload one image, or just one at a time. I can do that, and spend 2 days renaming all the functions, but I do not want to do that. Is there a better way to just load all 50 images, place them accordingly?
I have 24 movie clips on the stage: my_menu.image_holder_mc1 thru my_menu.image_holder_mc24. I want to load an image in each one. How do I identify the holder which to add a child.
The Code I have so far is....
Code: for (var i:Number=1; i<=24;i++){ var myLoader:Loader = new Loader(); myLoader.name = "image_"+i;
I've got a movieclip(we'll call this "A") on my stage, which attaches another movieclip("B") into itself. So it's nested.Now, once this movieclip("A") has attached the other movieclip("B") into itself,It uses a "gotoAndStop()" to send the frame of movieClip("B") to the right frame, eg. frame 2. Then it runs a loop which checks for all movieclips in "B" and populates an Array.The script I'm using for this is :
Code: for (var i=0; i<h.numChildren; i++) {// This loop is suppose to populate my "bitArray" Array with all of the attached clip's childclips if (h.getChildAt(i) is MovieClip) {[code]....
if there were 22 MovieClips on frame 2 in movieClip"B" , this code would still be able to populate my array with all 22 clips right?It doesn't. For some reason, if there were 22 clips, then out of the 22, the loop would only pick up 9. However, doing a trace with numChildren() in movieClip"B", it would still show 22. But my array would only show 9.I've attached a sample fla, I think it would explain my problem a lot better.Once you run it, it should spit out an output telling you how many movieclips in the attached movieclip, and it'll tell you how many clips it pushed onto the array.I can't seem to get the number of movieclips in my array to equal the number of clips in total inside my attached movieclip.