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




Attach Vs. Duplicate



Can you not attach a movie clip to a Duplicated MC? It seems that even the simplest of code will not attach a movieclip to a duplicated MC, but will work fine once I change the target to something /non-duplicated/...which is odd.



Ultrashock Forums > Flash > ActionScript
Posted on: 2005-01-24


View Complete Forum Thread with Replies

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

Duplicate Vs Attach
I have a project in which I use the DuplicateMovieClip function. It works, but I think I should have used AttachMovie instead. Is there any way to duplicate a movie into a movieClip? I don't know if I should continue to work with Duplicate or rewrite all the code and switch to Attach. Here are the files:
http://www.trina.net/Test/test2.fla
http://www.trina.net/Test/faces.fla
It is a simple program. I would like to be able to email the created image. To do this I think I need to load the images into a movieClip. Right now they are just duplicated onto the _root level.
Matt

Attach Or Duplicate Or Other
whats the best way (in your opinion) to duplicate a movie clip? and how would i hit test with the duplicated object?

Attach Or Duplicate ?
Hi,

I've got a background that I want to repeat in Y depending of the screen resolution!

So what is the better way to do it, attach from duplicate?

turb

Attach Vs Duplicate?
It just posted this in the wrong forum. It would be better here.
I am designing a flash 5 program and have run into a problem. I began using the duplicateMovieClip function and it works great. However I would like to be able to email an image created using the duplicated (and altered) covie clips. I think that I need to target a movie clip in order to email the specific image. I now think that I should have used the attachMovie function rather than the Duplicate function. I guess my question is: Is there anyway to duplicate a movieclip into a target rather than a level? If you want to look at my fla it is here.
http://www.trina.net/Test/test2.swf
http://www.trina.net/Test/test2.fla
http://www.trina.net/Test/faces.fla

This is not the real project, but a small file size version of it. Basically I woud like to be able to have a user e-mail the image that they create. Currently the duplicateMovieClip function just duplicates the clip to a level. I would like them to be duplicated to the "pad". I am pretty new to flash, and this may be a very easy problem to solve, but I am very frustrated with it. Any help would be great. Let me know if you have any questions about my question. Thanks.
Matt

Array Duplicate/attach MC
5 navigator in the main window and when any of the menu clicked the non clicked menu has to come and merge to the clicked one.
5 navigator has done thru Duplicate/attach MC working fine
while clicking the menu its not merging.


------------------------------------------------------------
Frame 1 consists of the following code: which work fine

menuArray = new Array("About","Q","Third","S","Menu 5");
_root.about.menu = menuArray[0];

for (i=0; i<menuArray.length; i++){
attachMovie(_root.menuArray[0],_root.menuArray[i],i);
var display = this[menuArray[i]];
_root.display.menu = menuArray[i];
eval(menuArray[i])._x = eval(menuArray[i-1])._x + 130;
eval(menuArray[i])._y = + 300;
}
------------------------------------------------------------
Inside the MC the Button Code not working:
on(press){
myX = this._x;

for(i=0 ;i<_root.menuArray.length;i++){
_root.menuArray[i]._x = myX;
}
}
------------------------------------------------------------

Attach Or Duplicate For Game, HELP
Im making a game, the cars move, and when you shoot the car, I want a 'decal' in the form of a movie clip to be attached to the car and move with it. The car is on the main timeline, the shoot will be fired from mouse. lets say the car's instance name is auto_1, and the 'bullet hole decal' has a instance name of "hole" if it matters. How do I attach it to the car?!?!

Duplicate And Attach Movies
I want to duplicate three instances of a movie clip, simultaneously as the movies are duplicated I also want to attach a movie clip on each of them. Is it possible ? can any body show me how to write a code for it.

Attach,Duplicate Or Load?
Hi,
I am having a real dilema with this... I want to have some code on my movie that lets me copy a movie clip more than once AND adds existing variables to each new one... I have tried this so far.


Code:
var n:Number = 1;
var r = _root.getNextHighestDepth();
var c = menuTarget.duplicateMovieClip(circle_mc,"circle"+n+"_mc",r++)


circle_mc.onPress=function(){

_root.menuTarget.c();

_root["circle"+n+"_mc"]._x+=100;

_root["circle"+n+"_mc"]._y+=100;

trace("circle"+n+"_mc");
trace(r);

n++;
r++;
}
I want to be able to take this new movie clip

["circle"+n+"_mc"]

and add a new variable to it...

Am I tackling this the wrong way? Any advice will be gratefully recieved.
Thanks in advance.
Colin.

Attach Duplicate A Movie In A Loop
want to make a raindrop effect, i can attach and 1 movieclip dynamically to the stage,
but i am unsure how to make a lots of duplicates of the raindrops in a loop

blue_box.onEnterFrame = function(){

blue_box.attachMovie("red_box", "newname1", 1);
}


this is the part im unsure about!!

blue_box.onEnterFrame = function(){
var:Number i = 0;i < 100; duplicateMovieClip"rainDrop
blue_box.attachMovie("rainDrop", "newname1", 1);
}

Duplicate And Attach Movie Within Another Movie Clip Problem
I'm having problems duplicating/attaching movie clips within a movie clip.

I have a panel_MC on stage. I want to be able to dynamically attach several movie clips (essentially they will be buttons) into this panel_MC. Unfortunately when I use mc.attachMovie() the previous movie clips are overridden..

here is some of my code.


Code:
var noOfIcons:Number = 10; /* 10 for easiness sake.. real number will be determined by a function */
var iconBtnXPos:Number = 0;


for (i=1; i<noOfIcons;i++){
var btnNo:Number = i;
panel.createEmptyMovieClip("container"+btnNo,this.getNextHighestDepth());
whereIsThis = panel["container"+btnNo].attachMovie("iconButton","icon"+btnNo, this.getNextHighestDepth());
trace("whereIsThis :"+ whereIsThis);
this.panel["container"+btnNo]["icon"+btnNo].iconLabel.iconText.text = btnNo;
this.panel["container"+btnNo]._x = iconBtnXPos;
this.panel["container"+btnNo]["icon"+btnNo].onRelease = iconBtnRelease;

iconBtnXPos +=52;//calculate next _x button position
}
Any ideas?

Detect A-Attach B-Release B-Attach To C ?
Ok here's something that sounds simple.

I have mc A moving slowly across the screen.
I would like to detect it's position x and y, and then at a certain coordinate(let's say x= 200 and y=300) attach mc B(which is just floating around) to attach itself to and follow mc A movement.
And then at some point attach mc B to attach itself to another mc(C).

Is it also possible to attach mc B to a certain pixel (xy) on mc A (or C).

Any ideas

Cheers

Trinitee

Duplicate Movieclip, Drag Duplicate, Leave Original Behind
Hello all,

I have been searching frantically for an answer to this. I know it has to be easy....

I want to duplicate a movieclip on press and also drag the duplicate, leaving the original behind. I've attached a sample of what I'm doing. Does anyone have any ideas? Is there a way to target the duplicated movieclip to drag that? And leave the original in it's original location?

Any help, guidance, nudging would be greatly appreciated. I've been trying to figure this out for hours.

Thanks,
jessicuh

Attach, Remove And Re-attach MC's
I've been trying to make three movieclips animate accross the stage. They fade in, move accross and fade out.

I've got it currently set up so that they are attached at runtime - fade in / animate / fade out and are removed. The problem i'm having is getting them to re-attach properly. I can't seem to get the re-attachment loop working correctly.... here's the code as far as i have it:


ActionScript Code:
_global.k = 0;
//max amount ofo clouds allowed on the stage
var cloudsV = 3;
 
    //create an empty clip to house all the clouds
    this.createEmptyMovieClip("CLOUDcontainer", this.getNextHighestDepth());
    //add the clouds
    addCLOUDS()
   
 
    function addCLOUDS(){
 
        do {
            //attaches the clouds from the library
            //possitions them [randomly on the y - within a range]
            //and set the speed randomly
            CLOUDcontainer.attachMovie("cloud", "cloud"+k, k+20)
            CLOUDcontainer["cloud"+k]._x = 900//randRange(50, 900)
            CLOUDcontainer["cloud"+k]._y = randRange(182, 400)
            CLOUDcontainer["cloud"+k].movementV = Math.random(5)+1
           
            k++;
          
        } while (k != cloudsV);
 
       
    }
   
_global.fadeOUT = function(me) {
   
    if(me._alpha>5){
    //simple fade out func
    me._alpha = me._alpha + ((1 - me._alpha)/10);
   
   
     }else {
 
        //removes the cloud after its been faded out
        removeMovieClip(me);
        //deducts one from the amount of clouds on the stage
        --k
        //calls the func to re-attch the clouds
        addCLOUDS()
        
     }
   
}
 
//random number within a range generator//
function randRange(min:Number, max:Number):Number {
    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
    return randomNum;
}
//
 



this is on the cloud MC frame 1


ActionScript Code:
this._alpha = 0;
 
this.onEnterFrame = function(){
   
    if(this._alpha<90){
    
    
     this._alpha = this._alpha + ((this._alpha+2)/3);
   
 }
 
    if(this._x>20){
       
        this._x = this._x - (this.movementV);
       
    }
   
    if(this._x<150){
       
        this.gotoAndStop("fadeOUT");
       
    }
 
}
 
stop();


this is on the cloud MC frame "fadeOUT"


ActionScript Code:
this.onEnterFrame = function (){
   
 fadeOUT (this)
 trace(" this = "+this)
 
}



I think its a fairly simple problem - but if anyone can help please let me know, it would be a big help [even if you can suggest a better way of doing this ]

Attach Clips From Xml, Reload Xml Attach Clips Again
i'm trying to figure out how to reset or refresh clips that are dynamically attached to another clip based on records returned through xml.

basically if the user chooses a different filter for the database query I need to be able to refresh a scrolling list made up of clips which will be different based on the filter.

this is what I have for a function. I try to use "attachEmptyMovieClip" but to no avail. any help would be great!


Code:
getAll=function(){


members = getMembers.firstChild.childNodes;

for (var i=0; i<members.length; i++) {
holder.createEmptyMovieClip("new_mc", 10);
item = holder.new_mc.attachMovie("listClip", "listClip" + i, i);
item._y = 23*i;
item.index = i;
trace(item.index);


item.memberName = members[i].attributes.last+", "+members[i].attributes.first;
item.first= members[i].attributes.first;
item.last= members[i].attributes.last;
item.listButton.tabEnabled=false;
item.listButton.onRelease=function(){
_root.triggeredClick="detail";
_root.selectedFirst= members[this._parent.index].attributes.first;
_root.selectedLast= members[this._parent.index].attributes.last;
_root.getDetails();
_root.firstLoad=false;






}
}

}

"Duplicate Scene" Does NOT Duplicate
I just erased a month's worth of work because Macromedia has a funny definition for "duplicate."

I have different scenes which will make up my movie. I build one. it has certain characteristics I want the other scenes to include. So I duplicate the first one, rename it, then make my changes. Straightforward, right? Only, duplicate actually seems to duplicate and link or attach the original and the copy. It does not make a copy, a separate and distinct scene!!!! SO I go back to my first scene, and everything is gone, because it's mysteriously linked or a clone or something of the one I just created (the copy). It's like you have two instances of the scene, and editing either one affects the other. It wasn't so in F5.

What the #$@$*%?!!
Can anyone explain?

How Can I Attach A Mc To Another Mc?
hey there - i have stupid problem with actionsscript:

actually i have a site where lots of mcs are to attach,
therefore i wrote a mc attachscript like this:

function attach_mc(mc,mctoattach,deepness) {
_root[mctoattach].attachMovie(mc,mc,deepness);
}

so the problem is, it just doesnt work

sometimes i attach an mc:

attach_mc("mc1","",1);

but want attach to it another mc DYNAMICALLY:

atach_mc("mc2","mc1",1);

you get the point?

how should a dynamic _root.attachMovie statement look like
so it works? any ideas or comments?

Attach A PDF?
I have a new web-site that i made completely in flash mx and i have a page for my resume.. i want to put the pdf icon of my resume on my page so that someone can click on it and it will download for them and open up in acrobat reader on their desktop.. How do i make it so that i can place my pdf file on my flash page? Please help me!

Attach A PDF?
I created a site in flash mx and i want to have a page that people can go into and click on a pdf icon and directly download my pdf file to their computer. I don't know how to get it so on my page all you see is the pdf icon.. how do i get the pdf icon onto my page for someone to download.. please help me!

Attach MC
Hey all,

I wanna ask, if it's possible to make that with the action attachmovie all the movie clips don't show up all at once, but each by each from up to down. Thanks for any idea.

Can't Attach
please help!

I can't even seem to attach this file in order to get help!!
I've tried attaching the following types of files (with the designated extensions and their file sizes) and none of them seem to work. I'm not sure how else to save and attach a file in order to get help from the bulletin board... I've tried:
Flash document .fla 20,647 kb
Flash movie .swf 938 kb
Compressed (zipped) folder .zip 939 kb
Is a swi the same thing as a swf? How do I get flash to save in that format? I don't see how attaching a .gif, .jpeg, or .bmp would help see a movie I'm making in flash. Does saving it in those formats work?

Please advise!!

THANK YOU!

Attach MC
Does anyone know how to attach a MC in AS3?
Thanks!

Attach This
Oh man!! This is seemingly basic stuff, but I just can't get it to work. I have a symbol called "Blue Square". which is a movie clip. I have an instance called "Blue". I want to create a second instance at a different x,y location on the stage. So, I try the code below, but nothing appears where Blue2 should be. What am I doing wrong?

G

myPreloadery("x4.jpg",600,20);


function myPreloadery(myMovie,xpos,ypos){

//delete this.Blue2
//this.createEmptyMovieClip("myHolder", 200)
//Blue2.loadMovie(myMovie);
_root.attachMovie("Blue Square","Blue2",200);

Blue2._x=xpos;
Blue2._y=ypos;

Blue2.loadMovie(myMovie);

_root.onEnterFrame = function() {

var myLoadedBytes = Blue2.getBytesLoaded();
var myTotalBytes = Blue2.getBytesTotal()

var myPercent = Math.floor((myLoadedBytes/myTotalBytes)*100);

if (myPercent == 100) {

delete _root.onEnterFrame
trace("Image 100% loaded!!")
trace(Blue2._height)

}
}


};

How To Attach Pdf?
Hi all,

Just wondering if anyone knows how to create a button action that will open a pdf file in a separate window?

Thanks!

How Do I Attach MCs Only Once?
I want to load animated movie clips with a toggle key (a blinking light that indicates something is turned on). Instead, it loads the first frame of the animated clip and when the toggle is shut off, it removes it. I've also tried the gotoAndplay method, and both produce the same "on/off" problem, so I figured I would have more luck with the attach MC.

is there a way to tell the program to detect for that attached movie clip, and if it exists, do not load another one/ or prevent that one from playing?

Attach 2 MCs
How do I attach 2 MCs to each other?

I don't think I want aatachMovieClip because that seems to:

add an instance of the symbol programmatically. The attachMovie() method adds a new instance of the specified symbol as a nested movie clip of the object from which the method is called.

I want to say if MC_A bumps into MC_B, then MC_A should attach itself to MC_B and follow it wherever it goes.

For my fishing game, I've tried just saying when there is a hitTest the second one's _y and _x equal the first one's, but I have some boolean vars that cause probs. The bools say if there is a hitTest, no other MC should have a hitTest.

Is there some special function for this?

Attach MC
Im having some problem attaching a movieclip on stage.
Im having a MovieClip that is laying on stage, and in this movieClip there is 3 other movieClip.
And each movieClip containing a button.
My problem is attaching a movieClip from library on stage when pressing a button.
i do have a movieClip as a container on stage, but nothing happen.
I guess it have something to do with my buttons being inside of a movieClip that is inside of a n other clip?

XML And Attach
Hey all Scripters,

this is the first of some questions i will have to post in the future, due to my lacking programming knowledge.
okay, here we go:

I have a XML picture loader which got the following code

ActionScript Code:
function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        description = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
            description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
        }
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
 
p = 0;
this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
        preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
        preloader._visible = false;
        if (picture._alpha<100) {
            picture._alpha += 10;
        }
    }
};
function firstImage() {
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[0], 1);
        desc_txt.text = description[0];
        picture_num();
    }
}
function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
}


some of you might remember the code from the kirupa tutorial.

this script loads a XML file which is formatted this way:

Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>test.jpg</image>
<caption>testimage</caption>
</pic>
Now i want to load all pics mentioned in the XML file to be displayed in a stack (a vertical row) and in a frame from the library (via the attachmovie command)

what would I need to do? I'm totally stuck on this.

Thanks a lot in advance guys!

Attach Mc
Could anyone tell me how I can attach a movieclip instead of loading a.jpg from the code below. Any help would be appreciated.


ActionScript Code:
btn39_btn.onRelease = function() {
    loadThenGrow("images/portraits/port_20.jpg");
};
// LoadTheGrow function takes a target image name.
// Targets are hard-coded for the moment because I'm lazy
function loadThenGrow(img) {
    bg_square_mc._parent.holder_mc.removeMovieClip();
    bg_square_mc._parent.createEmptyMovieClip("holder_mc", 1);
    bg_square_mc._parent.holder_mc._visible = false;
    bg_square_mc._parent.holder_mc.onData = function() {
        if (this.getBytesLoaded() == this.getBytesTotal()) {
            this._visible = false;
            // Image fully loaded, grab dimensions and resize
            // background clip
            w = this._width;
            h = this._height;
            bg_square_mc.growTo(w+1, h+1, 10, _root.showHolder);
        }
    };
    bg_square_mc._parent.holder_mc.loadMovie(img);
}
function showHolder() {
    w = bg_square_mc._parent.holder_mc._width;
    h = bg_square_mc._parent.holder_mc._height;
    bg_square_mc._parent.holder_mc._x = bg_square_mc._x-w/2;
    bg_square_mc._parent.holder_mc._y = bg_square_mc._y-h/2;
    bg_square_mc._parent.holder_mc._visible = true;
}

How O Attach A Movie?
I have a problem with attaching the movie. Line looks something like that: attachMovie( "pausa", "p", 100 )
Pausa is the linkage in Library (that should be OK).
When I hit CHECK SYNTAX I GET THIS:

******* You must export your movie as Flash 5 to use this action.
attachMovie( "pausa", "p", 100 );***********

HELP!!

Is It Possible To Attach Files?
Is it possible to attach files in a Flash interface? If not, what's a good alternative?

Attach Movie
Hi

Does anyone know why we choose to use Attach Movie instead of duplicate Movie ? what is the advantage?

Thanks in advance

MKit de HK

Attach Sound
Hello,
Could anyone tell me how to work with sound in flash 5
and how to make a continous background sound
Regards

Attach 2 CGIs To One SWF ? Possible ?
Hey guys, I need help, i'd like to know if there is a possibility to attach 2 CGIs to 1 SWF ?
Well, for one CGI, i use this syntax :
<param name=movie value="http://www.mypage.com/myflash.swf?cgilocation=http://www.mypage.com/mycgi.cgi">

I hope someone could help me ! Many thanks !
See you !

Attach Movie
Hi there,

Ok, I'm new to the multiple swf file idea. I thought it was pretty nice to have all the data in yust one file.......but, offcourse, it got to big.

So I Kicked all the background images in a BGlib.swf and all the pics in a PIClib.swf. Got the TUT about attachMovie and so it worked in my preview mode..........but not online??

Q: do you need loadmovie to use attach?
Q: is it possible to make a big library.swf but load just the MC you need?

oh, the code I used:
placeHolder.loadMovie("library.swf");
placeHolder.attachMovie("bg_ssl", "ssl", 0);

please help......
thanks

Attach Movie
i was wondering if its possible to do this via actionscript:
i have a button and i want to attach a movie from the library in the same position of the button when the button is clicked..and if i duplicate the button in another position it might have the same behaviour...thx

Attach Movie Help
I have this code
function create () {
for (i=0; i<30; i++) {
attachMovie("sub", "button"+i, i);
myButton = this["button"+i];
myButton._y = 15*i;
}
}
and this just attaches them in a line
I would like to have them in rows of 5
is this possible and how do I do it.

hope you can help

mac

Attach Movie
I have a problem using the attach.movieclip function.
I want to call a member (that I already have exported) of the library, by pressing another movie clip.
I want that it's been attached in another movie clip.
I also want that it attachs a copy each time the buttom is pressed, but i don't need that the name of the new instance changes each time.

What i'm doing is: Wirtting a script on the movie clip that serves like a button :

on (release) {
construct_zone.attachMovie("__2", "a", 0);
}

Is There A Max To Attach Movies
i have this space invaders type game. I attach all the spaceships on to the root level. Then when i go to shot my laser at the alien attackers the shot is also another movie clip and it is attahced to the root level too. I get one shot ot then if i shot another one a spaceship dispears except that no code yet envolves the aliens or the laser together. I mean they dont effect each other yet.
Please help if you have any ideas.
Brian

Attach Sound
HI,

plz tell me , if you know that how to attach sound from the library, i am trying but its not working.

Thanx in advance,

$hailesh

Attach Movie
I have a scene where I have an "attach movie action".
I've done a preloader for the movie but the problem is that the swf is showing 89k for the first frame. I'm sure that because of this action the movie loades all the information in the first frame.how can I escape from this problem without making another external swf. for the preloader?

thanks.

I Want To Attach A .txt File
hi every body,
i want to attach a .txt file to my .fla file that have 2 constants in i know it is easy but when i do it it doesnt work,so plz check it and tell me

my .txt file which is named variables.txt contains inside:

score1="850"&score2="1800"


and my .fla:

loadVariables ("variables.txt", "");

and score1 is then used in an if statement


if (_root.score>score1) {
_root.gotoAndPlay("secondstage");
}


that does see score1 as 0
not 850 as i want!!!!

Attach Movie
im trying to attach a movie with a blank target MC.
the blank clip is on frames 1 - 5. and on frame 5 i have an Action to attach it.

_root.target.attachMovie(badguy1, badguy, 0);

it doesn't work but i dont know why.can anyone help?¿?¿?¿

How Do I Attach A Url To A Button...
Hi All,

I have a 'skip intro' symbol...how to i attach the action to jump to a specified url??

thanks

sorry for the amount of dumb questions..but i have to start somewhere

cheers

Attach Sound
how to attach the sound.swf to another swf file

Is There A Way To Attach A .fla To My Reply?
before I reply to a question I usually build a sample file to assure that what I am saying is correct. I would like to post it so others can see a source and not just try to follow along with what I say.....I thought that I had seen it done before. thanks

Attach One At A Time
Hi there
I have got this script

for (i=0; i<5; i++) {
attachMovie("sub", "button"+i, i);
myButton = this["button"+i];
myButton._y = 15*i;
}

It works fine But I would like to know how to
change the script so that it attachs the moive
one at a time

Thanks

hope you can help

mac

Attach Movie ?
I want to load a MC into my main SWF from button action ON Release,(can someone run me through the attachmovie command)Big help Thanks Paul

Getting A Trailer To Attach To A MC
Hey peeps..

What i wanna create is a MC that dublicates and fade, just like a mousetrailer - But I want to attach it to a MC that follows a guide instead of the mouse, how do I do that ?

Any takers on this

How To Attach Sound
How would i on, on (rollOver) make it play a sound? ty - EnSanity

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