Private Function

I want a private in my app.cpp function. I don't want to declare in the header file, is there a way to do this?

So far, I've had, but it does not work:

App::App()
{

    setMenu();

}

void setMenu()
{

}

The definition of your method must have a namespace.

void::setupPages() {} App

}

Tags: BlackBerry Developers

Similar Questions

  • Make a private function

    Try to adjust a function in a package to make it private. Then set the procedure to use to display the results of the function
    It seems to be going in circles HELP!
    Thank you
    Carpet


    It's the original packaging


    CREATE OR REPLACE PACKAGE order_info_pkg
    FUNCTION ship_name_pf
    (p_basket in NUMBER)
    RETURN VARCHAR2;
    PROCEDURE basket_info_pp
    (p_basket in NUMBER,
    p_shop ON the NUMBER,
    p_date DATE);
    END;
    /
    CREATE OR REPLACE PACKAGE BODY order_info_pkg
    FUNCTION ship_name_pf
    (p_basket in NUMBER)
    RETURN VARCHAR2
    IS
    lv_name_txt VARCHAR2 (25);
    BEGIN
    SELECT shipfirstname. » '|| shiplastname
    IN lv_name_txt
    OF bb_basket
    WHERE idBasket = p_basket;
    RETURN lv_name_txt;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT. Put_line ('invalid cart id');
    END ship_name_pf;
    PROCEDURE basket_info_pp
    (p_basket in NUMBER,
    p_shop ON the NUMBER,
    p_date DATE)
    IS
    BEGIN
    SELECT idshopper, dtordered
    IN p_shop, p_date
    OF bb_basket
    WHERE idbasket = p_basket;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT. Put_line ('invalid cart id');
    END basket_info_pp;
    END;
    /



    And this is my adjusted with the returned errors


    CREATE OR REPLACE PACKAGE order_info_pkg
    PROCEDURE basket_info_pp
    (p_basket in NUMBER,
    p_shop ON the NUMBER,
    p_date DATE,
    p_shipname OUT VARCHAR2);
    END;
    /
    CREATE OR REPLACE PACKAGE BODY order_info_pkg
    FUNCTION ship_name_pf
    (p_basket in NUMBER)
    RETURN VARCHAR2
    IS
    lv_name_txt VARCHAR2 (35);
    BEGIN
    SELECT shipfirstname. » '|| shiplastname
    IN lv_name_txt
    OF bb_basket
    WHERE idBasket = p_basket;
    RETURN lv_name_txt;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT. Put_line ('invalid cart id');
    END ship_name_pf;
    PROCEDURE basket_info_pp
    (p_basket in NUMBER,
    p_shop ON the NUMBER,
    p_date DATE,
    p_shipname OUT VARCHAR2)
    IS
    BEGIN
    SELECT idshopper, dtordered, ship_name_pf (p_basket)
    IN p_shop, p_date, p_shipname
    OF bb_basket
    WHERE idbasket = p_basket;
    DBMS_OUTPUT. Put_line(p_basket||) e '|| p_shop | » '|| p_date | » '|| p_shipname);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT. Put_line ('invalid cart id');
    END basket_info_pp;
    END;
    /

    PACKAGE BODY ORDER_INFO_PKG errors:

    LINE/COL ERROR
    -------- -------------------------------------------------------------
    24/4 PL/SQL: statement ignored
    24/33 PLS-00231: function 'SHIP_NAME_PF' is not usable in SQL
    24/33 PL/SQL: ORA-00904: invalid identifier
    SQL >

    Hello

    It's because you're trying to use a function in a SQL statement. Just call the function outside SQL:

    PROCEDURE basket_info_pp
    (p_basket in NUMBER,
    p_shop ON the NUMBER,
    p_date DATE,
    p_shipname OUT VARCHAR2)
    IS
    BEGIN
    SELECT idshopper, dtordered
    IN p_shop, p_date
    OF bb_basket
    WHERE idbasket = p_basket;
    p_shipname: = ship_name_pf (p_basket);
    DBMS_OUTPUT. Put_line(p_basket||) e '|| p_shop | » '|| p_date | » '|| p_shipname);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT. Put_line ('invalid cart id');
    END basket_info_pp;
    END;

  • How to test a private with FlexUnit4 function

    Hello


    How I (if that's possible) test a private function of a class I want to test.


    I really want to change the function to the public only to test.


    Any suggestions

    This will work, Yes.

    is this the best way, probably. that or you could /ake extensions of your classes with public methods that call those protected and those test. However, is not much more that we can give you on this subject. private member function test is not the goal in my mind, so I don't have a lot of additional thoughts on doing.

    Mike

  • TestStand and LabVIEW treat differently polymorphics with instances with bodies of private classes.

    I have a class of LabVIEW and the class contains a method that is a polymorphic VI, and that polymorphic instances has. If I put the scope of Private, and the polymorphic bodies access to the public, then I can force developers who use the class to use the polymorphic VI (and not to call directly the instances). It's great. I like that.

    but...

    I have build a TestStand API that uses a polymorphic and instances as described above. I create a time of LabVIEW, with a type of call class member, and I target my class. TestStand does not support polymorphic VIs, meaning that polymorphs or its instances appear in the name of the Member list.

    This means that, to support my LabVIEW users and my TestStand users, I need to create two separate APIs, which is not a place of happiness to be. No matter who encounter this and found a solution? Or I'm looking at this wrong?

    It dawned on me later that we could actually change TS to be a static link to a particular instance VI via the polyVI. After all, you can manually select an instance specific polyVI. It would be just a way to declare in TS "link to this particular instance of the polyVI." Allowing the TS to say "I'm going through a public interface to join a private function."

    So instead of linking "A.i" you could bind to ' PolyVI.vi: A.i ".

  • How can I shorten it to a small function?

    I have a simple function that does the conversions, but I know there is a better way to do it besides using a bunch of otherwise if statements. How I shorten it?

    private function doConversions(value:int):void
        {
            if (selectedFromSpinner == "acres" &&  selectedToSpinner == "hectares")
            {
                txtOutput.text = (value * 0.404686).toString();
            }
            else if (selectedFromSpinner == "hectares" &&  selectedToSpinner == "acres")
            {
                txtOutput.text = (value * 2.47105381).toString();
            }
            else if (selectedFromSpinner == "ares" &&  selectedToSpinner == "acres")
            {
                txtOutput.text = (value * 0.0247105381).toString();
            }
            else if (selectedFromSpinner == "acres" &&  selectedToSpinner == "ares")
            {
                txtOutput.text = (value * 40.4685642).toString();
            }
    }
    

    Thank you

    You could probably make a little shorter with the help of a dictionary, but it would be probably slower.

    Basically, you'd do a table of implementation "" elements, each of which contains a table of "to the" elements, each having a multiplication factor. Then for each conversion, just look up the correct entries.

    You might speed it up by using integers instead of research/string comparisons.

    Alternatively, standardize to a single device: first convert everything in m2, and then convert the m2 in everything. That would make it much easier to maintain your code. Off the top of my head and not verified:

    // on app initialization:
    var toM2:Array = [];
    toM2['acres'] = somefactor;
    toM2['hectares'] = someotherfactor;
    // etc
    
    // for conversion:
    var m2:Number = value * toM2[selectedFromSpinner]; // convert to m2
    txtOutput.text = m2 * (1/toM2[selectedToSpinner]); // convert from m2
    
  • newbie on passing variables between functions

    Hi, I'm new to flash development and did only Java, C++, assembler before. This issue will be probably fairly simplistic. I want to click on a button, which will then call on another method, pass it several integers (ints) and the method returns an int after certain operations. Here is a snippet of my code.

    package
    {
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.media.Sound;
        import flash.text.TextField;
        import flash.text.TextFormat;
    
        import mx.controls.Text;
    
        import qnx.ui.buttons.Button;
        import qnx.ui.buttons.LabelButton;
        import qnx.ui.text.TextInput;
    
        import spark.components.TextArea;
    
        // The following metadata specifies the size and properties of the canvas that
        // this application should occupy on the BlackBerry PlayBook screen.
        [SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
        public class AIRHelloWorld extends Sprite
        {
            public function AIRHelloWorld()
            {
                //var R1 R2 and R3 are declared and read from here. 
    
    //here is where the call should happen
    //calculation button
                var total:Button = new Button();
                total.addEventListener(MouseEvent.CLICK, calculate, R1, R2, R3); //this should return an int
    
                //textformat for the calculate button
                var Calformat:TextFormat = new TextFormat();
                Calformat.color = 0xAA0000;
                Calformat.color = 0xAA0000;
                Calformat.size = 24;
                Calformat.italic = true;
                Calformat.align = "center";
    
                //text for the button
                var text:TextField = new TextField();
                text.text = "Calculate";
                text.setTextFormat(Calformat);
    
                //add text to calculation button
                total.addChild(text);
    
                stage.nativeWindow.visible = true;
            }
    
            private function calculate(event:MouseEvent, R1:int, R2:int, R3:int):int {
                return 0;
            }
    
            private function closeWindow(event:MouseEvent):void{
    
                stage.nativeWindow.close();
            }
    
            private function goToBackWindow(event:MouseEvent):void {
                stage.nativeWindow.orderToBack();
    
            }
        }
    }
    

    Needless to say, Adobe Flash builder don't like what I'm trying to do. Apparently EventListener does that take Boolean arguments. So how the values of R1 R2 and R3 to the function calculate?

    Thank you for your time

    Hello and welcome:

    In Flash/Flex/AIR event model is very simple and flexible.  In your example, it is better to create a LabelButton and add the event listener to that (fewer lines of code).  As:

    var button: LabelButton = new LabelButton();

    Button.label = "Push Me";

    button.addEventListener (MouseEvent.CLICK, DoCalculate);

    If necessary, adjust the location

    addChild (button);

    When the mouse is clicked, a "MouseEvent" event is sent to the DoCalculatefunction.  All event listeners must accept a parameter of an event. All events derive from the class of events 'event '.  Thus, the type of parameter can either be a MouseEvent from that which was given to generate, or the most high quality event.

    private function DoCalculate (event: Event): void

    {

    do something

    }

    Now what needs to be calculated would be information in the same point of view or accessible to the DoCalculate method.  So if you have 3 domains (e.g., TextInput), then those would be deprived of the main view and then attributes can be used to determine the result of the mouse click.  For example:

    SerializableAttribute public class MyApp extends Sprite

    {

    private var r1: TextInput = new TextInput();

    private var r2: TextInput = new TextInput();

    private var r3: TextInput = new TextInput();

    public void MyApp()

    {

    Add text entry to display a list

    make the application visible

    create a button

    Add button click listener

    }

    private function DoCalculate (event: Event): void

    {

    var sum: int = parseInt (this.r1.text) + parseInt (this.r2.text) + parseInt (this.r3.text);

    do something with sum

    }

    }

    Hope that helps.

  • get the TextInput text inside the different function?

    It's all in a single class

    method 1:

    var txtInpt:TextInput = new TextInput();txtInpt.width = 250;searchInpt.text = "Text";txtInpt.addEventListener(MouseEvent.CLICK, clearSearch);txtInpt.addEventListener(KeyboardEvent.KEY_DOWN, onKeyBoardEvent);MyContainer.addChild(searchInpt);
    

    method 1 creates a lot of UI for a container

    method 2 - onKeyBoardEvent - check what was the key code:

    private function onKeyBoardEvent(e:KeyboardEvent):void {
        if (e.keyCode == Keyboard.ENTER) {
    
        stage.focus = null;
    
    // here is where i would trace the text info
    
        }
    
    }
    

    Since the entry of search is created in method 1, method 2 does not have access to this

    How can I have access to the text entered in the txtInpt in my second method?

    Thank you!

    Hey dtater,

    to access the textinput object, use this:

    trace(e.currentTarget.text);
    

    You should get what you want. Good luck!

  • Successive function call

    private var lvl1 (): void {}

    private var lvl2 (): void {}

    private var lvl3 (): void {}

    private var lvl4 (): void {}

    private var lvl5 (): void {}

    private var lvl6 (): void {}

    private var lvl7 (): void {}

    private var lvl8 (): void {}

    private var lvl9 (): void {}

    private var lvl10 (): void {}

    for (i = 0, 11, i ++)
    {//calling functions lvl1, lvl2, lvl3 until the lvl10}

    How to call functions with a loop for? Sorry for the noob question

    Hey torres90,

    its probably best to do a single method and have simply an argument to specify what you want to run through something like a switch statement. so, something like this:

    private function lvl(num:int):void
    {
         switch (num)
         {
              case 1:
                   //do level 1 stuff
                   break;
              case 2:
                   //do level 2 stuff
                   break;
              case 3:
                   // do level 3 stuff
                   break;
    
              (...)
    
              case 10:
                   //do level 10 stuff
                   break;
         }
    
    }
    

    then call like this:

    for (var i:int = 0; i < 11; i++)
    {
         lvl(i+1);
    
    }
    

    in this way, you can sort to consolidate and to do the work - hope tha sheds some light. Good luck!

  • call a function to listener programmatically

    I have a function that is called on a ListEvent. I want to call it programmatically on the startup of the program as the default even if the user has not triggered the event.

    How can I do this?

    var tmpE:ListEvent = new ListEvent;
    tmpE.index = 0;
    
    onItemSelected(tmpE);
    
    private function onItemSelected(e:ListEvent):void {
          // some code
    }
    

    It is called and it works very well when the event is raised, but I would like the event to be triggered or call the listener automatically function at startup.

    Dave

    Thanks for the responses... Sorry to be a clear, I was really tired when the post was created.

    I want to be clicked on the list box (blue list as a user has clicked on it by default)

    I call the function of default listener like this:

    var tmpE:ListEvent = new ListEvent("listItemClicked", null, 0, 0, 0, 0, null);
    onItemSelected(tmpE);
    

    and he calls this function to listener:

    private function onItemSelected(e:ListEvent):void {
        if (currentList) {
            rightContainer.removeChild(currentList);
            currentList = null;
        }
    
        trace ("cell:" + e.cell + " data:" + e.data);
    
        switch (e.index) {
            case 0:
                trace("About");
                buildAbout();
                break;
            case 1:
                trace("General");
                break;
        }
        if (currentList) {
            rightContainer.addChild(currentList);
            rightContainer.layout();
        }
    }
    

    The listener function works perfectly if the user selects a list item, it relies also the default option at the start of the first section of code without problem, but the words or the first item in the list is not selected.

    When the program loads the first item by default, it is not obvious to the user that the first item in the list is already loaded and selected because the list item is not selected...

    Thanks for your help guys.

    @pyth... use it in future thanks.

  • Can I pass a second var to the listener function.

    new to actionscript and it can not find on google... I don't know it exists, but I have worked around him twice and really want to do it now and do not know how.

    When you add an event listener

    mybutton.addEventListener(MouseEvent.Mouse_UP, myListener);
    
    the above passes 1 variable of type event.
    
    I catch it as follows:
    
    private function myListener(eventVar:Event):void { //code }
    
    all is good.
    
    I would like to pass more variables to this event listener though.
    
    e.g.
    myButton.addEventListener(MouseEvent.Mouse_UP, myListener(what_goes_here, myVariable1:String, myEtc:int));
    
    private function myListener(e:Event, myVar:String, myEtc:int) { }
    
    don't know what is supposed to go in the 'what_goes_here' part of the code above so that it works.
    

    Any help much appreciated.

    TongueDar wrote:

    I don't know if it will help - and I probably do all wrong, but if you build the button in its own function, you can pass in local variables.

    So, something like this;

    function newButton(tBtn:Sprite, varA:String, varB:int):void
    {
        tBtn.addEventListener(MouseEvent.MOUSE_UP, btnUp);
        function btnUp(event:MouseEvent):void {
            // do something with the passed in variables.
        }
    }
    
    newButton(TargetSprite, "string", 0);
    

    It is more common to assign a variable typed using a function returned the same type:

    for example:

    private var firstButton:Button;
    private var secondButton:Button; 
    
    firstButton = createButton("First Button", 50, 25);
    secondButton = createButton("Second Button", 80, 40);
    
    private function createButton(label:String, width:int, height:int):Button
         {
         var result:Button = new Button();
         result.label = label;
         result.width = width;
         result.height = height;
         result.addEventListener(MouseEvent.CLICK, mouseEventClickHandler);
    
         return result;
         }
    
    private function mouseEventClickHandler(evt:MouseEvent):void
         {
         switch (evt.currentTarget)
                {
                case firstButton:    trace("first button was clicked");
                                     break;
    
                case secondtButton:  trace("second button was clicked");
                }
         }
    

    in the example above, you can simply use evt.currentTarget.label + 'has been clicked' instead, but it was written just to show how to handle multiple calls with the same function event.

  • How to optimize acceleration / friction function more

    Hello!

    In a few words what the code does:

    It begins to spin at a speed of 2 degrees and 5 seconds, it speeds up to 20 degrees per second.
    After that, the rotational speed remains 20 for 10 seconds and after that dry 10 are more
    He gets in the service of friction where it slows down to 2deg dry.

    but! as I am not good with optimization and writing clean code I have a need to ask if this is a good code or we can do even better (more optimized and cleaner).

    The code is the following:

    Box() is a simple box shape, nothing more

    
              import flash.display.MovieClip;
              import flash.events.Event;
    
    
              public class Main extends MovieClip
              {
    
                        protected var _box:Box = new Box();
    
                        private var fps:Number = stage.frameRate;
                        private var step:Number = 20;
                        private var minStep:Number = 2;
                        private var time:Number = 5;
                        private var increment:Number = (step - minStep) / (time * fps);
                                                                                              // 20 - 2 / 5 * 30
                                                                                              // 18 / 150
                                                                                              // 0.12
                        protected var timePassed:Number = 0
    
    
                        public function Main()
                        {
                                  _box.x = stage.stageWidth/2 - _box.width/2;
                                  _box.y = stage.stageHeight/2 - _box.height/2;
                                  this.addChild(_box);
    
                                  stage.addEventListener(Event.ENTER_FRAME, constantMovement);
                        }
    
    
    
                        private function friction():void
                        {
                                   _box.rotation += step;
                                      step -= increment;
                                      step = Math.max(2, step);
                        }
    
                        private function acceleration():void
                        {
                                   _box.rotation += minStep;
                                   minStep += increment;
                                   minStep = Math.min(minStep, 20);
                        }
    
                        private function constantMovement(event:Event)
                        {
                                  if(minStep < 20)
                                  {
                                            acceleration()
                                  }
                                  else if(minStep >= 20 && timePassed <= 10)
                                  {
                                            _box.rotation += 20;
                                            timePassed += 10 / (time * fps)
                                            trace("timePassed :" + timePassed)
                                  }
                                  else if (minStep >= 20 && timePassed >= 10)
                                  {
                                            friction();
                                  }
                        }
    
    
              }
    }
    
    

    If there is something more, that it can be please tell me / help me.

    You can do the following:

    1. replace the last ElseIf (minStep > = 20 & timePassed > = 10) with just something else, because the condition would be always true control reaches here.

    2 store the value 10 / (time * fps) in a private variable and use that directly, rather than assess every time that the value remains constant.

    You can also try to replace the if-else-if block with a block switch-box on a state variable in the class (with the values 0, 1, 2 mean acceleration, constant speed and slows down, you can set a constant symbolic to hold the values). Initialize the variable with the value 0 (acceleration), change to 1 when minStep becomes 20 and so on. Point No. 2 is always good too.

    DIA-

  • How to change the cursor on the roll on the function

    I make it a point and click game in AS3 with flash.

    I changed my slider skin by creating a new class of '' mouse. '' It works very well. Now, I'm trying to change the skin of the cursor when it is over an object on the stage.

    I read that the MouseEvent.ROLL_OVER is the correct method, but I can't understand how do...

    I have my mouse class like this:

    public class Souris extends MovieClip
        {
     private var engine:Engine;
            private var stageRef:Stage;
            private var p:Point = new Point(); 
    
            public function Souris(stageRef:Stage)
            {
                Mouse.hide(); //make the mouse disappear
                mouseEnabled = false; //don't let our cursor block anything
    mouseChildren = false;
    
                this.stageRef = stageRef;
                x = stageRef.mouseX;
                y = stageRef.mouseY;
    
                stageRef.addEventListener(MouseEvent.MOUSE_MOVE, updateMouse, false, 0, true);
                stageRef.addEventListener(Event.MOUSE_LEAVE, mouseLeaveHandler, false, 0, true);
                stageRef.addEventListener(Event.ADDED, updateStack, false, 0, true);
                stageRef.addEventListener(MouseEvent.ROLL_OVER,hover);
    
            }
    
            private function updateStack(e:Event) : void
            {
                stageRef.addChild(this);
            }
            private function hover(e:MouseEvent):void {
    souris.visible = false;
    }
    
            private function mouseLeaveHandler(e:Event) : void
            {
                visible = false;
                Mouse.show(); //in case of right click
                stageRef.addEventListener(MouseEvent.MOUSE_MOVE, mouseReturnHandler, false, 0, true);
            }
    
            private function mouseReturnHandler(e:Event) : void
            {
                visible = true;
                Mouse.hide(); //in case of right click
                removeEventListener(MouseEvent.MOUSE_MOVE, mouseReturnHandler);
            }
    
            private function updateMouse(e:MouseEvent) : void
            {
                x = stageRef.mouseX;
                y = stageRef.mouseY;
    
                e.updateAfterEvent();
            }
    
        }
    
    }
    }
    

    I have in my main class (class engine):


    private var souris:Souris;
    
    public function Engine(){
    
    
    
                            souris = new Souris(stage);
                stage.addChild(souris);
    
            }
    private function startGame(e:Event):void{
    ....
    ..
    

    I tried to put in the class of '' mouse. ''


    stageRef.addEventListener(MouseEvent.ROLL_OVER,hover);
    
    private function hover(e:MouseEvent):void {
    Engine.souris.visible = false; 
    handCursor.visible = true ;
    }
    

    But it seems wrong... I don't know what to put in my score function... (I got the "handCursor' in my library).

    Thank you very much for your help!

    Thx for your answers, I found a solution to my problem. It was MouseEvent.MOUSE_OVER. and not to the overthrow. But thanks for the links, I read it and it helps me with some codes.

    Thanks for your time!

  • private procedures

    Hello people...

    1 q:

    When (at what situation), we use private functions/procedures do we get any actual condition on this... or what to hide access?

    2 q:

    When we choose statement level triggers and rowlevel... I know a generic example... allowing the transaction between 09:00-18:00... then we use the triggers statement-level, and when the shutter effects each record in the table use us row-level triggers... but is there any obvious requirement to use particularly statement-level triggers?

    Thank you very much

    In my project once, I used by mistake of mutation of determination. (unable to query a table even after insertion/update)

    I wrote a package with two prcedures and set of global variables...

    a single procedure will establish values to global variables. (this procedure will call a rowlvel trigger, only no action performed after update online level assignting only to variables)

    procerdure one another is going to make my action on the variables (call statement level trigger, such as statement-level trigger is not question of mutation, in my application for the always a specific table row will be updated for a statement)

    It is one of the reporting level requirement, I used there may be a lot of people.

  • 1013: the private attribute may be used only on class property definitions.

    In the following code, I get an error. How to solve this problem?

    Line 301013: the private attribute may be used only on class property definitions.

    package

    {

    import flash.display.MovieClip;

    import flash.events.Event;

    Caesar/public class extends MovieClip

    {

    var speed: Number;

    public void Caesar()

    {

    addEventListener ("enterFrame"), move;

    }

    public void move(e:Event)

    {

    This.x = mouseX;

    This.y = mouseY;

    If (caesar.hitTestObject (MainClip.instance.enemyList [i]))

    {

    trace ('Caesar should');

    removeSelf();

    MainClip.instance.finishedMainClip ();

    }

    }

    }

    private function removeSelf (): void

    {

    removeEventListener (Event.ENTER_FRAME, move);

    If (stage.contains (this))

    {

    this.parent.removeChild (this);

    }

    }

    }

    Check your dash... Your removeSelf function is outside the definition of the class... that closing brace entered should be after him.

  • Code 1013: The private attribute may be used only on class property definitions.

    OK guys, being new to Action script game, I already find myself with errors.  I have studied this for the last few days, and every time I found a solution said, the solution is always the brace.  But for the life of me, I can't find a support missing!  Could someone look at this for me and guide me in the right direction, before losing the rest of my hair. :-)

    package 
    {
      import flash.display.Sprite;
      import flash.events.MouseEvent;
      public class Main extends Sprite
      {
      var xPos:int; //Stores the initial x position
      var yPos:int; //Stores the initial y position
      }
    public function Main():void
      {
      addListeners(alpine,armadillo,battery,blizzard,cactus,carnivoreplant,cloud,coolfire,coral,crystal,dandelion,darkfire); //A function to add the listeners to the clips in the parameters
      }
    private function getPosition(target:Object):void
      {
      xPos = target.x;
      yPos = target.y;
      }
    private function dragObject(e:MouseEvent):void
      {
      getPosition(e.target);
    
    
      e.target.startDrag(true);
      }
    private function stopDragObject(e:MouseEvent):void
      {
      if (e.target.hitTestObject(getChildByName(e.target.name + "Target"))) //Checks the correct drop target
      {
      e.target.x = getChildByName(e.target.name + "Target").x; //If its correct, place the clip in the same position as the target
      e.target.y = getChildByName(e.target.name + "Target").y;
      }
      else
      {
      e.target.x = xPos; //If not, return the clip to its original position
      e.target.y = yPos;
      }
    
    
      e.target.stopDrag(); //Stop drag
      }   
    private function addListeners(... objects):void
      {
      for (var i:int = 0; i < objects.length; i++)
      {
      objects[i].addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
      objects[i].addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
      }
      }
    }
    
    

    Firstly, the Builder must not have return datatype. Builder returns the data type of the class. Sub is certainly unacceptable.

    Also, I strongly suggest type you all properties and methods (except for builders, naturally).

    You class should look like this:

    package
    {
        import flash.display.Sprite;
        import flash.events.MouseEvent;
    
        public class Main extends Sprite
        {
            private var xPos:int; //Stores the initial x position
            private var yPos:int; //Stores the initial y position
    
            public function Main()
            {
                addListeners(alpine, armadillo, battery, blizzard, cactus, carnivoreplant, cloud, coolfire, coral, crystal, dandelion, darkfire); //A function to add the listeners to the clips in the parameters
            }
    
            private function getPosition(target:Object):void
            {
                xPos = target.x;
                yPos = target.y;
            }
    
            private function dragObject(e:MouseEvent):void
            {
                getPosition(e.target);
                e.target.startDrag(true);
            }
    
            private function stopDragObject(e:MouseEvent):void
            {
                if (e.target.hitTestObject(getChildByName(e.target.name + Target))) //Checks the correct drop target
                {
                    e.target.x = getChildByName(e.target.name + Target).x; //If its correct, place the clip in the same position as the target
                    e.target.y = getChildByName(e.target.name + Target).y;
                }
                else
                {
                    e.target.x = xPos; //If not, return the clip to its original position
                    e.target.y = yPos;
                }
    
                e.target.stopDrag(); //Stop drag
            }
    
            private function addListeners(... objects):void
            {
                for (var i:int = 0; i < objects.length; i++)
                {
                    objects[i].addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
                    objects[i].addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
                }
            }
        }
    }
    

Maybe you are looking for