questions about OBJECT oriented programming

good day to all, I am working on a class enemy now the idea I have is to give him an enemyUpdate method to make it move on its own using a while loop

< code >

public function updateEnemy (): void
{
var i: int = 0;
While (i > 30)
{
This. PositionX = + 10;
}
}

< code >

OK so I understand his partly caused because I'm not increasing 'i' in my loop

Now my problem is that I have the line of code above does not move correctly the enemy why so much?
Thanks for the info

If there is too much enemy opposes both on the scene, try this - in the enemy class add an event listener for the event enter frame:

this.addEventListener (Event.ENTER_FRAME, updateEnemy);

and update the position in the Manager.

private void updateEnemy(e:Event):void

{
This.x += 5;
}

To decide if the enemy movement or not, you can use if statement in the updateEnemy function.

Tags: Adobe Animate

Similar Questions

  • I'm still not sure how custom control and object-oriented programming interact, can someone enlighten me please?

    I spent some time trying to understand the relationship between the custom controls and object oriented programming. However, it is not quite clear to me yet.

    What I want to do:

    I want to have a custom control and hide its workings from the rest of the blockdiagram, so I don't have to wire for each similar object. Not only because I'm lazy , but also to keep the clean pattern and avoid mistakes.

    for example, a graph, a numerical factor and a button.

    When the button is pressed, the x scale must be changed according to the factor.

    So, this looks like a job for me to object-oriented programming. Once I created something that can do this, I can use it all through my program. The code that redraws the figure when you press the button as part of the object, so I can't connect extra wires and add a value change event when I add a new chart.

    Is this possible at all? I tried, but did not quite understand this time. I have to admit that I'm pretty new to OO programming and make custom controls. I use typedef clusters ' ed most my code so far, which works very well. But it's always a cluster of stupid, the only way to have nothing at all is in the block diagram in VI you use it in.

    The only thing I could come up with so far is to add an "event handler" Subvi who does and that he accepts a reference or a local variable to an object. Then, this sub - VI and the variable or reference can be put in parallel with the other stuff in the main loop of the program. But there must be a better way somewhere?

    I don't think I can solve this problem of definition of the objects of the Panel before custom and methods so that it can interact with the objects that it represents without help. I get the feeling that I must have missed it somewhere. The pointers will be appreciated.

    Thank you!

    Jacco.

    Jacco K wrote:

    What I want to do:

    I want to have a custom control and hide its workings from the rest of the blockdiagram, so I don't have to wire for each similar object. Not only because I'm lazy , but also to keep the clean pattern and avoid mistakes.

    ...

    The only thing I could come up with so far is to add an "event handler" Subvi who does and that he accepts a reference or a local variable to an object. Then, this sub - VI and the variable or reference can be put in parallel with the other stuff in the main loop of the program. But there must be a better way somewhere?

    Thank you!

    Jacco.

    Hi Jacco,

    These two things are exactly what are the Xcontrols, a basic VI with a façade that has an event structure (the façade VI).

    If you have any questions, I'm happy to guide you.

    Tone

  • Queue in object-oriented programming

    Hello

    I'm currently building multiple classes for the different data acquisition devices. What they all have in common, is that they use a 3D array of integer in the data buffer. I want to be able to switch between devices, so I decided to create a VI called "Record.vi" and the use of dynamic allocation to decide what device to call at run time.

    But I don't want a buffer to separate data for each device, so I will try to figure out how to create a more "global" space to save my data. Now, I decided to use a queue for this (as I don't want to LabVIEW to make copies of my table 3D all the time). My question is now how the queues are really handled in object-oriented programming, because in non-object oriented programming, if I create a queue and name it, say, 'data' and create the queue even elsewhere (again with the ' data' as name), I have access to the first queue created and do not get a new one. If I create now, for my problem, a class parent where all devices data inherit from and make a member variable "queue in 3d-table", what will happen? All the data devices that inherit from this class calls the same queue? Or it is duplicated? What is the best way to use common storage place in all the data devices? A global variable in the parent (that is, a static variable) class? Or should I create a 'normal', accessible global variable of all the screws?

    Thanks for the help!

    Christian

    If you do not want the child to use the buffer of parents can create an override for the child who creates his own stamp.

    Named queues the override VI could use its name in the name of the queue.

    For non designated queues, just pass the reference.

    Notes:

    DVR (data value reference) is also another way to share a buffer.

    3-d arrays:

    Unless all dimensions of thre sense I generally avoid them because they rate of N cut into cubes where "N" is the largest of its very small size (or something like that) so just a slice of the buffer bigger (because of processing delays) the blow (voice of experience speaking).

    Ben

  • (help) how to extend textbox of scene to the method of object-oriented programming

    Hi guys, just a simple question. I have a box of text inside the scene. I just want to know how will access using the methodology of object-oriented programming. Thank you for your help guys.

    Select the textfield and then assign it and the name of the instance in the properties panel. If you do not see an option for this in the properties panel, you must change this setting to be a dynamic textfield.  Once you have an instance name are entrusted to him, you use this name to target for what you want to do with it.  For example, if you call it 'tField', then to give him a text you would use...

    tField.text = "of the text."

  • A matter of OBJECT-oriented programming

    I am new to OBJECT oriented programming, this is probably a stupid question, but if I want to create an app that involves students it is necessary to create a class of studen in as3.0? If so, it is also necessary to call this class when I'm querying data from my db?

    Thank you.

    Well, more like a question of application of an OO one design!

    in any case you do not have to! But it is certainly a good idea to have an object representation of your business domain artifacts.

  • 'Normal' code and OBJECT-oriented programming code in the same project

    Hi guys,.

    Have large existing application written in ordinary data workflow code.

    Thought to add a new module, but he wrote in OOP - to learn.

    Is it possible to add OBJECT-oriented programming code to an existing project?  If so, it's a good idea or not?  What kinds of things should I be conscious re. mix of types of codes?

    Thank you.

    LVOOP is a natural extension of type-def clusters in libraries, so he has no problem mixing with 'normal' LabVIEW code  The only precaution that I recommend is the following:

    Class libraries always loading all their confined subVIs (called "methods" in the jargon of OBJECT-oriented programming), and the standard libraries of LVLIB always loading libraries contained everything (including class libraries).  This behavior "one thing costs so everthing charge" may be a domino effect through your project with all sorts of unnecessary things from loading.  To avoid this, be careful putting classes inside libraries and don't always put subVIs in classes if they do not need to be (I often have a regular library to hold 'to support' subVIs to a set of classes.)

    -James

  • Navigation in AS3 OBJECT oriented programming Menu does not

    OK, so frame 1 in the timeline/layer, I have this code

    Stop();

    var btn1:MCButton = new MCButton();

    Btn1.x = 1048;

    Btn1.y = 300;

    Btn1.label_txt. Text = "play";

    addChild (btn1);

    Btn1.gotoAndStop (10);

    var btn2:MCButton = new MCButton();

    btn2.x = 1048;

    btn2.y = 380;

    btn2.label_txt. Text = "help";

    addChild (btn2);

    var btn3:MCButton = new MCButton();

    btn3.x = 1048;

    btn3.y = 460;

    btn3.label_txt. Text = "highscore";

    addChild (btn3);

    and now I have a MCButton class (.as)

    package {}

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    SerializableAttribute public class extends MovieClip {} MCButton

    public void MCButton() {}

    manufacturer code #.

    Stop();

    this.buttonMode = true; a class film btn

    this.addEventListener (MouseEvent.MOUSE_OVER, sensitive); listen for a score event mouse

    this.addEventListener (MouseEvent.MOUSE_DOWN, down); listen for a mouse down event

    }

    private void hover(e:MouseEvent):void {}

    this.removeEventListener (MouseEvent.MOUSE_OVER, sensitive);

    this.addEventListener (MouseEvent.MOUSE_OUT, out);

    this.gotoAndStop (2);

    }

    private void out(e:MouseEvent):void {}

    this.removeEventListener (MouseEvent.MOUSE_OUT, out);

    this.addEventListener (MouseEvent.MOUSE_OVER, sensitive);

    this.gotoAndStop (1);

    }

    private void down(e:MouseEvent):void {}

    this.removeEventListener (MouseEvent.MOUSE_OVER, sensitive);

    this.addEventListener (MouseEvent.MOUSE_DOWN, down);

    this.gotoAndStop (3);

    }

    }

    }

    OK so I want btn1 (which is in my diapers) to frame 10, where I have a different menu for 'easy', 'medium' "hard", I put btn1.gotoAndStop (10); but that doesn't seem to work, so I'm really confused on what im doing wrong.

    Please help me,

    Thank you.

    You can not remove sth. not created:

    removeChild (btn6);

    ...

    var btn6:MCButton = new MCButton();


    you try to remove btn6-9, before they were created

    I understand why you want to do, but you must make sure that the part to be removed is left side first.

    You can do this by ensuring that the button you are trying to delete is really there

    Change each line that removes sth. TO:

    {if(btn6!=null)}

    removeChild (btn6);

    }

    {if(btn7!=null)}

    removeChild (btn7);

    }

    etc.

    Caution:

    Trying to set up a Navigation like this can not be considered good practice to OBJECT-oriented programming.

    That's why I said you should be aiming for a solution that does not rely on navigation of the timeline.

  • OBJECT-oriented programming using global vars, best way to do it?

    LS,

    Im a beginner when it comes to OOP.

    Not wanting all through calls to the class, I want to be able to have some application globals.

    Can set their standard package?

    Should I create a static class globals.as with vars?

    What is the right way to do this?

    Any help is greatly appreciated.

    Mac

    first of all, I would say that there are few cases where, you would need global variables, I have not used any in a long time and at the moment, I can't imagine any situation where I would do it. Although saying that it may be the easiest solution if you are new to OBJECT oriented programming.

    If I had to I would use a static class with vars, as you say

  • LabVIEW Object - Oriented Programming - tutorial

    Hello

    Are there tutorial manual LVOOP? I'm looking for a tutorial as LabVIEW Basics I and II, which explains the basics

    If you have any SSP you have access to a range of online courses , including the object-oriented design and programming in LabVIEW (the recommendation is to have taken 1 Core, Core 2 and Core 3 before taking this course to get the most benefits).

    If you come from of the object oriented and want to see how it applies to LabVIEW, take a look at the decisions behind the white paper Design.

    Hope that helps,

    Jeff Peacock

    Product Support Engineer | LabVIEW R & D | National Instruments | Certified LabVIEW Architect

  • question about .as files/programs

    I hope that my question has not been asked already, but I think that he has a simple answer, I just need confirmation of the pros

    Anyway, if I did a file or program in Flash, no flash builder, and it has the file extension ".de" that I would be able to open / export to flash builder and then debug him for the BB SDK and test subsequently on SIM(ie: like some people did on the AIRHelloWorld.as test app) BB?

    Thanks in advance!

    Lets say your file called called aaa.as. Create a Flex project in Flash Builder. On the last page of the wizard, replace the record suggested as "test.mxml" with the text "aaa.as". Click Finish.

    When the project opens the sheet and drop your real aaa.as in the place of one in the Project Explorer (or whatever the file manager on your platform).

    FB should automatically compile and produce an aaa.swf in the bin-debug folder. You will also need to modify the aaa - app.xml and create an icon for the appropriate application. After that, follow the instructions to get started on creating the debug launch for this project configuration.

  • Question about presentation simultaneous program via PL/SQL

    I encountered a strange problem. I have a table that contains 6 lines of project I want to apply a seeded competitor of (this operation because the seeded program runs about 100 min. and trying to break up to run faster). He shall submit the first 5 very well and returned a request id. On the 6th, he sends the request, but never comes back with a request id or even apply 0. The program just hangs and all 6 processes launching run and finish, but the main program continues to run and everything goes ever further. I have to cancel it, and when I do, I lose what was written in the newspaper, so I made a table bit debug and who inserts debugging information. Here is the presentation code and the results in the table of debugging. As you can see that it goes ever further beyond the loop. No idea why this is happening? I have had it before and am at a loss.

    Here is the section of the code:

    insert_debug_rec ('l_range_cnt: ': l_range_cnt, ' ');


    BECAUSE me in 1... l_range_cnt

    LOOP
    l_req_id: = apps. XX_DC_SUBMIT_REQUEST (p_application = > "PA")
    , p_program = > 'PAXACMPT '.
    , p_description = > 'update project summary amounts.
    , p_start_time = > NULL
    , p_sub_request = > FALSE
    , p_argument1 = > l_range_rec (i) .project_num_from
    , p_argument2 = > l_range_rec (i) .project_num_to
    , p_argument3 = > NULL
    , p_argument4 = > 'Y '.
    , p_argument5 = > NULL
    , p_argument6 = > 'Y '.
    , p_argument7 = > 'Y '.
    , p_argument8 = > NULL
    , p_argument9 = > 'Y '.
    , p_argument10 = > 'Y '.
    , p_argument11 = > 'ORDINARY '.
    , p_argument12 = > NULL
    , p_argument13 = > ' don't
    , p_argument14 = > NULL
    , p_argument15 = > 'Y '.
    p_argument16 = > 'I');
    COMMIT;

    IF l_req_id > 0 THEN
    fnd_file.put_line (fnd_file.log,'Update project summary amounts succesfully submitted ' |)
    "for the project numbers range: ' |" l_range_rec (i) .project_num_from |
    ' to : ' || l_range_rec (i) .project_num_to);
    l_req_tbl (i) .req_id: = l_req_id;
    insert_debug_rec ('The successful submission', ' l_req_tbl (i) .req_id: ' | ') l_req_tbl (i) .req_id);

    ON THE OTHER
    fnd_file.put_line (fnd_file.log, 'Update project summary amounts has not been submitted' |)
    "for the project numbers range: ' |" l_range_rec (i) .project_num_from |
    ' to : ' || l_range_rec (i) .project_num_to);
    l_error_flag: = 'Y ';
    insert_debug_rec ('No show', 'i:' | i);
    insert_debug_rec ("Message:" | ") fnd_message.get, ' ');


    END IF; -l_req_id > 0

    insert_debug_rec ('i:' | i, ' l_range_cnt: ' | l_range_cnt);

    END LOOP; --i IN 1... l_range_cnt

    insert_debug_rec ("before the status control loop ', 'l_range_cnt' | ') l_range_cnt); -never gets here.


    Debug table:

    l_range_cnt: 6
    . L_req_tbl (i) successful presentation Req_id: 13107760
    i: 1 l_range_cnt: 6
    . L_req_tbl (i) successful presentation Req_id: 13107761
    i: 2 l_range_cnt: 6
    . L_req_tbl (i) successful presentation Req_id: 13107762
    i: 3 l_range_cnt: 6
    . L_req_tbl (i) successful presentation Req_id: 13107763
    i: 4 l_range_cnt: 6
    . L_req_tbl (i) successful presentation Req_id: 13107764
    i: 5 l_range_cnt: 6

    I tried to make l_range_cnt be 1 just to see if she has the first set of ranges of project, and then finish running the program, but it's not. Debugging table results when range_cnt is 1 is:

    l_range_cnt: 1

    That's all, no message of presentation selected or not. But the program is subject to a time and ends very well.

    BTW, I should mention that apps. XX_DC_SUBMIT_REQUEST is simply a wrapper for fnd_submit_request. There is no that pass the variables on this procedure. Has to do with the security / patterns, etc.

    Edited by: MinnieB on April 30, 2013 11:30

    If these codes are all of the code to submit a request. I'll try to explain it.
    in the 1st loop:
    a.Run request
    b.Commit (validation of the request)
    c.Insert in the table (not yet commit)
    in the 2nd loop:
    a.Run request
    b.Commit (validate the request and 1.c)
    c.Insert in the table (not yet commit)

    If the last never loop commit 6.c insert into table.

    Am I wrong?

  • Object oriented programming

    I'm unable to transfer data from one point of view to another using objects.

    I have 2 views named FirstView.mxml and SecondView.mxml.

    I have 1 actionscript file named Pass.as

    Any help is very appreciated.

    Pass.As

    package components

    {

    public class Pass

    {

    [Bindable]

    public var first: String;

    public var second: String;

    public void Pass()

    {

    }

    public void setFirst(first:String):void

    {

    This.First = first;

    }

    public void setSecond(second:String):void

    {

    This.second = second;

    }

    public function getFirst (): String

    {

    back in the first place;

    }

    public function getSecond (): String

    {

    back then;

    }

    public void count with all (): String

    {

    first of all return + "" + second;

    }

    }

    }

    FirstView.mxml

    <? XML version = "1.0" encoding = "utf-8"? >

    " < = xmlns:fx s:View ' http://ns.Adobe.com/MXML/2009 "

    xmlns:s = "library://ns.adobe.com/flex/spark".

    title = 'FirstView.

    xmlns:components = "components.*" >

    < fx:Script >

    <! [CDATA]

    import components. Pass;

    [Bindable]

    public var pass: Pass;

    protected function handleClick(event:MouseEvent):void

    {

    pass = new Pass();

    pass.setSecond (inputbox2.text);

    pass.setFirst (inputbox1.text);

    navigator.pushView (SecondView);

    }

    []] >

    < / fx:Script >

    < fx:Declarations >

    <! - Place non-visual elements (e.g., services, items of value) here - >

    < / fx:Declarations >

    < s:Label text = "enter your identification number" x = "10" y = "10" >

    < / s:Label >

    < s:TextInput id = "inputbox1" x = "10" y = "33" >

    < / s:TextInput >

    < s:TextInput id = "inputbox2" x = "10" y = "145" >

    < / s:TextInput >

    < s:Button label = "Search" click = "handleClick (event)" x = "10" y = "362" > "

    < / s:Button >

    < / s:View >

    SecondView.mxml

    <? XML version = "1.0" encoding = "utf-8"? >

    " < = xmlns:fx s:View ' http://ns.Adobe.com/MXML/2009 "

    xmlns:s = "library://ns.adobe.com/flex/spark".

    title = "SecondView".

    xmlns:components = "components.*" >

    < fx:Script >

    <! [CDATA]

    import components. Pass;

    [Bindable]

    public var passData:Pass = new Pass().

    protected function handleClick(event:MouseEvent):void

    {

    Label3.text = passData.getAll ();

    }

    []] >

    < / fx:Script >

    < fx:Declarations >

    <! - Place non-visual elements (e.g., services, items of value) here - >

    < / fx:Declarations >

    < s:Label text = "{passData.getFirst ()}" = '10' XY '45' = > "

    < / s:Label >

    < s:Label text = "{passData.getSecond ()}" = '10' XY '145' = > "

    < / s:Label >

    < s:Label id = "label3" x = "10" y = "245" >

    < / s:Label >

    < s:Button label = "Search" click = "handleClick (event)" x = "10" y = "362" > "

    < / s:Button >

    < / s:View >

    you have 2 instances of passage here.

    in FirstView instead of the call

    navigator.pushView (SecondView);

    call

    navigator.pushView (SecondView, col);

    in SecondView instead of creating a new instance of the Pass you can access past created in FirstView through the property Explorer data in Secondview

    for example

    SecondView.mxml

    http://ns.Adobe.com/MXML/2009.

    xmlns:s = "library://ns.adobe.com/flex/spark".

    title = "SecondView".

    xmlns:components = "components.*" >

    import components. Pass;

    [Bindable]

    protected function handleClick(event:MouseEvent):void

    {

    Label3.text = (data in the form of Pass) .getAll ();

    }

    ]]>

  • Problem with the classes and the basics of object oriented programming.

    I got a main class called 'controll class:

    I'm addChild a btn on stage and create a listener to click the btn.

    When you click on the function of animation the curretn clip on the stage and moves out and addChild an another movieclip

    Levels_BG called

    Levels_BG contains fixed and controlled but his class onwl: Levels_BG

    That creates a certain number of 'boxes' on the scene that can be clicked to select a level.

    I'm tryin to achieve this goal:

    Click on a level area in the Levels_BG and I need to pass this variable to another class.

    Any help appriciated. SRY if this is confussing.

    Pavel has soon

    SWF here:

    http://www.2shared.com/document/pO8IIf4x/NumberGame.html

    Able to operate found this great guide:

    http://StackOverflow.com/questions/11083843/AS3-call-function-from-one-class-to-another

    I changed my function in control_Class:

    public static function startlevel (): void

    {

    trace ("from this class to it")

    }

    control_Class.startlevel ();

    thx for the help.

    Pav

  • ColdFusion object oriented programming

    Hello
    For the moment, I have a contact management application I am building.
    a contact has a title (m./Mme/Mlle) and can have multiple addresses, multiple phone numbers.

    CFC, I cannot make multiple inheritance. I can extend to 1 component, then extend to the next in a kind of 'daisy chain', but this is not ideal, that if something changes in my application there are a lot of dependencies.

    I'm learning to use what is called the aggregation by Hal Helms but I think this concept is difficult to grasp.

    I think I'm supposed to do something like the following see attached code:

    It seems to work very well, I have a setTitle() method in the contact.cfc which creates the object of title.

    The problem is, whenever I refer to the setTitle() method since the contact.cfc can I error saying that the return type is not of type 'title '.

    I think that i've got is it's completely wrong, or I'm missing something.

    Can someone please?

    My e-mail address is here

    You have defined the type of your cfargument tag to be the title, but as we can see from your attached code the path to the CFC is components.contact.title you need to change the type to that.

  • Calendar in OBJECT oriented programming

    Hello

    I need to get the order in which things are in my first game right. Here's what I want to do.

    1. Player click on the 'play' button, the button goes, and timer starts. It is all works well
    2. Then I want a text box to animate for 60frames. It works very well
    3. Then ONLY I want as my next video clips start to play

    How to do the step 3 wait only 60 images? I have no idea how this code.

    Help, please

    Images of recommended

    I create a movieclip in flash cc and add a textfield (for example, tf) with a police yellow (to view "your word") and assign a class (for example, WordBox).  I would like to use something like:

    package {}

    import flash.display.MovieClip;

    import flash.text.TextField;

    import com.greensock.TweenLite;  //<-i like="" to="" use="" this="" for="">

    SerializableAttribute public class extends MovieClip {} WordBox

    public void WordBox(s:String) {}

    S = This.TF.text;

    this.tf.autoSize = "left";

    this.addEventListener (Event.ADDED_TO_STAGE, init);

    }

    private void init(e:Event):void {}

    This position and start its interpolation if that's what you want

    This.x=(stage.stageWidth-this.width)/2;

    This.y = 0;

    TweenLite.to(this,1,{y:stage.stageHeight-this.height});)

    }

    public void textF (): String {}

    Return this.tf.text;

    }

    }

    }

    I also create a movieclip in flash with a textfield cc (for example, tf) for your tiles and create a tiling class (for example, mosaic) that will handle the display of the tile, movement and click:

    package {}

    import...

    Tile/public class extends MovieClip {}

    public void cage (s:String) {}

    S = This.TF.text;

    this.addEventListener (Event.ADD_TO_STAGE, init);

    this.addEventListener (MouseEvent.MOUSE_DOWN, downF);

    }

    private void init(e:Event):void {}

    position and assign a sinusoidal vertical movement

    }

    private void downF(e:MouseEvent):void {}

    dispatchEvent (new Event ("tileclickE"));

    }

    public function textF (): String {}

    Return this.tf.text;

    }

    }

    }

    and then in your controller class, you can retrieve the text of WordBox, distributed in a table, and when a tileclickE event is detected, determine if it was correct or incorrect slab click Tile click and take appropriate action.

Maybe you are looking for