当前位置: 动力学知识库 > 问答 > 编程问答 >

actionscript 2 - How to show tooltips inside a ScrollPane without letting Flash 8 hide the tooltip?

问题描述:

I have the content of a scrollpane that, when clicked, show a tooltip movieclip with attachMovieClip; the problem is that the attached movie clip, for the first rows, goes under the border of the ScrollPane and is partially invisible.

Is there a way to solve this problem (without changing the position of the attached movie clip?)

网友答案:

I assume you are loading a movieclip inside the ScrollPane's contentPath. This movieclip dynamically loads another movieclip, the tooltip. If you are loading the tooltip this way, the depth doesn't matter: everything within the ScrollPane object is clipped, and you will never be able to view what is underneath. This is the whole point of a ScrollPane class, of course; it shows only a bit of the underlying content at a time, and allows the user to scroll around.

Here is code that can replicate the problem:

this.attachMovie("tooltip1","tooltip1A", 100); //note the high level     
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
    tooltip1A._x = _xmouse;
    tooltip1A._y = _ymouse;
    updateAfterEvent();
};

Mouse.addListener(mouseListener);

Put this inside a library movieclip (call it paneContentMC). Open the Properties. Check "Export for Actionscript" and make the "Identifier:" text "paneContentMC1". Close the Properties, and then create some random graphics on the timeline in paneContentMC.

Create another movieclip called tooltip. Open the Properties. Check "Export for Actionscript" and make the "Identifier:" text "tooltip1".

Finally, on the scene's main timeline, create a ScrollPane and make the "contentPath" property "paneContentMC1". Put a stop(); command in the Actionscript for the first frame of this timeline.

There you have a clipped tooltip. How do you fix this?

You need to make the tooltip attach to an object outside the ScrollPane's content. Since you do not know what objects may or may not exist on the stage at runtime, pick a global object, like _root.

Go into the Actionscript inside paneContentMC. Change the code to:

var mc1:MovieClip = _root.attachMovie("tooltip1","tooltip1A", _root.getNextHighestDepth());

var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
    _root.tooltip1A._x = _xmouse;
    _root.tooltip1A._y = _ymouse;
    updateAfterEvent();
};

This does not solve the problem entirely, since tooltip1A is following the mouse around outside the ScrollPane. But if the tooltip1A is listening for movement events from the paneContentMC rather than from the mouse, this should work out.

(Edited to fix a voting error.)

分享给朋友:
您可能感兴趣的文章:
随机阅读: