GVKun编程网logo

简易 web-slide(简易鸡笼子制作方法)

10

在这里,我们将给大家分享关于简易web-slide的知识,让您更了解简易鸡笼子制作方法的本质,同时也会涉及到如何更有效地android–Facebooklideslideout菜单(不使用该库)、cs

在这里,我们将给大家分享关于简易 web-slide的知识,让您更了解简易鸡笼子制作方法的本质,同时也会涉及到如何更有效地android – Facebook lide slideout菜单(不使用该库)、css3 实现 jQuery 的 slideUp 和 slideDown 效果、CSS3相当于jQuery slideUp和slideDown?、flex4 hslider和vslider滑条高亮的内容。

本文目录一览:

简易 web-slide(简易鸡笼子制作方法)

简易 web-slide(简易鸡笼子制作方法)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="./index.css">
</head>
<body>
  <div class="container">
    <div class="slide" id="1">1</div>
    <div class="slide" id="2">2</div>
    <div class="slide" id="3">3</div>
    <div class="slide" id="4">4</div>
    <div class="slide" id="5">5</div>
    <div class="slide" id="6">6</div>
  </div>
  <script src="./a.js"></script>
</body>
</html>
.container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}
.slide {
  width: 100%;
  height: 100%;
  font-size: 50px;
  text-align: center;
}
@keyframes zoomIn {
  from {
    opacity: 0;
    -webkit-transform: scale3d(0.3, 0.3, 0.3);
    transform: scale3d(0.3, 0.3, 0.3);
  }

  50% {
    opacity: 1;
  }
}

.zoomIn {
  animation: zoomIn 0.5s;
}
let num = 1;
let total = 6;
function page(num) {
  window.location.hash = ''#'' + num;
  document.getElementById(num).classList.toggle(''zoomIn'');
  setTimeout(() => {
    document.getElementById(num).classList.toggle(''zoomIn'');
  }, 500);
}
function prev() {
  if (num <= 1) {
    return
  }
  num -= 1;
  page(num);
}
function next() {
  if (num >= total) {
    return
  }
  num += 1;
  page(num);
}
window.addEventListener(''keydown'', (e) => {
  // console.log(e);
  if (e.code === ''ArrowDown'' || e.code === ''ArrowRight'') {
    next();
  }
  if (e.code === ''ArrowUp'' || e.code === ''ArrowLeft'') {
    prev();
  }
});

android – Facebook lide slideout菜单(不使用该库)

android – Facebook lide slideout菜单(不使用该库)

我想在我的应用程序中使用facebook菜单.这里有许多线程,所有这些都建议使用一个库,它实际上只是截取屏幕截图并将图像向右滑动,以便在左侧显示菜单并在一些过渡时滑动图像.但在这种情况下,右侧的布局因其图像而无法点击.

但我还有另一种方法,我有一个根布局已经有菜单布局和内容布局.但根布局在左侧设置了一些负边距,因此不可见.像这样-

当用户按下菜单按钮时,菜单布局向右滑动,根布局的左边距设置为0.所以现在我们看到的是 –

现在,真正的问题从这里开始

我想用一些动画来滑动两个布局.因此,当我为菜单布局设置动画时,内容布局,即使我对其应用相同的动画,两种布局的动画也不会达到相同的速度.所以我尝试通过设置边距来向右/左移动ROOT LAYOUT.但是这样做就没有在屏幕上显示.我哪里错了.我设定保证金的方式如下所示 –

int width = leftLayout.getWidth();
isLayoutShown = !isLayoutShown;
if(isLayoutShown){
    rootLayoutParams.setMargins(0,0);
    rootLayout.setLayoutParams(rootLayoutParams);    
}else{
    rootLayoutParams.setMargins(-width,0);
    rootLayout.setLayoutParams(rootLayoutParams);
}
最佳答案
终于以某种方式我可以做到.这是我点击左上角菜单按钮时使用的代码:

@Override
public void onClick(View v) {
rootLayoutParams = new LayoutParams(rightLayout.getWidth(),rightLayout.getHeight());

if (lhsMenu.getVisibility() == View.GONE) {
    lhsMenu.setVisibility(View.VISIBLE);
    Animation slideRight = setRightSlidingAnimation();
    rightLayout.setAnimation(slideRight);
    lhsMenu.setAnimation(slideRight);
} else {
    Animation slideLeft = setLeftSlidingAnimation();
    rightLayout.setAnimation(slideLeft);
    lhsMenu.setAnimation(slideLeft);
    lhsMenu.setVisibility(View.GONE);
    }
}

更新:还设置rightLayout的左右边距(如果需要),以便rightLayout不会缩小.

_rightLayoutParams.setMargins(width,-width,0);

在我的情况下宽度= 200.

css3 实现 jQuery 的 slideUp 和 slideDown 效果

css3 实现 jQuery 的 slideUp 和 slideDown 效果

      最近打算做一些交互优化方面的轮子。虽然轮子别人都弄过,但是自己没弄过。重复造轮子对知识理解还是有好处的。本次轮子如题目。直接代码。

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>slideup 和 slideDown效果</title>
    <style type="text/css">
    * {
        margin: 0;
        padding: 0;
    }
    #box {
        margin: 0 auto;
        margin-top: 40px;
        width: 200px;
    }

    #box li {
        list-style: none;
    }

    #box ul {
        transition: all 1s;
        overflow: hidden;
        height: 0;
    }

    .show {
        height: 63px !important;
    }
    </style>
</head>

<body>
    <div id="box">
        <h2>菜单</h2>
        <ul class="show">
            <li>html</li>
            <li>css</li>
            <li>JavaScript</li>
        </ul>
    </div>
    <script type="text/javascript" src="./jquery.js"></script>
    <script type="text/javascript">
    $(''body'').on(''click'', ''h2'', function() {
        $("#box ul").toggleClass(''show'')
    })
    </script>
</body>

</html>

  注意:变化的 ul 需要提前设定 height,还有 overflow 属性。

CSS3相当于jQuery slideUp和slideDown?

CSS3相当于jQuery slideUp和slideDown?

我的应用程序执行不好与jQuery的slideDown和slideUp。我想在支持它的浏览器中使用CSS3等效。

是否可以使用CSS3过渡来更改display:none;显示:block;同时向下或向上滑动项目?

解决方法

你可以这样做:
#youritem .fade.in {
    -webkit-animation-name: fadeIn;
}

#youritem .fade.out {
    -webkit-animation-name: fadeOut;
}

@-webkit-keyframes fadeIn {
    0% {
        opacity: 0;
        -webkit-transform: translateY(startYposition);
    } 
    100% {
        opacity: 1;
        -webkit-transform: translateY(endYposition);
    }
}

@-webkit-keyframes fadeOut {
    0% {
        opacity: 1;
        -webkit-transform: translateY(startYposition);
    } 
    100% {
        opacity: 0;
        -webkit-transform: translateY(endYposition);
    }
}

示例 – 滑动和淡化:

这幻灯片和动画的不透明度 – 不基于容器的高度,但在顶部/坐标。
View example

示例 – 自动高度/无Javascript:这是一个实时样本,不需要高度 – 处理自动高度,没有javascript。
View example

flex4 hslider和vslider滑条高亮

flex4 hslider和vslider滑条高亮

在flex3中滑条高亮有个属性 showTrackHighlight="true"; 但是在flex4中不知道什么原因没有

后来在网上翻到一个别人重写的滑块组件 效果图如下:



Hslider.as

package com.bufoon.component
{
	{
		
		import com.bufoon.skin.HSliderSkin;
		
		import flash.events.Event;
		import flash.events.MouseEvent;
		import flash.geom.Point;
		
		import mx.core.InteractionMode;
		import mx.events.ResizeEvent;
		
		import spark.components.Button;
		import spark.components.HSlider;
		import spark.effects.animation.Animation;
		
		/**
		 *  The color for the slider track when it is selected.
		 *  
		 *  @langversion 3.0
		 *  @playerversion Flash 10
		 *  @playerversion AIR 1.5
		 *  @productversion Flex 4
		 */
		[Style(name="accentColor",type="uint",format="Color",inherit="yes",theme="spark")]
		
		/**
		 *  Specifies whether to enable track highlighting between thumbs
		 *  (or a single thumb and the beginning of the track).
		 *
		 *  @default false
		 *  
		 *  @langversion 3.0
		 *  @playerversion Flash 10
		 *  @playerversion AIR 1.5
		 *  @productversion Flex 4
		 */
		[Style(name="showTrackHighlight",type="Boolean",inherit="no")]
		
		public class HSlider extends spark.components.HSlider
		{
			/**
			 *  @private
			 */
			private var animator:Animation = null;
			
			[SkinPart(required="false")]
			public var trackHighLight:Button;
			
			[Bindable]
			private var _accentColor:uint;
			private var accentColorChanged:Boolean
			
			[Bindable]
			private var _showTrackHighlight:Boolean = true;
			private var showTrackHighlightChanged:Boolean;
			
			public function HSlider()
			{
				super();
				setStyle("skinClass",HSliderSkin);
			}
			
			
			/**
			 *  @private
			 */
			override protected function updateSkindisplayList():void
			{
				super.updateSkindisplayList();
				if (!thumb || !track || !trackHighLight)
					return;
				
				var thumbRange:Number = track.getLayoutBoundsWidth() - thumb.getLayoutBoundsWidth();
				var range:Number = maximum - minimum;
				
				// calculate new thumb position.
				var thumbPosTrackX:Number = (range > 0) ? ((pendingValue - minimum) / range) * thumbRange : 0;
				
				// convert to parent's coordinates.
				var thumbPos:Point = track.localToGlobal(new Point(thumbPosTrackX,0));
				var thumbPosParentX:Number = thumb.parent.globalToLocal(thumbPos).x+thumb.getLayoutBoundsWidth()/2;
				
				//thumb.setLayoutBoundsPosition(Math.round(thumbPosParentX),thumb.getLayoutBoundsY());
				trackHighLight.setLayoutBoundsSize(Math.round(thumbPosParentX),trackHighLight.getLayoutBoundsHeight());
			}
			
			/**
			 *  @private
			 *  Warning: the goal of the listeners added here (and removed below) is to 
			 *  give the TrackBase a change to fixup the thumb's size and position
			 *  after the skin's BasicLayout has run.   This particular implementation
			 *  is a hack and it begs a solution to the general problem of what we've
			 *  called "cooperative layout".   More about that here:
			 *  http://opensource.adobe.com/wiki/display/flexsdk/Cooperative+Subtree+Layout
			 */
			override protected function partAdded(partName:String,instance:Object):void
			{
				super.partAdded(partName,instance);
				
				if (instance == trackHighLight)
				{
					trackHighLight.focusEnabled = false;
					trackHighLight.addEventListener(ResizeEvent.RESIZE,trackHighLight_resizeHandler);
					
					// track is only clickable if in mouse interactionMode
					if (getStyle("interactionMode") == InteractionMode.MOUSE)
						trackHighLight.addEventListener(MouseEvent.MOUSE_DOWN,trackHighLight_mouseDownHandler);
				}
			}
			
			/**
			 *  @private
			 */
			override protected function partRemoved(partName:String,instance:Object):void
			{
				super.partRemoved(partName,instance);
				
				if (instance == trackHighLight)
				{
					trackHighLight.removeEventListener(MouseEvent.MOUSE_DOWN,trackHighLight_mouseDownHandler);
					trackHighLight.removeEventListener(ResizeEvent.RESIZE,trackHighLight_resizeHandler);
				}
			}
			
			/**
			 *  @private
			 *  Handle mouse-down events for the slider track hightlight. We
			 *  calculate the value based on the new position and then
			 *  move the thumb to the correct location as well as
			 *  commit the value.
			 */
			protected function trackHighLight_mouseDownHandler(event:MouseEvent):void
			{
				this.track_mouseDownHandler(event);
			}
			
			/**
			 *  @private
			 */
			private function trackHighLight_resizeHandler(event:Event):void
			{
				updateSkindisplayList();
			}
			
			/**
			 *  @private
			 */
			override public function styleChanged(styleProp:String):void
			{
				var anyStyle:Boolean = styleProp == null || styleProp == "styleName";
				
				super.styleChanged(styleProp);
				if (styleProp == "showTrackHighlight" || anyStyle)
				{
					showTrackHighlightChanged = true;
					invalidateProperties();
				}
				
				if (styleProp == "accentColor" || anyStyle)
				{
					accentColorChanged = true;
					invalidateProperties();
				}
				
				invalidatedisplayList();
			}
			
			override protected function commitProperties():void
			{
				super.commitProperties();
				
				if (showTrackHighlightChanged)
				{
					this.trackHighLight.visible = this._showTrackHighlight;
					showTrackHighlightChanged = false;
				}
				if(accentColorChanged){
					this.trackHighLight.setStyle("themeColor",this.accentColor);
					accentColorChanged = false;
				}
			}
			
			public function set accentColor(color:uint):void
			{
				this._accentColor = color;
				accentColorChanged = true;
				this.invalidateProperties();
			}
			
			
			public function get accentColor():uint
			{
				return this._accentColor;
			}
			
			public function set showTrackHighlight(show:Boolean):void
			{
				this._showTrackHighlight = show;
				showTrackHighlightChanged = true;
				this.invalidateProperties();
			}
			
			public function get showTrackHighlight():Boolean
			{
				return this._showTrackHighlight;
			}
		}
	}
}

HSliderSkin.mxml

<?xml version="1.0" encoding="utf-8"?>

<!--

AdobE SYstemS INCORPORATED
copyright 2008 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use,modify,and distribute this file
in accordance with the terms of the license agreement accompanying it.
-->

<!--- The default skin class for the Spark HSlider component. The thumb and track skins are defined by the
HsliderTrackHighLightSkin,HSliderThumbSkin and HSliderTrackSkin,classes,respectively.  

@see de.patrickheinzelmann.components.spark.HSlider
@see spark.skins.spark.HSliderThumbSkin
@see spark.skins.spark.HSliderTrackSkin
@see de.patrickheinzelmann.components.spark.skins.HsliderTrackHighLightSkin

@langversion 3.0
@playerversion Flash 10
@playerversion AIR 1.5
@productversion Flex 4
-->
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
			 xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minHeight="11" alpha.disabled="0.5">
	
	<fx:Metadata>
		<![CDATA[ 
		/** 
		* @copy spark.skins.spark.ApplicationSkin#hostComponent
		*/
		[HostComponent("com.bufoon.component.HSlider")]
		]]>
	</fx:Metadata> 
	
		<fx:Script fb:purpose="styling">
		/* Define the skin elements that should not be colorized. 
		For slider,the skin itself is colorized but the individual parts are not. */
		static private const exclusions:Array = ["track","thumb","trackHighLight"];
		
		/**
		 * @private
		 */  
		override public function get colorizeExclusions():Array {return exclusions;}
		
		/**
		 * @private
		 */
		override protected function initializationComplete():void
		{
			useChromeColor = true;
			super.initializationComplete();
		}
	</fx:Script>
	
		<fx:Script>
		/**
		 *  @private
		 */  
		override protected function measure() : void
		{
			// Temporarily move the thumb to the left of the Slider so measurement
			// doesn't factor in its x position. This allows resizing the
			// HSlider to less than 100px in width. 
			var thumbPos:Number = thumb.getLayoutBoundsX();
			thumb.setLayoutBoundsPosition(0,thumb.getLayoutBoundsY());
			super.measure();
			thumb.setLayoutBoundsPosition(thumbPos,thumb.getLayoutBoundsY());
		}
	</fx:Script>
	
	<s:states>
		<s:State name="normal" />
		<s:State name="disabled" />
	</s:states>
	
	<fx:Declarations>
		<!--- The tooltip used in the mx.controls.Slider control. 
		To customize the datatip's appearance,create a custom HSliderSkin class.-->
		<fx:Component id="datatip">     
			<s:DataRenderer minHeight="24" minWidth="40" y="-34">  
				<s:Rect top="0" left="0" right="0" bottom="0">
					<s:fill>
						<s:SolidColor color="0x000000" alpha=".9"/>
					</s:fill>
					<s:filters>
						<s:DropShadowFilter angle="90" color="0x999999" distance="3"/>
					</s:filters>
				</s:Rect>
				<s:Label id="labeldisplay" text="{data}"
						 horizontalCenter="0" verticalCenter="1"
						 left="5" right="5" top="5" bottom="5"
						 textAlign="center" verticalAlign="middle"
						 fontWeight="normal" color="white" fontSize="11">
				</s:Label>
			</s:DataRenderer>
		</fx:Component>
	</fx:Declarations>
	
	<!--- The default skin class is HSliderTrackSkin. 
	@copy spark.components.supportClasses.TrackBase#trackHighlight
	@see spark.skins.spark.HSliderTrackSkin -->
	<s:Button id="track" left="0" right="0" top="0" bottom="0" minWidth="33" width="100"
			  skin/>
	
	<!--- The default skin class is HSliderTrackSkin. 
	@copy spark.components.supportClasses.TrackBase#track
	@see de.patrickheinzelmann.components.spark.skins.HsliderTrackHighLightSkin -->
	<s:Button id="trackHighLight" left="0" right="0" top="0" bottom="0" minWidth="33" width="100"
			  skin/>
	
	<!--- The default skin class is HSliderThumbSkin.
	@copy spark.components.supportClasses.TrackBase#thumb 
	@see spark.skins.spark.HSliderThumbSkin -->
	<s:Button id="thumb" top="0" bottom="0" width="11" height="11" 
			  skinaccentColor="0xFF00FF" />
</s:SparkSkin>

HSliderTrackHighLightSkin.mxml

<?xml version="1.0" encoding="utf-8"?>

<!--

AdobE SYstemS INCORPORATED
copyright 2008 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use,and distribute this file
in accordance with the terms of the license agreement accompanying it.

-->

<!--- The default skin class for the track of a Spark HSlider component.  

@see spark.components.HSlider

@langversion 3.0
@playerversion Flash 10
@playerversion AIR 1.5
@productversion Flex 4
-->
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
			 xmlns:fb="http://ns.adobe.com/flashbuilder/2009">
	
	<fx:Metadata>
		<![CDATA[ 
		/** 
		* @copy spark.skins.spark.ApplicationSkin#hostComponent
		*/
		[HostComponent("spark.components.Button")]
		]]>
	</fx:Metadata> 
	
		<fx:Script fb:purpose="styling">
		[Bindable]
		private var highlightColor:uint;
		
		/**
		 * @private
		 */
		override protected function initializationComplete():void
		{
			highlightColor = this.getStyle("themeColor");
			super.initializationComplete();
		}
		
		override public function styleChanged(styleProp:String):void
		{
			super.styleChanged(styleProp);
			if(styleProp == "themeColor"){
				var trackHighlightColor:uint = this.getStyle("themeColor");
				highlightColor = trackHighlightColor;
			}
		}
	</fx:Script>
	
	<s:states>
		<s:State name="up" />
		<s:State name="down" />
		<s:State name="over" />
		<s:State name="disabled" />
	</s:states>
	
	<!-- fill -->
	<s:Rect left="1" right="1" top="4" bottom="4" bottomLefTradiusX="2" bottomLefTradiusY="2" topLefTradiusX="2" topLefTradiusY="2" bottomrighTradiusX="0" bottomrighTradiusY="0" topRighTradiusX="0" topRighTradiusY="0">
		<s:fill>
			<s:SolidColor color="{highlightColor}" alpha="0.5" />
		</s:fill>
	</s:Rect>
	
	<!-- hit area -->
	<s:Rect left="0" right="0" top="0" bottom="0">
		<s:fill>
			<s:SolidColor alpha="0"/>
		</s:fill>
	</s:Rect>
</s:SparkSkin>

VSlider.as

package com.bufoon.component
{
	
	import com.bufoon.skin.VSliderSkin;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import mx.core.InteractionMode;
	import mx.events.ResizeEvent;
	
	import spark.components.Button;
	
	/**
	 *  The color for the slider track when it is selected.
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 10
	 *  @playerversion AIR 1.5
	 *  @productversion Flex 4
	 */
	[Style(name="accentColor",theme="spark")]
	
	/**
	 *  Specifies whether to enable track highlighting between thumbs
	 *  (or a single thumb and the beginning of the track).
	 *
	 *  @default false
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 10
	 *  @playerversion AIR 1.5
	 *  @productversion Flex 4
	 */
	[Style(name="showTrackHighlight",inherit="no")]
	
	public class VSlider extends spark.components.VSlider
	{
		[SkinPart(required="false")]
		public var trackHighLight:Button;
		
		[Bindable]
		private var _accentColor:uint;
		private var accentColorChanged:Boolean;
		
		[Bindable]
		private var _showTrackHighlight:Boolean = true;
		private var showTrackHighlightChanged:Boolean;
		
		public function VSlider()
		{
			super();
			setStyle("skinClass",VSliderSkin);
		}
		
		/**
		 *  @private
		 */
		override protected function updateSkindisplayList():void
		{
			super.updateSkindisplayList();
			if (!thumb || !track || !trackHighLight)
				return;
			
			var thumbRange:Number = track.getLayoutBoundsHeight() - thumb.getLayoutBoundsHeight();
			var range:Number = maximum - minimum;
			
			// calculate new thumb position.
			var thumbPosTrackY:Number = (range > 0) ? thumbRange - (((pendingValue - minimum) / range) * thumbRange) : 0;
			
			// convert to parent's coordinates.
			var thumbPos:Point = track.localToGlobal(new Point(0,thumbPosTrackY));
			var thumbPosParentY:Number = thumb.parent.globalToLocal(thumbPos).y+thumb.getLayoutBoundsHeight()/2;
			
			trackHighLight.setLayoutBoundsPosition(trackHighLight.getLayoutBoundsX(),thumbPosParentY);
			trackHighLight.setLayoutBoundsSize( trackHighLight.getLayoutBoundsWidth(),track.getLayoutBoundsHeight()-thumbPosParentY);
		}
		
		/**
		 *  @private
		 *  Warning: the goal of the listeners added here (and removed below) is to 
		 *  give the TrackBase a change to fixup the thumb's size and position
		 *  after the skin's BasicLayout has run.   This particular implementation
		 *  is a hack and it begs a solution to the general problem of what we've
		 *  called "cooperative layout".   More about that here:
		 *  http://opensource.adobe.com/wiki/display/flexsdk/Cooperative+Subtree+Layout
		 */
		override protected function partAdded(partName:String,instance:Object):void
		{
			super.partAdded(partName,instance);
			
			if (instance == trackHighLight)
			{
				trackHighLight.focusEnabled = false;
				trackHighLight.addEventListener(ResizeEvent.RESIZE,trackHighLight_resizeHandler);
				
				// track is only clickable if in mouse interactionMode
				if (getStyle("interactionMode") == InteractionMode.MOUSE)
					trackHighLight.addEventListener(MouseEvent.MOUSE_DOWN,trackHighLight_mouseDownHandler);
			}
		}
		
		/**
		 *  @private
		 */
		override protected function partRemoved(partName:String,instance:Object):void
		{
			super.partRemoved(partName,instance);
			
			if (instance == trackHighLight)
			{
				trackHighLight.removeEventListener(MouseEvent.MOUSE_DOWN,trackHighLight_mouseDownHandler);
				trackHighLight.removeEventListener(ResizeEvent.RESIZE,trackHighLight_resizeHandler);
			}
		}
		
		/**
		 *  @private
		 *  Handle mouse-down events for the slider track hightlight. We
		 *  calculate the value based on the new position and then
		 *  move the thumb to the correct location as well as
		 *  commit the value.
		 */
		protected function trackHighLight_mouseDownHandler(event:MouseEvent):void
		{
			this.track_mouseDownHandler(event);
		}
		
		/**
		 *  @private
		 */
		private function trackHighLight_resizeHandler(event:Event):void
		{
			updateSkindisplayList();
		}
		
		/**
		 *  @private
		 */
		override public function styleChanged(styleProp:String):void
		{
			var anyStyle:Boolean = styleProp == null || styleProp == "styleName";
			
			super.styleChanged(styleProp);
			if (styleProp == "showTrackHighlight" || anyStyle)
			{
				showTrackHighlightChanged = true;
				invalidateProperties();
			}
			
			if (styleProp == "accentColor" || anyStyle)
			{
				accentColorChanged = true;
				invalidateProperties();
			}
			
			invalidatedisplayList();
		}
		
		override protected function commitProperties():void
		{
			super.commitProperties();
			
			if (showTrackHighlightChanged)
			{
				this.trackHighLight.visible = this._showTrackHighlight;
				showTrackHighlightChanged = false;
			}
			
			if(accentColorChanged){
				this.trackHighLight.setStyle("themeColor",this.accentColor);
				accentColorChanged = false;
			}
		}
		
		public function set accentColor(color:uint):void
		{
			this._accentColor = color;
			this.accentColorChanged = true;
			this.invalidateProperties();
		}
		
		
		public function get accentColor():uint
		{
			return this._accentColor;
		}
		
		public function set showTrackHighlight(show:Boolean):void
		{
			this._showTrackHighlight = show;
			showTrackHighlightChanged = true;
			this.invalidateProperties();
		}
		
		public function get showTrackHighlight():Boolean
		{
			return this._showTrackHighlight;
		}
	}
}

VSliderSkin.mxml

<?xml version="1.0" encoding="utf-8"?>

<!--

AdobE SYstemS INCORPORATED
copyright 2008 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use,and distribute this file
in accordance with the terms of the license agreement accompanying it.
-->

<!--- The default skin class for the Spark VSlider component. The thumb and track skins are defined by the
VSliderThumbSkin and VSliderTrackSkin classes,respectively.  

@see spark.components.VSlider
@see spark.skins.spark.VSliderThumbSkin
@see spark.skins.spark.VSliderTrackSkin

@langversion 3.0
@playerversion Flash 10
@playerversion AIR 1.5
@productversion Flex 4
-->
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
			 xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minWidth="11" alpha.disabled="0.5">
	<fx:Metadata>[HostComponent("com.bufoon.component.VSlider")]</fx:Metadata>
	
		<fx:Script fb:purpose="styling">
		/* Define the skin elements that should not be colorized. 
		For slider,"trackHighLight"];
		
		/**
		 * @private
		 */   
		override public function get colorizeExclusions():Array {return exclusions;}
		
		/**
		 * @private
		 */
		override protected function initializationComplete():void
		{
			useChromeColor = true;
			super.initializationComplete();
		}
	</fx:Script>
	
		<fx:Script>
		/**
		 *  @private
		 */  
		override protected function measure() : void
		{
			// Temporarily move the thumb to the top of the Slider so measurement
			// doesn't factor in its y position. This allows resizing the
			// VSlider to less than 100px in height. 
			var thumbPos:Number = thumb.getLayoutBoundsY();
			thumb.setLayoutBoundsPosition(thumb.getLayoutBoundsX(),0);
			super.measure();
			thumb.setLayoutBoundsPosition(thumb.getLayoutBoundsX(),thumbPos);
		}
	</fx:Script>
	
	<s:states>
		<s:State name="normal" />
		<s:State name="disabled" />
	</s:states>
	
	<fx:Declarations>
		<!--- The tooltip used in the mx.controls.Slider control.
		To customize the datatip's appearance,create a custom VSliderSkin class. -->
		<fx:Component id="datatip">
			<s:DataRenderer minHeight="24" minWidth="40" x="20"> 
				<s:Rect top="0" left="0" right="0" bottom="0">
					<s:fill>
						<s:SolidColor color="0x000000" alpha=".9"/>
					</s:fill>
					<s:filters>
						<s:DropShadowFilter angle="90" color="0x999999" distance="3"/>
					</s:filters>
				</s:Rect>
				<s:Label id="labeldisplay" text="{data}"
						 horizontalCenter="0" verticalCenter="1"
						 left="5" right="5" top="5" bottom="5"
						 textAlign="center" verticalAlign="middle"
						 fontWeight="normal" color="white" fontSize="11">
				</s:Label>
			</s:DataRenderer>
		</fx:Component>
	</fx:Declarations>
	
	<!--- The default skin class is VSliderTrackSkin.
	@copy spark.components.supportClasses.TrackBase#track 
	@see spark.skins.spark.VSliderTrackSkin -->
	<s:Button id="track" left="0" right="0" top="0" bottom="0" minHeight="33" height="100"
			  skin/>
	
	<!--- The default skin class is VSliderTrackSkin. 
	@copy spark.components.supportClasses.TrackBase#trackHighLight
	@see de.patrickheinzelmann.components.spark.skins.VsliderTrackHighLightSkin -->
	<s:Button id="trackHighLight" left="0" right="0" top="0" bottom="0" minHeight="33" height="100"
			  skin/>
	
	<!--- The default skin class is VSliderThumbSkin. 
	@copy spark.components.supportClasses.TrackBase#thumb
	@see spark.skins.spark.VSliderThumbSkin -->
	<s:Button id="thumb" left="0" right="0" width="11" height="11" 
			  skin/>
	
</s:SparkSkin>

VSliderTrackHighLightSkin.mxml

<?xml version="1.0" encoding="utf-8"?>

<!--

AdobE SYstemS INCORPORATED
copyright 2008 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use,and distribute this file
in accordance with the terms of the license agreement accompanying it.

-->

<!--- The default skin class for the track of a Spark VSlider component.  

@see spark.components.VSlider

@langversion 3.0
@playerversion Flash 10
@playerversion AIR 1.5
@productversion Flex 4
-->
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
			 xmlns:fb="http://ns.adobe.com/flashbuilder/2009">
	
	<fx:Metadata>
		<![CDATA[ 
		/** 
		* @copy spark.skins.spark.ApplicationSkin#hostComponent
		*/
		[HostComponent("spark.components.Button")]
		]]>
	</fx:Metadata> 
	
		<fx:Script fb:purpose="styling">
		[Bindable]
		private var highlightColor:uint;
		
		/**
		 * @private
		 */
		override protected function initializationComplete():void
		{
			highlightColor = this.getStyle("themeColor");
			super.initializationComplete();
		}
		
		override public function styleChanged(styleProp:String):void
		{
			super.styleChanged(styleProp);
			if(styleProp == "themeColor"){
				var trackHighlightColor:uint = this.getStyle("themeColor");
				highlightColor = trackHighlightColor;
			}
		}
	</fx:Script>
	
	<s:states>
		<s:State name="up" />
		<s:State name="down" />
		<s:State name="over" />
		<s:State name="disabled" />
	</s:states>
	
	<!-- fill -->
	<s:Rect left="4" right="4" top="1" bottom="1" radiusX="2" radiusY="2">
		<s:fill>
			<s:SolidColor color="{highlightColor}" alpha="0.5" />
		</s:fill>
	</s:Rect>
	
	<!-- hit area -->
	<s:Rect left="0" right="0" top="0" bottom="0">
		<s:fill>
			<s:SolidColor alpha="0"/>
		</s:fill>
	</s:Rect>
</s:SparkSkin>
使用方法

<component:HSlider showTrackHighlight="true" accentColor="0xff0000"/>
	<component:VSlider showTrackHighlight="true" accentColor="0xff0000"/>

原文地址:  http://www.patrick-heinzelmann.de/blog/2011/01/25/spark-slider-with-track-highlight/

我们今天的关于简易 web-slide简易鸡笼子制作方法的分享已经告一段落,感谢您的关注,如果您想了解更多关于android – Facebook lide slideout菜单(不使用该库)、css3 实现 jQuery 的 slideUp 和 slideDown 效果、CSS3相当于jQuery slideUp和slideDown?、flex4 hslider和vslider滑条高亮的相关信息,请在本站查询。

本文标签: