固定大小的滚动条UIScrollBar复写

using UnityEngine;
using System.Collections.Generic;

[ExecuteInEditMode]
[AddComponentMenu("NGUI/Interaction/NGUI Scroll Bar Fixed Size")]
public class UIScrollBarFixSize : UIScrollBar
{
    public float mFixedSize = 0.1f;

    /// <summary>
    /// The size of the foreground bar in percent (0-1 range).
    /// </summary>

    public override float barSize
    {
        get
        {
            return mSize;
        }
        set
        {
            if (mFixedSize != 0)
                mSize = mFixedSize;

            float val = Mathf.Clamp01(value);

            if (mSize != val)
            {
                mSize = mFixedSize != 0 ? mFixedSize : val;
                mIsDirty = true;

                if (NGUITools.GetActive(this))
                {
                    if (current == null && onChange != null)
                    {
                        current = this;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AS3.0 TLFTextField 最新的组件库 以往的有BUG,这个可是最新的哦 package { import fl.controls.UIScrollBar; import fl.text.TLFTextField; import flash.events.Event; import flashx.textLayout.conversion.TextConverter; import flashx.textLayout.edit.IEditManager; import flashx.textLayout.elements.FlowElement; import flashx.textLayout.elements.InlineGraphicElement; import flashx.textLayout.elements.ParagraphElement; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.events.CompositionCompleteEvent; import flashx.textLayout.events.StatusChangeEvent; /** * 使用 TLFTextField 类创建使用文本布局框架 (TLF) 的高级文本显示功能的文本字段。 * TLFTextField 对象与 TextField 对象类似,但 TLFTextField 对象可以利用 flashx 包中包含的 TLF 类的属性和方法。TLF 提供了大量格式选项和功能。 * @author */ public class STLFTextField extends TLFTextField { //最大段落数 private var _maxParagraph:uint = 0; //UI滚动条 private var uiScrollBar:UIScrollBar; public function STLFTextField() { super(); } private function tlfEventHandle(e:Event):void { super.textFlow.flowComposer.updateAllControllers(); if (uiScrollBar) { uiScrollBar.scrollPosition = uiScrollBar.maxScrollPosition; uiScrollBar.validateNow(); } } /** * 过滤段落数达到最大值时文本的段落 */ private function filtrationPar():void { if (_maxParagraph == 0) return; if (textFlow.numChildren > _maxParagraph) { for (var i:uint = 0; i < textFlow.numChildren - _maxParagraph; i++ ) { textFlow.removeChildAt(0); } } } /** * 在文本中插入图片 * @param src 图片的路径或者库里面的MC实例 * @param width 图片的宽,默认是图片宽度 * @param height 图片的高,默认是图片的高度 */ public function insertImg(src:Object, width:Object = "auto", height:Object = "auto"):void { if(!textFlow.hasEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE)) super.textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE, tlfEventHandle); if(super.textFlow.interactionManager is IEditManager) { IEditManager(super.textFlow.interactionManager).insertInlineGraphic(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值