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

Handling Mouse Event

New Here ,
Dec 28, 2008 Dec 28, 2008
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.
TOPICS
ActionScript
636
Translate
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 ,
Dec 29, 2008 Dec 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/


Translate
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
New Here ,
Dec 30, 2008 Dec 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.


Translate
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
Guru ,
Dec 30, 2008 Dec 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;
}
Translate
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
New Here ,
Dec 30, 2008 Dec 30, 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.
Translate
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
Guru ,
Dec 31, 2008 Dec 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.
Translate
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
New Here ,
Jan 01, 2009 Jan 01, 2009
LATEST
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.
Translate
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
New Here ,
Dec 31, 2008 Dec 31, 2008
tutvid.com has a great tutorial that refers to some of these. Go to the one with the scrolling gallery.
Translate
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