我的皮肤:
# edit.html.erb
<%= f.email_field :email, :required => true, :pattern => EMAIL_REGEX %>
我的创建对象'砖'视图
pattern
类DataAboutBrick用于保存有关对象的数据:
pattern="(?i-mx:\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z)"
中保:
<s:DataGroup id="view1" width="100%" height="100%" itemRenderer="views.itemRenderers.BrickItemRenderer" dataProvider="{hostComponent.createArray()}">
<s:layout>
<s:TileLayout />
</s:layout>
</s:DataGroup>
介质在单击对象时更改所有对象的颜色。并且只需要改变要按下的对象的颜色。
答案 0 :(得分:1)
假设您已定义Brick和BrickSkin,您可以定义更改BrickItemRenderer中颜色的功能,如下所示:
<?xml version="1.0"?>
<spark:DefaultComplexItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:spark="spark.skins.spark.*">
<fx:Script><![CDATA[
[Bindable("dataChanged")]
override public function set data(value:Object):void
{
super.data = value;
var brick:Brick = new Brick();
brick.colorBrick = value.color;
brick.addEventListener(MouseEvent.CLICK, brickClicked,false,0,true);
this.addElement(brick);
}
private function brickClicked(event:Event)
{
event.stopImmediatePropagation();
event.preventDefault();
data.color = 0x00FF00;// Please make sure your color variable defined in DataAboutBrick.as is Bindable.
}
]]></fx:Script>
</spark:DefaultComplexItemRenderer>