I have written the following code:
It is a widget that takes an image list. When the mouse passes over the
widget borders appear to show it as a button. Button presses simply
change the image.
It works perfectly in IE5.5
In NS4.75 it works except that when I press the mouse button inside the
widget, move the mouse out, then release the button, the 3d border never
goes away, I have to click.
In NS6 the 3d borders never appear, but the widget work perfectly
otherwise.
I seem to recall reading in the help list about the problem with NS4.75,
but I can't find it. The NS6 problem is new?
Heres the code:
function msgFlatImage( xPos, yPos, ImageList )
{
this.superClass = DynLayer;
this.superClass();
this.id = "FlatImage" + (msgFlatImage.Count++);
this.moveTo( xPos, yPos );
this.setBgColor( "#c0c0c0" );
this.ImageList = ImageList;
this.CurrentImage = 0;
var listener = new EventListener( this );
listener.oncreate = function( event )
{
// get the target of this event
var target = event.getTarget();
// make the image and set it to the first image in the image
list
target.dynimage = new DynImage();
target.dynimage.setImage( target.ImageList[target.CurrentImage]
);
// shortcut (also makes for faster javascript)
var dynimage = target.dynimage;
target.addChild( dynimage );
target.setSize( dynimage.getWidth(), dynimage.getHeight() );
dynimage.moveTo( 0, 0 );
// now add the 3d borders
var dynimage = target.dynimage;
target.borderL = new DynLayer( null, 0, 0, 1, dynimage.h,
"#f0f0f0" );
target.borderT = new DynLayer( null, 0, 0, dynimage.w, 1,
"#f0f0f0" );
target.borderR = new DynLayer( null, dynimage.w-1, 1, 1,
dynimage.h-1, "#808080" );
target.borderB = new DynLayer( null, 1, dynimage.h-1,
dynimage.w-1, 1, "#808080" );
dynimage.addChild( target.borderL );
dynimage.addChild( target.borderT );
dynimage.addChild( target.borderR );
dynimage.addChild( target.borderB );
target.borderL.setVisible( false );
target.borderT.setVisible( false );
target.borderR.setVisible( false );
target.borderB.setVisible( false );
}
listener.onmouseover = function( event )
{
// get the target of this event
var target = event.getTarget();
// and show the borders
target.borderL.setVisible( true );
target.borderT.setVisible( true );
target.borderR.setVisible( true );
target.borderB.setVisible( true );
}
listener.onmouseout = function( event )
{
// get the target of this event
var target = event.getTarget();
// and show the borders
target.borderL.setVisible( false );
target.borderT.setVisible( false );
target.borderR.setVisible( false );
target.borderB.setVisible( false );
target.borderL.setBgColor( "#f0f0f0" );
target.borderT.setBgColor( "#f0f0f0" );
target.borderR.setBgColor( "#808080" );
target.borderB.setBgColor( "#808080" );
}
listener.onclick = function( event )
{
// get the target of this event
var target = event.getTarget();
// and change the image
if ( target.CurrentImage++ == target.ImageList.length-1 )
{
target.CurrentImage = 0;
}
target.dynimage.setImage( target.ImageList[target.CurrentImage]
);
}
listener.onmousedown = function( event )
{
// get the target of this event
var target = event.getTarget();
target.borderL.setBgColor( "#808080" );
target.borderT.setBgColor( "#808080" );
target.borderR.setBgColor( "#f0f0f0" );
target.borderB.setBgColor( "#f0f0f0" );
}
listener.onmouseup = function( event )
{
// get the target of this event
var target = event.getTarget();
target.borderL.setBgColor( "#f0f0f0" );
target.borderT.setBgColor( "#f0f0f0" );
target.borderR.setBgColor( "#808080" );
target.borderB.setBgColor( "#808080" );
}
this.addEventListener( listener );
}
msgFlatImage.Count = 0;
msgFlatImage.prototype = new DynLayer();
msgFlagImage.prototype.getSubClass = function()
{
return( msgFlatImage );
}
Gregor
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help