在浏览器中运行良好,但直接由flash player出错:ReferenceError:错误#1056

时间:2011-07-13 15:14:47

标签: flex flex-spark

我写了一个flex演示,定制了带有圆角的Spark TextInput皮肤和一个搜索图标,比如mac os x搜索框,它在浏览器中运行良好(通过Flash Player浏览器插件).html或.swf ,但直接由flash播放器出错。

错误:

ReferenceError: Error #1056: Cannot create property allowCodeImport on flash.system.LoaderContext.
    at mx.core::CrossDomainRSLItem/completeCdRslLoad()
    at mx.core::CrossDomainRSLItem/itemCompleteHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

有测试演示,包括来源:http://www.ycoder.com/wp-content/uploads/2011/07/CustomComponentSkinTest.zip

CustomTextInput

package component{
    import skin.CustomTextInputSkin;
    import spark.components.TextInput;
 
    [Style(name="icon", inherit="no", type="Object")]
    [Style(name="radius", inherit="true", type="Number")]
 
    public class CustomTextInput extends TextInput{
        [Embed(source="/images/search.png")]
        private const defaultIcon:Class;    
 
        public function CustomTextInput(){
            super();
            this.setStyle('icon', defaultIcon);
            this.setStyle('radius', 10);
            this.setStyle("skinClass", CustomTextInputSkin);
        }
    }
}

CustomTextInputSkin

<!-- border -->
 <!--- @private -->
 <s:Rect left="0" right="0" top="0" bottom="0" id="border" radiusX="{hostComponent.getStyle('radius')}" radiusY="{hostComponent.getStyle('radius')}" >
     <s:stroke>
         <!--- @private -->
         <s:SolidColorStroke id="borderStroke" weight="1" />
     </s:stroke>
 </s:Rect>
 
 <!-- fill -->
 <!--- Defines the appearance of the TextInput component's background. -->
 <s:Rect id="background" left="1" right="1" top="1" bottom="1" radiusX="{hostComponent.getStyle('radius')}" radiusY="{hostComponent.getStyle('radius')}" >
     <s:fill>
         <!--- @private Defines the background fill color. -->
         <s:SolidColor id="bgFill" color="0xFFFFFF" />
     </s:fill>
 </s:Rect>
 
 <!-- shadow -->
 <!--- @private -->
 <s:Rect left="1" top="1" right="1" height="1" id="shadow" radiusX="{hostComponent.getStyle('radius')}" radiusY="{hostComponent.getStyle('radius')}" >
     <s:fill>
         <s:SolidColor color="0x000000" alpha="0.12" />
     </s:fill>
 </s:Rect>
 <s:HGroup id="textGroup" gap="0" height="100%" paddingLeft="4" paddingRight="4">
     <!-- icon -->
     <s:Image id="icon" includeIn="normal" x="0" y="0" source="{hostComponent.getStyle('icon')}" verticalAlign="middle" height="100%"/>
     <!-- text -->
     <!--- @copy spark.components.supportClasses.SkinnableTextBase#textDisplay -->
     <s:RichEditableText id="textDisplay"
                         verticalAlign="middle"
                         widthInChars="10"
                         left="1" right="1" top="1" bottom="1"  height="100%"/>
 </s:HGroup>

测试用例

<?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"
               xmlns:component="component.*"  >
    <s:VGroup paddingLeft="20" paddingTop="20">
        <s:TextInput />
        <component:CustomTextInput  />
        <component:CustomTextInput  radius="12" icon="images/device.png" text="ABC Test ... hohoho" editable="false" />
    </s:VGroup>
</s:Application>

2 个答案:

答案 0 :(得分:1)

原因是: Flex SDK 4.5仅支持Flash Player 10.2 + ,而我的独立Flash播放器版本为10.0。,我的Flash播放器插件版本为10.2。。认为

答案 1 :(得分:0)

你皮肤上的这条线是罪魁祸首:

<s:Image id="icon" includeIn="normal" x="0" y="0" source="{hostComponent.getStyle('icon')}" verticalAlign="middle" height="100%"/>

由于您在样式中设置了图标,因此在创建完成后,它会尝试从互联网上获取该图像,因为HTTP请求通过浏览器(但是,它应该尝试请求OS浏览器) )。我不是100%确定错误是否存在,但我的问题是,为什么你还要在独立的flash播放器中运行它呢?