Skip to main content
Known Participant
December 8, 2010
Answered

Help getting rollover listners to work in a scroll pane

  • December 8, 2010
  • 1 reply
  • 722 views

In AS2, how can i get a roll over listner in a MC inside a scroll pane to display a MC tool tip on the stage outside of the scroll pane? I am using the following code in the main time line to display the tool tip and it dosn't seem to be working:

//****Sel******//

selectionTxt._visible = false;
Sel.onRollOver = function()
{
selectionTxt._visible = true;
}

Sel.onRollOut = function()
{
selectionTxt._visible = false;
}

Any clue would be appreciated

This topic has been closed for replies.
Correct answer Ned Murphy

The content is not on the main timeline. It

does not appear on the stage until you preview it.


IF you are loading it from the library via its linkage ID, then the following may work...

selectionTxt._visible = false;

sp.content.Sel.onRollOver = function()
{
    selectionTxt._visible = true;
}

sp.content.Sel.onRollOut = function()
{
    selectionTxt._visible = false;
}

1 reply

Ned Murphy
Legend
December 8, 2010

There are a couple of things you need to attend to.  First, you need to wait until the scrollpane has loaded its content before you can try to assign code to anything within it.  Second, you need to target the button (Sel) via the scrollpane's content property ("sp" is the instance name of the scrollpane in the example below)...

selectionTxt._visible = false;

var listenerObject:Object = new Object();


listenerObject.complete = function(eventObject:Object) {
      sp.content.Sel.onRollOver = function()
      {
            selectionTxt._visible = true;
      }

      sp.content.Sel.onRollOut = function()
      {
            selectionTxt._visible = false;
      }
};


sp.addEventListener("complete", listenerObject);

Note:  The code, scrollpane, and selectionTxt are all on the main timeline.

jaswerlAuthor
Known Participant
December 8, 2010

Thanks for the timely response. I used the code and named the scroll pane instance "sp". I assume the listenerObject.complete is a call to the complete event for the loading of the content. However it's not working. I note 2 things: the scroll pane is marked as an swf. Is that correct? The second thing is that my selectionTxt MC is on the stage, not inside the scroll panel. Does that make a difference? Also the SP content is in the library and I set up a linkage. Is thet correct?

Ned Murphy
Legend
December 8, 2010

For the example I showed, the content is an swf loaded into the scrollpane, not a library object.  The scrollpane, textfield, and code are all on the main timeline.  It works when I test it.