How do I use setCursor in Flash?

I'm using the list component in Flash (I'm using the Flash MX version in Flash 2004). I want to change the mouse to a selection hand when I mouse over items in my list. I have not been able to get setCursor to work. I want something like:

onClipEvent(enterFrame) {
    this.onRollOver = function() {
  fl.tools.setCursor( 7 );
}  
}
LVL 1
Aspirin99Asked:
Who is Participating?
 
negatyveCommented:
> Do I need to change any of that to match my list component's instance name?

No, the code don't need to be changed. http://www.negatyve.com/EE/ListBoxHandCursor.zip
0
 
BillystyxCommented:
_root.useHandCursor=true;

Billystyx
0
 
BillystyxCommented:
but put the code on the main timeline (or the parent to the mc)


    myList.onRollOver = function() {
 this.useHandCursor=true;
}  

billystyx
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
ddlamCommented:
click your list component.
press F9 to open action script panel.
then add:

on(itemRollOver){
    fl.tools.setCursor( 7 );
}

/*
you mightn't be able to change the cursor by useHandCursor=true;
hope the fl.tools.setCursor( 7 ) include the drag() method to attach the cursor and hide the original cursor.
*/
0
 
BillystyxCommented:
you can - I tested it first:)
0
 
ddlamCommented:
it's different between itemRollOver and rollOver   o^^O
0
 
negatyveCommented:
@ Billystyx: your method sets the use of handCursor on the list component itself (because treats it as a big button, making it quite useless, as you cannot click items)
@ ddlam & Aspirin99: setCursor is a Flash javascript  method, not an Actionscript one, to be used only during authoring time, useless in a public movie

@ Aspirin99: if you want to do it in a public movie (not to be used as an authoring panel), the quickest way to do it without creating a custom cell renderer is to write in the first frame of your movie:

import mx.controls.listclasses.SelectableRow;

SelectableRow.prototype._setValue = SelectableRow.prototype.setValue;
SelectableRow.prototype.setValue = function(itmObj:Object, state:String):Void
{
      this._setValue(itmObj, state);
      this.backGround.useHandCursor = itmObj != undefined;
}
0
 
BillystyxCommented:
thanks negatyve - i didn't actually test the list control:)
(looks pretty though!)

billystyx
0
 
Aspirin99Author Commented:
Thanks to all for the help, but I'm not getting any of it to work correctly. Here's what happens.

_root.door.song_list.onRollOver = function() {
 this.useHandCursor=true;
}

For the above, I get a hand cursor. I thought this was the solution, but when I use this either on the movie or outside of the movie, none of the items in the list can be selected.

For the following:
on(itemRollOver){
    fl.tools.setCursor( 7 );
}

Or

on(itemRollOver){
this.useHandCursor=true;
}

The above does nothing in my movie.  I've tried placing it on the list component as a solo piece of code and in a clip event everframe and as a function.

As for:

import mx.controls.listclasses.SelectableRow;

SelectableRow.prototype._setValue = SelectableRow.prototype.setValue;
SelectableRow.prototype.setValue = function(itmObj:Object, state:String):Void
{
     this._setValue(itmObj, state);
     this.backGround.useHandCursor = itmObj != undefined;
}

I could not get the above to work. Is that compatible with Flash MX?
0
 
negatyveCommented:
>I could not get the above to work. Is that compatible with Flash MX?

ok, the you are using ListBox component (not List as I thought). Use this:

FSelectableItemClass.prototype._displayContent = FSelectableItemClass.prototype.displayContent;
FSelectableItemClass.prototype.displayContent = function(itmObj, selected)
{
      this._displayContent(itmObj, selected);
      this.highlight_mc.useHandCursor = (this.fLabel_mc.labelField.text != "")
}
0
 
Aspirin99Author Commented:
Do I need to change any of that to match my list component's instance name? For example, what are .highlight_mc and .fLabel_mc?  The path to my list component is: _root.door.song_list.

 I plugged it into the first frame on the timeline that contains the list component, and it had no effect.
0
 
Aspirin99Author Commented:
Thanks for making the FLA. I moved the code from frame one of the timeline that contained the component to frame one of the _root timeline (like you said from the start), and it worked. I will use this code A LOT. Thanks a million!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.