Noob Help - Actionscript Returns

I am brand new at using actionscript and am having a hard
time understanding what the return..... code/command/function?? is
for. Here is a simple example of script :
var number1:Number = 5;
var number2:Number = 2;
var numberSum:Number;
function addNumbers(pNum1:Number, pNum2:Number):Number {
var sum:Number = pNum1 + pNum2;
return sum;
numberSum = addNumbers(number1, number2);
trace('The sum of number1 and number 2 is: ' + numberSum);
I'm not seeing how the return code is related to the last
part of the script. I understand that it is "returning" the var sum
but where is it going and how is it related to the last bit?

The return is getting set to the variable numberSum. The
following line tells us this: numberSum =
addNumbers(number1,number2);
When you set a variable = a function, the variable is
expecting a return value to come out of that function.
"But why can't you just call the variable sum?" - The
variable sum is local to the function only, and therefore is only
available inside of the function. In order to get its value out of
the function, you need to tell the function to return it to the
caller, which, in this instance, happens to the variable
numberSum.

Similar Messages

  • Please help me return my skype!!!! Please!!!!

    Please help me return my skype!!!! Please!!!!

    Hello,
    Please explain what the problem is.
    TIME ZONE - US EASTERN. LOCATION - PHILADELPHIA, PA, USA.
    I recommend that you always run the latest Skype version: Windows & Mac
    If my advice helped to fix your issue please mark it as a solution to help others.
    Please note that I generally don't respond to unsolicited Private Messages. Thank you.

  • Search help to return multiple values

    Hi all,
    I've created a search help and I'd like it to return several values to different fields, I don't want these fields to be seen on the selection screen.
    For example:
    1. User clicks on search help for FIELD1 and selects a value from the pop-up box
    2. Program populates FIELD1 depending on the user selection
    3. Program also populates FIELD2 and FIELD3 which can be used in the program at a later date.
    I can do 1 and 2 but I'm having an issue with 3.  I've tried selecting all fields in the search help as Export, but although that populates the fields in the search help test facility, it doesn't know which fields I want it to populate in my program.
    I've also tried using FM F4IF_FIELD_VALUE_REQUEST but can only get this to return one line in table RETURN_TAB.
    The screen fields are declared as:
    PARAMETERS: FIELD1 LIKE TAB1-FIELD1 MATCHCODE ZSEARCH_HELP,
                             FIELD2 LIKE TAB1-FIELD2 NO-DISPLAY,
                             FIELD3 LIKE TAB1-FIELD3 NO-DISPLAY.
    Any help is appreciated.
    Gill

    Thanks for your suggestion but what I failed to put in my original post was that FIELD1 is a description field and FIELD2 and FIELD3 are the actual key fields for the table which I need.
    So, I can't do your suggestion of populating them based on FIELD1, I need to know which line the user selects to populate these key fields as FIELD1 may not be unique within the table.
    Does that make sense?
    That's why I wanted the search help to return all 3 values then I can populate FIELD2 and FIELD3 from that.

  • HT1338 MacBook now takes 1 minute to go to sleep after all windows closed, any help to return it to normal

    MacBook now takes >1 minute to go to sleep after all applications are closed.  Need help in returning it to the normal 10 sec for sleep

    First, Try using Disk Utility to do a Disk Repair, as shown in this link, while booted up on your install disk. You could have some directory corruption. Let us know what errors Disk Repair reports and if DU was able to repair them. This could just be a start in repairs and you may need a better utility to finish the job.
    Then Repair Permissions.
    No need to report any Permissions errors........we all get them.
       DALE

  • ActionScript 3 Noob Help - 1180: Call to a possibly undefined method addChild.

    Hey everyone, i'm in the process of learning ActionScript 3. I'm woking on my first OOP game with a class other than the document class.
    Right now, my game has a preloader library symbol called PreLoader and one called MainMenu (they have been exported for actionscript). All other objects are subobjects of these Movie Clips. My code si split into three actionscript files called Main.as (the document class. I had planned this to load and unload the preloader, mainmenu, and game itself) MainMenu.as (meant to controll the main menu's buttons and listeners) and PreLoader.as (which has the pre-Loader code in it.) I was having a lot of trouble with unloading the main menu and preloader after I was finished with them, so I let the document class handle them, which led to a series of errors as follows:
    C:\Users\...\hamletgame\Main.as, Line 19    1120: Access of undefined property mainMenu.
    C:\Users\...\hamletgame\Main.as, Line 20    1180: Call to a possibly undefined method addChild.
    C:\Users\...\hamletgame\Main.as, Line 20    1120: Access of undefined property mainMenu.
    C:\Users\...\hamletgame\Main.as, Line 21    1180: Call to a possibly undefined method removeChild.
    C:\Users\...\hamletgame\Main.as, Line 21    1120: Access of undefined property preLoader.
    C:\Users\...\hamletgame\Main.as, Line 25    1180: Call to a possibly undefined method removeChild.
    C:\Users\...\hamletgame\Main.as, Line 25    1120: Access of undefined property mainMenu.
    Thank you all very much in advance. I'm sure its something simple i've missed. My code is posted below.
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var preLoader:PreLoader;
            var mainMenu:MainMenu;
            public function Main()
                preLoader = new PreLoader;
                addChild(preLoader);
            static public function loadMainMenu():void
                mainMenu = new MainMenu();
                addChild(mainMenu);
                removeChild(preLoader);
            static public function loadGame():void
                removeChild(mainMenu);
    PreLoader.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class PreLoader extends MovieClip
            //Declare Variables Here
            //Constructor Function
            public function PreLoader()
                gotoAndStop(1);
                addEventListener(Event.ENTER_FRAME, loading);
            //Functions
            private function loading (event:Event):void
                var total:Number = stage.loaderInfo.bytesTotal;
                var loaded:Number = stage.loaderInfo.bytesLoaded;
                loadingBar.scaleX = loaded/total;
                if(loaded==total)
                    gotoAndStop(2);
                    removeEventListener(Event.ENTER_FRAME, loading);
                    playButton.addEventListener(MouseEvent.CLICK, startMovie)
            private function startMovie (event:MouseEvent):void
                removeEventListener(MouseEvent.CLICK, startMovie);
                Main.loadMainMenu();
    MainMenu.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class MainMenu extends MovieClip
            //Constructor Function
            public function MainMenu()
                addEventListener(Event.ENTER_FRAME, onFrameEnter);
            //Other Functions
            private function onFrameEnter(event:Event):void
                if(currentFrame==30)
                    stop();
                    playGameButton.addEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                    instructionsButton.addEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                    creditsButton.addEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
                else
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
            private function onPlayGameButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                Main.loadGame();
            private function onInstructionsButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
            private function onCreditsButtonClick(event:MouseEvent):void
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);

    I'm not sure why I'm not able to use all 3 of your classes as intended.  I read that you cannot access the Document Class from other classes directly.  So This is what I have:
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var preLoader:PreLoader;
            var mainMenu:MainMenu;
            public function Main()
                preLoader = new PreLoader;
                addChild(preLoader);
                                  trace("Main");
            public function loadGame():void
                                  trace("loadGame start");
                //removeChild(mainMenu);
                                  trace("loadGame finish");
    MainMenu.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
        public class MainMenu extends MovieClip
            //Constructor Function
                        var playGameButton:PlayGameButton;
                        var instructionsButton:InstructionsButton;
                        var creditsButton:CreditsButton;
                        var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var container1_mc:MovieClip;
            public function MainMenu()
                                  trace("MainMenu");
    PreLoader.as  (this is where the heart of your app is)
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
              import flash.display.Loader;
              import flash.display.LoaderInfo;
        public class PreLoader extends MovieClip
            //Declare Variables Here
                        var playGameButton:PlayGameButton;
                        var instructionsButton:InstructionsButton;
                        var creditsButton:CreditsButton;
            var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var loadingBar:LoadingBar;
                        var playsButton;
                        var container_mc:MovieClip;
            //Constructor Function
            public function PreLoader()
                gotoAndStop(1);
                addEventListener(Event.ENTER_FRAME, loading);
            //Functions
            public function loading (event:Event):void
                var total:Number = stage.loaderInfo.bytesTotal;
                var loaded:Number = stage.loaderInfo.bytesLoaded;
                                  loadingBar=new LoadingBar();
                                  addChild(loadingBar);
                                  loadingBar.x=50;
                                  loadingBar.y=50;
                                  var playsButton=new PlaysButton();
                loadingBar.scaleX = loaded/total;
                if(loaded==total)
                                            removeChild(loadingBar);
                                            //stop();
                                            trace("loaded equals total");
                    gotoAndStop(2);
                    removeEventListener(Event.ENTER_FRAME, loading);
                                            addChild(playsButton);
                                            playsButton.x=50;
                                            playsButton.y=250;
                    playsButton.addEventListener(MouseEvent.CLICK, startMovie);
            public function startMovie(event:MouseEvent):void
                //removeEventListener(MouseEvent.CLICK, startMovie);
                                  trace("startMovie");
                                  loadMainMenu();
                         public function loadMainMenu():void
                        var main:Main;
                        var mainMenu:MainMenu;
                        var preLoader:PreLoader;
                        var container1_mc:MovieClip;
                                  trace(currentFrame+"cf");
                                  trace("loadMainMenu start");
                                  container1_mc= new MovieClip();
                                  addChild(container1_mc);
                                  playGameButton=new PlayGameButton();
                                  trace("1");
                                  instructionsButton= new InstructionsButton();
                                  creditsButton = new CreditsButton();
                                  playGameButton.x=100;
                                            playGameButton.y=100;
                                            instructionsButton.x=200;
                                            instructionsButton.y=100;
                                            creditsButton.x=300;
                                            creditsButton.y=100;
                                            trace(creditsButton.name);
                                            trace(creditsButton.x);
                                            trace(creditsButton.y);
                                            trace(container1_mc.x);
                                            trace(container1_mc.y);
                                  addChild(playGameButton);
                                  playGameButton.name="playGameButton";
                                  instructionsButton.name="instructionsButton";
                                  creditsButton.name="creditsButton";
                                  trace(creditsButton.name);
                                  trace("2");
                                            addChild(instructionsButton);
                                            addChild(creditsButton);
                                  trace("loadMainMenu finish");
                                  MainMenus();
                        public function MainMenus():void
                addEventListener(Event.ENTER_FRAME, onFrameEnter);
                                  trace("MainMenus");
                                  //loadMainMenu();
            public function onFrameEnter(event:Event):void
                                  trace("AA");
                if(currentFrame==0)
                                            if(creditsButton.name=="creditsButton"){
                    stop();
                                            trace("frame 30");
                                            trace(currentFrame);
                                            trace(creditsButton.name);
                    playGameButton.addEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                    instructionsButton.addEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                    creditsButton.addEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
                else
                    removeEventListener(Event.ENTER_FRAME, onFrameEnter);
            public function onPlayGameButtonClick(event:MouseEvent):void
                                  trace("A");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
                //main.loadGame();
            public function onInstructionsButtonClick(event:MouseEvent):void
                                  trace("B");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
            public function onCreditsButtonClick(event:MouseEvent):void
                                  trace("C");
                playGameButton.removeEventListener(MouseEvent.CLICK, onPlayGameButtonClick);
                instructionsButton.removeEventListener(MouseEvent.CLICK, onInstructionsButtonClick);
                creditsButton.removeEventListener(MouseEvent.CLICK, onCreditsButtonClick);
    I've exported each button and movie clip which resides on the stage in the Library.  I've removed them from the stage/Timeline and just have the Exports in ActionScript on Frame 1.  I also noticed I couldn't access frame 30 and had to change the code to "if(currentFrame==0)....."
    I hope this gets you started in the right direction though I'm not sure what I've done is what you're looking for.

  • Noob help

    Hi folks,
    Well I am new to the whole mac thing and am keen to get cracking. I want to install Leopard but all the copies I can find on e-bay all have things like Macbook Pro labeled on the disk. Am I right in saying that will not install on my new pretty G4? It currently has Tiger but have heard that leopard is a better OS. As this is all new to me any help would be gratefully appreciated. Would I be best to stick with Tiger as a noob or try and upgrade?

    It is a 1.2Ghz CPU and currently has 512MB of ram. Soon to be upgraded to max of 1.5GB though. Thing is the ibook is currently in transit to me (bought from ebay). lol. I am just uber excited about getting it. My very first mac. Been windows user for 20 years and it slowly getting worse so time to change now before it gets past the point of no return. I assume this e-bay listing would be fine:
    http://cgi.ebay.co.uk/Mac-OSX-LeopardW0QQitemZ320483098806QQcmdZViewItemQQptZUK_Computing_Software_SoftwareSR?hash=item4a9e4800b6
    Anyone know where I can get a cheap copy? Under £50 would be fantastic.
    The ibook I have is http://support.apple.com/kb/SP43 but with a superdrive and an 80GB hard drive.

  • Help ActionScript variables on other domain

    I hope somebody can help me out. I have been thumping my head
    on this one for awhile. I have javascript calling within
    actionscript and it seems to work on every domain on my server but
    does not work on any other domains. The code is this:
    varsObject.theurl = flash.external.ExternalInterface.call(
    'function() { return window.location.toString(); }' );
    ( works in FireFox only mind you )
    I figured it must be somehow a cross domain policy issue. So
    in my fla file at the top i put
    System.security.loadPolicyFile("
    http://www.mydomain.com/crossdomain.xml");
    And in the file I put this
    <?xml version="1.0"?>
    <!--
    http://www.mydomain.com/crossdomain.xml
    -->
    <cross-domain-policy>
    <allow-access-from domain="*" />
    </cross-domain-policy>
    I am hoping one of you sharp people can point me to what i am
    doing wrong!

    Hi,
    Thanks for your reply,
    Can you please send me a sample code, for eg taking 3 rows and 3 cols(3 X3), i would really appreciate it
    Please awaiting your reply, just need help in accessing the string[][] you mentioned
    please reply soon..
    Thanks,

  • Help Needed: Returning Back to Windows 8 after downgrading to Windows 7

    Hi guys, im just new here.
    I have a MSI GE40 gaming laptop which I bought 2 months back.
    Within those 2 months of usage, I always encounter my laptop to be very slow in shutting down. It always take, maybe up to 10 minutes to fully shut down. The screen goes black but the power button stays on orange color, & as I said, it takes a long time  for the power button to be completely unlit. But for start up, its blazing fast.
    Thinking that windows 8 itself is the culprit of super slow shutting down, I searched the net on how to downgrade to windows 7.
    Of course I did make a back up first on a 16gb usb flash drive using the pre-installed recovery software from MSI which was completed successfully.
    Then I made some tweaks on the bios (ie select legacy & disable secure boot) & boot using windows 7 installation DVD, deleted all partitions (since the notebook comes with GPT partition) to be able to install windows 7. I installed all the drivers which I downloaded from MSI website specific to my notebook.
    But the problem is not solved, it is still very slow in shutting down, & now even boot up becomes very slow too.
    So I downloaded & execute the firmware & bios for windows 7 from msi website (again, specific to my model). But still the same, the notebook is still very slow both in shutting down & start up.
    So I decided to go back again to windows 8, I tried to boot from the flash drive (I adjusted from the bios & make the flash drive to be the first priority) but it did not boot from it. I tried F11 on start up & selected to boot from usb flash drive but again, to no avail.
    So the last one I did was downloaded windows 8, make a bootable flash drive out of it, boot from it and luckily, I succeed - I have now again a windows 8 msi ge40 laptop.
    But I wanted my laptop to be reinstated to factory setting, i.e, all preinstalled softwares are there, the bios is default for windows 8. So I tried to update the bios to the one for windows 8 again (since I downgraded the bios to the one for windows 7 when I downgraded the OS to windows 7). But I could not update the bios, the laptop is not booting from usb flash drive containing the bios.
    I tried also to recover using F3 on start up but the system does not recognize the flash drive (with system back up). I tried also on PC settings but to no avail.
    Now guys, I need your help.
    How can I return back my laptop to default factory settings?
    Thank you.
    (sorry for my not so good English)

    Hello:
    I think it's not only about the OS version, you need to return this back to your shop to repair with the slow shot down issue, because the OS should be shot down in 30 seconds, far from your GE40 times.

  • Need help on returning arrays from C++ to Java

    Hi all, I hava a C++ application that contains a method that will return a float array to Java. I was able to write the Java Code, the JNI code to call the C++ method and compile them successfully. However on calling the native method from Java, the data in the array returned was not what I want. Please look through my code and see what is wrong with it.
    My Java Code:
    public native float[] Statistics(int inputKey); // This is the native method
    public float[] Stats(int k){ //Java method to call the native method so that I can use it in a Bean for a JSP.
    inputKey = k;
    float[] p = new float[4];
    p = Statistics(inputKey);
    return p;
    For this native method, an integer is passed from Java to the native side and the native method will use this integer to generate a float array size of 4 and populate it with data and return it back to Java.
    My JNI code
    extern "C"
    JNIEXPORT jfloatArray JNICALL
    Java_com_jspsmart_upload_FinalWaterMark_Statistics(JNIEnv *env, jobject obj, jint inputKey)
         jfloatArray floatArray = env->NewFloatArray(4); //This creates a new Java floatArray to store the C++ array
         CWatermarker2App p; // This is the C++ class to be used
         jfloat *stats = p.OnWatermarkStatistics(inputKey) // The C++ method returns a float pointer for an array of size 4
         env->SetFloatArrayRegion(floatArray, 0 , 4 , stats); //storing the C++ float array into the Java float Array
         return floatArray; // return the Array to Java
    In this example, I should have the data returned as [4952.0 2529.0 1706.0 33.6] in the array.
    But i am getting junk instead like 2.53E-23, 1.402E-15 etc..
    Is this a type conversion mistake?
    Please help!

    The first thing I notice - probably not the problem - is the line defining p. There is no reason to define this as an array of size 4, because the return from the native method is going to wipe that definition, replacing it with the return value of the native method. Alternatives:
    1. float[] p = null.
    2. float[] p = Statistics(inputKey);
    3. return Statistics(k);

  • Need help on returning input

    Hi. I'm making a DateTimePicker (DTP), and I need help on getting a method to return a Date only when the DTP is closed, and I want this to be done in the DTP class itself.
    For now, I've used an infinite loop and it seems to work fine without lagging the computer (my computer is above average), but I'm not sure if there's another more efficient way.
    I would prefer not to use threads, but if that's the only option then I suppose it's unavoidable.
    I'm using:
    while(true){
        switch(returnState){
        case UNINITIALIZED: continue;
        case SET: return cal.getTime();
        case CANCELED:
            default:
            return null;
    }Screenshots:
    http://i34.tinypic.com/53rb7n.png
    http://i33.tinypic.com/2nsxct4.png
    Azriel~

    You could put any component in a JOptionPane or a JDialog and then easily query the component for results once it has returned.
    For example:
    QueryComponent.java creates a component that can be placed in a JOptionPane and then queried.
    import java.awt.GridLayout;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JComponent;
    import javax.swing.JTextField;
    * A simple component that has two JTextFields and two
    * corresponding "getter" methods to extract information
    * out of the JTextFields.
    * @author Pete
    public class QueryComponent
      private JPanel mainPanel = new JPanel();
      private JTextField firstNameField = new JTextField(8);
      private JTextField lastNameField = new JTextField(8);
      public QueryComponent()
        mainPanel.setLayout(new GridLayout(2, 2, 5, 5));
        mainPanel.add(new JLabel("First Name: "));
        mainPanel.add(firstNameField);
        mainPanel.add(new JLabel("Last Name: "));
        mainPanel.add(lastNameField);
      public String getFirstName()
        return firstNameField.getText();
      public String getLastName()
        return lastNameField.getText();
      // get the mainPanel to place into a JOptionPane
      public JComponent getComponent()
        return mainPanel;
    }QueryComponentTest.java places the component above into a JOptionPane, shows the pane, and then queries the QueryComponent object for the results.
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JComponent;
    public class QueryComponentTest
      private JPanel mainPanel = new JPanel();
      public QueryComponentTest()
        JButton getNamesBtn = new JButton("Get Names");
        getNamesBtn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            getNamesAction();
        mainPanel.add(getNamesBtn);
      // occurs when button is pressed
      private void getNamesAction()
        // create object to place into JOptionPane
        QueryComponent queryComp = new QueryComponent();
        // show JOptionPane
        int result = JOptionPane.showConfirmDialog(mainPanel,
            queryComp.getComponent(), // place the component into the JOptionPane
            "Get Names",
            JOptionPane.INFORMATION_MESSAGE);
        if (result == JOptionPane.OK_OPTION) // if ok selected
          // query the queryComp for its contents by calling its getters
          System.out.println("First Name: " + queryComp.getFirstName());
          System.out.println("Last Name:  " + queryComp.getLastName());
      public JComponent getComponent()
        return mainPanel;
      private static void createAndShowUI()
        JFrame frame = new JFrame("QueryComponentTest");
        frame.getContentPane().add(new QueryComponentTest().getComponent());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args)
        java.awt.EventQueue.invokeLater(new Runnable()
          public void run()
            createAndShowUI();
    }Edited by: Encephalopathic on Sep 29, 2008 8:16 PM

  • Help with returning query from loadURL()

    I finally came across loadURL() and figured out that I can
    use it to invoke my ColdFusion components without page
    reloading--very handy!
    Now, I need to figure out how to do this to return values
    from my components. Has anyone done this and have an example I
    could see, or at least point out to me a suggestion of code for
    successfully doing this?
    Right now, my component looks like this:
    <cfcomponent output="no">
    <cffunction name="getComments" access="remote"
    output="no" returntype="query">
    <cfset var rsComments = "">
    <cfquery name="rsComments" datasource="xmlTest">
    SELECT *
    FROM comments
    ORDER BY commenter DESC
    </cfquery>
    <cfreturn rsComments>
    </cffunction>
    </cfcomponent>
    I am trying to use loadURL() as follows:
    function myQuery() {
    var myDatasetURL = 'xmlTest.cfc?method=getComments';
    var req = Spry.Utils.loadURL("GET", myDatasetURL, true);
    In Firebug, the "Response" shows a serialized WDDX packet.
    I've not really messed with these before, so any help would be
    greatly appreciated!
    Thanks
    Joel

    Your first mistake was to choose an array. An array has a fixed length, so it's not appropriate for storing a sequence whose length you don't know in advance. You should choose a List instead; an ArrayList would be a reasonable implementation to choose.
    Then you just add the Point to the ArrayList. Here's how you declare it:
    List<Point> points = new ArrayList<Point>();and here's how you use it in the listener:
    points.add(evt.getPoint());Returning anything from the listener to its caller, which is something buried in the GUI hierarchy, would be... um... pointless.

  • Need help in returning error condition from web service

    Hi,
    I need one help regarding webservice. Currently my web service is returning "true" value when it works fine without any issues but it returns "false" when any any error is encountered. So my question is, can we return error instead of string "false". I dont know how to return exact error from webservice. If you any idea then please mail me.
    Below is a small code snippet:
    System.out.println("User "+ userFullName + usrKey + " end date has been updated to "+usrEndDate +" in IDM DB");
    result = true;
    catch (tcAPIException e) {
    log.error("Error in finding the user" + e.getMessage());
    result = false;
    } catch (tcUserNotFoundException e) {
    log.error("Error in getting user status" + e.getMessage());
    result = false;
    } catch (tcStaleDataUpdateException e) {
    log.error("Error in updating end date of user" + e.getMessage());
    result = false;
    }catch (Exception e1) {
    e1.printStackTrace();
    result =false;
    return result;
    Here i want to return error instead of false. Can we do that?
    Thanks,
    Kalpana.

    instead of storing false store below
    use result=e1.getMessage();
    Edited by: Nishith Nayan on Feb 23, 2012 8:07 PM

  • Powershell - Help with returning dynamic variable values

    Add-Type -AssemblyName System.Windows.Forms
    $frm1 = New-Object System.Windows.Forms.form
    $frm1.Name = "Hey"
    $flw1 = New-Object System.Windows.Forms.FlowLayoutPanel
    $flw1.flowdirection = 'TopDown'
    $frm1.controls.add($flw1)
    $m = "apple","orange","banana"
    for($i=0;$i -le $m.Length-1;$i++){
    $lb = New-Object System.Windows.Forms.linkLabel
    $lb.text = $m[$i]
    $m[$i] = $null
    $flw1.Controls.Add($lb)
    $lb.add_Click({Write-Host $lb.text})
    $frm1.showdialog()
    Could someone please help me with a method to return the value of the label that was clicked? Or a means to identify which linklabel was clicked. Thank you.

    Hi, jrv-
    Awfully sorry to trouble you. Could you please assist with the solution to this script or a better way to approach this scenario? I need to return the current value of label ($lb) from the form ($frm1), when $btnfrm2 on form ($frm2) is clicked.
    Thank you.
    Add-Type -AssemblyName System.Windows.Forms
    $frm1 = New-Object System.Windows.Forms.form
    $frm1.Name = "Hey"
    $flw1 = New-Object System.Windows.Forms.FlowLayoutPanel
    $flw1.flowdirection = 'TopDown'
    $frm1.controls.add($flw1)
    $m = "apple","orange","banana"
    function frmDisplay{
    $frm2 = New-Object System.Windows.Forms.Form
    $btnfrm2 = New-Object System.Windows.Forms.Button
    #$btnfrm2.Add_Click()
    $btnfrm2.text = 'Click'
    $frm2.Controls.Add($btnfrm2)
    $frm2.Add_Shown({$frm2.Activate()})
    [void] $frm2.ShowDialog()
    for($i=0;$i -le $m.Length-1;$i++){
    $lb = New-Object System.Windows.Forms.linkLabel
    $lb.text = $m[$i]
    $m[$i] = $null
    $flw1.Controls.Add($lb)
    $lb.add_Click({Write-Host $this.text; (frmDisplay)})
    $frm1.showdialog()

  • Noob help to format date to insert into mysql

    Sorry, if this question has been asked before, I did di a search but could not find an answer that I could understand.  I am pretty new to DW and my coding skills are not good so please go easy on me.
    I have a simple form to insert records to a mysql database.  I have created a form validarion behaviour to require the fields that are set as not-NULL in the database.  How do I modify the code to allow the date format to be entered in the dob field in the form as DD/MM/YYYY but inserted correctly in the database as YYYY/MM/DD?
    Finally, how would I then modify it further to default to todays date?
    Here's my code:
    <?php require_once('Connections/mypms.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO demographics (title, firstname, surname, dob, address1, address2, town, county, postcode) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['firstname'], "text"),
                           GetSQLValueString($_POST['surname'], "text"),
                           GetSQLValueString($_POST['dob'], "date"),
                           GetSQLValueString($_POST['address1'], "text"),
                           GetSQLValueString($_POST['address2'], "text"),
                           GetSQLValueString($_POST['town'], "text"),
                           GetSQLValueString($_POST['county'], "text"),
                           GetSQLValueString($_POST['postcode'], "text"));
      mysql_select_db($database_mypms, $mypms);
      $Result1 = mysql_query($insertSQL, $mypms) or die(mysql_error());
    $recordID = mysql_insert_id();
      $insertGoTo = "detail_tab.php?recordID=$recordID";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
      exit();
    $colname_insert = "1";
    if (isset($_GET['recordID'])) {
      $colname_insert = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
    mysql_select_db($database_mypms, $mypms);
    $query_insert = sprintf("SELECT px_id, title, firstname, surname, dob, address1, address2, town, county, postcode FROM demographics WHERE px_id = %s", $colname_insert);
    $insert = mysql_query($query_insert, $mypms) or die(mysql_error());
    $row_insert = mysql_fetch_assoc($insert);
    $totalRows_insert = mysql_num_rows($insert);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>address</title>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_validateForm() { //v4.0
      var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
      for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
        if (val) { nm=val.name; if ((val=val.value)!="") {
          if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
            if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
          } else if (test!='R') { num = parseFloat(val);
            if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
            if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
              min=test.substring(8,p); max=test.substring(p+1);
              if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
        } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
      } if (errors) alert('The following error(s) occurred:\n'+errors);
      document.MM_returnValue = (errors == '');
    //-->
    </script>
    </head>
    <body>
    <p> </p>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" onSubmit="MM_validateForm('firstname','','R','surname','','R','dob','','R');return document.MM_returnValue">
      <table align="center">
        <tr valign="baseline">
          <td nowrap align="right">Title:</td>
          <td><input type="text" name="title" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Firstname:</td>
          <td><input type="text" name="firstname" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Surname:</td>
          <td><input type="text" name="surname" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Dob:</td>
          <td><input type="text" name="dob" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Address1:</td>
          <td><input type="text" name="address1" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Address2:</td>
          <td><input type="text" name="address2" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Town:</td>
          <td><input type="text" name="town" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">County:</td>
          <td><input type="text" name="county" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Postcode:</td>
          <td><input type="text" name="postcode" value="" size="32"></td>
          <td><input name="Search" type="button" id="Search" value="Search"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right"> </td>
          <td><input type="submit" value="Insert record"></td>
          <td> </td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1">
    </form>
    <p> </p>
    </body>
    </html>
    <?php
    mysql_free_result($insert);
    ?>
    Thank you for your help :-)

    barrydocks wrote:
    thanks for the reply osgood;
    I was hoping for a more simple solution than a JQuery date picker, I have read this threat where the SQL queries is aletered:
    http://forums.adobe.com/thread/450108
    Which I tried but could not make work.
    I haven't tried DATE_FORMAT but the example implies that it would work when SELECTING the date from the database to output to a page in a more conventional FORMAT. However you want to INSERT the date using the correct format.
    barrydocks wrote:
    http://forums.adobe.com/thread/1097555
    but I don't know how to use this in my code that already has form validation?
    That thread is implying that you would need to convert the date inserted into the form field before it is inserted into the database in the correct format.......so you may as well use a datepicker.
    Problem with letting anyone insert a date manually is that a date can be written in many formats which are NOT acceptable by the database. A datepicker overcomes all of these issues. Getting the date back out of the database is a case of simply converting via php into a format which is applicable to your country or your usage OR using the method in the first thread you provided.
    Lets see if anyone else can offer a more simple solution for you.

  • Need help with Return syntax

    I though that the two pieces of code below would perform the same function but apparently i am missing something. The code is supposed to multiply two integers. Both use the add method.
    //Method that adds two integers this method works great
    public static int add(int a, int b)
             if(a <= 0)
                return (a < 0) ? add(MCH.succ(a), MCH.pred(b)) : b;
             else
                return (a > 0) ? add(MCH.pred(a), MCH.succ(b)) : b;
          }//The variable total is defined earlier as what ever a originally was and is not modified.
      //This method for multiplying also works great for positive numbers but i wanted to shorten it.
      public static int multiply(int a, int b)
              if(b==1)
                    return a;
              return multiply(add(total,a),--b) ;
        //This code i though was the same as above just in one line but apparently not
        //10*10 will return 10
        // 5*5 will return 5
        public static int multiply(int a, int b)
              return (b==1) ? multiply(add(total,a),--b) : a;
          }Why are the two sections of code returning different values. Any help is much appreciated

    I tried 5*6 which produced 5 as an answer using the second version of multiply so it looks like no matter what i put in the output is always the first int.

Maybe you are looking for