Copy link to clipboard
Copied
I currently have a movieclip which is loaded on the main timline on top of other buttons that call other movie clips.
I'm not sure what additional code I add to make the movie clip load on frame 2 of the main timeline, thus not interfering with the buttons below.
var that = this;
var myRectangle;
function addFromLibrary(e)
{
if (!myRectangle)
{
myRectangle = new lib.Rectangle();
that.addChild(myRectangle);
}
}
function removeClip(e)
{
if (myRectangle)
{
that.removeChild(myRectangle);
myRectangle = null;
}
}
this.buttonAdd.addEventListener("click", addFromLibrary);
this.buttonRemove.addEventListener("click", removeClip);
background info: you can always diable a button by:
1. assign its visible property to false (eg, this.buttonAdd.visible = false; )
2. remove its event listener (eg, this.buttonAdd.removeEventListener("click", addFromLibrary); )
3. remove the button from the display (eg, this.buttonAdd.parent.removeChild(this.buttonAdd); )
now, if you want to add something from your library to the stage (assign it a linkage name - eg, mcID) at a certain frame, add code at that frame:
var mc = new lib.mcI
...Copy link to clipboard
Copied
if you want a movieclip (or anything else) to appear on frame 2 of the main timeline, add an empty keyframe to frame 2 and add the desired object to that keyframe.
if you want to use code to add a movieclip to frame 2, explain
Copy link to clipboard
Copied
Yes I'd like to add the movie clip to frame 2 using code.
I've tried a couple of things none are working:
Added the following
var _this = this
_this.stop();
then as follows with a frame label which works.
myRectangle = new lib.Rectangle();
that.addChild(myRectangle);
that._goto('frameload');
However, the button instance still appears active on the stage screen below the loaded mc.
Thanks
to
Copy link to clipboard
Copied
your posts are confusing.
in your first post you wrote, "I'm not sure what additional code I add to make the movie clip load on frame 2 of the main timeline, thus not interfering with the buttons below."
in your second post you wrote, "However, the button instance still appears active on the stage screen below the loaded mc."
and i can't tell if you're having trouble adding a movieclip on frame 2 and/or there's some button problem.
Copy link to clipboard
Copied
Haha yes sorry my communication of what I'm experimenting with isn't too clear.
I'll atempt to explain, with a diagram:
Copy link to clipboard
Copied
background info: you can always diable a button by:
1. assign its visible property to false (eg, this.buttonAdd.visible = false; )
2. remove its event listener (eg, this.buttonAdd.removeEventListener("click", addFromLibrary); )
3. remove the button from the display (eg, this.buttonAdd.parent.removeChild(this.buttonAdd); )
now, if you want to add something from your library to the stage (assign it a linkage name - eg, mcID) at a certain frame, add code at that frame:
var mc = new lib.mcID();
this.addChild(mc);
if you want the code to be on one frame and add the symbol to a different frame, you can use that code in a button listener (if that's how you navigate to that other frame) or you can start a timer loop and check if the playhead's entered that frame and then add the symbol (and stop the loop).
Copy link to clipboard
Copied
That's excellent, thanks for the options.
I was assuming it would only come from a mouse trigger, didn't think about adding the addChild to the frame.
Copy link to clipboard
Copied
you're welcome.