Flash Builder 4 自动完成功能停止使用多个脚本标签

发布于 2024-12-09 12:09:38 字数 1426 浏览 0 评论 0原文

在一个非常特殊的情况下,我在使用 Flash Builder 4 时遇到了一致的问题,其中智能感知自动完成功能停止工作。

当我在数据组中使用内联组件时会发生这种情况。 我有一个用于组件类的 Script 标记,然后,在 DataGroup 中,我在 itemRenderer 下有一个 Component 标记,在该组件的类标记下有一个 Script 标记。此时智能感知停止工作。有没有人遇到过这种情况并找到解决方法?

这是一个源代码示例。 将其加载到 Flash Builder 中,如果您遇到与我相同的问题,则自动完成功能在第一个 Script 标记中将不起作用。这很烦人,因为我喜欢使用内联组件。

<?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" width="400" height="300">
  <fx:Script>
    <![CDATA[
      //Try to use auto-complete
      //It doesn't work
      var p:Object;
    ]]>
  </fx:Script>
  <s:DataGroup>
    <s:itemRenderer>
      <fx:Component className="MyItemRenderer">
        <s:Group implements="mx.core.IDataRenderer">
          <fx:Script>
            <![CDATA[
              //auto-complete is ok here...
              private var _data:Object;

              public function get data():Object {
                return _data;
              }

              public function set data(value:Object):void {
                _data = value;
                invalidateProperties();
              }
            ]]>
          </fx:Script>
        </s:Group>
      </fx:Component>
    </s:itemRenderer>
  </s:DataGroup>
</s:Group>

I am having a consistent problem with Flash Builder 4 in a very specific case where the intellisense auto-complete stops working.

It happens when I use inline components in a DataGroup.
I have one Script tag for the component class, and then, in the DataGroup I have a Component tag under itemRenderer and a Script tag under that component's class tag. At this point intellisense stops working. Has anyone encountered this and found a work-around?

Here is a source code example.
Load it in Flash Builder and if you have the same problem I do, auto-complete will not work in first Script tag. This is annoying since I like to use inline components.

<?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" width="400" height="300">
  <fx:Script>
    <![CDATA[
      //Try to use auto-complete
      //It doesn't work
      var p:Object;
    ]]>
  </fx:Script>
  <s:DataGroup>
    <s:itemRenderer>
      <fx:Component className="MyItemRenderer">
        <s:Group implements="mx.core.IDataRenderer">
          <fx:Script>
            <![CDATA[
              //auto-complete is ok here...
              private var _data:Object;

              public function get data():Object {
                return _data;
              }

              public function set data(value:Object):void {
                _data = value;
                invalidateProperties();
              }
            ]]>
          </fx:Script>
        </s:Group>
      </fx:Component>
    </s:itemRenderer>
  </s:DataGroup>
</s:Group>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仙气飘飘 2024-12-16 12:09:38

这是因为内联项渲染器中实现了 IDataRenderer。如果您删除它或创建项目渲染器组件,智能感知/自动完成应该按预期工作。

It's because of the implements IDataRenderer in the inline Item Renderer. If you remove this or create an item renderer component intellisense/autocomplete should work as expected.

娇纵 2024-12-16 12:09:38

好的,这是另一个效果更好的解决方法,因为它允许我将项目渲染器代码保留在同一个 mxml 文件中,并且只需进行最小的更改。我很偶然地发现了它。您所做的不是将项目渲染器的 标记内联定义为 标记的子元素,而是将其移动到 标记并为其指定一个类名。然后,将该类名放入 标记内。这对我来说比外部化项目渲染器组件稍微好一些。

这是一个简单的例子:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx">
  <fx:Declarations>
    <fx:Component className="PrintLine" id="printLineFactory">
      <s:Label implements="mx.core.IDataRenderer" width="100%">
        <fx:Script>
          <![CDATA[
            private var _data:Object;

            public function get data():Object {
              return _data;
            }

            public function set data(value:Object):void {
              _data = value;
              invalidateProperties();
            }

            override protected function commitProperties():void {
              super.commitProperties();
              if (_data) {
                text = String(_data);
              }
            }
          ]]>
        </fx:Script>
      </s:Label>
    </fx:Component>
  </fx:Declarations>
  <fx:Script>
    <![CDATA[
      //auto-complete works here now!
    ]]>
  </fx:Script>
  <s:layout>
    <s:VerticalLayout />
  </s:layout>
  <s:Scroller height="100">
    <s:viewport>
      <s:DataGroup width="100%">
        <s:layout>
          <s:VerticalLayout />
        </s:layout>
        <s:itemRenderer>
          PrintLine
        </s:itemRenderer>
      </s:DataGroup>
    </s:viewport>
  </s:Scroller>
</s:Application>

我必须这样做仍然是愚蠢的,而且我仍然讨厌 Adob​​e。 :-(

更新:
使用类名“PrintLine”仅适用于上述代码,因为根标记是应用程序标记。在自定义子组件中,您需要绑定到工厂引用:

<s:itemRenderer>{printLineFactory}</s:itemRenderer>

Ok, here is another work-around which works better since it lets me keep the item renderer code in the same mxml file with minimal change. I found it quite by chance. What you do is instead of defining the item renderer's <fx:Component> tag inline as a child element of the <s:itemRenderer> tag, you move it to the <fx:Declarations> tag and give it a class name. Then, put that class name inside the <s:itemRenderer> tag. This is slightly better for me than externalizing the item renderer component.

Here is a bare-bones example:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx">
  <fx:Declarations>
    <fx:Component className="PrintLine" id="printLineFactory">
      <s:Label implements="mx.core.IDataRenderer" width="100%">
        <fx:Script>
          <![CDATA[
            private var _data:Object;

            public function get data():Object {
              return _data;
            }

            public function set data(value:Object):void {
              _data = value;
              invalidateProperties();
            }

            override protected function commitProperties():void {
              super.commitProperties();
              if (_data) {
                text = String(_data);
              }
            }
          ]]>
        </fx:Script>
      </s:Label>
    </fx:Component>
  </fx:Declarations>
  <fx:Script>
    <![CDATA[
      //auto-complete works here now!
    ]]>
  </fx:Script>
  <s:layout>
    <s:VerticalLayout />
  </s:layout>
  <s:Scroller height="100">
    <s:viewport>
      <s:DataGroup width="100%">
        <s:layout>
          <s:VerticalLayout />
        </s:layout>
        <s:itemRenderer>
          PrintLine
        </s:itemRenderer>
      </s:DataGroup>
    </s:viewport>
  </s:Scroller>
</s:Application>

That I have to do this is still stupid and I still hate Adobe. :-(

UPDATE:
Using the class name "PrintLine" only works in the above code because the root tag is an Application tag. In custom sub-components, you need to bind to the factory reference instead:

<s:itemRenderer>{printLineFactory}</s:itemRenderer>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文