Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-20-2008, 02:10 PM   #1
talmand
Registered User
 
Join Date: Jun 2008
Location: Alabama
Posts: 2
Default Detecting Mouse Click

I'm trying to figure out how to get functionality like the Info Panel that the Flash IDE has. That panel is always updating with the location of the cursor, knows the color/alpha of the element under the cursor and if you select something the text boxes change to show information about the selected object. After looking through the help references I cannot see any functionality that explains how this is done.

I've played with using a setInterval and enterFrame on my windowSWF and that does what I want but it doesn't interact very well with the Actions panel. And sometimes the cursor just acts weird as the panel is running its code. Often times the behavior goes away if I click on the stage though so I'm tempted to stick a mouse click command in there for a spot off to the edge of the stage.

So does anybody know the proper way to detect when an element has been selected? Or at least point me to somewhere that explains it?
talmand is offline   Reply With Quote
Old 07-14-2008, 03:34 PM   #2
rtsamir
Ronen Tsamir
 
Join Date: Oct 2006
Location: Israel
Posts: 33
Default

I was researching this my self for a while and I think that there is no option to get 'select' event in JSFL.
rtsamir is offline   Reply With Quote
Old 07-14-2008, 04:02 PM   #3
jslice390
Member
 
Join Date: Feb 2007
Posts: 53
Default This might help

You were pretty close to having it work right. I couldn't get it to work until I figured out how to get MMExecute to return variables. What you need to do is declare a variable in your jsfl, set its value and then at the very end of that jsfl script just type the name of the variable. That will return the value of your jsfl variable through MMExecute and then you can use the data in your .swf. Here's some example code:

ActionScript Code:
var xLoc = "var loc = fl.tools.penLoc.x;\n";     xLoc +="loc;"; //Returns loc (fl.tools.penLoc.x)     var yLoc = "var loc = fl.tools.penLoc.y;\n";     yLoc +="loc;"; //Returns loc (fl.tools.penLoc.y) var mySelection = "var loc = fl.tools.penLoc;\n";     mySelection +="var selection = fl.getDocumentDOM().selection;\n";     mySelection +="var selectionToDisplayInSWF = selection[0];\n";     mySelection +="selectionToDisplayInSWF;";//***Returns the first element in the selection array*** addEventListener("enterFrame", checkFrame); function checkFrame(evt){     position.text = "x: " + MMExecute(xLoc) + ", y: " + MMExecute(yLoc);     mytxt.text = MMExecute(mySelection); }

*In order for this to work you'll need two textfields... position and mytxt.
__________________
Jamin Hall
jslice390 is offline   Reply With Quote
Old 07-16-2008, 05:39 PM   #4
talmand
Registered User
 
Join Date: Jun 2008
Location: Alabama
Posts: 2
Default

Well, your code does what it advertises but doesn't really solve the problems I have.

It does give the location of the cursor which is handy to have. But it doesn't really detect the mouse click, it more or less just returns what is selected. This is easily accomplished and I actually had this working. Plus the problems with the IDE acting strangely with the enterFrame event such as the cursor constantly changing states and the inability to double-click objects on the stage is still there.

So far my experience is that extensions (or at least mine) do not behave well with the IDE when using enterFrame events. That was why I was hoping for a way to just detect the click and then run my function with that click.

Being able to see the code for the Info panel would be wonderful to solve this problem.
talmand is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prev & Next slide on Mouse click soulfly ActionScript 2.0 2 11-24-2006 08:44 AM
Problems detecting when the mouse has left an object. OM2 ActionScript 2.0 0 06-18-2006 05:40 PM
How to detect Mouse right click tiru ActionScript 2.0 6 10-04-2005 09:17 AM
Extremely Frustrated with Mouse and Centering - Advise Please RedWombat ActionScript 1.0 (and below) 16 09-16-2005 05:18 PM
Move movie clip towards mouse click AndySmith ActionScript 1.0 (and below) 8 10-28-2002 01:12 PM


All times are GMT. The time now is 11:07 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.