Square Duplication / Disposition Problem
Hello all.
Can you guys help me to sort out this little problem i have!! wich is the best approuch to do the following..
i have my stage ( 640 x 480 ) and i have one MC in my library that will be my square that i want to display on the stage.
what i want is... propagate this "square" in my stage.... with the best porportion i can have.. for instance...
1 element will render 1 square with stage size 2 elements will render 2 square (side by side) 3 elements will render 3 squres ( 2 on one row, 1 on the next row ) 4 elements : x x x x
5 elements: x x x x x
6 elements x x x x x x
7: x x x x x x x
... 10: x x x x x x x x x x
the goal is to make a grid of thumbnails with the same size disposed on the stage
Best regards, Bruno
Ultrashock Forums > Flash > ActionScript
Posted on: 2006-12-04
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
MovieClip Duplication Deletes Previous Duplication
I have created 2 instances of a movie clip based button inn_btn and out_btn.
They are both contained in the same movie clip to which the following code is attached. The code duplicates the buttons in a column but as each of the out_btn buttons is deletes the inn_btn one that proceeds it. If I remove all the references to the out_btn one, all the inn_btns duplicate and work fine. If I keep the code in for the out_btns, all the out_btns appear and work fine but only the original inn_button is present. I've stepped it through and seen each inn_btn get deleted as the out_btn is created. I've tried lots of variations on this all with the same results.
I am fairly new to action script but doing lots of learning!
ActionScript Code:
onClipEvent (load) {
trace("Main init");
var inSel = 0;
var outSel = 1;
numButtons = 9;
vSpacing = 22;
//duplicate buttons
for (i=0; i<numButtons; i++) {
if (i != 0) {
inn_btn0.duplicateMovieClip("inn_btn"+i, i);
this["inn_btn"+i]._y += i*vSpacing;
out_btn0.duplicateMovieClip("out_btn"+i, i);
this["out_btn"+i]._y += i*vSpacing;
}
this["inn_btn"+i].onPress = function() {
trace(this._name);
};
this["out_btn"+i].onPress = function() {
trace(this._name);
};
}
}
How Do I Cut A Square Out Of A Larger Square Using Actionscript
I want to use actionscript to draw a square in a larger square that appears as a hole or window in the larger square. I know how to use AS to draw a square, but I can not seem to find a way to cut one square out of another. Does anyone know how to do this?
Duplication
I have this simple code but it just wount duplicate
Code:
onClipEvent (enterFrame) {
x=_root._xmouse;
y=_root._ymouse;
_name="circle"+i;
duplicateMovieClip ( "circle", _name, i );
_root[_name]._x=x;
_root[_name]._y=y;
_root[_name]._xscale=x;
_root[_name]._yscale=y;
_root[_name]._rotation=x*y;
i++;
}
Duplication Var
Right, I'm a wee bit stuck!
I'm trying to create a movie with 6 draggable MC's and 2 target areas. Each MC has a different numerical value.
I want the user to try out different combinations of MCs in the target areas and see the total of the two MC's within the target areas in a text box by pressing a calculate button.
I want to calculation to work even when only one target area is filled by a movie clip.
can anyone help?
Maybe a few keys: DuplicateMovie etc? Please help
Self Duplication
I need to be able to click on a movie clip, and then reproduce that movie clip on screen, and if I click the same movie clip again, that another duplicate is produced.
Is this possible?
Duplication
I have a duplicated movie and I can't seem to make it do what I want.
Heres what I have, a movie clip that has been duplicated 3 times
----------------------
movie1-(instance name movie1)
movie2-(instance name movie2)
movie3-(instance name movie3)
----------------------
I also have a button that has been duplicated 3 times
----------------------
button1
button2
button3
----------------------
The button Code
----------------------
on (release) {
if (this.url.indexOf("|")>0) {
var z = this.url.split("|");
_root[z[0]].gotoAndPlay(z[1]);
}
}
----------------------
The Array Code
----------------------
linkArray =
[["movie1|1"],
["movie2|1"],
["movie3|1"]];
myMenu["holder"+k]["menu"+m].url = linkArray[k][m];
----------------------
----------------------
What I want to do is if you click button1, movie1 plays if you click button2, movie2 plays and it you click button3, movie3 plays. A problem I'm have is I don't know how to make a specific movie clip play when the movie clip is being duplicated. Another problem is I have to put the movie clip in with the main button and I can't seem to target the movie clip when it is inside another movie clip.
----------------------
Take a look at the menu
http://www.medeirosdesign.com
Download the file
http://www.medeirosdesign.com/Menu.fla.zip
Duplication
whats the best way (in your opinion) to duplicate a movie clip? and how would i hit test with the duplicated object?
MC Duplication
hello,
ive noticed that when you duplicate movie clips, you are able to set that depth of the MC, but on what layer is it produced?
can you assign on what layer it goes?
thx !!
Duplication.
I'm making a game where you can fire bullets, but so far all that happens is I fire the bullet and then I have to wait for it to end so I can fire another one. How can I duplicate the bullet so I can fire it more?
[F8] Duplication
I had somebody work on my site with me, as I am not exactly a pro at flash. The problem is I am trying to add a new page and can't really figure it out. I am a photographer. On my site, I have three galleries. I just wanted to see if there was an easy way to duplicate the page so I could add another gallery. You can check out my site at www.BradChristopher.com I would be so greatful to anybody who could help me out. It is very detrimental to my career right now.
Duplication Help
I was just playing around with the duplicate movie command and I ran into a problem. It deletes some of my earlier instances when I press the button. I have attached the fla. I think it has something to do with the level I load it on but i am not sure. Any help appreciated. Thanks.
Duplication/setProp Help Please
I am trying to get a script to duplicate a movieClip to form a grid of items according to the number of elements in an XML doc. the duplication work perfectly but I cant get the spacing to work.it will make the first row of four MC's and then places all the rest directly beneath those. I am really frustrated andf any help would be great. Thanks everyone!
---------------------code----------------------
//functions
function getLoaded(success){
productCount=xmlObj.firstChild.childNodes.length
for(i=0;i<20;i++){
nodeObj=xmlObj.firstChild.childNodes[i]
duplicateMovieClip(gallery.pic,"pic"+i,i)
set("gallery.pic"+i+".picName",nodeObj.attributes["name"])
for(k=0;k<productCount;k++){
if(horiz==4){
setProperty("gallery.pic"+k,_y,startY*(height*20))
setProperty("gallery.pic"+k,_x,startX)
horiz=0
}
setProperty("gallery.pic"+k,_x,startX+(horiz*(widt h+5)))
setProperty("gallery.pic"+k,_y,startY)
startY="gallery.pic"+k._y
testX=gallery.pic18._x
testY=gallery.pic18._y
horiz++
}
}
}
//INIT Vars (duplication and lable set)
dupCount=0
countX=0
countY=0
width=gallery.pic._width
//grid Vars
horiz=0
rows=0
width=gallery.pic._width
height=gallery.pic._height
startX=gallery.pic._x
startY=gallery.pic._y
//meat
stop()
//XML
xmlObj= new XML
xmlObj.load("mydoc.xml")
xmlObj.onLoad=getLoaded
=============================================
Movie Duplication
I have a button on stage. On Press it duplicates a MC (instance name dragme) 20 times, adding variable "a" to the instance name to give a unique instance name.
Then it should move each separate instance of the MC by 20 pixels.
On Release it should remove the instances again.
Here's the code:
----------------
on (press) {
startDrag ("_root.dragme" add a, true);
set (a, 1);
while (a<=20) {
duplicateMovieClip ("_root.dragme", "dragme" add a, a);
setProperty ("_root.dragme" add a, _x, getProperty("_root.dragme" add a, _x) + 10);
set (a, a++);
}
}
on (release) {
stopDrag ();
set (a, 1);
while (a<=20) {
removeMovieClip("_root.dragme" add a);
set (a, a+1);
}
}
Got Duplication Done....now To Randomize
Hi guys....long to no see
Got myself some troubles again.
I got this duplication thing going on working like this:
Duplicate Movie Clip ("/blok&name", blok&name, name)
and this going on for like 200 times. with adding 1 to every name with every duplicate.
Now I have about 200 of these mc's on my stage and I want to play them randomly untill every single one is done (the mc is 5 frames, fading out).
How to go about this....thx for the help already
Duplication Question
Ok.
I'm duplicating a MC with
amount = 40;
for (i=1; i<amount; ++i) {
duplicateMovieClip ("mc0", "mc"+i, i);
eval("mc"+i)._x = eval("mc"+(i-1))._x+6;
eval("mc"+i+".num") = i;
}
Duplication Question
Ok., I'm duplicating a MC the question is this the MC named mc has a varible in in named Text, after I duplicate the MC mc how do I set the varible in lets say the 1st thru the 3rd duplicated MC
so if I want to say
"todd" on duplicate 1 // "coker" on dupicate 2// "random" on duplicate 3
How can I talk to specific duplicated MC's ??
Please help
Movie Duplication
on (release) {
duplicateMovieClip ("Line", "Line" add l, l);
setProperty ("Line" add l, _x, Number (getProperty ( "Line" add l, _x ))+Number ( 15+(getProperty ( "Line" add l, _width ) ) ));
l = Number ( l )+1;
}
what is wrong with this script???
when i press the button it duplicates the movie but when i press it secend time it does nothing!!!
i want it to duplicate the same movie on and on but it only duplicate it once.
Duplication Effect
I have this code moving a mc to a target position what I want to do is to have it duplicate itself behind and have the last few fade away like a trail effect . I know its not easy or is it .I have done some duplication before but I dont know the best way to go around the effect I want .
[code]
onClipEvent (load) {
targetx=9;
targety=8;
targetxScale=71.7;
targetyScale=22.8;
}
onClipEvent (enterFrame) {
xdif=targetx-this._x;
this._x+=xdif/5;
ydif=targety-this._y;
this._y+=ydif/5;
scalexdif=targetxScale-this._width;
this._width+=scalexdif/5;
scaleydif=targetyScale-this._height;
this._height+=scaleydif/5;
}
Duplication And Remove
I have a mc called ball and two buttons that one sets a variable active=true; and the the other active =false; then I have a function on the main timeline
[code]function incball () {
if (active) {
for ( i=0; i<20; i++ ) {
_root.ball.duplicateMovieClip( "ball"+i, i );
_root["ball"+i]._x+= i*20;
_root.ball._visible=false;
if (!active) {
_root["ball"+i].removeMovieClip();
_root["ball"+i]--;
_root.ball._visible=true;
}
}
}
}
Duplication And Remove Again
a function on the _root level been called from a mc,clipevent that is triggered from a button either to duplicate or remove
Code:
function incball () {
if (active) {
for ( i=0; i<20; i++ ) {
_root.ball.duplicateMovieClip( "ball"+i, i );
_root["ball"+i]._x+= i*20;
_root.ball._visible=false;
if (!active) {
_root["ball"+i].removeMovieClip();
_root["ball"+i]--;
_root.ball._visible=true;
}
}
}
}
clipevent
Code:
onClipEvent ( enterFrame ) {
if (_root.active) {
_root.incball();
}
}
button says _root.active =true and the remove button says _root.active=false;
The problem is in the remove code it just doesn't remove I want it to remove back to its original state of one clip [/b]
Duplication And Remove HELP
Please help this is driving me mad . I have a function that is been checked from a mc to see if the button is clicked if it is it says active and it duplicates the ball mc if the other button is pressed it says active= false and it should remove the clip set in the function but it wont this is driving me mad.ddddddd
[code]function incball () {
if (active) {
for ( i=0; i<20; i++ ) {
_root.ball.duplicateMovieClip( "ball"+i, i );
_root["ball"+i]._x+= i*20;
_root.ball._visible=false;
}
} else {
removeMovieClip (_root["ball"+i]);
_root["ball"+i]--;
_root.ball._visible=true;
}
}
Duplication Prob
hey guys i just found a bug in the next code:
pro = {xp:630, mmbdup:7, mtbdup:6, dbb:22.5};
alpha = Math.floor(Math.random()*60)+20;
mmb1.fill._alpha = alpha;
for (i=2; i<=pro.mmbdup; i++) {
duplicateMovieClip(_root.mmb1, "mmb"+i, i);
alpha = Math.floor(Math.random()*60)+20;
_root["mmb"+i].fill._alpha = alpha;
}
_root.mtb1.endx = pro.xp;
for (i=2; i<=pro.mtbdup; i++) {
duplicateMovieClip(_root.mtb1, "mtb"+i, i);
pro.xp -= pro.dbb;
_root["mtb"+i].endx = pro.xp;
}
the bug is in the duplication depth. since it places 2 objects in the same depth and it writes over the old object it makes i duplication all 6 and the other only 2.
is there a way to fix this without using an external var that will inc a depth count???
is there a way without using external var???
Random Duplication
can anyone show me a bit of code that shows how to duplicate a movie clip every time a button is pressed. Eg. when i click a button a circle appears, and when i click it again, another appears but with a random offset (like 5 pixels left of the previous one)
Cheers!
Scene Duplication?
This is crazy.
I imported the MC of a scene that someone did into my library. This one scene however, is like over 300 kb because it's got all the cool effects & stuff.
So I can actually preview it in the library too. The second I attempt to drag it to the stage of my animation ... it all crashes! I've tried it on 2 different, powerful computers too.
What should I do? This extra scene really needs to be added to the animation I've already completed.
OH! And I tried copying layers upon layers of frames and pasting. Because this ani scene is so complex and includes all sorts of masks, etc....it totally screwed it up and would be quite a bit of work to fix. I've wasted 2 hours fooling with it!
Does anyone have any advice to give?
Thanks!
(urgent)
Duplication Question.
Ok, I can duplicate a Movie Clip just fine, I'm using the code
code: if (i<20) {
box.duplicateMovieClip ("box" + i, i)
}
i++
So this gives each created box a name of box1, box2, box3, etc. Now how can I move all those boxes at once without actually putting a line of code for each box? Any ideas here would be great because this is really bogging me down.
Loading MC Duplication?
Hi All,
I designing a "loading bar" that grows while the clip is loading, but also has those semi-transparent angled bars moving from left to right as well on top. Is there a way to move these angled bars across using actionscript and a movie clip?
For example, could I animate just one of those angle bars moving in its own movie clip then have some actionscript duplicate it, one by one, a second or so apart until the movie is loaded? Or would it just be easier to draw a long line of them and animate with a tween and mask?
Thanks in advace
Duplication Level
Hi everyone,
ok im having some trouble with a movie that im making.Ok i have a global variable called"N" set to 70.
i have a movie clip on the main stage called "Ninja" and on this ninja movie clip i have the following code: code: onClipEvent (enterFrame) {
if(this.hitTest(_root["mc"+90])){
this.gotoAndStop(75);
_root["mc"+90].gotoAndStop(21);
if (N>=70 && N<=89) {
duplicateMovieClip(_root.Ninja, "NMC"+N, N);
N++;
}else {N = 70;}
}
}
so i want every time the movie clip is hit to duplicate its self between the levels 70 - 89 so there will never be more than 19 instances on screen. i know the hit part works because it is sending the ninja movie to frame 75 as stated. However it is duplicating the movie always to layer 70 and not incrementing thus deleting the original movie on layer 70 so there is only one instance appearing at a time.
also when debugging i get the following results:
Movie Clip: Frame=10 Target="_level0.NMC70.instance33"
Movie Clip: Frame=10 Target="_level0.NMC70.instance34"
so its copying the instance but not assigning a new level
any help would be absolutly great as i havent got much hair left on my poor balding head.
P.S. using MX
Clip Duplication
I want to duplicate an instance (horizontally,maximum 10 duplication)whenever i click a button. The duplication will come randomly.I mean sometime it will show 5 boxes, then 9boxes and so on. Please help.
Thanks
Button Duplication
Hello,
Can anyone tell me how to duplicate a button so that i can change the text and code in the duplicated button? When i duplicate and rename my button and i change something in it it changes both the text and code on the button.
What am i doing wrong?
Cheers!
Button Duplication Help
Hey
I've just built a site for my company and am really new to flash.
I am having difficulty making a simple menu for my website. If you have a look at my menu.fla you can see i have one button that works correctly but i am unsure as to how i can duplicate the button so that the same flash plays (ie the blinking) but the link and button text changes. Can anyone help?
Thank you in advance.
Pete
Randomization And Duplication.
lets say I a have an MC called bullets, and I want it to duplicate and appear in a random location. How would I do that?
Laser Duplication
You guys were very helpful with my last problem, but now i have another.
Basically, My game consists of a spaceship that fires a laser at a blue circle. I want the circle to unload when hit by the laser, but it wont. Here is my code:
On spaceship:
onClipEvent(load){
moveSpeed=10;
_root.laser._visible=false;
laserCounter=1;
speedX=8;
speedY=8;
}
onClipEvent (enterFrame) {
if(key.isDown(key.LEFT)){
this._x+=-speedX;
}
if(key.isDown(key.RIGHT)){
this._x+=speedX;
}
if(key.isDown(key.UP)){
this._y+=-speedY;
}
if(key.isDown(key.DOWN)){
this._y+=speedY;
}
}
on (keyPress "a") {
laserCounter++;
_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
_root["laser"+laserCounter]._visible=true;
}
on laser:
onClipEvent (load) {
laserMoveSpeed=12;
this._y=_root.ship._y;
this._x=_root.ship._x+40;
}
onClipEvent(enterFrame) {
this._x+=laserMoveSpeed;
if (this._x>800){
this.removeMovieClip();
}
if(this.hitTest(_root.hi)){
_root.gotoAndPlay("scene2",1);
}
}
onClipEvent(enterFrame){
if(this.hitTest(_root.laser)){
this.unloadMovie();
}
}
(using Flash Mx)
THANKS!
I Have A Duplication Problem
Hi,
I hope there is someone out there that can help me understand how to
reference MC's duplicated inside MC's.
OK, here is what I have. I created an empty MC to hold an image that will be
loaded from an XML file. I also created a dynamtic text box in another MC.
This to will be loaded with text coming from the same XML.
The next thing I did was to take those two MC's and put them in a third MC
on own layer. The two MC's are placed side by side. On a third layer I placed
a button which only has the hit area made the rest are blank. I place the
button over the top of the two MC's. This new MC will be used in a forth MC
which will have a duplicate function to create as many dups as needed from
the amount of items in the XML file.
After completing the over all MC which has all the duped MC's in it I load it
into a scrollPlane.
Here is my problem. I can't seem to reference anything inside the MC which
holds the duped MC's to dynamicly fill each duped MC.
IF you know how or know of a tutorial to do this I would greatly thankful.
Best regards
Toby
[F8] Symbol Duplication
I have a flash template that I am working on. In the template I have a gallery that consists of 4 movie clips. I want to add more movie clips which have the same animation as the existing movie clips. When I duplicate the symbol and change the picture it changes the picture in both the duplicate and the original that it was duplicated from. Any help would be greatly appreciated.
Duplication Layers PLEASE LOOK
Hi I found when I randomly duplicate moviclips they lay them selves out over the top so my custom sursor is behind it any idea how to keep the cursor on top?
P.S. The cursor is on the top layer.
[F8] Help With Menu Duplication
Hi there,
I wonder if someone can help me with this problem I have has for the last 24 hrs, I am copying a menu in a flash template.
The menu that I have in the template has 6 buttons and I need 9
I have tried duplicating 3 of the buttons to make up the nine but when I try to edit the 3 additional buttons it also changes the buttons of the ones I have copied, how can I stop this, I know this must be very simple and easy thing to do, but I just need to be poibed in the right direction.
Many thanks in advance to anyone who can help me solve the problem.
Foxconn.
[F8] Duplication/Spawning
Hi I have made a boat sysmbol for a game and I like it to spawn outdie the stage and then slowly move along to the other side. How would I go about doing this?
I'd Apperciate the help .
[F8] Duplication And Moving
Hi heres what I want to do seems pretty simple should be easy for you guys
Ok I have a movie clip called 'boat' and its instances names is 'boat', I want this movieclip to be of screen and, then I want it to spawn on the left side of the stage (500 x 350) !so you can't see it! then I want it to slowly move 4px every frame (Frame rate = 25) and then once it is in the cetre of the stage I would like another to spawn and this to continue, simple?. Give it ago I could do it.
Thx in advance!
[F8] No Insistances Name Duplication
Hey I want to be able to a have a loop which just coniously duplicates the movieclip with (no insistances names) and then moves 1px every frame (frame rate = 25), so you get a contious loop of movieclips passing across the stage. :P
[F8] Timed Duplication.
How do I get it so my duplication code reruns through itself after a certain time I don't want to use frames because it slows the movie down is there a way of doing this without using frames?
Help: Duplication And Collision
I'm trying to make a movie clip duplicate when it collides with something
I have this so far
Code:
onClipEvent(enterFrame){
move();
if (_root.cone_move, hitTest(_root.block))
{
_root.text = "Collision Detected";
duplicateMovieClip (_parent.cone_move, "cone_move"+dupenumber,1);
dupenumber = dupenumber+1;}
else {
_root.text = "No Collision";
}
}
"cone_move" is the movie clip, "block" is what its crashing into.
Ideally i'd like it so each time the movie clip collides, it duplicates, and each dupe acts in the same way.
I'd appreciate anyone's help as i'm some-what of a newbie.
note: made in flash8
Possible Duplication Problem
Hi Guys,
I am not sure if this a duplication problem as such. What I am trying to do is effectively create a dynamic questionnaire. I am creating 'pages' as DisplayObjects, where each page has several child objects (buttons, text, images etc) and the pages as a whole are added/removed from the main timeline DisplayObject when they need to be displayed.
I load all the images I need in at the beginning and once they are fully loaded I add them to the appropriate 'page'. This all seems to work fine. The problem I have is that certain pages are of the same type and thefore require the same images.
So, I add an image to the first 'page', create a second page and then if I want to add an image to the third page that existed on the first, it will only ever appear on the third. In essence I can only use an image I have loaded in once and I need to be able to reuse. Is this something that can be done?
I have tried several of the duplication methods around but none seem to achieve this.
Any help would be appreciated.
Thanks for your time
An Arrow And Duplication
Dear all,
I am new to actionscript and just learning it.
The attached picture verymuch explains my problem. Can I have some directions how to do it or any help?
Shown Ellipses are MCs (MC1_1 and MC1_2) inside another main MC (MC1)
Thanks in advance.
MovieClip Duplication
Hi,
I have a MovieClip, MC1, in the center of my stage. Within this MC I am attaching a lot of other movieclips, applying AS animation, etc.
Now, I am using a reflection look at the bottom as if MC1 is hovering over a shiney surface. Now, all I want at the bottom is a duplicate of MC1 just inverted vertically.
How do I achieve this without coding the MC's inside MC1 and it's reflection? I tried using duplicateMovieClip to no avail.
Thanks!
Steve
Duplication Problem?
Hey all.. wonder if anyone knows why a duplicated movieClip keeps re-using itself when the duplicate function is called? What I want is to duplicate a clip over and over again when an event occurs, but it just keeps re-using itself.. any ideas?
Cheers in advance
Movieclip Duplication
I am trying to make something in which once spacebar is pressed it randomly generates a specific movieclip on the Yaxis, on the right side of the screen. Once generated i want it to tween across the screen and disappear off to the left. Three seconds after that first movie clip is generated, i want the same movie clip to generate again, on the yaxis and tween across the screen. I want this to occur a near unlimited amount of times.
any help would be appreciated. thanks.
MovieClip Duplication Help
I am trying to make something in which once spacebar is pressed it randomly generates a specific movieclip on the Yaxis, on the right side of the screen. Once generated i want it to tween across the screen and disappear off to the left. Three seconds after that first movie clip is generated, i want the same movie clip to generate again, on the yaxis and tween across the screen. I want this to occur a near unlimited amount of times.
any help would be appreciated. thanks.
Duplication Problem
while creating movieclip(var mc:Movieclip= new Movieclip) dynamically in as3, how to duplicate movieclip(mc)
|