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

Trying to convert flash to javascript (part 2)

Engaged ,
Mar 02, 2021 Mar 02, 2021

Copy link to clipboard

Copied

Okay here's part two:

I used to have this:


/*IndexNext1.addEventListener(MouseEvent.CLICK, IndxNext1);

function IndxNext1(event:MouseEvent):void
{
gotoAndPlay("Indx1");
}


Left Turn Stalk Behavior

leftStalk.addEventListener(MouseEvent.MOUSE_OVER, leftOver);

function leftOver(event:MouseEvent):void
{
this.leftStalk.gotoAndPlay("over");
}
leftStalk.addEventListener(MouseEvent.MOUSE_OUT, leftOut);

function leftOut(event:MouseEvent):void
{
this.leftStalk.gotoAndStop("stop");
}

leftStalk.addEventListener(MouseEvent.MOUSE_DOWN, leftClick);

function leftClick(event:MouseEvent):void
{
this.leftStalk.gotoAndStop("down");
}

leftStalk.addEventListener(MouseEvent.MOUSE_UP, leftUp);

function leftUp(event:MouseEvent):void
{
this.leftStalk.gotoAndPlay("over");
}

*/

 

And I tried replacing it with this.

 

this.leftStalk.addEventListener("mouseover", leftOver);

function leftOver()
{
this.leftStalk.gotoAndPlay('over');
}

 

this.leftStalk.addEventListener("mouseout", leftOut);

function leftOut()
{
this.leftStalk.gotoAndStop('stop');
}

 

this.leftStalk.addEventListener("onmousedown", leftClick.bind(this));

function leftClick()
{
this.leftStalk.gotoAndStop('down');
}


this.leftStalk.addEventListener("onmouseup", leftUp.bind(this));

function leftUp()
{
this.leftStalk.gotoAndPlay('over');
}

 

How much am I getting wrong?  LOL

 

Thanks in advance!

 

Rick

Views

768

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 , Mar 02, 2021 Mar 02, 2021

with as3, you don't need to explicitly reference the timeline that contains the objects and that you want to control.  with createjs, you need to explicitly reference those:  and with createjs and js, in general, there's no object typing:  and inside createjs functions, the timeline reference is lost.  one way to resolve that is to pass a reference to it using bind():

 

this.IndexNext1.addEventListener("click", IndxNext1.bind(this));

function IndxNext1(e)
{
this.gotoAndPlay("Indx1");
}


//Left Turn

...

Votes

Translate

Translate
Engaged ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

Perhaps. but there's one file in particular that will be a major pain.  Our IT folks said they'd look at it, but to be honest, they are encased in a culture of "no, it can't be done."    : )

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 ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

ok.

 

let me know if you want me to bid on converting it. (with new clients i quote a cost that doesn't need to be paid until i finish and the work is accepted.)

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
Engaged ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

LATEST

I'll do that.  Talking to the boss this afternoon.

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