Load MovieClip to specific frame on main timeline

Explorer ,
Jan 27, 2021

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);

 

Views

63

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Adobe Community Professional , Jan 29, 2021
kglad Adobe Community Professional , Jan 29, 2021
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...

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Jan 27, 2021

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Jan 28, 2021

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jan 28, 2021

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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Jan 29, 2021

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:

 

Screenshot 2021-01-29 at 11.12.57.pngScreenshot 2021-01-29 at 11.14.11.png

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jan 29, 2021

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).

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 02, 2021

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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
kglad LATEST
Adobe Community Professional ,
Feb 02, 2021

Copy link to clipboard

Copied

you're welcome.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more