Actionscript 3 Flex4:滚动条中的部分内容未显示
在我的项目中,我有一个面板,它使用我基于Spark面板蒙皮创建的自定义蒙皮。在这个皮肤中,我向显示组(“contentGroup”)添加了一个Spark Scroller,在这个组中我添加了带有一些标签和图像的“ListItems” 直到今天,我注意到当垂直滚动条到达底部时,仍有内容显示,如图所示: (因为我不能发布图片,这里有链接:) 正如您在图像中看到的,滚动条垂直滚动条已到达终点,但仍有一些内容低于底部限制(正如您可以看到我的简单自定义滚动条尚未到达底部) 以下是面板外观代码的一部分(滚动部分): PanelSkin.mxml:Actionscript 3 Flex4:滚动条中的部分内容未显示,actionscript-3,apache-flex,flex4,scroller,Actionscript 3,Apache Flex,Flex4,Scroller,在我的项目中,我有一个面板,它使用我基于Spark面板蒙皮创建的自定义蒙皮。在这个皮肤中,我向显示组(“contentGroup”)添加了一个Spark Scroller,在这个组中我添加了带有一些标签和图像的“ListItems” 直到今天,我注意到当垂直滚动条到达底部时,仍有内容显示,如图所示: (因为我不能发布图片,这里有链接:) 正如您在图像中看到的,滚动条垂直滚动条已到达终点,但仍有一些内容低于底部限制(正如您可以看到我的简单自定义滚动条尚未到达底部) 以下是面板外观代码的一部分(滚动
\u maxProdutosVisiveis
是同时可见的最大产品
obj
是保存列表项数据的对象
我想我已经包括了所有相关的内容,但请随意要求其他任何内容
有没有办法解决这个问题
感谢您的帮助:)经过数小时的搜索并尝试了不同的方法来解决这个问题,我注意到我忘了添加列表项的默认高度和宽度 更改: ListaItem.mxml:
致:
让一切恢复正常。无论如何,谢谢大家:)我并没有阅读所有的代码,但对于它的实际工作来说,它似乎太复杂了。几乎可以肯定,没有必要通过设置每个项目的x、y、宽度和高度来布置它们。大多数情况下,使用Flex并让Flex为您进行布局要容易得多,这样就不会有任何会把事情搞砸的小错误。我会使用它,但这只是代码的一部分,组件是构建的,因此它的内容可以以您喜欢的任何方式显示,例如,如果设置了正确的属性,它将以“W”的形式显示列表项。已解决:在ListaItem中,我忘记在根组件中添加默认宽度和高度。如果您已解决了答案,请不要将主题行更改为“已解决”,并编辑问题以包含答案。将你的答案作为正式答案发布;当时它不允许我这样做,我知道我会忘记回来发布答案,所以我编辑了这个问题。根据建议更正,谢谢。
<s:Group id="algoGroup" x="0" y="0" width="100%" height="100%" minWidth="0" minHeight="0">
<s:Scroller id="contentScroller" x="0" y="0" width="85%" height="100%" minWidth="0" minHeight="0">
<s:Group id="contentGroup" x="0" y="0" width="85%" height="100%" minWidth="0" minHeight="0">
</s:Group>
</s:Scroller>
<componentes:customScroller id="contentScrollbar" x="10" y="10" width="10%" height="100%"/>
</s:Group>
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
contentBackgroundAlpha="0.0"
currentState="Horizontal"
width.Horizontal="200" height.Horizontal="100"
height.Vertical="260" width.Vertical="128">
<s:states>
<s:State name="Horizontal"/>
<s:State name="Vertical"/>
</s:states>
<fx:Declarations>
<fx:Script>
<![CDATA[
import objectos.GlobalVars;
/*Vars - State -> Vertical
Bindable Vars -- Omitted
*/
public var ID:Number = -1;
public function resize(nW:Number, nH:Number):void
{
if(this.currentState == "Vertical")
{
_realIW = _iW2 = (_iW2 * nW) / _w2;
_realIH = _iH2 = (_iH2 * nH) / _h2;
if(_iW2 > _iH2)
_iW2 = _iH2;
else
_iH2 = _iW2;
_xImg = (_xImg * nW) / _w2;
_yImg = (_yImg * nH) / _h2;
_xTit = (_xTit * nW) / _w2;
_yTit = (_yTit * nH) / _h2;
Titulo.width = (Titulo.width * nW) / _w2;
Titulo.setStyle("fontSize", (GlobalVars.instance.getGlobal("fontSize") * 0.9));
_xDes = (_xDes * nW) / _w2;
if(Titulo.measureText(Titulo.text).width > Titulo.width)
_yDes = (_yDes * nH) / _h2;
else
_yDes = Titulo.y + Titulo.measureText(Titulo.text).height;
Descricao.width = (Descricao.width * nW) / _w2;
Descricao.setStyle("fontSize", (GlobalVars.instance.getGlobal("fontSize") * 0.7));
_xPre = (_xPre * nW) / _w2;
_yPre = (_yPre * nH) / _h2;
Preco.width = (Preco.width * nW) / _w2;
_xIco = (_xIco * nW) / _w2;
_yIco = (_yIco * nH) / _h2;
IconEspecial.width = (IconEspecial.width * nW) / _w2;
IconEspecial.height = (IconEspecial.height * nH) / _h2;
_xDeL = (_xDeL * nW) / _w2;
_yDeL = (_yDeL * nH) / _h2;
DescricaoL.width = (DescricaoL.width * nW) / _w2;
DescricaoL.setStyle("fontSize", (GlobalVars.instance.getGlobal("fontSize") * 0.7));
}
else
{
_realIW = _iW = (_iW * nW) / _w;
_realIH = _iH = (_iH * nH) / _h;
if(_iW > _iH)
_iW = _iH;
else
_iH = _iW;
Imagem.x = (Imagem.x * nW) / _w;
Imagem.y = (Imagem.y * nH) / _h;
Titulo.x = (Titulo.x * nW) / _w;
Titulo.y = (Titulo.y * nH) / _h;
Titulo.width = (Titulo.width * nW) / _w;
Titulo.setStyle("fontSize", (GlobalVars.instance.getGlobal("fontSize") * 0.9));
Descricao.x = (Descricao.x * nW) / _w;
Descricao.y = (Descricao.y * nH) / _h;
Descricao.width = (Descricao.width * nW) / _w;
Descricao.setStyle("fontSize", (GlobalVars.instance.getGlobal("fontSize") * 0.7));
Preco.x = (Preco.x * nW) / _w;
Preco.y = (Preco.y * nH) / _h;
Preco.width = (Preco.width * nW) / _w;
IconEspecial.x = (IconEspecial.x * nW) / _w;
IconEspecial.y = (IconEspecial.y * nH) / _h;
IconEspecial.width = (IconEspecial.width * nW) / _w;
IconEspecial.height = (IconEspecial.height * nH) / _h;
_sW = (_sW * nW) / _w;
_sY = (_sY * nH) / _h;
}
}
private function resizeImg():void
{
var ratio:Number = Imagem.contentWidth / Imagem.contentHeight;
if(Imagem.contentWidth > Imagem.contentHeight)
{
if(this.currentState == "Vertical")
{
Imagem.width = _iW2;
Imagem.height = _iW2 / ratio;
}
else
{
Imagem.width = _iW;
Imagem.height = _iW / ratio;
}
}
else
{
if(Imagem.contentHeight > Imagem.contentWidth)
{
if(this.currentState == "Vertical")
{
Imagem.height = _iH2;
Imagem.width = _iH2 * ratio;
}
else
{
Imagem.height = _iH;
Imagem.width = _iH * ratio;
}
}
else
{
if(this.currentState == "Vertical")
{
Imagem.height = (_iH2 > _iW2)?_iW2:_iH2;
Imagem.width = ((_iH2 > _iW2)?_iW2:_iH2) * ratio;
}
else
{
Imagem.height = (_iH > _iW)?_iW:_iH;
Imagem.width = ((_iH > _iW)?_iW:_iH) * ratio;
}
}
}
Imagem.x += (_realIW - Imagem.width) / 2;
Imagem.y += (_realIH - Imagem.height) / 2;
}
public function get useBar():Boolean
{
if(Separador != null)
return Separador.visible;
else
return false;
}
public function set useBar(value:Boolean):void
{
if(Separador != null)
Separador.visible = value;
}
]]>
</fx:Script>
<mx:Image id="Imagem" x.Horizontal="10" y.Horizontal="10" x.Vertical="{_xImg}" y.Vertical="{_yImg}" maintainAspectRatio="false" complete.Horizontal="resizeImg()" complete.Vertical="resizeImg()"/>
<s:Label id="Titulo" x="98" y="10" text="Label" width="102" maxDisplayedLines="2" x.Vertical="{_xTit}" y.Vertical="{_yTit}" verticalAlign.Vertical="middle" textAlign.Vertical="left"/>
<s:Label id="Descricao" x="98" y="43" text="Label" width="102" maxDisplayedLines="3" color="#999999" x.Vertical="{_xDes}" y.Vertical="{_yDes}"/>
<s:Label id="Preco" x="113" y="78" text="Label" width="87" maxDisplayedLines="1" x.Vertical="{_xPre}" y.Vertical="{_yPre}"/>
<mx:Image x="93" y="73" width="20" height="20" id="IconEspecial" x.Vertical="{_xIco}" y.Vertical="{_yIco}"/>
<mx:HRule id="Separador" x="0" y="{_sY}" width="{_sW}" strokeColor="#000000" shadowColor="#000000" includeIn="Horizontal"/>
<s:Label id="DescricaoL" x.Horizontal="1" y.Horizontal="177" x.Vertical="{_xDeL}" y.Vertical="{_yDeL}" text="Label" width="127" color="#999999" visible.Horizontal="false" maxDisplayedLines="3"/>
</s:Group>
var item:ListaItem = new ListaItem();
var iW:Number = 0;
var iH:Number = 0;
if(yPos == -1 || xPos == -1)
{
yPos = 0 - ((_group.height - (10 * (_maxProdutosVisiveis - 1))) / _maxProdutosVisiveis) - 10;
xPos = 0;
}
yPos += ((_group.height - (10 * (_maxProdutosVisiveis - 1))) / _maxProdutosVisiveis) + 10;
xPos = 0;
iW = _group.width;
iH = ((_group.height - (10 * (_maxProdutosVisiveis - 1))) / _maxProdutosVisiveis);
item.x = xPos;
item.y = yPos;
item.ID = obj.idProduto;
item.Titulo.text = (obj.Titulo_Produto != null)?obj.Titulo_Produto:obj.Titulo;
item.Descricao.text = obj.Descricao;
item.Preco.text = obj.Valor + " €";
item.IconEspecial.source = this.specialIcon;
_margem = iH + 10;
item.addEventListener(MouseEvent.CLICK, goToApresentacao);
_group.addElement(item);
_components.addItem(item);
item.width = iW;
item.height = iH;
item.Imagem.source = obj.url;
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
contentBackgroundAlpha="0.0"
currentState="Horizontal"
width.Horizontal="200" height.Horizontal="100"
height.Vertical="260" width.Vertical="128">
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
contentBackgroundAlpha="0.0"
currentState="Horizontal"
width="200" height="100"
height.Vertical="260" width.Vertical="128">