• User

    contact form con multiselect

    Ciao a tutti, ho un form realizzato in flash, configurabile tramite xml.
    Una semplice pagina .net si preoccupa di inviare il messaggio.
    Nel form ho un campo dropdown e vorrei che ci fosse la possibilità di selezionare più di un valore. Sono un neoflash e non so proprio dove sbattere la testa.

    Actionscript (solo la parte che controlla il dropdown):

    
    
    case "dropdown" :
                        //if this is a drop down list
                        mcHolder.attachMovie("drop down","mcItem"+i,mcHolder.getNextHighestDepth());
                        mcHolder["mcItem"+i].type = "drop";
    
                        //remember the colors
                        mcHolder["mcItem"+i].background = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.background);
                        mcHolder["mcItem"+i].border = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.border);
                        mcHolder["mcItem"+i].text = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.text);
                        mcHolder["mcItem"+i].symbol = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.symbols1);
                        mcHolder["mcItem"+i].backgroundRoll = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.backgroundRoll);
                        mcHolder["mcItem"+i].borderRoll = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.borderRoll);
                        mcHolder["mcItem"+i].textRoll = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.textRoll);
                        mcHolder["mcItem"+i].backgroundSelect = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.backgroundSelect);
                        mcHolder["mcItem"+i].borderSelect = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.border);
                        mcHolder["mcItem"+i].textSelect = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.textSelect);
    
                        //change the colors
                        (new Color(mcHolder["mcItem"+i].txtLabel).setRGB(Number(xml.firstChild.childNodes[0].attributes.text)));
                        (new Color(mcHolder["mcItem"+i].mcBack).setRGB(mcHolder["mcItem"+i].background));
                        (new Color(mcHolder["mcItem"+i].mcBord).setRGB(mcHolder["mcItem"+i].border));
                        (new Color(mcHolder["mcItem"+i].mcLabel).setRGB(mcHolder["mcItem"+i].text));
                        (new Color(mcHolder["mcItem"+i].mcSymbol).setRGB(mcHolder["mcItem"+i].symbol));
                        (new Color(mcHolder["mcItem"+i].mcLine).setRGB(mcHolder["mcItem"+i].symbol));
    
                        //resize the text field
                        mcHolder["mcItem"+i].mcBack._width = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.width1);
                        mcHolder["mcItem"+i].mcBack._height = Number(xml.firstChild.childNodes[0].childNodes[0].attributes.height1);
                        mcHolder["mcItem"+i].mcBord._width = mcHolder["mcItem"+i].mcBack._width+2;
                        mcHolder["mcItem"+i].mcBord._height = mcHolder["mcItem"+i].mcBack._height+2;
                        mcHolder["mcItem"+i].mcLabel.txtLabel._width = mcHolder["mcItem"+i].mcBack._width-40;
                        mcHolder["mcItem"+i].mcSymbol._y = (mcHolder["mcItem"+i].mcBord._height-mcHolder["mcItem"+i].mcSymbol._height)/2+1;
                        mcHolder["mcItem"+i].mcLine._y = (mcHolder["mcItem"+i].mcBord._height-mcHolder["mcItem"+i].mcLine._height)/2+1;
                        mcHolder["mcItem"+i].mcSymbol._x = mcHolder["mcItem"+i].mcBord._width-18;
                        mcHolder["mcItem"+i].mcLine._x = mcHolder["mcItem"+i].mcBord._width-26;
    
                        //change the label and the text
                        mcHolder["mcItem"+i].mcLabel.txtLabel.text = String(xml.firstChild.childNodes[1].childNodes*.childNodes[0].attributes.name);
                        mcHolder["mcItem"+i].txtLabel.text = String(xml.firstChild.childNodes[1].childNodes*.attributes.label);
                        mcHolder["mcItem"+i].txtLabel._width = Number(xml.firstChild.childNodes[0].attributes.labelWidth);
                        mcHolder["mcItem"+i].txtLabel._x = -(Number(xml.firstChild.childNodes[0].attributes.labelWidth))-5;
                        mcHolder["mcItem"+i].txtLabel.autoSize = "right";
    
                        //set methods for the buttons that will be created
                        var initButton:Object = new Object();
                        initButton.useHandCursor = false;
                        initButton.onRollOver = function() {
                            Tweener.addTween(this.mcBack,{_color:this._parent._parent.backgroundRoll, time:.2});
                            Tweener.addTween(this.mcLabel,{_color:this._parent._parent.textRoll, time:.2});
                        };
                        initButton.onRollOut = function() {
                            Tweener.addTween(this.mcBack,{_color:this._parent._parent.background, time:.1});
                            Tweener.addTween(this.mcLabel,{_color:this._parent._parent.text, time:.1});
                        };
                        //create the buttons for the list 
                        var newYY:Number = 0;
                        for (var j:Number = 0; j<xml.firstChild.childNodes[1].childNodes*.childNodes.length; j++) {
                            mcHolder["mcItem"+i].mcMenu.attachMovie("button2","mcButton"+j,mcHolder["mcItem"+i].mcMenu.getNextHighestDepth(),initButton);
    
                            mcHolder["mcItem"+i].mcMenu["mcButton"+j].mcBack._width = mcHolder["mcItem"+i].mcMenu["mcButton"+j].mcLabel.txtLabel.text=mcHolder["mcItem"+i].mcBord._width;
                            mcHolder["mcItem"+i].mcMenu["mcButton"+j].mcBack._height = mcHolder["mcItem"+i].mcBack._height;
                            mcHolder["mcItem"+i].mcMenu["mcButton"+j]._y = newYY;
                            newYY += mcHolder["mcItem"+i].mcBack._height;
    
                            mcHolder["mcItem"+i].mcMenu["mcButton"+j]._text = String(xml.firstChild.childNodes[1].childNodes*.childNodes[j].attributes.name);
                            mcHolder["mcItem"+i].mcMenu["mcButton"+j].mcLabel.txtLabel.text = String(xml.firstChild.childNodes[1].childNodes*.childNodes[j].attributes.name);
    
                            (new Color(mcHolder["mcItem"+i].mcMenu["mcButton"+j].mcBack).setRGB(mcHolder["mcItem"+i].background));
                            (new Color(mcHolder["mcItem"+i].mcMenu["mcButton"+j].mcText).setRGB(mcHolder["mcItem"+i].text));
                        }
                        //position buttons
                        mcHolder["mcItem"+i].mcMask._y = mcHolder["mcItem"+i].mcBord._height;
                        mcHolder["mcItem"+i].mcMask._height = newYY;
                        mcHolder["mcItem"+i].mcMask._width = mcHolder["mcItem"+i].mcBord._width;
                        mcHolder["mcItem"+i].mcMenu._y = -mcHolder["mcItem"+i].mcMenu._height;
                        break;
    
    
    
    

    Actionscript dropdown clip (nella libreria)

    
    //declare variables
    var background:Number;
    var border:Number;
    var text:Number;
    var symbol:Number;
    var backgroundRoll:Number;
    var borderRoll:Number;
    var textRoll:Number;
    var backgroundSelect:Number;
    var borderSelect:Number;
    var textSelect:Number;
    
    var this2:Object = this;
    var type:String;
    
    //mouse listener - check if the mouse is over this text field
    var mouseListener:Object = new Object();
    mouseListener.onMouseMove = function() {
        //change colors
        if (_parent.selectedObj != this2) {
            if (_xmouse>0 && _ymouse>0 && _xmouse<mcBack._width && _ymouse<mcBack._height) {
                Tweener.addTween(mcBack,{_color:backgroundRoll, time:.5});
                Tweener.addTween(mcBord,{_color:borderRoll, time:.5});
                Tweener.addTween(mcLabel,{_color:textRoll, time:.5});
            } else {
                Tweener.addTween(mcBack,{_color:background, time:.2});
                Tweener.addTween(mcBord,{_color:border, time:.2});
                Tweener.addTween(mcLabel,{_color:text, time:.2});
            }
        }
    };
    mouseListener.onMouseDown = function() {
        //check last selected object
        //set focus on this text field    
        if (_xmouse>0 && _ymouse>0 && _xmouse<mcBack._width && _ymouse<mcBack._height) {
            if (_parent.selectedObj != this2) {
                Tweener.addTween(mcBack,{_color:backgroundSelect, time:.5});
                Tweener.addTween(mcBord,{_color:borderSelect, time:.5});
                Tweener.addTween(mcLabel,{_color:textSelect, time:.5});
    
                _parent.selectedObj = this2;
    
                //open list
                Tweener.addTween(mcMenu,{_y:mcBord._height, time:.1});
            } else {
                Tweener.addTween(mcBack,{_color:background, time:.2});
                Tweener.addTween(mcBord,{_color:border, time:.2});
                Tweener.addTween(mcLabel,{_color:text, time:.2});
    
                //close list
                Tweener.addTween(mcMenu,{_y:-mcMenu._height, time:.1});
                if (_parent.selectedObj.type == "drop") {
                    _parent.selectedObj = null;
                }
            }
    
        } else {
            if (!this2.first) {
                Tweener.addTween(mcBack,{_color:background, time:.2});
                Tweener.addTween(mcBord,{_color:border, time:.2});
                Tweener.addTween(mcLabel,{_color:text, time:.2});
    
                //close list
                Tweener.addTween(mcMenu,{_y:-mcMenu._height, time:.1});
                if (_parent.selectedObj.type == "drop") {
                    setTimeout(delayChange,1);
                }
            }
        }
    };
    Mouse.addListener(mouseListener);
    
    function delayChange() {
        _parent.selectedObj = null;
    }
    
    //font
    var fontFmt:TextFormat = new TextFormat();
    fontFmt.font = "Font";
    txtLabel.embedFonts = true;
    txtLabel.setTextFormat(fontFmt);
    
    

    XML:

    
    <?xml version="1.0" encoding="utf-8"?>
    <settings>
    
        <design text="0xCCCCCC" required="0xF53800" requiredStar="R" margin="15" labelWidth="150">
        
            <items
            
                background="0xF7F7F7"
                border="0xEAEAEA"
                text="0x333333"
                
                backgroundRoll="0xECECEC"
                borderRoll="0xE0E0E0"
                textRoll="0x333333"
                
                backgroundSelect="0xACACAC"
                borderSelect="0x959595"
                textSelect="0xFFFFFF"
                
                symbols1="0xEAEAEA"
                symbols2="0xFFFFFF"
                symbols3="0x5A5A5A"
                
                width1="200"
                height1="23"
                
                height2="80"
                
                height3="23"
                
                width2="15"
                height4="15"
                
                wrongFlash="0xF53800"
            
            ></items>
            
            <nothing></nothing>
            <nothing></nothing>
            <nothing></nothing>
            
            <button
            
                width="50"
                height="22"
                
                background="0xF7F7F7"
                border="0xEAEAEA"
                text="0x333333"
                
                backgroundRoll="0xACACAC"
                borderRoll="0x959595"
                textRoll="0xFFFFFF"
            
            ></button>
        
        </design>
        
        <form>
        
            <item type="textfield" label="Name:" required="true" minLetters="1" maxLetters="20" wrong="Please enter a valid name"></item>
            <item type="textfield" label="Surname:" required="true" minLetters="1" maxLetters="20" wrong="Please enter a valid surname"></item>
            <item type="textfield" label="Company:" required="true" minLetters="1" maxLetters="20" wrong="Please enter a valid Company name"></item>
            <item type="textfield" label="Email:" required="true" validation="email" wrong="Please insert a corect email address.." email="this"></item>
            <item type="dropdown" label="test:" subject="this">
                <option name="toscana"></option>
                <option name="lazio"></option>
                <option name="liguria Arredamenti"></option>
                <option name="sardegna"></option>
                <option name="piemonte"></option>
          
            </item>
            <item type="textarea" label="Message:" required="true" wrong="Why would you even try to send a message without an actual message?"></item>
            <item type="checkbox" label="" required="false" extraMargin="10">
                <option name="select me"></option>
            </item>
            <item type="button" label="Send" extraMargin="15"></item>
        
        </form>
        
        <send
        
            to="[email protected]"
            from="Pincopallo"
            
            sentLk="Sending.. Please wait."
            sentOk="Your message was sent. You will get an anwser in the next days."
            sentNok="There was an error while sending your message. Please try again."
        
        ></send>
    
    </settings>