Aspirin99
asked on
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 );
}
}
onClipEvent(enterFrame) {
this.onRollOver = function() {
fl.tools.setCursor( 7 );
}
}
but put the code on the main timeline (or the parent to the mc)
myList.onRollOver = function() {
this.useHandCursor=true;
}
billystyx
myList.onRollOver = function() {
this.useHandCursor=true;
}
billystyx
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.
*/
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.
*/
you can - I tested it first:)
it's different between itemRollOver and rollOver o^^O
@ 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.Se lectableRo w;
SelectableRow.prototype._s etValue = SelectableRow.prototype.se tValue;
SelectableRow.prototype.se tValue = function(itmObj:Object, state:String):Void
{
this._setValue(itmObj, state);
this.backGround.useHandCur sor = itmObj != undefined;
}
@ 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.Se
SelectableRow.prototype._s
SelectableRow.prototype.se
{
this._setValue(itmObj, state);
this.backGround.useHandCur
}
thanks negatyve - i didn't actually test the list control:)
(looks pretty though!)
billystyx
(looks pretty though!)
billystyx
ASKER
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.onRol lOver = 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.Se lectableRo w;
SelectableRow.prototype._s etValue = SelectableRow.prototype.se tValue;
SelectableRow.prototype.se tValue = function(itmObj:Object, state:String):Void
{
this._setValue(itmObj, state);
this.backGround.useHandCur sor = itmObj != undefined;
}
I could not get the above to work. Is that compatible with Flash MX?
_root.door.song_list.onRol
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.Se
SelectableRow.prototype._s
SelectableRow.prototype.se
{
this._setValue(itmObj, state);
this.backGround.useHandCur
}
I could not get the above to work. Is that compatible with Flash MX?
>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.proto type._disp layContent = FSelectableItemClass.proto type.displ ayContent;
FSelectableItemClass.proto type.displ ayContent = function(itmObj, selected)
{
this._displayContent(itmOb j, selected);
this.highlight_mc.useHandC ursor = (this.fLabel_mc.labelField .text != "")
}
ok, the you are using ListBox component (not List as I thought). Use this:
FSelectableItemClass.proto
FSelectableItemClass.proto
{
this._displayContent(itmOb
this.highlight_mc.useHandC
}
ASKER
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.
I plugged it into the first frame on the timeline that contains the list component, and it had no effect.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!
Billystyx