2011-04-15 17 views
-1

我想創建flex應用程序,通過它我可以驗證用戶年齡我使用下面的代碼可以告訴我爲什麼我不能看到mx組件「dialogtitle」,「dialogcontent」「dialogbutton」mx自定義組件不工作在flex

<?xml version="1.0" encoding="UTF-8"?> 
<mx:VBox creationComplete="{initComponent();}" height="219" width="560" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:components="components.*" xmlns:local="*"> 
<mx:Script><![CDATA[ 
    import com.people.classes.*; 
    import com.people.interfaces.*; 
    import com.people.utils.*; 
    import flash.events.*; 
    import flash.utils.*; 
    import mx.binding.*; 
    import mx.containers.*; 
    import mx.controls.*; 
    import mx.core.*; 
    import mx.events.*; 
    import mx.styles.*; 
    import components.DialogTitle.*; 
    import components.DialogContent.*; 
    private var birth_str:String; 
    private var _controller:IControlManager; 
    private var testDate:Date; 
    private var i:int; 
    private var ageErrorTimer:int = 0; 

    public function _AgeVerify_Spacer1_c() : Spacer 
    { 
     var _loc_1:* = new Spacer(); 
     _loc_1.height = 14; 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_HBox1_c() : HBox 
    { 
     var _loc_1:* = new HBox(); 
     _loc_1.percentWidth = 100; 
     _loc_1.setStyle("horizontalAlign", "center"); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     _loc_1.addChild(_AgeVerify_VBox2_c()); 
     _loc_1.addChild(_AgeVerify_VBox3_c()); 
     _loc_1.addChild(_AgeVerify_VBox4_c()); 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_Label4_c() : Label 
    { 
     var _loc_1:* = new Label(); 
     _loc_1.text = "Year"; 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_Label6_i() : Label 
    { 
     var _loc_1:* = new Label(); 
     ageError = _loc_1; 
     _loc_1.visible = false; 
     _loc_1.text = "You have supplied an incorrect date. Please try again."; 
     _loc_1.setStyle("paddingLeft", 19); 
     _loc_1.setStyle("fontSize", 12); 
     _loc_1.setStyle("color", 16711680); 
     _loc_1.id = "ageError"; 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_VBox3_c() : VBox 
    { 
     var _loc_1:* = new VBox(); 
     _loc_1.setStyle("horizontalAlign", "center"); 
     _loc_1.setStyle("verticalGap", 1); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     _loc_1.addChild(_AgeVerify_Label3_c()); 
     _loc_1.addChild(_AgeVerify_ComboBox2_i()); 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_Label2_c() : Label 
    { 
     var _loc_1:* = new Label(); 
     _loc_1.text = "Month"; 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_ComboBox1_i() : ComboBox 
    { 
     var _loc_1:* = new ComboBox(); 
     months = _loc_1; 
     _loc_1.width = 60; 
     _loc_1.setStyle("fontSize", 11); 
     _loc_1.id = "months"; 
     BindingManager.executeBindings(this, "months", months); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_ComboBox3_i() : ComboBox 
    { 
     var _loc_1:* = new ComboBox(); 
     years = _loc_1; 
     _loc_1.width = 100; 
     _loc_1.setStyle("fontSize", 11); 
     _loc_1.id = "years"; 
     BindingManager.executeBindings(this, "years", years); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_Spacer2_c() : Spacer 
    { 
     var _loc_1:* = new Spacer(); 
     _loc_1.height = 13; 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_Label3_c() : Label 
    { 
     var _loc_1:* = new Label(); 
     _loc_1.text = "Day"; 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function initComponent() : void 
    { 
     dialogButtons.addEventListener("onOK", onOK); 
     var _loc_1:* = new Date(); 
     i = 0; 
     while (i < 31) 
     { 

      days_arr.push((i + 1)); 
      var _loc_3:* = i + 1; 
      i = _loc_3; 
     } 
     i = 0; 
     while (i < 12) 
     { 

      months_arr.push((i + 1)); 
      var _loc_3:* = i + 1; 
      i = _loc_3; 
     } 
     i = _loc_1.getFullYear(); 
     while (i > 1899) 
     { 

      years_arr.push(i); 
      var _loc_3:* = i - 1; 
      i = _loc_3; 
     } 
     days.selectedIndex = 0; 
     months.selectedIndex = 0; 
     years.selectedIndex = 0; 
     return; 
    }// end function 


    public function _AgeVerify_Label5_i() : Label 
    { 
     var _loc_1:* = new Label(); 
     underAge = _loc_1; 
     _loc_1.visible = false; 
     _loc_1.setStyle("paddingLeft", 19); 
     _loc_1.setStyle("fontSize", 12); 
     _loc_1.setStyle("color", 16711680); 
     _loc_1.id = "underAge"; 
     BindingManager.executeBindings(this, "underAge", underAge); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_Label1_i() : Label 
    { 
     var _loc_1:* = new Label(); 
     _AgeVerify_Label1 = _loc_1; 
     _loc_1.setStyle("fontSize", 13); 
     _loc_1.setStyle("fontWeight", "bold"); 
     _loc_1.setStyle("color", 7105644); 
     _loc_1.id = "_AgeVerify_Label1"; 
     BindingManager.executeBindings(this, "_AgeVerify_Label1", _AgeVerify_Label1); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_Canvas1_c() : Canvas 
    { 
     var _loc_1:* = new Canvas(); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     _loc_1.addChild(_AgeVerify_Label5_i()); 
     _loc_1.addChild(_AgeVerify_Label6_i()); 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_VBox2_c() : VBox 
    { 
     var _loc_1:* = new VBox(); 
     _loc_1.setStyle("horizontalAlign", "center"); 
     _loc_1.setStyle("verticalGap", 1); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     _loc_1.addChild(_AgeVerify_Label2_c()); 
     _loc_1.addChild(_AgeVerify_ComboBox1_i()); 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_VBox4_c() : VBox 
    { 
     var _loc_1:* = new VBox(); 
     _loc_1.setStyle("horizontalAlign", "center"); 
     _loc_1.setStyle("verticalGap", 1); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     _loc_1.addChild(_AgeVerify_Label4_c()); 
     _loc_1.addChild(_AgeVerify_ComboBox3_i()); 
     return _loc_1; 
    }// end function 


    public function _AgeVerify_ComboBox2_i() : ComboBox 
    { 
     var _loc_1:* = new ComboBox(); 
     days = _loc_1; 
     _loc_1.width = 60; 
     _loc_1.setStyle("fontSize", 11); 
     _loc_1.id = "days"; 
     BindingManager.executeBindings(this, "days", days); 
     if (!_loc_1.document) 
     { 
      _loc_1.document = this; 
     } 
     return _loc_1; 
    }// end function 


    public function onOK(event:Event) : void 
    { 
     var event:* = event; 
     testDate = new Date(years.selectedItem, (parseInt(months.selectedItem.toString()) - 1), days.selectedItem); 
     if (testDate.getFullYear() == years.selectedItem && testDate.getMonth() == (parseInt(months.selectedItem.toString()) - 1) && testDate.getDate() == days.selectedItem) 
     { 
      birth_str = months.selectedItem + "/" + days.selectedItem + "/" + years.selectedItem; 
      if (Formatters.getYearsOld(birth_str) < 13) 
      { 
       ageError.visible = false; 
       underAge.visible = true; 
       if (ageErrorTimer > 0) 
       { 
        clearTimeout(ageErrorTimer); 
       } 
       ageErrorTimer = setTimeout(function() : void 
     { 
      ageError.visible = false; 
      underAge.visible = false; 
      return; 
     }// end function 
     , 6000); 
      } 
      else 
      { 
       _controller.updateAge(birth_str); 
       visible = false; 
      } 
     } 
     else 
     { 
      underAge.visible = false; 
      ageError.visible = true; 
      if (ageErrorTimer > 0) 
      { 
       clearTimeout(ageErrorTimer); 
      } 
      ageErrorTimer = setTimeout(function() : void 
     { 
      ageError.visible = false; 
      underAge.visible = false; 
      return; 
     }// end function 
     , 6000); 
     } 
     return; 
    }// end function 

]]></mx:Script> 
<mx:DialogTitle title="Age Verification Needed" width="172" height="45"/> 
<mx:DialogContent children="[_AgeVerify_Label1_i(), _AgeVerify_Spacer1_c(), _AgeVerify_HBox1_c(), _AgeVerify_Spacer2_c(), _AgeVerify_Canvas1_c()]"/> 
<mx:DialogButtons id="dialogButtons" okCaption="CONTINUE"/> 

+3

'VAR _loc_1:* =新的ComboBox();' - 這看起來像一些反編譯。碼。 – alxx 2011-04-15 07:49:31

+0

約定alxx,反編譯代碼。偷竊不好,mmmkay? – 2011-04-15 14:48:54

回答

1

我想是因爲你的import語句它。你只使用*如果你的導入包(文件夾),而這些都是類,所以只需使用以下命令:

import components.DialogTitle; 
+0

我沒有檢查這是否是問題,但很好的發現= D>! – rekaszeru 2011-04-15 11:01:49

+0

我已更改導入components.DialogTitle。*;導入components.DialogTitle;但仍然不能看到組件,可能是什麼問題提前致謝 – 2011-04-15 14:15:28