Spawning Objects to Stage and making them move a certain distance in a given direction.

Here is my code:
function createEnemy(event:TimerEvent):void
                var enemyAppear = new MovieClip;
                enemyAppear = new Enemy();
                enemyAppear.x = Math.random()*stage.stageWidth;
                enemyAppear.y = 285;
                enemyStorage.addChild(enemyAppear);
                //Removes Enemy From Stage and adds a point to scoreboard
                stage.addEventListener(MouseEvent.CLICK, clickEnemy);
                function clickEnemy(event:MouseEvent):void
                if(cursor.hitTestObject(enemyAppear))
                        enemyAppear.parent.removeChild(enemyAppear);
                        stage.removeEventListener(MouseEvent.CLICK, clickEnemy);
                        score++
                        messageDisplay.text = String(score);
What I am trying to do is spawn a enemy to stage and when it appears on the stage I would like it to move across the stage a certain distance.
Visual Example:
O = enemy,   X = original position, Y = new position
O (Spawns @ Location X)   X ---------------------------------------------------------> Y ( Moved from location X to Location Y)
Any help would be appreciated.
Thanks Casey

You can start by trying the built-in Tween class, and if you're happy with getting that working the way you want, you can consider moving on to a third party tweening class such as TweenLite...
import fl.transitions.Tween;
var certainDistance:Number = 200;
var moveTime:Number = 2; // seconds
function createEnemy(event:TimerEvent):void
                var enemyAppear = new Enemy();
                enemyAppear.x = Math.random()*stage.stageWidth;
                enemyAppear.y = 285;
                enemyStorage.addChild(enemyAppear);
                //Removes Enemy From Stage and adds a point to scoreboard
                stage.addEventListener(MouseEvent.CLICK, clickEnemy);
                 var tweenX:Tween = new Tween(enemyAppear, "x", null, enemyAppear.x, enemyAppear.x+certainDistance, moveTime, true);// tween out
                function clickEnemy(event:MouseEvent):void
                if(cursor.hitTestObject(enemyAppear))
                        enemyAppear.parent.removeChild(enemyAppear);
                        stage.removeEventListener(MouseEvent.CLICK, clickEnemy);
                        score++
                        //messageDisplay.text = String(score);

Similar Messages

  • How do I prevent Adobe from taking my jpegs and making them pdf files? I have had to uninstall Adobe to access my photos as jpegs.

    How do I prevent Adobe from taking my jpegs and making them pdf files? I have had to uninstall Adobe to access my photos as jpegs.

    I would suggest you change your file associations so that jpgs open in a program other than Acrobat.  Assuming you have a Windows machine, just go to the Start, and search for "file associations" ... it's part of the Control Panel.
    Scroll down to the file type jpg, and set it to open with whatever graphic preview or editing program you have that you want to use as the default.  From that point on, when you click on a jpg, it should not open Acrobat and instantly try to convert it to a pdf.

  • Taking multiple shots and making one movie from them

    I've searched the forums and can't find the answer....
    I've got a video of a school musical that I'm editing. It was shot from several different angles. Is there a way for me to line the two videos up, and then pinpoint somehow which portions I want to use from each? I've tried to split the clips and insert others, but it's very difficult when it's in the middle of a song to get the precision correct.
    any help would be appreciated. Thanks!

    In iMovie 09, you can use the Cutaway feature. Make sure advanced tools are selected in iMovie Preferences. Drag the second clip on top of the main clip, select Cutaway, and the underlying sound track will continue. [See Tutorial Here|http://www.kenstone.net/fcphomepage/imovie_09stone.html#cutaway%20pip]
    Also see the section on the Precision Editor.
    However, to use multiple cameras with timecodes and have them easily line up, you need Final Cut Express or Final Cut Pro.

  • Sending objects with sockets (and making a mess thereof)

    I'm playing about with client/server interaction and have made a simple program where a server waits for a connection on its given port, accepts a socket connection and every second checks for any input from the client and sends a Point object with co-ordinates to the client
    The client in renders the Point object and every second checks for an updated Point from the server, whenever the left or right arrow keys are used the server is sent the keyevent object to process and change the co-ordinates of the point which will then be sent back
    But it doesn't work, the server thread hangs on the if statement testing for a new object to read. If the code looking for a new object is comented out, the system works perfectly (with the random co-ordinates shown, the Point object itself is held in another class and would be used if the server could read the input)
              try
                   ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
                       ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
                       boolean temp = true;
                       while (temp == true)
                        sleep(1000);
                        Object o = in.readObject();
                        if (in.readObject() != null)
                             parent.process.updatePoint((KeyEvent)in.readObject());
                        out.writeObject(new Point((int)(Math.random() * 200), (int)(Math.random() * 200)));
              } Could anyone advise me why it specifically doesn't work? Having said that I realise my design is probably rather inefficient and generally poor and any general tips are welcome to
    Any help appreciated

    I think we are going to need to see the other side of your program. If your code hangs at the if statement:
                        if (in.readObject() != null)
                             parent.process.updatePoint((KeyEvent)in.readObject());
                        }Then i would have to assume the object is never recieved.

  • Navigating through objects in flex and refreshing them

    In an mxml file called Rate,
    I have a vertical box called stepsVB and an array called steps.
    This stepsVB is activated in a state called "states"
    when currentState = "" i see something else.
    steps contain objects of mxml files. step1.mxml, step2.mxml, step3.mxml and step4.mxml
    when i click on the next button, I navigate from step1 to step2 and so on using
    stepsVB.removeChildAt(0);
    stepsVB.addChildAt(steps[2], 0);
    when i move from step1 to step2 and step2 to step3 and change my currentState to "", if I press my next button, i see step3 instead of step1.
    How do I move to step1 instead of step3. Also, I need to execute my creation complete method for each step as I move.
    In other words, I need to set it up in such a way that the whole flex file refreshes. How do I accomplish this?
    Your help is greatly appreciated.
    Thank you very much
    Nikhil

    Hi,
    If you want to map your actionscript class to your server's
    Java class. You can run a util function
    registerClassAlias("dev.echoservice.Book",Book);
    where "dev.echoservice.Book" is the fully qualify name of
    your java class. Book is your actionscript class.
    Calling this util before you make your remoteobject call. You
    can put this in your actionscript class constructor, it makes this
    call whenever you create your class. However, it seems to be better
    to call it when the class is loaded. To do so you can declare it as
    static
    public static var a:* =
    registerClassAlias("dev.echoservice.Book",Book);
    OR
    You can also declare it as metaData in your class as:
    [RemoteClass(alias="dev.echoservice.Book")]
    However, I found someone saying that it didn't work in sdk
    compilation, but webtier compilation. It might be some
    configuration issue. I haven't tried it yet.
    To display the properties in the dataGrid, you just have to
    either use Array or ArrayCollection. If databinding is involved,
    the datagrid need to know the Collection.Change event. It is better
    to use ArrayCollection, therefore, adding new item to
    arrayCollection the datagrid get repopulate.
    hope it helps!
    William Chan

  • Adding .class files to your project and making them work.

    Ok, im fairly new to java and having trouble understanding how to make importing of .class files work. Im using eclipse 3.2
    I have the files in a directory and I have gone to project->properties->java build path->libraries->add external class folder and pointed it to the correct place.
    Now, I am trying to use some of the classes it provides. I get no errors when creating the object with this code:
    com.ECS.client.jax.ItemSearchRequest itemRequest = new com.ECS.client.jax.ItemSearchRequest();
    Before I did the add external class folder that code would error cause it didnt know what com.ECS was. Now it works fine. My problem is that when I try to use a class, it does not recognize it as a class. After doing the above code I have:
    itemRequest.setSearchIndex("Books");
    its giving me an error on the period, saying: "Syntax error on token(s), misplaced construct(s)". Its not seeing that it is a class, so I can't use it. But when I am creating the object I get no errors. For reference, here is the chunk of code:
    com.ECS.client.jax.ItemSearchRequest itemRequest = new com.ECS.client.jax.ItemSearchRequest();
    itemRequest.setSearchIndex("Books");
    the second line of which errors. So my question is, how do I get it to recognize that the itemRequest is a class when I have imported the .class files to my project already?

    It's working fine. It's just that you have to put your code in a method.

  • Targeting Arrays and making them invisible

    Hi: I'm having trouble targeting elements of an array using AS3. I have five buttons in an array named botons.
    var botons:Array = [boton_1, boton_2, boton_3, boton_4, boton_5];
    Each button goes to a different page, but they all are on the same layer like navigation bar.
    When page 1 is visited button 1 should be invisible and the others visible. When on page 2, button 2 should be invisible but all others visible.
    I used the following to make the entire array invisible and it works.
    for(var i:int; i<clips.length;i++)
    botons[i].visible=false;
    How can I make each button invisible when visiting its page, but make the rest visible?
    Thanks
    German

    Ned:
    Here is my entire script. I added what you suggested. It still doesn't work.
    Page names: first, second, third, fouth, and fifth.
    boton_1.addEventListener(MouseEvent.CLICK, goPNext);
    boton_2.addEventListener(MouseEvent.CLICK, goPNext);
    boton_3.addEventListener(MouseEvent.CLICK, goPNext);
    boton_4.addEventListener(MouseEvent.CLICK, goPNext);
    boton_5.addEventListener(MouseEvent.CLICK, goPNext);
    function goPNext (evt:MouseEvent)
    switch (evt.currentTarget.name)
    case "boton_1":
    gotoAndStop("first");
    break;
    case "boton_2":
    gotoAndStop("second");
    break;
    case "boton_3":
    gotoAndStop("third");
    break;
    case "boton_4":
    gotoAndStop("fourth");
    break;
    case "boton_5":
    gotoAndStop("fifth");
    break;
    }// end switch
    }// function
    for(var i:uint = 0; i < 5; i++)
    getChildByName("boton"+i).addEventListener(MouseEvent.CLICK, navigate);
    function navigate(e:MouseEvent):void
    for(var i:uint = 0; i < 5; i++)
    getChildByName("boton"+i).visible = true;
    e.currentTarget.visible = false;
    // determine where to navigate based on e.currentTarget
    ERROR
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at subtraction_fla::MainTimeline/frame1()
    German

  • Is there a tutorial for uploading fill- able forms to website and making them submit-table?

    I want to upload a couple of fillable forms (pdf's) to website and allow customers to fill and submit. Is there a tutorial out there for this that someone could point me to? I can't seem to find one that really answers my questions.

    A problem you'll encounter with those types of forms is security when transmitting the data. Obviously, the forms will contain sensitive information, and using email or a non-secure posting to a web server would not be acceptable. I personally would not send such data that way.
    It's possible to set up the form and web server so that the data is submitted securely. If your web server can handle that, it would be the best way to go. You would have to somehow program the web server to manage it all. Now I'm being vague, but that's because there are a lot of details to consider.

  • Can you share iCalander/Address Book with other users and restrict them from seeing certain entries?

    I'm doing some research for my boss concerning iCloud. He would like to setup a way to syncronize iCalender and the Address Book between three users but keep his personal information private. For example, he wants to be able to update his calender from his phone about an upcoming meeting/project so that the three computers at work are all updated and see upcoming events. Same goes for the contacts. If he adds a new contact or if I add a new contact, for a client or whoever it may be, he wants it to sync up for everyone. At the same time, if he adds a personal event to iCal such as, "Dinner with the girlfriend" or something irrelevant to work, he doesn't employees to be able to see that. My first idea was to setup an iCloud account but I'm wondering if you can even restrict certain things within an account.
    Anyone have any other ideas? They would be greatly appreciated.

    iCloud appears to provide no Address Book sharing. You might be able to do this through Google, but it would be likely to be all contacts or none.
    iCloud allows you to share calendars privately (editable if you wish) to other iCloud users or publicly (non-editable) to anyone - they would need a CalDAV client to read it, such as iCal or Google Calendars.
    You share individual calendars, so private events should be in their own calendar which is not shared.
    More on Calendar sharing here:
    http://support.apple.com/kb/PH2690

  • Taking clips from itunes movies and putting them into imovie

    I'm doing a school project and making a movie trailer and i need to take clips from a movie on my itunes and put it onto imovie so i can take clips from the movie. HELP PLEASE!!!

    How did the movie get into iTunes? Does it have digital rights copy protection? I guess you're not seeing the movie when you look in music in the iMovie media browser, is that right?

  • Aligning objects on stage throughout timeline

    I am new to Flash and am probably missing the obvious.
    I want to select objects on the stage and move them to a new
    position, or align them to a guide line. However, I want to do this
    for a whole series of frames in the timeline. In essence, select
    all frames in the timeline, and then select all objects on the
    stage, and align them to the left side and top side.
    However, it seems to only align objects in the current frame.
    I started with one circle on stage, then added more keyframes
    in the timeline, changing the color of the fill at different
    keyframes.
    Is there another way to do what I want?
    Thanks,
    Patrik

    I found it...Edit Multiple Frames.

  • How to i write a script that makes multiple selections in a pdf and exports them to excel?

    I have a large number of PDFs
    Not all the PDFs contain information we need. We want to be able to automate a script that extracts certain info from the PDFs and opens them in a certain format in excel.
    Acrobat allows me to make a single selection and export as excel.
    How do i export multiple parts to excel from the pdfs and ensure that the resulting excel is in a format that i can use without much fixing needed (e.g. merged cells)?

    This type of process can't really be done using JavaScript. You would need to read the contents of the file, word by word, decide (based on some logic) what data to extract, and then collect it and at the end export to a plain-text file. Not a simple process...

  • How to get multiple Move A Fixed Distance vi's to work?

    OK, I've seen other postings where people didn't have luck with this vi.  Hopefully, the debugging I'm working on will help the community in figuring it out.  I'm looking start with a really simple FTC autonomous prototype to drive (straight) down the ramp, turn (towards a goal - hopefully we'll have a sensor too), deploy goal grabber, then drive backwards a specific distance and orientation (to the parking zone), then spin to deposit the goal.  So, the first challenge was drive forward, turn and back up.  This should've been a 30-minute exercise.  We probably have dozens of man-hours invested so far - with no luck.
    So, I've included a series of vi's:
    3movedistance_test doesn't work: it only goes forward; in fact it doesn't go exactly 360 degrees
    ditto on 2movedistance_test
    1movedistance_test seems to work fine
    when I dial down the power on 1movedistance_test to 20%, one motor moves ~360, the other moves ~120
    [oops - gonna have to upload the rest of the files separately - only 3 attachments allowed]
    3movedistance_parallel - I can dial down the speed to 1, and both motors turn exactly 180 - it looks like they're taking turns though, they individually index about 30 times
    That's phase 1 of the research.
    Phase 2 was to get the sledgehammer out and skip the Move A Fixed Distance vi, and use the Wait For Rotation vi with a standard Move Motors vi.  MoveDistanceJC has the following characteristics:
    at 80% power, Motor B goes ~2-1/4 revolutions (obviously greater than 0.1") and Motor C goes 2-1/3 revolutions
    at 50% power, Motor B goes ~1-1/4 revolutions and Motor C goes 1-1/3 revolutions
    at 20% power, Motor B goes ~1/3 revolution and Motor C also goes 1/3 revolutions
    Attachments:
    3movedistance_test.vi ‏24 KB
    2movedistance_test.vi ‏18 KB
    1movedistance_test.vi ‏18 KB

    We're apparently not the only ones either:
    Mike5027 2014.10.06
    Mike5027 2014.10.09
    4644Mentor 2012.02.23
    robuff 2012.02.24
    philbot 20211.05.03
    FTC7785 2013.10.21
    The vi help is sparse in detail.
    These are the only 3 possible workarounds that I could find that got me started on the variation in MoveDistanceJC:
    How to calibrate NXT motors to travel the same distance?
    LabVIEW example: Motors
    FRC704 2011.02.13

  • When I had a PC I simply took the wire going to my monitor and connected to my big screen TV to watch Netflix movies...How do I take them from my IMAC and connect them to my TV now?

    When I had a PC I simply took the wire going to my monitor and connected to my big screen TV to watch Netflix movies...How do I take them from my IMAC and connect them to my TV now?

    This could be problematic.
    It will depend on what model of iMac you have.
    You may want to post machine info.
    blue apple > about this mac > more info button. Click on the hardware line. It has a little triangle in front of the work hardware.
    Leave out the serial number.
    Example:
    Machine Name: iMac
    Machine Model: PowerMac4,1
    CPU Type: PowerPC 750 (33.11)
    Number Of CPUs: 1
    CPU Speed: 600 MHz
    L2 Cache (per CPU): 256 KB
    Memory: 768 MB
    Bus Speed: 100 MHz
    Boot ROM Version: 4.1.9f1
    Most of the iMac's have sometype of video output port on the back.  You will problably need a converter.
    The 'hollywood' industry has been making it more difficult to get video out over time to prevent copying.
    Robert

  • I started making a movie and all was well. I added a few more pictures and some sound and played it back. It plays so far and then the pictures break up into colors and then the screen turns green.  The sound continues.

    I am making a movie from still pictures. I used no theme and then started adding pictues. When I played it back, all was well. Then I added a few more pictures and some sound. When I play iot back it plays just so far and then the sound continues, but the screen turns green or the pictures break up into colors.

    Sorry, everyone.  I think I may have figured out what it was all down to...........
    I had left the IDE ribbon cable plugged into my third HDD, with the power cable unplugged.  I did this so as not to endanger my years of work on the third drive, until Windows had setup.  I have in the past, accidentally chosen the wrong partiton to format, so this seemed a good way to avoid it from then on.
    This was not a problem on my old system, but it seems this system doesn't like it.
    I must have left the drive completely unplugged, the times Windows did setup.  Amazing really.  I couldn't see the woods for the trees.
    Anyway, I'm sorry to have bothered everyone with my problem.
    Cheers
    Marcus
    edit :   Sorry Syar2003, I didn't see your reply until I had posted mine.  Many thanks for taking the time to try and help me, it seems as though I may have sorted it now.  I am using IDE drives until I can afford SATA.  But many thanks for the heads-up on the NF4-SATA compliance, I'll be sure to bare that in mind.
    I didn't actually check the NVRAID/IDE ROM version before updating the bios, so I have no idea if the revision was changed when Liveupdate flashed the Bios, I'm afraid.  I didn't know they would be updated at the same time.
    Again, cheers
    Marcus

Maybe you are looking for

  • Where do we put authorised user name for approving DMS document in DMS work

    HI I am on a support role and here is a document creation through DMS and it goes approval for 4 level , upon each level mail trigger to the user id (approval authorised person) . now company changed the users for approving authority , so i have to c

  • Updated record should come in txt file

    Hi Friends, My requirements like this way, any changes make in mara, mard, mbew, makt, vbak, vbap, vbrk and abrp table. that newly created data should come in .txt file of application server. I have already developed a program for that. it is downloa

  • How to change payment date

    Once again I've gone in circles over something simple. Adobe pisses me off! How do I change my billing payment date?

  • How do I Change Font and Font Color in Navigation Menu?

    I recently purchased iLife 08 and i'm having a hard time finding the tool to change the fonts in the navigation menu at top of page. Is it even possible?

  • My ipod is really messed up please help me

    the screen is distorted (i can only see a bit of the menu screen in a quarter of my screen.) my ipod also doesnt not turn on,ive tried turing it on and reseting it but it dont work and everytime i plug it in to my pc it makes a buzzing noise but my p