Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Trouble Adding Duplicated Movieclips To Array



whats up everybody,

once again its almost time to choke the young'ns. I'm on my last nerve and someone or something is gonna catch the wrath.

i have a question or problem that seems easy enough to handle. i've been trying to store my duplicated movie clips inside an array so i can access the x and y positions later. i have duplicate about 20 movie clips and need to have their names stored in an array while they're being duplicated. here's what my code looks like so far:

var intervalID;
intervalID = setInterval(checkLoadStatus, 100);

function checkLoadStatus() {
if(Title.loaded){
clearInterval(intervalID);

//split artist string into array
aArtists = Title.artists.split(",");
aPhotos = Title.photos.split(",");

// initialize stars with Title data
star_amount = aArtists.length;
trace("XXstar_amount = " + star_amount);



//declare arrays
a_Stars = new Array(star_amount);
a_centerCheck = new Array(star_amount);


for (i=0; i<star_amount; i++){

a_Stars[i] = duplicateMovieClip("star", "star" + i, 1+i );

//set length of array
a_Stars[i] = this["star" + i];

//set boolean values to check for position
a_centerCheck[i] = false;

}
star._visible = false;
trace("AAthe elements in a_Stars: " + a_Stars[1]._name);
trace("ZZthe elements in a_centerCheck: " + a_centerCheck[5]);
}
}


the problem is that flash is not storing the elements of the array. on my trace command a_Stars array keeps coming up empty while a_centerCheck displays its elements all fine. stars(the duplicated movie clip) is a child so the target is i believe to be ok. (but is probably wrong also - i just don't know).
any help, as always, is greatly appreciated.

thanks
erase



Ultrashock Forums > Flash > ActionScript
Posted on: 2003-04-16


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Duplicated MovieClips Across Scenes And Dynamic Text Trouble
First off, I really appreciate flashkit.com and this board.

Ok, let's say I use the duplicateMovieClip function in the first scene of my movie to create some movieClips. Then let's say my movie proceeds to the second scene:

Are the movieClips I made by duplicating in the first scene deleted?
If not, can I access thier properties somehow from the second scene?
Also, if they're not deleted, how can I avoid duplicating them again if my movie needs to return to the first scene in which they were originally duplicated?

Finally, let's say I have a movieClip containing another movieClip containg some dynamic text. I can change the text value of the dynamic text, and it's _visible property is set at "true", but I can't see it in my movie. Anyone know why?

Thank you very much for your help.

Adding Unique Dynamic Text Fields To Duplicated Movieclips
Hey All,

I'm working on a piece for work. I need to figure out how to add unique dynamic text fields to duplicated movieclips. Unique as in unique instance names and variable names. Thanks for any help that anyone can provide.

I have a movieclip on the stage that contains a dynamic text field.

the text field will house text that is being pulled from an xml file.

What I need is to have the dynamic text field in all the duplicated movieclips have a unique instance name and variable name.

I assume that a nested for loop would be required, but I'm not sure as I am not the greatest actionscripter. Here's what I have so far:

myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {

// populate the amount of rows based on the amount of nodes
rows = this.firstChild.childNodes.length;

// enter how many columns are needed
columns = 3;

// starting position of the first movieclip (holder)
xpos = 20;
ypos = 20;

// spacing between each holder
vspace = 1;
hspace = 10;

// the width and height of the holder movieclip
wclip = holder._width;
hclip = holder._height;

// counter
theclip = 1;

// make the grid
for (var i = 0; i<rows; i++) {
for (var j = 0; j<columns; j++) {
var thegrid = holder.duplicateMovieClip("holder"+theclip, theclip+1);
thegrid._x = xpos+((wclip+hspace)*j);
thegrid._y = ypos+((hclip+vspace)*i);
theclip++;
}
}
}
myPhoto.load("thumbnails2.xml");

Adding MovieClips To An Array Via For Loop
I have 91 seperate movieclips that make up a maze. I need them to put them in an array, so that I can use the hitTestObject to see if the guy hits the maze. Right now I have the following code, but it doesn't seem to be working.


Code:
var mazeArray:Array = new Array();
for(var i:Number = 1; i<=91; i++)
{
var c:MovieClip = this.getChildByName("maze"+i) as MovieClip;
mazeArray[i] = c;
}
Thanks!

Trouble Adding Numbers In Array
As an excercise, I'm trying to create a class that will take the average value of numbers in an array.
I'm stuck on adding the values of the array elements. I keep getting "NaN" for the total. Below is my code.


ActionScript Code:
private function getTotal ():Number
    {
        var total:Number;
        for (var i = 0; i<numArray.length; i++)
        {
            total += Number(numArray[i]);
        }
        trace("total= "+total);
        return (total);
    }

Trouble Adding Dynamically Named Elements To An Array Immediate Help Is Needed
OK, here we go... if someone can help me figure this out, I will have successfully completed my site in time for the deadline today at noon...

-- I have an array located at "_parent.emptyWindows"
-- "_parent[this._name]" gives me the name of the current MC and the value I want to add to array "emptyWindows"
-- I'm trying to add an element in this manner:


Code:
_parent.emptyWindows[_parent[this._name]] = _parent[this._name];
That is not working, but not even this is working for me:


Code:
_parent.emptyWindows["bird"] = "bird";
Here I've given an explicit value and name for the element to be added to the array, but obviously something is wrong in my context and I just am NOT finding it.

Any guesses???
Much appreciation,
The Dust

Duplicated Movieclips
Hi
OK, I'v made a space invaders game, like the old sckool one where aliens come down in lines and shoot at you etc. My problem is getting the alien lazers to come from the alien ships, which are duplicated from a single movie clip. I cant seem to track the aliens to get there _x and _y possitions to launch the lazers from. I've tried using their _level0.4space3 names from the objects list when testing, but thats no good!
Can anyone help, PLEASE.
Cheers
Joe

My Movieclips Get Duplicated
Hi there,

While testing an swc to drag and drop movieclips, my draggers got duplicated.
Of course I don't want the draggers to be duplicated and I traced my problem
back to setChildIndex and similtaneously running the movieclip.

In short: A movieclip contains a dragger, the childIndex of the the dragger is changed
and then the movieclip is played. Resulting in 2 draggers.

I've put my problem in a file:

http://www.liauw.nl/bugs/setchildIndex_bug_or_feature.fla

My question is: Can I avoid the duplication (while running the clip)?

thx,
Ronald

How To Name Duplicated Movieclips?
original code:

ActionScript Code:
for(i=0;i<4;i++){
  this.item.duplicateMovieClip("item" + i, i)
  this["item" + i]._x = random(500)
}


I'm having trouble with formatting it into a function. using "this._blah" won't work. so instead of referring to the movieclip as:

this["item" + i]

how else can I name it?

Adding Movieclips Inside Of Two Other Movieclips... XML Powered Slideshow
hello..

I have been working on this project that used part of the kirupa.com tutorial for XML slideshows as a base. What it does is takes a set of thumbnails from an XML file and puts them in a movie clip on different layers. (Each thumbnail a new movieclip on a new layer of the original movieclip)

Anyways, what I am trying to do is make a menu movieclip pop up when a button is clicked. Inside this movieclip is where I want to throw the movieclip for thumbnails to load on. The menu movieclip is working fine and whatnot, but I cannot figure out how to get the thumbnails to load inside that second movieclip.

Here is a chunk of my code:


Code:
function createThumbnailScroller(current_mc, currentThumbFile, thumbCenter) {
thumbnail_scroller.createEmptyMovieClip("t"+current_mc, thumbnail_scroller.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+20)*current_mc;
target_mc.pictureValue = thumbNumb[current_mc];
//trace(thumbNumbforJS[current_mc]);
target_mc.onEnterFrame = function() {
thumbWidth = target_mc._width;
};
target_mc.onRelease = function() {
//tell JS to jump to that slide
flash.external.ExternalInterface.call("jumpToSlide", thumbNumbforJS[current_mc] )
//set scroller movieclip back in its original position (go back to main screen)
yVal = 362;
scroller_move();
};
target_mc.onRollOver = function() {
fadeDown(this);
};
target_mc.onRollOut = function() {
fadeUp(this);
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(currentThumbFile, "thumbnail_scroller.t" + current_mc);
}

"thumbnail_scroller" is the movieclip which is inside of "scroller", the menu movieclip.


Thanks...


EDIT:

I got it working.. I just had to add "_root.movieclipname." in front of the movieclips I referred.

Adding Movieclips Inside Of Two Other Movieclips... XML Powered Slideshow
hello..

I have been working on this project that used part of the kirupa tutorial for XML slideshows as a base. What it does is takes a set of thumbnails from an XML file and puts them in a movie clip on different layers. (Each thumbnail a new movieclip on a new layer of the original movieclip)

Anyways, what I am trying to do is make a menu movieclip pop up when a button is clicked. Inside this movieclip is where I want to throw the movieclip for thumbnails to load on. The menu movieclip is working fine and whatnot, but I cannot figure out how to get the thumbnails to load inside that second movieclip.

Here is a chunk of my code:


Code:
function createThumbnailScroller(current_mc, currentThumbFile, thumbCenter) {
thumbnail_scroller.createEmptyMovieClip("t"+current_mc, thumbnail_scroller.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+20)*current_mc;
target_mc.pictureValue = thumbNumb[current_mc];
//trace(thumbNumbforJS[current_mc]);
target_mc.onEnterFrame = function() {
thumbWidth = target_mc._width;
};
target_mc.onRelease = function() {
//tell JS to jump to that slide
flash.external.ExternalInterface.call("jumpToSlide", thumbNumbforJS[current_mc] )
//set scroller movieclip back in its original position (go back to main screen)
yVal = 362;
scroller_move();
};
target_mc.onRollOver = function() {
fadeDown(this);
};
target_mc.onRollOut = function() {
fadeUp(this);
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(currentThumbFile, "thumbnail_scroller.t" + current_mc);
}

"thumbnail_scroller" is the movieclip which is inside of "scroller", the menu movieclip.


Thanks...

Detecting Duplicated Movieclips
hey,
when you duplicate a movie you have to give it a new name and a depth...
the problem is to talking to this duplicated movieclips
ex:
amount = 25;
while (amount>0) {
duplicateMovieClip (mc, "mc"+i, i);
i = i+1;
amount = amount-1;
}

How Do I Remove Duplicated Movieclips
Here's the problem.

I have a 2 frame movie. The first is a welcome type of page. The second has a feature where the user can duplicate a variety of different movie clips and move them about etc.

However, when the user goes back to the first frame, all of the duplicated clips created in the 2nd frame are still there.

How can i make tham go away?

Masking Duplicated Movieclips
I am having trouble creating masks for 10 duplicated movie clips

i only want to mask a very small area, i am immitating the effect of about 10 movieclips moving up or down, the problem is the movie clip has no solid colored areas.

I need a way to hide the movieclip as intt moves to the border that i do have

i have tried duplicating a movieclip drawn to the border i wanted
and duplicating it for each of the mc's i want to hide as they move.

and then setting the duplicated masks for each of the movie clips
but it doesn't work i can still see the mc's move and be under the border.


any help would be greatly appreciated
thanks

Masking Duplicated Movieclips
Please help, I've looked at loads of similar problems on the forums but can't quite get mine right.

I have a movieclip which contains some dynamic text fields. This movie clip gets duplicated x amount of times (depending on the number of variables in the text field).

I originally tried just masking the layer with the original movieclip on, but that just didn't work at all and movie ran as normal.

I have tried embedding a mask within the movieclip to be masked, but that was just stupid cause the mask moved with the movieclip!

I have tried making another movieclip exactly the same size as the original and positioning it above the original then using .setmask but for some reason thats just duplicating the movie and not making it a mask (so I have a big rectangle duplicating on my screen).

code i'm using at the mo is: -

for (i=0;i<my_array.length;i++){
duplicatemovieclip ("mymovie", ["mymovie"+i], i)
duplicatemovieclip ("mymask", ["mymask"+i], i)
_root["mymovie"+i]._y = (_root.mymovie._y)+21*i;
_root["mymask"+i]._y = (_root["mymask"+i]._y)+21*i;
_root.setmask(["mymask"+i]);
}

If someone can please tell me what i'm doing wrong i'd be soooo grateful! Cheers

Controlling Duplicated Movieclips
I inserted a movieclip in "FRAME 1"

This movie clip contains a figure moving using a motion tween. When the motion ends, i put a stop();

Its instance name is mask.


I want to duplicate six times. I want to duplicate it each 3 frames.

So I did this:



In "FRAME 1" I initializated the variable:

i = 1;


In "FRAME 5" I duplicate mask once, usign the following code:

duplicateMovieClip("mask", "mask"+i, i);
i++; // I increase i by one, to count how many times mask has been duplicated


In "FRAME 6" i check how many times mask has been duplicated.

if (i >= 6) {
gotoAndPlay(10); // stop to duplicate
} else {
gotoAndPlay(2); // go and duplicate mask again
}

Finally, in "FRAME 10" I have my 6 duplicated movies:

mask
mask1
mask2
mask3
mask4
mask5


I "FRAME 20" i want to change the position of all these movies.

I want to change the position of all the movies one by one and play them again. I want the main timeline go 3 frames and then move and replay a duplicated movie.

The dull solution is put in each 3 frames the following instruction:

maskn._X = 120;
maskn.gotoandplay (1);

where n corresponds to the number of the duplicated movie.

For example:

In "FRAME 23" I should put:

mask._X = 20;
mask.gotoandplay (1);

In "FRAME 26" I should put:

mask1._X = 20;
mask1.gotoandplay (1);

In "FRAME 27" I should put:

mask7._X = 20;
mask2.gotoandplay (1);




But I want to create a loop that moves the movies one by one, similar as the loop which creates them.

HOW CAN I CREATE THIS LOOP?

I have troubles referring the movieclip and get acces to its properties...

I have tried:

"FRAME 23"
i = 1; // i restart the variable, so i start moving the first duplicated movie clip


"FRAME 25"

In this frame i have no idea how to refer to the movie clip

a.
I have tried

"mask" + i._x = 120;
"mask" + i.gotoandplay (1);

or

"mask" + "i"._x = 120;
"mask" + "i".gotoandplay (1);

or

mask + i._x = 120;
mask + i.gotoandplay (1);

IT DOES NOT WORK

b.
with (mask + i) {
_x = 120;
gotoandplay (1);
}

or

with ("mask" + "i") {
_x = 120;
gotoandplay (1);
}



or

with ("mask" + i) {
_x = 120;
gotoandplay (1);
}

c.
pelicula = mask + i;

pelicula._x = 120;
pelicula.gotoandplay (1);

or

pelicula = "mask" + i;

pelicula._x = 120;
pelicula.gotoandplay (1);


NONE OF THESE WORK.....


"FRAME 28"

if (i >= 6) {
gotoAndPlay(30); // stop to duplicate
} else {
gotoAndPlay(25); // go and duplicate mask again
}


"FRAME 30"
stop();

Create New Row For Duplicated Movieclips
k, i have a script that duplicates a moviclip 'item' yada yada.

code:
i=1
while (i<20){
duplicatemovieclip(item, "item"+i, i);
_root["item"+i]._x = 50*i;
_root["item"+i]._y = 0;
i++;
}


duplicates movieclip item setting xpos as 50*i each time. This produces a row of duplicated clips. Now i want to limit the rowlength to only 4 movieclips, and then start a new row.

code:
i=1
while (i<20){
duplicatemovieclip(item, "item"+i, i);
if(i<5){
_root["item"+i]._x = 50*i;
_root["item"+i]._y = 0;
}else{
_root["item"+i]._x = 50*i;
_root["item"+i]._y = 50;
}

i++;
}



this works for making the first row 4 movieclips and then putting the rest on a new yposition row. But i cant make it work for additional rows.

This is probably not the best way to do it... would you use an arrayor something?

Scrolling Duplicated Movieclips
Hey Guys,

I have a problem! I have a moviclip with 6 rows that needs to be duplicated everytime i scroll up or down depending on the amount of rows in a seperate text file! Is this possible? If it is possible can someone help me out please?

wlsn18

HitTest With Duplicated MovieClips
Hey I'm stuck!

I am making a shooter game and the bullets are duplicated movieClip and the monsters are also duplicated movieClips so how do you do hitTest with them? I can do it with one duplicated movieClip and then other static clips cause I can put this.hitTest(monster) but what if the monster also has a dynamic name?

Hugs for any help on this

[F8] How Can I Get Control Of My Duplicated Movieclips?
This is my problem: it wont work!

code for scene1:


Code:
fire=false;
counter=0;
cannon.onEnterFrame=function() {
var dx=_xmouse-this._x;
var dy=_ymouse-this._y;
var radians=Math.atan2(dy,dx);
degrees=radians*180/Math.PI;
this._rotation=radians*180/Math.PI;
//points at your mouse.

if (fire==true) {
duplicateMovieClip(shell,shell+counter,counter++);
shell._x=this._x;
shell._y=this._y;
shell._rotation=this._rotation;
}
}
onMouseDown=function() {
fire=true;
}
onMouseUp=function() {
fire=false;
}


code for the shell movieclip (the bullet):


Code:
onClipEvent(enterFrame) {
xd=5*Math.cos(this._rotation/180*Math.PI);
yd=5*Math.sin(this._rotation/180*Math.PI);
this._x+=xd;
this._y+=yd;
}


code for an enemy:


Code:
onClipEvent(enterFrame) {
if (this.hitTest(_root.shell+counter)) {
this.gotoAndStop(2);//destroyed.
}
}


why doesnt this work???

Please help...

Hittest For Duplicated Movieclips
Could someone please tell me how to have a hittest for duplicated movieclips. I got it to detect a hit from the original movieclip, but not the ones that spawn off of it. My function renames the original movieclip+1. For example: flying_mc, flying_mc1, flying_mc2 ect...

Thanks

Duplicated MovieClips As Masks?
I want to duplicate a movie clip (multiple times), and use the resulting duplicates as a mask for artwork on the layer below.

The way I've tried to set this up is like this: I put my original MC on a layer, and set that layer as a mask. I put the layer below as masked. Then I duplicate my movie clips per action script. Predictably, this didn't work (I thought it sounded too simple).

Does anyone know if this is even possible? That is, can I create multiple objects on the stage and have them all work as masks on a single layer of artwork?

Is Masking The Duplicated Movieclips Possible?
I ve got a mouse trail, I would like to mask all the trails to a image, is it possible masking the duplicated movieclips (that come as trails) to a image that is below ?? using set mask()?? as for me only the actual movie masks the image but not the duplicated ones, unfortunately. can anyone help plz. below is the code i ve used.

var a:Number=0;

onEnterFrame=function():Void{
a+=1;
duplicateMovieClip(mcAni,"mcAni"+a,a);
img.setMask("mcAni"+a);
if(a>36){
removeMovieClip(mcAni)
a=0;
}
mcAni._x+=(_xmouse-mcAni._x)/15;
mcAni._y+=(_ymouse-mcAni._y)/15;

}

Searching For Duplicated Movieclips
Hi everybody,

I have several movieclips on stage, all of them an instance of the same movieclip (they were created using duplicateMovieclip, and the number of mc created varies each time). In each mc there is a textfield called mt. I would like to "search", using code, for the last duplicated movieclip, and change the text in the textfield. The movies are named mc1, mc2, mc3, etc.

Can anyone help me figure out how to create a code for this?
Thanks a lot

This is the code I have been using, but it changes the text in all the movies.


Code:
for (var mcs in _root) {
if (typeof _root[mcs] == "movieclip") {
_root[mcs].mt.text="Last movie"
}
}

Addressing Duplicated Movieclips
Is there (or what is the) best method to address duplicated movieclips?

For example if you duplicate a number of movieclips (or attach or anything else) through a for loop and give them names like mc1, mc2, etc, how can you address them outside the loop? Especially if the number of times you duplicate the clips is read from a file which can change constantly.

Example - an image gallery where you just add the files to your xml and they show up in the gallery.

Masking Duplicated MovieClips
I'm working with a holiday card and can't figure out how to mask the snow that I've generated. Can anyone help with some examples or information on where to figure this out? Thanks.

Is Masking The Duplicated Movieclips Possible?
I ve got a mouse trail, I would like to mask all the trails to a image, is it possible masking the duplicated movieclips (that come as trails) to a image that is below ?? using set mask()?? as for me only the actual movie masks the image but not the duplicated ones, unfortunately. can anyone help plz. below is the code i ve used.

var a:Number=0;

onEnterFrame=function():Void{
a+=1;
duplicateMovieClip(mcAni,"mcAni"+a,a);
img.setMask("mcAni"+a);
if(a>36){
removeMovieClip(mcAni)
a=0;
}
mcAni._x+=(_xmouse-mcAni._x)/15;
mcAni._y+=(_ymouse-mcAni._y)/15;

}

[help] How To Count Duplicated MovieClips?
This might be the silliest question ever, but please bear with me, as I am new to AS.
I was wondering if it's possible to do some sort of count to see how many "duplicate Movie Clips" there are on the stage at a certain time.

So I have AS that duplicates a certain movie clip, I then need to know at a specific time how many of those duplicate movie clips are currently on the screen/stage.

I hope you understand. I would be really grateful for any help.
Thanks!!

Targeting Duplicated Movieclips
i'm drawing (based on an elipse) and using this code:
    duplicateMovieClip(ponto, "ponto" + i, this.getNextHighestDepth());
i varies from zero to 359, so how can i target every (or any) of the recent created mcs?
my prob is the duplicated movie clip's name! how to write it?
if i use ("ponto" + i) i get a String, not my mc.
Any help would be apreciated!
TiA

Adding Variables From Duplicated Mc's
ok so i'm using MX but developing for 5.
what I'm trying to do is create a flash form for media buys.
the row of input text is a mc and when you hit the + button it duplicates for the next set of info.
At the bottom is a TOTALS list that needs to calculate all the costs above and keep updating each time new info is added.

can someone please help me out with this? I don't know how to script in how to keep adding new mc's into the totals section.

I hope I'm being clear enough and if not please ask me for more details. I'm semi-desperate

you can
get the zip file here
or
get the fla alone
or
get the swf alone

and Please email me at brad@goofydawg.com if you have comments/answers
AIM: BradFlower
ICQ: 11767987

THANKS to all for even looking at this... DOUBLE thanks if you help!!!

Dynamic Links In Duplicated MovieClips
hi there!
i have a project where i want to have different mcs generated with "duplicateMovieClip". but every mc is supposed to have its own link or action assigned.
i'm thankful for any ideas/ hints...
thanks and peace, kolt

Duplicated Movieclips +instance Names
I have created a file that duplicates movieclips on a button press- automatically giving them the instance names mcname1, mcname2 and so on.
The problem is, that I want a piece of code that referrs to all of the newly created movieclips.. eg

(if (_root["mcname"]+1to14._x == _root.anothermovieclip._x ..blah

What can I put after the original movieclip name that covers all the new clips mcname1 right up to the maximum allowed mcname14 (which should probably go where I put +1to14). Is there a function that you can use that selects all movieclips with the name "mcname*".
I'd appreciate the help of anyone that understands what I'm talking about!!

Cheers.

How To Prevent Unloading Duplicated MovieClips?
Hi Guys!
I got a problem in my little flash thingie.
I have got a movieclip "cross_0" in the second frame i duplicate it("cross_1","cross_2" ...) and after getting some userinput, the root changes to third frame. the duplicated movieclip unloads, only the original "cross_0"
remains. what am i supposed to do to stop them from unloading?
thx in forward

Collision Detection In Duplicated Movieclips With Themselves
Hi,
Can you just tell me how to find collision detection in duplicated
movies with different instances of the same.
zab

Pass Variables To Duplicated Movieclips
hi, i have a problem with a template i am making, the use of it is to load a timer for a cyber cafe, but i want it to load as many buttons as i say in a txt file, everything is ok up to the point where i want to give each button a number, the main button has a text field where i want the number, but i have noticed that if i give any created instance a variable number, the rest get the same, any idea of how can i get around this?
here's the code i used, but i don't know what can i do next.

loadVariablesNum("data.txt", 0);
_root.onEnterFrame=function(){
for(i=2;i<varcabs;i++){
duplicateMovieClip(mc1,"mc"+i,i);
setProperty ("mc"+i, _x, (31*i)-6);
setProperty ("mc"+i, _y, 362);
}}

maybe if someone wants to check the fla...

[MX04] Formating Duplicated Movieclips
Hi all,

I am using the following code to duplicate a movieclip (itemInstance) and get them to stack one below the other.

Code:

// get position of template movie clip
yPos = getProperty("itemInstance", _y);

// iterate over array elements
for (i=0; i<(names.length-1); i++) {
// clone movie clip and name it
duplicateMovieClip("itemInstance", "itemInstance"+i, i);
// set position
setProperty("itemInstance"+i, _y, yPos+i*108);
}

This works fine, but I want it to stack 10 vertically and then go right 300px (or so) and then go back to the top and stack another 10. And so on, like bricks in a wall.

Just so you know the number for 'i' is dictated by the number of names in a database.

Code help would be great but even just a push in the right direction!

Many thanks

[F8] PLEASE HELP Really Stuck - Communicating With Duplicated MovieClips
Hi,

I've been trying everything I can think of to get this fairly basic flash movie working but to no avail!

I've created a tsunami menu made up of duplicated menu items. Each menu item should have a rollover and selected state of 240% which works fine. My problem is that I also want the movie to loop showing an example of each of the different menu item categories if the user has not yet interacted, so that when each category is shown, the matching menu item scales to 240% then scales back and moves onto the next category.

I'm thinking I could reference the level each movie clip is on or something. How would I reference it? I really dont have a clue. Any help would be very much appreciated.

I've attached my source file in case it helps to clarify.

Thanks

Joanna

[CS3] Control A Series Of Duplicated Movieclips (AS2)
Hello,

I am trying to control a duplicated MC using actionscript 2. The duplication and everything is fine, but I need something that will account for the different instances (so that the hitTest will work on the duplications).

Here is the code, any help would be really appreciated
---

escaped = 0;
forked = 0;
forkx = 25;
forkspeed = 300;
beanspeed = 10;
i = 2;

fork.onEnterFrame = function() {

if (Key.isDown(Key.RIGHT)) {
fork._x += forkx;
}
if (Key.isDown(Key.LEFT)) {
fork._x -= forkx;
}
if (Key.isDown(Key.DOWN)) {
fork._y += forkspeed;
} else {
fork._y = -137.9;
}
if (fork._y>=4.1) {
fork._y = 4.1;

}

if (_root.bean.hitTest(_root.fork)) {
forked = forked+1;
bean._x=0;


i = i + 1;
duplicateMovieClip (_root.bean, "bean" + i, i);

}

if (_root.bean.hitTest(_root.jar)) {
escaped = escaped+0.25;

}
};

Many Thanks,
David

Registration Point Of The Duplicated Movieclips
Hi all,

I am duplicating a movieclip that has another movie clip inside it. After duplication I replace the image of the second movie clip. The image is shown correctly but the registration point of the main clip seems to go default, top left, even in the original clip it was in the middle. So the clip looks missplaced.

Is there a way to keep the registration point from the original clip when duplicating?

Thanks.

Individual Actions To Duplicated Movieclips
I have a movieclip that contains a button, and is duplicated a variable number of times. I now need to make each of these buttons load a different jpg file (1.jpg, 2.jpg, 3.jpg, etc.) by using loadMovie, when clicked. how can I assign this action to each duplicated MC??


Thanks

Targeting Random, Duplicated Movieclips
I an going to be trying to create a dynamically created menu using duplicated movieclips that trail the mouse. when the user moves the mouse movieclips are left as a trail. When the user clicks a button, random movieclips that were laid down will become menu items. My problem is, is how do you tell the action to select 3 random movieclips from what is already laid on the stage. Depending on where the mouse is moved on the stage, or how long it's moved around on the stage will determine how many instances there are on stage, so you could have very few to very many instances to choose from. I already have the action to duplicate.

this is abbreviated:

i=1
duplicate "clip"+1
i=i+1

You get the idea. So that means that the clips are going to be named, clip1, clip2, clip3, etc...

How do I target the highest number clip so that I can generate a random number from it.

Thanks for your help

Moving Multiple Duplicated Movieclips
My game creates 12 (or so) movieclips that are duplicated from the main movieclip called "monster_mc". Each movieclip should detect which character (the other three movieclips there each one being a different one wizard_mc, warrior_mc, ranger_mc) is closest to them and then go towards them accordingly.

As of right now they all go after ranger_mc because it is the last one in a series of if statements. How can I stop it from doing that? I've posted my .fla below as well as a picture of how it should work.

The blue dots are the monsters. The one in the left hand corner is showing how it checks to see how close everything else is (using Pythagorean theorem) in comparison to it's current X,Y position. My math checks out but the problem is that it's reading from one Movieclip and that shouldn't be happening.

Thanks for the help.

Argh Duplicated Movieclips Disappear
Hi people!
Somehow in every game I tried to create, my duplicated movieclips dissapear as new movieclips are created. It happens randomly.
So sometimes when new duplicates are created it goes well, but other times older created movieclips dissapear.

This is the code I use:

Code:

onClipEvent(load) {
i = 1;
a = 1;
}
onClipEvent(enterFrame) {
rand = Math.round(Math.random()*60);
if (rand == 12) {
i++
duplicateMovieClip("_root.dummy", "dummy"+i, i);
_root["dummy" + i]._x = 660;
_root["dummy" + i]._visible = true;
}

Arand = Math.round(Math.random()*90);
if (Arand == 12) {
a++
duplicateMovieClip("_root.carrie", "carrie"+a, a);
_root["carrie" + a]._x = 660;
_root["carrie" + a]._visible = true;
}
}
Any help would be appreciated!! Thanks in advance!!

Making Duplicated Movieclips Into Buttons
How can I get my movieclip which has been duplicated to act as a button? Neither of these seem to work:

Code:
"thumbContainer"+nextPicture.onMouseDown = function(){
trace("Clicked")
}

Code:
currentButton = "thumbContainer"+nextPicture
currentButton.onMouseDown = function(){
trace("Clicked")
}
It doesn't work with onRollOver either. Is the first way an ok way to reference it? As in, will having the instancename made up of two parts make a difference? Also, I don't know if any of the following make a difference, I don't know:It's got a jpg loaded into it already
It's part of a for loop that duplicates a load of them, they all need the same code.
I forgot the other thing I thought of.
I@m sure this is something really stupid, but I can't figure it out right now.

Vertically Align Duplicated Movieclips
Ok this is driving me nuts.

Each duplicated clip is a different height to fit some xml text.

How do I vertically space out the duplicated movie clips so they don't overlap?


Code:
result_mc.duplicateMovieClip("mc" + i,i);
result_mc._visible = false;


//Y Placement

this["mc" + i]._y = ((s) * (this["mc" + i].resultBg._height + spacing)) + (result_mc._y);
s++;

//Scale result's box to fit text

if (this["mc" + i].description._height >= this["mc" + i].resultBg._height) {
this["mc" + i].resultBg._height = (20 + this["mc" + i].description._height + this["mc" + i].title._height);
}
The equation under Y Placement is wrong. any help?

Argh Duplicated Movieclips Disappear
Hi people!
Somehow in every game I tried to create, my duplicated movieclips dissapear as new movieclips are created. It happens randomly.
So sometimes when new duplicates are created it goes well, but other times older created movieclips dissapear.

This is the code I use:

Code:

onClipEvent(load) {
i = 1;
a = 1;
}
onClipEvent(enterFrame) {
rand = Math.round(Math.random()*60);
if (rand == 12) {
i++
duplicateMovieClip("_root.dummy", "dummy"+i, i);
_root["dummy" + i]._x = 660;
_root["dummy" + i]._visible = true;
}

Arand = Math.round(Math.random()*90);
if (Arand == 12) {
a++
duplicateMovieClip("_root.carrie", "carrie"+a, a);
_root["carrie" + a]._x = 660;
_root["carrie" + a]._visible = true;
}
}
Any help would be appreciated!! Thanks in advance!!

Creating New MovieClips With Duplicated Clips
I want to create a new movie clip on the fly with pre-existing duplicated clips. Is there a way to do this with attachMovie() or something similar?

Average Percentage Of All Duplicated Movieclips
I'm creating preloader for each duplicated movieclip which is loading external file. I need a average percentage of all duplicated movies.

Lets suppose if there are 15 files loading dynamically, then I need to show overall percentage "15%, 50%...." of all duplicated movie clips.

Below is the sample code for duplicating and loading file.


ActionScript Code:
_root.holder["prenext" + s].onEnterFrame = function ()
{
this.loadedb = _root.holder["nextpic" + this.s].getBytesLoaded ();
this.totalb = _root.holder["nextpic" + this.s].getBytesTotal ();
this.percent = Math.round (this.loadedb / this.totalb * 100);
                   
this._xscale = this._xscale + (this.percent - this._xscale) / 10;
                                if (this.percent == 100)
                                {
                                this._xscale = 100;
                      this.onEnterFrame = false;
        }
};

Problems About Menus With Duplicated Movieclips
i dowload menus like: 3d spiral menu, from ultrashock an locks very nice but this kind of menus are maded with only one movieclip duplicated so how i can use that kind of menu? i cant change text or urls because the same change will be in all the elements, or may be i am loosing something, any idea?

Adding Actions To A Duplicated Movieclip
Hi

I have to duplicate a rectangle movie clip that I have and then put different actions on them. My code can't seem to do it. It doesn't even do the onLoad function... Help me please. Thanks


Quote:





// this is on frame 1

_root.speed = 10;

// duplicate the rectangle which is outside the stage
rect.duplicateMovieClip("rect1",1,{_x:400,_y:350}) ;

_root.rect1.onLoad = function() {
oldX = this._x;
oldY = this._y;
toX = 150;
toY = 150;
}

_root.rect1.onEnterFrame = function() {
this._x += (this.toX-this._x)/_root.speed;
this._y += (this.toY-this._y)/_root.speed;
}

stop();

Copyright © 2005-08 www.BigResource.com, All rights reserved