0

I embed SVG graphics in my Flex application using

package MyUI
{
    public class Assets
    {
        [Embed(source="/assets/pic.svg"]
        [Bindable]
        public static var svgPic:Class;
    }
}

and then extending the Tree class with some of my own code, setting the icon upon adding a node to the data provider:

public class MyTree extends Tree
{
    public function MyTree()
    {
        // ...
        this.iconField = "svgIcon";
        // ...
        this.dataProvider = new ArrayCollection;
        this.dataProvider.addItem({ /* ... */ svgIcon: MyUI.Assets.svgPic /* ... */ });
        // ...
    }
}

Now I have two things I want to do:

  • use the SVG graphics in multiple places in the app, scaling them to the appropriate size for each appearance, i. e. scale them to a proper icon size when using them in the tree
  • change the size of the icon at runtime, e. g. display a slightly larger icon for selected items or let an icon "pulse" as a response to some event

I read the Flex documentation on the 9-slice scaling properties in the Embed tag, but I think that's not what I want.


Edit:

I unsuccessfully checked the "similar questions" suggested by SO, among others this one:

Flex: Modify an embedded icon and use it in a button?

4

2 回答 2

1

子类mx.controls.treeClasses.TreeItemRenderer并使其将图标大小调整为所需的尺寸,或者使用与 TreeItemRenderer 相同的接口创建自己的项目渲染器实现。使用以下属性设置自定义项目渲染器itemRenderer

exampleTree.itemRenderer = new ClassFactory( ExampleCustomItemRendererClass );
于 2009-01-14T19:24:37.207 回答
0

这个问题的答案可能会为您指明正确的方向,而无需更多地了解您遇到的麻烦:

Flex:修改嵌入式图标并在按钮中使用它?

希望能帮助到你!

于 2009-01-14T15:25:48.080 回答