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

Java script is not active for PNG

Explorer ,
Jan 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

Hello, guys!

I have very good animation with well-working interactive parts.

All the things work well, but I can not fix one problem. I want to use .png in HTML5 technology as symbol (pb or movie clip) with JS.

As soon as i put any graphics to already working vector Pb (with working code) it stops be active at all.

I can't press it and all of my animations stops. Code works perfectly only if I use vector graphics. As soon as I add even .png dot - stop working.

For .swf file with AS3 it works perfect - no problems.

So, can you tell me what's the problem?

How can I add JS to symbol with .png and force it to work well?

I don't want use vector graphics as it decreases FPS significantly, I need to create .png animation (let MC move one side by click and other side by another click).

Here are .png file which I want to animate.Procedure.png

Thank you so much for your help!

With best regards, Igor.

Views

412

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 11, 2018 Jan 11, 2018

here's one way to do that:

// edit these 3 parameters to suit your needs

var leftside_start = 100;

var leftside_end = 300;

var inc=3;

var loopI;

this.leftside.addEventListener('click',startF.bind(this));

function startF(){

if(this.leftside.x<(leftside_start+leftside_end)/2){

inc = Math.abs(inc);

} else {

inc = -Math.abs(inc);

}

clearInterval(loopI)

loopI=setInterval(loopF.bind(this),50);

}

function loopF(){

this.leftside.x+=inc;

if(inc>0 && this.leftside.x>=leftside_end){

clearInterval(loopI);

this.leftside.x = lef

...

Votes

Translate

Translate
Community Expert ,
Jan 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

as long as your not using timeline tweening there shouldn't be any problems.  if you are using timeline tweening, there are several potential pitfalls.

bottomline, it's safest to avoid timeline tweening with symbols you want to control with code.

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 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

Thank you mate, I really use timeline. Could you tell me how to animate it with code without timeline reference? I'm a pilot, not designer, but I need to fix it as the last point of my animation.

You can see "Procedures" on the left side and I want to animate it by click to the rite side and by second click to the beginning position (left).

Снимок экрана 2018-01-12 в 1.56.05.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 11, 2018 Jan 11, 2018

Copy link to clipboard

Copied

here's one way to do that:

// edit these 3 parameters to suit your needs

var leftside_start = 100;

var leftside_end = 300;

var inc=3;

var loopI;

this.leftside.addEventListener('click',startF.bind(this));

function startF(){

if(this.leftside.x<(leftside_start+leftside_end)/2){

inc = Math.abs(inc);

} else {

inc = -Math.abs(inc);

}

clearInterval(loopI)

loopI=setInterval(loopF.bind(this),50);

}

function loopF(){

this.leftside.x+=inc;

if(inc>0 && this.leftside.x>=leftside_end){

clearInterval(loopI);

this.leftside.x = leftside_end;

} else if(inc<0 && this.leftside.x<=leftside_start){

clearInterval(loopI);

this.leftside.x = leftside_start;

}

}

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 12, 2018 Jan 12, 2018

Copy link to clipboard

Copied

It doesn't work...:(

Снимок экрана 2018-01-12 в 16.53.41.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 12, 2018 Jan 12, 2018

Copy link to clipboard

Copied

do you have an object with instance name "leftside"??????  that was supposed to be a tip-off for you to use the name of the movieclip on the left side of your screen shot.

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 14, 2018 Jan 14, 2018

Copy link to clipboard

Copied

Ah... thank you. I'll try next time/ I used transparent PB to animate this.

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 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

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
LEGEND ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

"PB"?

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 17, 2018 Jan 17, 2018

Copy link to clipboard

Copied

LATEST

Pushbutton.

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