mx自定义组件不在flex中工作

时间:2011-04-15 07:19:04

标签: flex flex3 flex4 flexbuilder

我想创建flex应用程序,通过它我可以验证用户年龄我使用下面的代码你可以告诉我为什么我看不到mx组件“dialogtitle”,“dialogcontent”“dialogbutton”

<?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"/>

1 个答案:

答案 0 :(得分:1)

我认为这是因为你的import语句。你只使用。*如果你导入一个包(一个文件夹),而这些是类,所以只需使用以下内容:

import components.DialogTitle;