• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Load MovieClip to specific frame on main timeline

Explorer ,
Jan 27, 2021 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

277

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jan 29, 2021 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

...

Votes

Translate

Translate
Community Expert ,
Jan 27, 2021 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 28, 2021 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 28, 2021 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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 29, 2021 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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2021 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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 02, 2021 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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

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