Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I use setCursor in Flash?

Posted on 2005-05-10
12
Medium Priority
?
845 Views
Last Modified: 2012-06-27
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 );
}  
}
0
Comment
Question by:Aspirin99
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 18

Expert Comment

by:Billystyx
ID: 13972615
_root.useHandCursor=true;

Billystyx
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 13972656
but put the code on the main timeline (or the parent to the mc)


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

billystyx
0
 
LVL 9

Expert Comment

by:ddlam
ID: 13972810
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 18

Expert Comment

by:Billystyx
ID: 13973061
you can - I tested it first:)
0
 
LVL 9

Expert Comment

by:ddlam
ID: 13973185
it's different between itemRollOver and rollOver   o^^O
0
 
LVL 27

Expert Comment

by:negatyve
ID: 13973444
@ 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
 
LVL 18

Expert Comment

by:Billystyx
ID: 13973456
thanks negatyve - i didn't actually test the list control:)
(looks pretty though!)

billystyx
0
 
LVL 1

Author Comment

by:Aspirin99
ID: 13977213
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
 
LVL 27

Expert Comment

by:negatyve
ID: 13977323
>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
 
LVL 1

Author Comment

by:Aspirin99
ID: 13977915
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
 
LVL 27

Accepted Solution

by:
negatyve earned 2000 total points
ID: 13978015
> 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
 
LVL 1

Author Comment

by:Aspirin99
ID: 13978377
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question