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

HTML5 Canvas - Logic Problem?

Engaged ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

 I have MC symbols which can be set to the stage though ComboBoxes and dragged and dropped into a position.

 

I need to check if any have been dropped into the position and have a hitTest, in order to run some functions, one being:

 

 

function updateLF_Move_Left() {
    if (root.LeftFrame.x >= 508.3) {
        root.LeftFrame.x -= 1;
        root.LFLensHolder.x -= 1;
        root.LFLensSupports.x -= 1;
        root.ButtonRotateCWLeftFrame.x -= 1;
        root.ButtonRotateCCWLeftFrame.x -= 1;
        if (concaveSphereLensSet == true) {
            root.ConcaveSphereLens.x -= 1;
        } else if (convexSphereLensSet == true) {
            root.ConvexSphereLens.x -= 1;
        }
    }
}

 

 

The global variables in the above code are initially set to false before the function. E.g.

 

 

this.concaveSphereLensSet = false;
this.convexSphereLensSet = false;

 

 

The value of the corresponding symbol variable is set to true on drop/hitTest, if the dropped symbol has the corresponding name. I can test that works and is true on hitTest.

 

I have an Adobe Animate HTML5 Canvas movie, but EaselJS would also apply.

In that movie, I have symbols which can be set to the stage though ComboBoxes and dragged into a position.

I need to check if any have been dragged into the position and have a hitTest, in order to run some functions, one being:

function updateLF_Move_Left() {
    if (root.LeftFrame.x >= 508.3) {
        root.LeftFrame.x -= 1;
        root.LFLensHolder.x -= 1;
        root.LFLensSupports.x -= 1;
        root.ButtonRotateCWLeftFrame.x -= 1;
        root.ButtonRotateCCWLeftFrame.x -= 1;
        if (concaveSphereLensSet == true) {
            root.ConcaveSphereLens.x -= 1;
        } else if (convexSphereLensSet == true) {
            root.ConvexSphereLens.x -= 1;
        }
    }
}

The global variables in the above code are initially set to false before the function. E.g.

this.concaveSphereLensSet = false;
this.convexSphereLensSet = false;

 

The value of the corresponding symbol variable is set to true on drop/hitTest, if the dropped symbol has the corresponding name. I can test that works and is true on hitTest.

 

For the symbol in the above logic, root.ConcaveSphereLens, if that symbol is on stage, and the corresponding variable is true, then the above function works for that symbol. No problem there.

 

However, if that symbol is not on the stage, then the following symbol, root.ConvexSphereLens, does now work (i.e. move left as per the function).

 

The logic seems to be simple enough.

 

If the value of the  variable in the function above is not true, then the corresponding symbol in the logic statement should be ignored.  But it's not being ignored.

 

So what's wrong?

 

 

Views

139

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

Engaged , Feb 25, 2022 Feb 25, 2022

OK, worked it out....

Votes

Translate

Translate
Engaged ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

Really needs an ability to edit posts in the forum...please ignore the above!

 

I'll repost as follows:

 

 I have MC symbols which can be set to the stage though ComboBoxes and dragged and dropped into a position.

 

I need to check if any have been dropped into the position and have a hitTest, in order to run some functions, one being:

 

function updateLF_Move_Left() {
    if (root.LeftFrame.x >= 508.3) {
        root.LeftFrame.x -= 1;
        root.LFLensHolder.x -= 1;
        root.LFLensSupports.x -= 1;
        root.ButtonRotateCWLeftFrame.x -= 1;
        root.ButtonRotateCCWLeftFrame.x -= 1;
        if (concaveSphereLensSet == true) {
            root.ConcaveSphereLens.x -= 1;
        } else if (convexSphereLensSet == true) {
            root.ConvexSphereLens.x -= 1;
        }
    }
}

 

The global variables in the above code are initially set to false before the function. E.g.

 

this.concaveSphereLensSet = false;
this.convexSphereLensSet = false;

 

The value of the corresponding symbol variable is set to true on drop/hitTest, if the dropped symbol has the corresponding name. I can test that works and is true on hitTest.

 

For the symbol in the above logic, root.ConcaveSphereLens, if that symbol is on stage, and the corresponding variable is true, then the above function works for that symbol. No problem there.

 

However, if that symbol is not on the stage, then the following symbol, root.ConvexSphereLens, does now work (i.e. move left as per the function).

 

The logic seems to be simple enough.

 

If the value of the  variable in the function above is not true, then the corresponding symbol in the logic statement should be ignored.  But it's not being ignored.

 

So what's wrong?

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 ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

By on stage in the above, I meant on drop and hitTest...

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 ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

Any ideas?

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 ,
Feb 25, 2022 Feb 25, 2022

Copy link to clipboard

Copied

LATEST

OK, worked it out....

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