Skip to main content
Srihari_Ch
Known Participant
December 29, 2008
Question

Handling Mouse Event

  • December 29, 2008
  • 5 replies
  • 770 views
How to access x and y co-ordinates when a mouse's left butto is clicked upon a JPG file whichis placed on a stage, so that we can view the jpeg contents on the stage?

Please can anyone please send code to my mail.
This topic has been closed for replies.

5 replies

Participating Frequently
December 31, 2008
tutvid.com has a great tutorial that refers to some of these. Go to the one with the scrolling gallery.
clbeech
Inspiring
December 31, 2008
very good. well then you have two basic options here - to make an 'actual' popup you would need to execute a JavaScript method with the externalInterface class or use fscommand - however this may only work 'sometimes' with today's popup blockers that are enabled on most user's browsers. secondly, you could 'fake' a popup window using an addtional MovieClip that you bring to the stage dynamically when the call is made, under AS3 one does so by invoking the constructor of the MC's class.

however, AS3 is so vast that there may be another method or class available that i am still yet unaware of to construct a popup window.
Srihari_Ch
Known Participant
January 2, 2009
You said that,
to make an 'actual' popup you would need to execute a JavaScript method with the externalInterface class or use fscommand. Please can you tell me whether this task can be done using ActionScript 3.0 API clases.

If so, please mention /reply me the class name which is used for the same task.
clbeech
Inspiring
December 30, 2008
in the code that Dave has posted above "e" represents the event, event objects have properties, one of which (two actually) named 'target' represents the object being clicked - eg. the Display Object "myImage" - which has a properties called mouseX and mouseY, you can access these properties to display the coordinates relative to the scope of the Display Object - however 'how' you display the value is a different matter, if you want to place the 'on screen' for the user, you should add one or two dynamic textFields to you file that you can then assign the values to for display. so lets assume you've done so, and the instances are named xText and yText (remember to embed the font in the fields) - so then to display the values you would use something like:

function mDown(e:MouseEvent) {
xText.text = e.target.mouseX;
yText.text = e.target.mouseY;
}
Srihari_Ch
Known Participant
December 31, 2008
Already ihad developed the application with 2 text-boxes on the stage and accessing those text-boxes through instances created for them. I had got the required output there.

But, present requirement is to get the output of x,y co-ordinae values is in a pop-up box like, for example,
When you keep your mouse-pinter on any window's Maximise/Minimise button,
it shows or displays in a pop-up with Maximise(Restore Down)/Minimise respectively.
Srihari_Ch
Known Participant
December 30, 2008
Thanks a lot for your help......

As I am new to the AS3 platform, You had helped me....

Now I need to display these x and y co-ordinate values in a pop-up when clicked.

You can see the sample output here for Mouse_RollOver event in the below link:
http://www.flashdesignerzone.com/tutorials/t1025.php

"But, I couldn't understand the code present in above link."

Please explain me....

(Presently, I am using Action Script 3.0(AS3) with Flash 9 and have no idea about previous versions.)

Please, I request you to give me step-by-step process.


Inspiring
December 29, 2008
The mouse event object carries all the info you need.

Something like so should get you going:

myImage.addEventListener(MouseEvent.CLICK, mDown);

function mDown(e:Event){
trace(e);
}


--
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/