HTML5 MC Click = Move Root Timeline Forward 5 Frames or Back 5 Frames = Random 10 to 20 Frame Jump?

Explorer ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

I made two movie clips so that where ever they are placed on a timeline, when clicked one would move the root forward and the other would move the root backward by 5 frames. For some odd reason I can't account for, sometimes the movie clip would jump 20 frames - as if the specified frame number value were being added.

See video for this odd, buggy behavior in action: 

The code I am using for the Forward Movie Clip that contains a Button is:

this.p_Next.removeAllEventListeners("click");

Jump5 = 0; // my attempt to clear any previous value that may be adding up somewhere that could account for the clip jumping more than the 5 frames indicated next: 

Jump5 = exportRoot.timeline.position+5;

function Next5(){
	this.parent.gotoAndStop(Jump5);
	this.gotoAndPlay(0); // This is a 2 frame MC, the first frame contains the "removeAllEventListeners" above. 
	}

this.p_Next.addEventListener("click", Next5.bind(this));

	this.stop();

 

For the Reverse MC, the code is nearly identical:

this.p_Prev.removeAllEventListeners("click");

Back5 = 0;
Back5 = exportRoot.timeline.position-5;

function Prev5(){
	this.parent.gotoAndStop(Back5);
	this.gotoAndPlay(0);
	}

this.p_Prev.addEventListener("click", Prev5.bind(this));
	
	this.stop();

 

Shouldn'ty this work perfectly? Is there something I am over looking? 

Is there a better way to do this? 

Any helpful insight would be greatly appreciated, thank you. 

 

TOPICS
Error

Views

58

Likes

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
Adobe Community Professional ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

are those movieclips in more than one keyframe?  if so, that's a problem.

Likes

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 ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

Yes, where ever I have a section (for example section C) that has more content than can fit in its allotted space, I create more frames for it, again in this case: C2 and C3. 

Instead of adding code to buttons for every case like this I simply wanted one MC for each operation I can drop into the frame that will move the root timeline forward or back by 5 frames. Should be simple... 

 

I notice that after using the buttons for section C, if I then jump to a section without the buttons then to the next section with those buttons (section D) then the buttons there act fine, as if something is clearing whatever is causing the problem... 


I have used this before in assets that are currently live and operating fine, but for whatever reason, the movie clips that work fine in other assets are acting oddly in this one. I re-use the same framework which has not been a problem before. 

 

Thanks! 

Likes

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 ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

So, I kind of found a workaround. Since all my variables are stored in an external JS script, I moved the functions there:

this.Next5=function()
{Jump5 = exportRoot.timeline.position+5;
this.gotoAndStop(Jump5);}
	
this.Prev5=function()
{Back5 = exportRoot.timeline.position-5;
this.gotoAndStop(Back5);}

 

Because when I declared them in the FLA itself, I naturally got a Function Not Defined error, which is maddening because yes, again, they are indeed Defined: 

function Next5(){
exportRoot.timeline.position+5;
this.parent.gotoAndStop(Jump5);
}

// looks defined to me...

 

The only catch of course, is adding this code inside the MC that contains the button does not work for some mysterious reason:

this.p_Next.removeAllEventListeners("click");
this.p_Next.addEventListener("click", Next5.bind(this));

Wouldn't it be a nice time saver if it did work? Can anyone explain why it does not? 

 

What does work, which is less of a time saver, is placing that code on the frame that contains the MC and now having to give it an Instance Name (Next) and placing this code on the containg frame:

this.Next.p_Next.removeAllEventListeners("click");
this.Next.p_Next.addEventListener("click", Next5.bind(this));

What's the big differene, you ask? Good question. 

How is targeting the p_Next button from outside the MC different from targeting it from inside? Well, at least it works. 

There must be a better way to create useful, re-usable and simple navigation elements in this program, does everyone manually code for each button that jumps to a next or previous frame every time that's needed? 

There must be a better way. 

Thanks. 

Likes

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
Adobe Community Professional ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

LATEST

i'd code once and be done.  it's quicker, easier to debug and easier to maintain/update.

Likes

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