2011-05-09 5 views
0

내가 내 친구 중 하나에서이 코드를 촬영했지만, 실제에 내가이 코드를 실행하여 점점 오전 오류 거기에 많은 완전히 엉망이다, 나는 몇 가지 질문을 가지고이것을 mmxl aaplication에서 클래스 코드로 사용하는 방법은 무엇입니까?

내가이 코드를 사용할 수있는 방법
  1. 우리가 알고있는 것처럼 mx 스크립트에서 공용 클래스를 사용할 수 없다는 것을 알고 있듯이
  2. .mx_internal을 볼 수 있듯이 mx_internal을 제거 할 때 '점 앞에 객체 정의'오류가 발생합니다. mx.binding.mx_internal 가져 오기를 사용하고 아무 것도 출력하지 않는 네임 스페이스 mx_internal 응용 프로그램을 사용하려고했습니다.

지금 당신은 ther 쉬운 방법은 문제를 해결하는 것입니다하지만 내 전체 프로젝트는이 방법에만있다

사전에 도움을 주셔서 감사합니다 나는 지난 15 일 에서이 문제를 해결하기 위해 노력하고있어, pls 코드는

package components 
{ 
    import flash.events.*; 
    import flash.utils.*; 
    import mx.binding.*; 
    import mx.containers.*; 
    import mx.controls.*; 
    import mx.core.*; 
    import mx.events.*; 
    import mx.styles.*; 

    public class DialogTitle extends HBox implements IBindingClient 
    { 
     private var _110371416title:String = "Dialog Title"; 
     public var _DialogTitle_Image1:Image; 
     public var _DialogTitle_Image2:Image; 
     public var _DialogTitle_Label1:Label; 
     var _bindingsBeginWithWord:Object; 
     private var _1859425293showCloseButton:Boolean = false; 
     var _bindingsByDestination:Object; 
     var _watchers:Array; 
     var _bindings:Array; 
     private var _documentDescriptor_:UIComponentDescriptor; 
     private static var _watcherSetupUtil:IWatcherSetupUtil; 

     public function DialogTitle() 
     { 
      _documentDescriptor_ = new UIComponentDescriptor({type:HBox, propertiesFactory:function() : Object 
      { 
       return {height:27, childDescriptors:[new UIComponentDescriptor({type:Spacer, propertiesFactory:function() : Object 
       { 
        return {width:5}; 
       }// end function 
       }), new UIComponentDescriptor({type:Image, id:"_DialogTitle_Image1"}), new UIComponentDescriptor({type:Spacer, propertiesFactory:function() : Object 
       { 
        return {width:5}; 
       }// end function 
       }), new UIComponentDescriptor({type:Label, id:"_DialogTitle_Label1", stylesFactory:function() : void 
       { 
        this.fontSize = 14; 
        this.color = 16777215; 
        this.fontWeight = "bold"; 
        return; 
       }// end function 
       }), new UIComponentDescriptor({type:Spacer, propertiesFactory:function() : Object 
       { 
        return {percentWidth:100}; 
       }// end function 
       }), new UIComponentDescriptor({type:Image, id:"_DialogTitle_Image2", events:{click:"___DialogTitle_Image2_click"}, propertiesFactory:function() : Object 
       { 
        return {useHandCursor:true, buttonMode:true, mouseChildren:false, toolTip:"Close"}; 
       }// end function 
       }), new UIComponentDescriptor({type:Spacer, propertiesFactory:function() : Object 
       { 
        return {width:13}; 
       }// end function 
       })]}; 
      }// end function 
      }); 
      _bindings = []; 
      _watchers = []; 
      _bindingsByDestination = {}; 
      _bindingsBeginWithWord = {}; 
      mx_internal::_document = this; 
      if (!this.styleDeclaration) 
      { 
       this.styleDeclaration = new CSSStyleDeclaration(); 
      } 
      this.styleDeclaration.defaultFactory = function() : void 
      { 
       this.backgroundColor = 9947478; 
       this.horizontalGap = 0; 
       this.verticalAlign = "middle"; 
       this.verticalGap = 0; 
       return; 
      }// end function 
      ; 
      this.height = 27; 
      this.percentWidth = 100; 
      return; 
     }// end function 

     private function _DialogTitle_bindingExprs() : void 
     { 
      var _loc_1:* = undefined; 
      _loc_1 = CustomEmbeddedAssets.logoImageSmall; 
      _loc_1 = title; 
      _loc_1 = EmbeddedAssets.dialogClose; 
      _loc_1 = showCloseButton; 
      return; 
     }// end function 

     public function get showCloseButton() : Boolean 
     { 
      return this._1859425293showCloseButton; 
     }// end function 

     override public function initialize() : void 
     { 
      var target:DialogTitle; 
      var watcherSetupUtilClass:Object; 
      .mx_internal::setDocumentDescriptor(_documentDescriptor_); 
      var bindings:* = _DialogTitle_bindingsSetup(); 
      var watchers:Array; 
      target; 
      if (_watcherSetupUtil == null) 
      { 
       watcherSetupUtilClass = getDefinitionByName("_components_DialogTitleWatcherSetupUtil"); 
       var _loc_2:* = watcherSetupUtilClass; 
       _loc_2.watcherSetupUtilClass["init"](null); 
      } 
      _watcherSetupUtil.setup(this, function (param1:String) 
      { 
       return target[param1]; 
      }// end function 
      , bindings, watchers); 
      var i:uint; 
      while (i < bindings.length) 
      { 

       Binding(bindings[i]).execute(); 
       i = (i + 1); 
      } 
      mx_internal::_bindings = mx_internal::_bindings.concat(bindings); 
      mx_internal::_watchers = mx_internal::_watchers.concat(watchers); 
      super.initialize(); 
      return; 
     }// end function 

     public function get title() : String 
     { 
      return this._110371416title; 
     }// end function 

     private function _DialogTitle_bindingsSetup() : Array 
     { 
      var binding:Binding; 
      var result:Array; 
      binding = new Binding(this, function() : Object 
      { 
       return CustomEmbeddedAssets.logoImageSmall; 
      }// end function 
      , function (param1:Object) : void 
      { 
       _DialogTitle_Image1.source = param1; 
       return; 
      }// end function 
      , "_DialogTitle_Image1.source"); 
      result[0] = binding; 
      binding = new Binding(this, function() : String 
      { 
       var _loc_1:* = title; 
       var _loc_2:* = _loc_1 == undefined ? (null) : (String(_loc_1)); 
       return _loc_2; 
      }// end function 
      , function (param1:String) : void 
      { 
       _DialogTitle_Label1.text = param1; 
       return; 
      }// end function 
      , "_DialogTitle_Label1.text"); 
      result[1] = binding; 
      binding = new Binding(this, function() : Object 
      { 
       return EmbeddedAssets.dialogClose; 
      }// end function 
      , function (param1:Object) : void 
      { 
       _DialogTitle_Image2.source = param1; 
       return; 
      }// end function 
      , "_DialogTitle_Image2.source"); 
      result[2] = binding; 
      binding = new Binding(this, function() : Boolean 
      { 
       return showCloseButton; 
      }// end function 
      , function (param1:Boolean) : void 
      { 
       _DialogTitle_Image2.visible = param1; 
       return; 
      }// end function 
      , "_DialogTitle_Image2.visible"); 
      result[3] = binding; 
      return result; 
     }// end function 

     public function set showCloseButton(param1:Boolean) : void 
     { 
      var _loc_2:* = this._1859425293showCloseButton; 
      if (_loc_2 !== param1) 
      { 
       this._1859425293showCloseButton = param1; 
       this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "showCloseButton", _loc_2, param1)); 
      } 
      return; 
     }// end function 

     public function ___DialogTitle_Image2_click(event:MouseEvent) : void 
     { 
      dispatchEvent(new Event("onCancel")); 
      parent.visible = false; 
      return; 
     }// end function 

     public function set title(param1:String) : void 
     { 
      var _loc_2:* = this._110371416title; 
      if (_loc_2 !== param1) 
      { 
       this._110371416title = param1; 
       this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this, "title", _loc_2, param1)); 
      } 
      return; 
     }// end function 

     public static function set watcherSetupUtil(param1:IWatcherSetupUtil) : void 
     { 
      DialogTitle._watcherSetupUtil = param1; 
      return; 
     }// end function 

    } 
} 

답변

1

그냥 던져주세요. 이 코드는 mxmlc 컴파일러에 의해 MXML 클래스에서 자동 생성되었으며 프로덕션 환경에서는 사용할 수 없습니다. 그것은 컴퓨터가 아니라 인간을위한 것입니다. 혼자서 올바른 코드를 작성하십시오. 나는 그것이 더 명확하고 유지할 수 있기를 희망한다. 예,이 코드는 친구가 작성한 것이 아닙니다 :)

+0

통해 UR 바로 친구가 될 수 있지만이어야 실행 내가 오류가 무엇인지 그렇게 할 수 있다면 유, 나에게 그것의 모든 솔루션을 제공 할 수 있습니다 : 그리고 여기에 도움을 줄 수있는 간단한 파이썬 스크립트 당신이 그것을 할 수있다 그런 식으로 배울 수 있습니다 –

+0

이 코드가 MXML에서 생성 된 경우 MXML을 사용하여 'DialogTitle' 컴포넌트에 사용하거나 친구에게 원래의 MXML 버전 인 DialogTitle을 제공하도록 요청하십시오. – Constantiner

0

이 파일은 태그를 사용하여 레이아웃을 설명하는 .mxml 파일에서 디 컴파일됩니다. 그러나 일부 디 컴파일러는 완전히 변환 할 수 없으며 이와 같은 파일을 보게됩니다.

앞서 살펴본 바와 같이 UIComponentDescriptor의 인수는 많은 키 - 값 쌍을 포함하는 개체입니다. 이 키의 몇 가지 유형이 있습니다

  1. type : 클래스 ->이 .mxml 파일의 노드 태그입니다이 구성 요소의 유형입니다
  2. id : 문자열 ->이의 ID입니다 > 구성 요소의 스타일
  3. propertiesFactory 설정 - 기능 : Func을을 - 구성 요소가
  4. stylesFactory을 트리거> 이벤트 대상 : 또한 변수 이름 인 노드, 당신은 <fx:Script> 태그에
  5. event을 사용할 수 있습니다 그 이벤트의

    new UIComponentDescriptor({ 
        "type":Canvas, 
        "id":mainCanvas, 
        "styleFactory":function():void { 
         this.borderStyle="none"; 
        }, 
        "propertiesFactory":function():Object { 
         return({ 
          "label":"main" 
          "childDescriptors":[new UIComponentDescriptor({ 
          // button's code in here 
          }); 
          ] 
         }) 
        } 
    }) 
    

    :

    <mx:Canvas id="mainCanvas" borderStyle="none" label="main"> 
        <mx:Button click="onClick(event)" /> 
    </mx:Canvas> 
    

    가로 변환됩니다

    당신이 할 수 - 기가>는

코드 같은 일부 속성과 자식 노드를 포함 btnOnClick()btnOnClick(event)과 같은 mxml 태그에서 click 이벤트를 작성하면 컴파일러는 균일하게하려면 뭔가를해야합니다. t 핸들러는 올바른 인수를 허용합니다. 따라서 Button 태그에 대해 언급하면 ​​"event"에 해당하는 값은 {"click":"__on_click"}과 같습니다.그리고 컴파일러는이 같은 수 있습니다 새로운 함수 호출 __on_click, 생성됩니다 : 당신은 .mxml에 UIComponentDescriptor를 변환 한 후, 분명히

public function __on_click(event:MouseEvent):void { 
    onClick(event); 
} 

을, 당신은 이벤트 기능을 교체해야합니다. 생성자를 들어

:

.mxml 파일이 생성자가 할 수 없지만, 컴파일러가 UIComponentDescriptor 포함이 .as 파일 하나를 생성합니다. 생성자는 변수에 대해 초기화를 수행합니다. .mxml 파일로 변환 할 때 변수 선언 다음에이 초기화 작업을 수행해야합니다. 예를 들어 :

public function MyCanvas(){ 
    this._documentDescriptor_ = new UIComponentDescriptor({ 
    //…… 
    }); 
    this.myArray = new Array(); 
} 

이로 변환해야합니다

<fx:Script><![CDATA[ 
var myArray:Array = new Array(); 
]]></fx:Script> 

그래서 무거운 작업은 .mxml 태그로 UIComponentDescriptor를 변환하는 것입니다.

UIComponentDescriptor2XML

관련 문제