Skip to main content
Participant
May 11, 2006
Question

attachMovie problem

  • May 11, 2006
  • 1 reply
  • 269 views
Hi, for some reason the attachMovie in this piece of code just refuses to run

theListener.onLoadInit = function(loadedMc:MovieClip) {
var dropShadow:DropShadowFilter = new DropShadowFilter(0, 45, 0xFFFFFF, 100, 2, 2, 255, 1);
loadedMc.filters = [dropShadow];
loadedMc.createEmptyMovieClip("mc_picover", 2);
trace(loadedMc.mc_picover.attachMovie("mc_picover", "mc_over", 1));
loadedMc.mc_picover._alpha = 0;
loadedMc.mc_picover._width = _root.mc_slide.mc_slideshow["pic"+thePic]._width - 2;
loadedMc.mc_picover._x = 1;
loadedMc.mc_picover._y = 1;
loadedMc.onRollOver = function() {
var overTween:Tween = new Tween(loadedMc.mc_picover, "_alpha", None.easeIn, loadedMc.mc_picover._alpha, 100, 1, true);
};
loadedMc.onRollOut = function() {
var overTween:Tween = new Tween(loadedMc.mc_picover, "_alpha", None.easeIn, loadedMc.mc_picover._alpha, 0, 1, true);
};

if (thePic < theArray.length-1) {
thePic++
loadPic(thePic);
}
};

function loadPic(id:Number) {
var newClip:MovieClip = _root.mc_slide.mc_slideshow.createEmptyMovieClip("pic"+id, id);
newClip._y = 30;
newClip._x = 13;
newClip._x += _root.mc_slide.mc_slideshow["pic"+(id-1)]._width + _root.mc_slide.mc_slideshow["pic"+(id-1)]._x;
theImage.loadClip(theArray[id][1], newClip);
};


everything else works (bar the stuff trying to reference the attached movie), any ideas? the trace just returns "undefined".

i've checked the export for as box and the linkage is all correct, i can use the same peice of code to attach it to any other movie (dynamically created or not) but the movie i actually want to attach it to wont accept it
This topic has been closed for replies.

1 reply

Participating Frequently
May 11, 2006
Not sure what you end goal is but here is what I get from your "attachMovie" portion of the code.

You are trying to attach a dynamically created movieclip to itself...correct?

>> loadedMc.createEmptyMovieClip("mc_picover", 2);

This creates an empty movieclip name "mc_picover" inside the movieclip "loadedMc".

>>trace(loadedMc.mc_picover.attachMovie("mc_picover", "mc_over", 1));

This line then tries to attached the dynamically generated "mc_picover" to itself and rename it "mc_over".

Just a few things to point out...

1) you cannot use "attachMovie" on dynamically created movieclips. To use attachMovie, a movieclip must exist in the Library and have a linkage name defined. A linkage name and an instance name are not the samething.

2) You do not have to manually attach a dyanmically generated movieclip. It is automatically a child of the movieclip that the method is applied to. That is, loadedMc.createEmptyMovieClip("mc_picover", 2); creates a movieclip with an instance name "mc_picover" and makes it a child of "loadedMc".

3) I may have totally missed your question so, if I have, let me know.

Tim


Participant
May 12, 2006
No text available