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

line to movieclip collision

Community Beginner ,
Oct 16, 2023 Oct 16, 2023

Copy link to clipboard

Copied

Dear All Thank you for your time

I have aproblem that cant seem to work out looked on line and read some books but cant find

a solution. I have one movie clip that is tweened on a straight path that is movable with the mouuse

as wel as rotatable with buttons, the imbedde tweened object cabn also be moved with buttons . The collision object is a line that rotates 360deg with a button . That all works, what I cant figure out to do is display the distance to the line as the tweened object approaches the like a countdown to a colision.

added a photo to help explain.

Thank you all

ray drawing.png

Views

819

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 Beginner ,
Nov 05, 2023 Nov 05, 2023

Copy link to clipboard

Copied

Dear Kglad 

Thanks It is supposed to look like this three dots in a row with blue dot in the center.

Peter25066516vwuz_0-1699224046462.png

What I get using the scale factors(root.yellowmc.dot1.x = x2/stage.scaleX) is this.

Peter25066516vwuz_1-1699224179162.png

Best Regrds 

and thanks for your help

Peter

 

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 ,
Nov 06, 2023 Nov 06, 2023

Copy link to clipboard

Copied

is the red dot, dot3?  (and choosing easy-to-remember names makes debugging easier.)

 

if so, you never assign an x,y, so it's at the default 0,0

 

what do different dots represent?

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 Beginner ,
Nov 07, 2023 Nov 07, 2023

Copy link to clipboard

Copied

Dear Kglad 

I have renamed everything to make it clearer  as you suggested the red dot is now "endpath" , this shows up the end of the flight path (red line).

The blue dot with a faded black stroke is now labled as "intersection" this is the point where the radio ray intersects the aircraft.

The black dot is now "startpath" this the starting path of the aircraft 

Concept is at the end of the flightpath (red path ) the is a yellow dot this  a  nested movie clip "endredline" .

The endpath uses the cordinates  endredline to postion itself on the end of the path

The start path uses the end of the flightpath mc to set position of the start path

The intercection (blue dot)uses a maths formula to work out its intersection using all the graphic points created.

When reset is selected you should seee a black dot on the plane a blue dot in the center and a red dot at the end of the path .I tried the scale and gave it the cordinates but it places the black and blue dot together now and red dot is off stage. Tried also again to use the old method old Local to global works good on the desktop but still the same on the laptop screen, have attched some photos .

FLA Link here version 6b

Best Regards Peter

 

 

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 ,
Nov 07, 2023 Nov 07, 2023

Copy link to clipboard

Copied

all the dots are correct except the blue and red?

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 Beginner ,
Nov 07, 2023 Nov 07, 2023

Copy link to clipboard

Copied

Dear Kglad

Thank you for your help

Yes that is correct also the two drawn lines are not correct as they base there position on the blue and red dots and the refence points of the two lines. Without the dots in the right plus the simulator will not work.

Is there a way to change the reference of the stage so it aligns with the movi clip position that way the stage acts a local reference not a global one.

Best Regards

Peter

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 Beginner ,
Nov 08, 2023 Nov 08, 2023

Copy link to clipboard

Copied

Dear Kglad 

Thanks for your help

I have made a simple FLA to aid in trouble shooting the problem, it seems when you pass the cordinates of the scalex and y they do not change the red dots position to global cordinate which is shown as the the same location as the intial position , this is then  passed to the graphic drawn circle. If you use the local to global it uses the location set up for the variable so both dots superimpose on each other.The other weird thing is graphic drawn dot locastion always shows 0,0. When I check "this.greendot.reddot1.localToGlobal(0, 0);" as  formulted by the local to global in the desktop the it shows (261.75,187.3)  wheras the laptop top shows  (654.375,468.25) yet the initial positions of the console log for both red and green dots are the  same on both computers.

Best Regards Peter

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 ,
Nov 08, 2023 Nov 08, 2023

Copy link to clipboard

Copied

why is reddot a child of greendot?

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 Beginner ,
Nov 08, 2023 Nov 08, 2023

Copy link to clipboard

Copied

Dear Kglad

Thank you for your reply

The child sets the end of the movie clip line by refencing this the endpoint I can  draw a circle on the canvas at that point. Now with having two specific points I can draw a line between the points, this allows me to use math to calculate the point where the two lines cross .By having the dot at the end of line as a child allows to move or rotate the line anywhere and then reset to find the crossover point. Unless there is another way to find the end point of the movie clips line it is the only way I can work out how to do it.

 

Best Regards

Peter

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 ,
Nov 09, 2023 Nov 09, 2023

Copy link to clipboard

Copied

why not have reddot a child of the main timeline like greendot?

 

the reason i ask is because when you change the position of greendot, you change the position of reddot.

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 Beginner ,
Nov 09, 2023 Nov 09, 2023

Copy link to clipboard

Copied

Dear Kglad

Thanks for your help

Bothe the red and green dot have to move and rotate together if I put them on the maintime line they become seperate identities, so how would I attach the dot to the other end of the line so that a line can be drawn between the two points and be able to rotate and drag move with the other dot if they are seperate movie clips.

Best Regards

Peter

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 ,
Nov 10, 2023 Nov 10, 2023

Copy link to clipboard

Copied

ok.

 

what is it you want done with tester.fla?

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 ,
Nov 10, 2023 Nov 10, 2023

Copy link to clipboard

Copied

if you're trying to position the yellow dot over the red dot, use

 

var root = this;
 
var yellowdot;
var k = this.greendot.reddot1.x
var j = this.greendot.reddot1.y
var m= (this.greendot.reddot1.x+this.greendot.x);
var n= (this.greendot.reddot1.y+this.greendot.y);
 
function newdot1(A, B) {
yellowdot = new createjs.Shape();
root.addChild(yellowdot);
yellowdot.graphics.setStrokeStyle(200);
yellowdot.alpha = (.8);
yellowdot.graphics.beginFill("yellow").drawCircle(A, B, 10);
}
newdot1(m, n);

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 ,
Nov 10, 2023 Nov 10, 2023

Copy link to clipboard

Copied

again, you're notation/naming makes understanding your code more difficult.

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 Beginner ,
Nov 10, 2023 Nov 10, 2023

Copy link to clipboard

Copied

Thanks Kglad

Sorry but that wont work, it is because the child of one movie clip will always has its own refence coordintaes as such it cannot be referenced the same as the parent. It is only when I add the local to global function that I can get the intersection part  to work  but as we have seen this local to global breaks down on other screens. The only way out I can see is to try some code i saw on you tube.

Thanks for your help

Best Regards

Peter

 

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 ,
Nov 10, 2023 Nov 10, 2023

Copy link to clipboard

Copied

what won't work?

 

the code i just posted does work with the test fla you sent to position the yellow over the red.

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 Beginner ,
Nov 10, 2023 Nov 10, 2023

Copy link to clipboard

Copied

Dear Kglad

The lines need to rotate with a button and move with the mouse,this means as a child its reference point it is not the same as the movie clip so the x and y of the graphic dot  shows a  static position whereas the parent  movie clip shows a stage position because the top and bottom points show different localities one global and one local   a straight line cannot be drawn between the two dots as the second point is not a global point rather a local point. 

 As such I cannot use the algorithim for finding the intersection of the two lines as they rely on all  points being refenced to the stage global position not to the local position. When I use the local to global it works as expected but only on my monitor not on laptops with a smaller screen size.

As this will be shown on all types of screens including tablets it needs to be fit for all purposes. Looking at the video it looks like I need some trig functions to make it the rotation work

 

Best Regards

Peter

 

 

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 ,
Nov 10, 2023 Nov 10, 2023

Copy link to clipboard

Copied

what am i supposed ti do with the test fla?

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 Beginner ,
Nov 13, 2023 Nov 13, 2023

Copy link to clipboard

Copied

LATEST

Dear Kglad

The test file was to highlight the root cause of the problem without the extra items of the animation. With the  root cause of the problem being the unabilty to tranform the local coordinates to Global reference, that has the ability to be shown on all monitors the same way . I might have to a try a different method now or a different Java script plug dsuch as Zim or Gasp  to see if it can be done another way.

Thanks for your help will let you know if I find a solution that works .

Peter

 

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