6 Replies Latest reply on Oct 25, 2006 10:53 PM by prachis

    Code not working

    prachis
      I want that whenever I click on the E-mail button, It should open the outlook to send an E-mail to "abc@xyz.com" this address.
      for this, I have added the following code in my application.

      Code:

      public function handleClickHelp(event):Void{
      var cp:String;
      var w:Number;
      var h:Number;
      var emailH:MovieClip; // this is also given as the <Instance Name> of a Button E-mail.
      if(_root.admin =="ok"){
      w=650;
      h=650;
      cp = "helpAdmin"
      }else{
      w=650;
      h=450;
      cp = "help";
      }
      mapopup = PopUpManager.createPopUp(this, Window, true,{title:"Help",closeButton:true,_width:w,_height:h,_x:200,_y:50,contentPath:cp});
      mapopup.addEventListener("click",mapopup.deletePopUp);
      mapopup.content.emailH.onPress = function(){
      getURL ("mailto:ingo.schneider@fr.non.schneider-electric.com;rafael.cortes@fr.schneider-electric .com" + "&subject=Help mail")
      Alert.show("E-mail","Help", Alert.OK,_root);
      }

      }
      But this is not working :(.
      Can you please help?
        • 1. Re: Code not working
          AnandMX Level 1
          kindly explain where u hv added the code, i this a class, and if it is a class tell me how u have written it and share the complete class structure.
          also let me know if u r getting some error message
          • 2. Code not working
            prachis Level 1
            Okay,

            I have written the code in an actionscript file (.as file). The button is there in the .fla file, and i have given the instance name of the button in .fla file as emailH.

            Here is the code from actionscript file.

            Code:

            import mx.utils.Delegate;
            import mx.core.UIObject;
            import mx.controls.*;
            import mx.managers.PopUpManager;
            import mx.containers.Window;


            class Options extends UIObject{

            public var helpBt:Button;
            public var delegateHelp:Function;

            public function Options(){
            init();
            }
            private function init():Void{

            helpBt = Button(createClassObject(Button, "helpBt", 7,{_x:577, _y:29, _width:77, _height:22,falseUpSkin:"help_etat1",falseDownSkin:"help_etat1",falseOverSkin:"help_etat2" }));
            delegateHelp = Delegate.create(this,this.handleClickHelp);
            helpBt.addEventListener("click", delegateHelp);

            }

            public function handleClickHelp(event):Void{
            var cp:String;
            var w:Number;
            var h:Number;
            var emailH:MovieClip;
            if(_root.admin =="ok"){
            w=650;
            h=650;
            cp = "helpAdmin"
            }else{
            w=650;
            h=450;
            cp = "help";
            }
            mapopup = PopUpManager.createPopUp(this, Window, true,{title:"Help",closeButton:true,_width:w,_height:h,_x:200,_y:50,contentPath:cp});
            mapopup.addEventListener("click",mapopup.deletePopUp);
            mapopup.content.emailH.onPress = function(){
            getURL ("mailto:abc@xyz.com " + "&subject=Help mail")
            Alert.show("E-mail","Help", Alert.OK,_root);
            }

            }

            }
            Thanks for your attention.
            • 3. Re: Code not working
              ggshow Level 2
              make sure your have you Alert & Window components in your library
              • 4. Re: Code not working
                prachis Level 1
                yes i have. :(
                • 5. Re: Code not working
                  AnandMX Level 1
                  Hey i dont know what had happen, but this is working fine if i link your class with my MovieClip...
                  import mx.utils.Delegate;
                  import mx.core.UIObject;
                  //import mx.controls.*;
                  import mx.controls.Button;
                  import mx.controls.Alert;
                  import mx.managers.PopUpManager;
                  import mx.containers.Window;
                  class Options extends UIObject {
                  // public var helpBt:Button;
                  public var helpBt:MovieClip;
                  public var delegateHelp:Function;
                  public function Options() {
                  trace("called");
                  init();
                  }
                  private function init():Void {
                  //helpBt = new Button(this.createClassObject(Button, "helpBt", 7,{_x:577, _y:29, _width:77, _height:22,falseUpSkin:"help_etat1",falseDownSkin:"help_etat1",falseOverSkin:"help_etat2" }));
                  helpBt=new MovieClip()
                  helpBt=this.attachMovie("Button","helpBt",this.getNextHighestDepth())
                  for (var i in helpBt){
                  trace(i +":"+helpBt );
                  }
                  delegateHelp = Delegate.create(this, this.handleClickHelp);
                  helpBt.addEventListener("click", delegateHelp);
                  }
                  public function handleClickHelp(event):Void {
                  trace("HandleClick Called ")
                  var cp:String;
                  var w:Number;
                  var h:Number;
                  var emailH:MovieClip;
                  if (_root.admin == "ok") {
                  w = 650;
                  h = 650;
                  cp = "helpAdmin";
                  } else {
                  w = 650;
                  h = 450;
                  cp = "help";
                  }

                  var mapopup = PopUpManager.createPopUp(this, Window, true, {title:"Help", closeButton:true, _width:w, _height:h, _x:200, _y:50, contentPath:cp});
                  mapopup.addEventListener("click", mapopup.deletePopUp);
                  mapopup.content.emailH.onPress = function() {
                  getURL("mailto:abc@xyz.com "+"&subject=Help mail");
                  Alert.show("E-mail", "Help", Alert.OK, _root);
                  };
                  }
                  }
                  //it gives me url error.. i hope your createClassObject declaration is wrong
                  • 6. Code not working
                    prachis Level 1
                    No, but it's working fine. I mean it is generating the class object properly! My problem is, it is not identifying that emailH button (which is there on the popup manager 'mapopup'). When I click on that button, it should create a new message in outlook for sending the e-mail. But nothing is happening after clicking on the button.