Button inside movie won't react to rollOver

Hi there,
I am developing a sort of panorama movie where the image
scrolls around. That is working but when I try to set some hotspots
on it by adding buttons in the movieClip I can't get them to react
to rollOver action since (onRelease and onPress) it is already used
by the main movieClip.
Any idea on a work around?
I have been reading for 4 hours and can't find a good
solution.

i am not expert coder so I have make a movie clip to the
Mouse so I startDrag() and use the hit test to change the status of
my Buton.mc.
But i am still unnable to use on(press), and all the other
mouse functions because they are use by the main movieClip
if you would be so kind and explain me how to do that or a
link to some tutorial I would really appreciate.

Similar Messages

  • AS3 Putting Buttons Inside Movie Clip

    I am practicing AS3 (after years of AS2) and am having trouble having a button inside a movie clip talk to another movie clip on the main timeline. Here is the code:
    OneButton.addEventListener(MouseEvent.CLICK, OneButtonClicked);
    function OneButtonClicked(event:MouseEvent):void
    MovieTarget.gotoAndStop(1);
    MovieDescription.gotoAndStop("One");
    TwoButton.addEventListener(MouseEvent.CLICK, TwoButtonClicked);
    function TwoButtonClicked(event:MouseEvent):void
    MovieTarget.gotoAndStop(2);
    MovieDescription.gotoAndStop("Two");
    The code above works, but if I put OneButton and TwoButton inside a movie clip, I know longer can target MovieTarget and MovieDescription. The reason I want to put OneButton and TwoButton inside it's own MC is so I can dim each button after it is clicked by toggling the playhead inside that MC. Help? Thanks!

    Start over from the begining
    press  f8 and chose movieClip then draw your untoggled button call the movie button then create another movie and create your toggled button or greyed out button and call it greyedButton.  Go to main stage add 2 button instances and 2 greyedButton instances( just drag from library).  you have 4 instances on stage.  give call instance names and place one them on top of each other so u can only see 2 buttons on stage.  put the greyed button under the button.
    now with action script
    button1.addEventListener(MouseEvent.CLICK, OneButtonClicked);
    function OneButtonClicked(event:MouseEvent):void
    MovieTarget.gotoAndStop(1);
    MovieDescription.gotoAndStop("One");
    button1.visible = false; //  here the greyed button will show
    button2.addEventListener(MouseEvent.CLICK, TwoButtonClicked);
    function TwoButtonClicked(event:MouseEvent):void
    MovieTarget.gotoAndStop(2);
    MovieDescription.gotoAndStop("Two");
    button1.visible = true; // here button1 will go back to its orignal state
    button2.visible = false // here the greyed button will show

  • Buttons inside movie clip dont work

    I have a simple HTML website with 5 buttons one of which, a movie clip, drops down 3 more buttons but the buttons dont always work. I get wierd issues for instance: whether I'm on the mcs page or another page completly the drop down buttons only work when Im on the parent movie clips page. When the buttons do work and you click on the button of the page your on  they only work once then the whole issue repeats itself. Hopefully to clarify here is the code inside of the movie clip that directs the drop down buttons.
    stop();
    var cdButton:URLRequest= new URLRequest("character desin.html");
    cd_btn.addEventListener(MouseEvent.CLICK, cd);
    function cd(event:MouseEvent):void
            navigateToURL(cdButton,"_self");
    var caButton:URLRequest= new URLRequest("concept art.html");
    ca_btn.addEventListener(MouseEvent.CLICK, ca);
    function ca(event:MouseEvent):void
            trace("ca_btn");
            navigateToURL(caButton,"_self");
    var dsButton:URLRequest= new URLRequest("draw sketch.html");
    ds_btn.addEventListener(MouseEvent.CLICK, ds);
    function ds(event:MouseEvent):void
            trace("ds_btn");
            navigateToURL(dsButton,"_self");

    From what I see you are trying to somehow program a Actionscript only iframe navigation. That will never work without an external Interface call to the Browsers Javascript. This is complicated stuff and surely not what you have in mind. If concept art, draw sketch etc. are all separate swf files, you should load them (instead of the html you embedded them in)

  • How to add button inside move clip and call it from main timeline?

    Hi,
    On the main timeline I  have a movie clip called clock_mc and playBtn
    playBtn is  placed in the center of clock_mc
    When you press playBtn clock_mc starts playing
    playBtn.addEventListener(MouseEvent.CLICK, playClock);
    function playClock(event:MouseEvent):void
        if (event.target == playBtn)
            clock_mc.play();
            playBtn.visible = false;
            trace ("play button was clicked");
    This is working fine for me.
    But I want to add replayBtn to the last frame of clock_mc and set up the function on main Timeline.
    Another words when the clock_mc rich last frame you see replayBtn.
    code example:
    replayBtn.addEventListener(MouseEvent.CLICK, playClock);
        if (event.target == replayBtn)
            clock_mc.play();
            replayBtn.visible = false;
            trace ("replay button was clicked");
    I've tryed to placed the replayBtn on the stage on the main timeline and I've set it up to replayBtn.visible = false;
    And then I add replayBtn.visible = true; to last AS frame of clock_mc but it wont work
    Even when I put the button physically to the last frame of clock_mc it will not work either.
    Please help

    I've solved the problem:-)
    I've set replayBtn.visible = false; on first frame of clock_mc
    and  replayBtn.visible = true; at the last frame
    and than as you sugested I'v add:
    clock_mc.replayBtn.addEventListener(MouseEvent.CLICK, replayClock);
    function replayClock(event:MouseEvent):void
            clock_mc.play();
            trace ("replay button was clicked");
    I couldn't see replayBtn at the firs stage because I have clockTween assosiated with clock:
    clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
    and I had replyBtn in the wrong place so when clock_mc was coming up on the stage replayBtn was on the left side of the stage :/
    Now I have to solve only one thing.
    Maybe you would have any suggestions please.
    I've set up stop(); in a first frame of clock_mc
    that when you see clock_mc sliding in it has to wait for playBtn to be clicked
    because I have two tween:
            clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
            playTween = new Tween(playBtn, "x", Regular.easeOut, -720,514, .5, true);
            playBtn.visible = true;
    so when you click on playBtn:
    function playClock(event:MouseEvent):void
        if (event.target == playBtn)
            clock_mc.play();
            playBtn.visible = false;
            trace ("play button was clicked");
    everythink is working fine except when I clik on replayBtn it play for I sec because there is stop(); on the first frame of clock_mc

  • Button inside MC won't work - Basic

    Hi everyone,
    I'm a pretty novice user of Flash 8. I have a basic button
    that when users click on, just takes them to another frame on the
    timeline. When it's outside the movie clip of a map, it works fine:
    on (release) {
    gotoAndStop("Scene 1", "villa2");

    you just have a path issue here and need to call the correct
    path. If there is only one scene then you do not need to use the
    scene parameter. dz's code will work by calling to the _root
    timeline or use _level0 or _parent._parent (if understand your
    structure correctly) so it should read:
    on(release) {
    _root.gotoAndStop('villa2');
    that is if this code is being attached to the button, if it
    is on the timeline of the button's parent clip it would read:
    the_btn.onRelease = function() {
    _root.gotoAndStop('villa2');
    I find it interesting that a getURL would work for this
    though, I'm not sure how you would have done that, but I digress
    PS. you can post your fla here, zip the file, mount it on
    your server, and post the address to the file using the http link,
    in the reply window (use the 'Reply' link in the top of the
    window)

  • Run Button inside a movie effect outside a movie

    hi
    I am working in flash 8 on Windows XP. I am creating a US Map
    Project . Under which when i mouse over on a particular US-state
    it's size is increased. I did it by using a movie clip. I made such
    moive clip's for each state of USA.
    Now my requirement is when i mouse over on a particular US
    State it must grow its size. and further it must have few spots on
    that movie. on which when user clicks a small panel with some
    information about that location should be shown.
    For this i made a movie for each US State. and set mouse over
    event .
    on(rollover){
    mcName.gotoAndPlay(2);
    till here it works fine. But for further spots for locations
    i made button in each moive.
    Now when i mouseover on movie it gives me desired results.
    But when i try to click on the button
    inside that movie. It doesnt work.
    Please Urgent Help is required .

    Inderdeep wrote:
    > hi
    > I am working in flash 8 on Windows XP. I am creating a
    US Map Project . Under
    > which when i mouse over on a particular US-state it's
    size is increased. I did
    > it by using a movie clip. I made such moive clip's for
    each state of USA.
    > Now my requirement is when i mouse over on a particular
    US State it must grow
    > its size. and further it must have few spots on that
    movie. on which when user
    > clicks a small panel with some information about that
    location should be shown.
    >
    > For this i made a movie for each US State. and set mouse
    over event .
    > on(rollover){
    > mcName.gotoAndPlay(2);
    > }
    > till here it works fine. But for further spots for
    locations i made button in
    > each moive.
    >
    > Now when i mouseover on movie it gives me desired
    results. But when i try to
    > click on the button
    > inside that movie. It doesnt work.
    >
    > Please Urgent Help is required .
    The problem with flash is that you can't nest button within
    button even tho it is
    in a movie clip. You need to use movie clips instead. In that
    movie, on first frame
    you have stop(); action and the button with roll over action
    to jump frame which
    has the OVER state content. Than from there you have more
    buttons to branch out the
    tree.
    Best Regards
    Urami
    Beauty is in the eye of the beer holder...
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Buttons inside a movieclips won't work...

    I have a movieclip that has several buttons inside it. When I use this code:
    mc.onRollOver = function()
         // do stuff
    The buttons won't work anymore..

    Hello there Mr. Ned Murphy,
    Is there any other way to make buttons inside a movieclip work?
    The scenario of my project is having a panel for control buttons, progress bar, sound buttons(on/off). When the cursor is rollover the panel, it will animate going up to reveal buttons which hidden below, for the shortcut of every scenes.
    This is what I got.
    control_panel_mc->2 frames w/ stop(); on each->2 layers->1st layer(bottom)panel contains buttons->2nd layer(contains button w/ a "swapdepths very important")
    and on the 2nd frame 2nd layer theres no button w/ a swapdepths and on the actionscript I have that code: mc.onRollOut = function{ //do something };
    Any other suggestion please...
    Thanks and more power,

  • Button inside a movie clip

    Ok, i'm new at action script so i have a problem
    I have a sound inside a movie clip (sound_MC) in the main
    timeline, and i have another movie clip with a button inside, and I
    need that button to control that sound movie clip
    on (release) {
    gotoAndStop("off_radio"); // this goes to another frame in
    the movieclip with the button (works fine)
    on (release) {
    _root.gotoAndPlay("stop_loop"); // this goes to another
    frame of the sound MC (doesn't work)
    // i have this in the stop button
    on (release) {
    gotoAndStop("on_radio");
    on (release) {
    _root.gotoAndPlay("start_loop");
    // and this for the play button
    whats the code for that ?
    what should i do?

    i solve the problem !! :-D
    but now i hold like to now how i make a fade out sound
    command when i enter a frame and a fade in when i enter in another
    frame
    here are the examples:
    http://tubo_centeno.web.simplesnet.pt/problem/problem.html
    http://tubo_centeno.web.simplesnet.pt/problem/problem.fla
    can anyone help me?

  • My iPad 2 won't react to any touch, except for the accessibility button.

    MY iPad 2, using the software of IOS 8 something, won't react to my touch. I can't even restart it. I was updating 4 apps at once. The only thing I could press is the accessibility button. Also, after updating to IOS 8,there is a strip of screen in the middle of my iPad that won't react to my touch. Now the whole screen won't.

    iOS Reset -
    Try a reset. Press & hold the Power and Home buttons simultaneously, ignoring the red power off slider, until the Apple logo appears. Then release both buttons. This should not affect any content on the device, it is similar to rebooting your computer.

  • Problems with button inside draggable movie clip

    I am building a click through presentation that has some small text in it. To maintain the design and allow for readability, I have added a zoom feature.
    Here is the structure of the movie,
    Stage - contains pages movie clip and forward/reverse click buttons for changing pages
         pages_mc - contains 24 frames, one page per frame and buttons
    There is a button at the _root level that uses a tweener to scale the pages_mc up to 170%. When this is clicked, it allows the pages to be dragged around the screen so you can look at different sections. When you click the button again, it returns the pages back to their original size stops drag.
    My problem is, on the pages, there are buttons with links to external sites. Once startDrag has been invoked, I cannot touch the buttons inside the movie clip. Is there a way to make these buttons work?
    I need the finished quickly so any assistance is welcome.
    Code below
    magUp_btn.onRelease = function() {
    this._visible = false;
    TweenLite.to(pages_mc, .25, {_x:-250, _y:-193, _xscale:170, _yscale:170});
    TweenLite.to(magUp_mc, .75, {_alpha:0});
    TweenLite.to(magDown_mc, .75, {_alpha:25});
    magDown_btn._visible = true;
    pages_mc.onPress = function(){
    this.startDrag();
    pages_mc.onRelease = function(){
    this.stopDrag();
    pages_mc.onReleaseOutside = function(){
    this.stopDrag();
    pages_mc.useHandCursor = false;
    TweenLite.to(instr_mc, 1, {_alpha:100});
    magDown_btn.onRelease = function() {
    TweenLite.to(pages_mc, .25, {_x:0, _y:0, _xscale:100, _yscale:100});
    TweenLite.to(magUp_mc, .75, {_alpha:25});
    TweenLite.to(magDown_mc, .75, {_alpha:0});
    this._visible = false;
    magUp_btn._visible = true;
    pages_mc.onPress = function(){
    this.stopDrag();
    TweenLite.to(instr_mc, 1, {_alpha:0});
    I don't know how to turn drag off when I zoom out without using the onPress command, but I know that this is probably what is getting in the way of the button working?
    Thanks!

    One option is to make the background of the pages be the draggable parts rather than the movieclips that contain the pages and buttons.  That way, the buttons could be atop the background and not have their access blocked.
    Instead of coding the pages_mc, you would essentially have the background coded for the drag...
    pages_mc.bkgnd.onPress = function(){
        startDrag(this._parent);

  • Buttons inside a movie

    I am having an issue with some buttons inside of a movie that
    should reference a specific frame on Scene 1. the code I have is
    on (release) {
    gotoAndPlay("scene1", 546);
    But it is doing is resetting to the begging of the movie
    instead of going to frame 546 in scene 1. You can take a look at
    the file by going to ftp://supersilo.com/exchange use the username
    of expert and pass of exchange

    don't use scenes for navigation and don't use the goto
    functions. use frame labels and the goto methods. for example

  • Target a button inside of a Movie Clip

    I am trying to target a button inside a dynamically loaded
    movieclip, such as the following (but is not working):
    clipAnswerYesNo: Movieclip
    testbutton: embeded button
    Script is on main timeline.
    _root.clipAnswerYesNo.testbutton.onRelease = function() {
    trace(userAnswer);
    D

    ensure both the movieClip and the button have instance names.
    also, maybe change your trace to:
    trace("hit button"+userAnswer);
    it is possible that the trace and therefore the button is
    working, it's just the path to userAnswer is incorrect...

  • Buttons in movie clip won't bring up scenes

    I've created a movie clip within my main scene.
    I have 6 buttons in that clip. I would like these buttons to
    call up the appropriate scenes but it isn't. I don't know whether I
    cannot have buttons in movie clips call up new scenes or if my
    actions script is simply wrong.
    Here are some of the actions I've tried to upload the scene
    or swf files:
    thanks.
    on (release) {
    _root.gotoAndPlay("instance name");
    ----Also, named 1st frame of scenes with matching instance.
    on (release) {
    _root.gotoAndPlay("scene name");
    on (release) {
    gotoAndPlay("scenename",1);
    on (release){
    uploadMovie ("name.swf",1);
    }

    use frame labels only and use the goto methods (like your
    first 2 goto statements) and not the goto functions (like your last
    2 goto statements).
    also, there is no uploadMovie() method in actionscript. use
    loadMovieNum() if you want to load name.swf into _level1.

  • Button inside a button

    hello
    I have a rectangle MC with rollOver event.
    Inside that rectangle, I would like to have 1 with its own
    rollOver event.
    The rollOver event for the button doesn't ork whereas the the
    one for the rectangle does work.
    It looks as if the rollover of the rectangle cancels the
    event for the button.
    Do you have any solution?
    thanks

    ritpas wrote:
    > hello
    >
    > I have a rectangle MC with rollOver event.
    > Inside that rectangle, I would like to have 1 with its
    own rollOver event.
    > The rollOver event for the button doesn't ork whereas
    the the one for the
    > rectangle does work.
    > It looks as if the rollover of the rectangle cancels the
    event for the button.
    You are correct. You can't place button within button or
    button within movie clip
    with buttons events. Flash can't have collision of two hit
    states therefor it will
    cancel the other buttons within the main clip/button.
    you need to find other arrangement like movie clip with
    hitTest actions or multiple
    frames and invisible buttons....where on roll over invisible
    button you jump to frame
    with other content where there is no longer that button to
    collide with other buttons,
    and so on...
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Use Buttons to move square from left to right

    Hey,
    I am working a a Java Game for school, it's kind of a Space Invaders clone. I want to control the shooting object at te bottom of the screen by 2 buttons, one for left movement, and one for right. But my buttons won't react to it being clicked. I have pasted the code below so you can take a look. Please can anybody help me?
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class Animation extends JPanel implements ActionListener{
    JButton button=new JButton("links");
    JButton button2=new JButton("rechts");
    ClickCounter clickCounter=new ClickCounter();
    int xpos=0;
    int xpos2=0;
    int height=15;
    int width=60;
    int dx=3;
    int dxshooter=3;
    int shoot=300;
    int ykogel=0;
    int dxkogel=3;
    int number=12;
    int xposkogel;
    int yposkogel;
    int ovalx1=xpos,ovalx2=xpos+100,ovalx3=xpos+200,ovalx4=xpos+300,ovalx5=xpos+400,ovalx6=xpos+500;
    int ovaly1=15,ovaly2=15,ovaly3=15,ovaly4=15,ovaly5=15,ovaly6=15;
    int ovalxb1=xpos+19,ovalxb2=xpos+19+100,ovalxb3=xpos+19+200,ovalxb4=xpos+19+300,ovalxb5=xpos+19+400,ovalxb6=xpos+19+500;
    int ovalyb1=5,ovalyb2=5,ovalyb3=5,ovalyb4=5,ovalyb5=5,ovalyb6=5;
    Timer fastTicker;
    Animation(){
    fastTicker=new Timer(25,this);
    void start(){
    this.add(button);
    button.setSize(100,50);
    button.move(0,320);
    button.addActionListener(this);
    this.add(button2);
    button2.setSize(100,50);
    button2.move(600,320);
    button2.addActionListener(this);
    fastTicker.start();
    public void actionPerformed(ActionEvent e){
    yposkogel=312-ykogel;
    ovalx1=xpos;ovalx2=xpos+100;ovalx3=xpos+200;ovalx4=xpos+300;ovalx5=xpos+400;ovalx6=xpos+500;
    ovalxb1=xpos+19;ovalxb2=xpos+19+100;ovalxb3=xpos+19+200;ovalxb4=xpos+19+300;ovalxb5=xpos+19+400;ovalxb6=xpos+19+500;
    //bolletjesanimatie
    if(e.getSource()==fastTicker){
    xpos+=dx;
    ykogel+=dxkogel;
    xposkogel=xpos2;
    if (xpos>this.getWidth()-width-500||xpos<0){
    dx=-dx;
    if(e.getSource()==fastTicker){
    xpos2+=dxshooter;
    //schietding
    if (xpos2>240||xpos2<-210){
    dxshooter=-dxshooter;
    //kogelanimatie
    if(ykogel>310){
    ykogel=0;}
    //vergelijking van bolletje/kogel
    if(yposkogel==15&&xposkogel>=ovalx6&&xposkogel<=ovalx6+60){
    ovaly6=1500;
    ovalyb6=1500;}
    if(yposkogel==15&&xposkogel>=ovalx5&&xposkogel<=ovalx5+60){
    ovaly5=1500;
    ovalyb5=1500;}
    if(yposkogel==15&&xposkogel>=ovalx4&&xposkogel<=ovalx4+60){
    ovaly4=1500;
    ovalyb4=1500;}
    if(yposkogel==15&&xposkogel>=ovalx3&&xposkogel<=ovalx3+60){
    ovaly3=1500;
    ovalyb3=1500;}
    if(yposkogel==15&&xposkogel>=ovalx2&&xposkogel<=ovalx2+60){
    ovaly2=1500;
    ovalyb2=1500;}
    if(yposkogel==15&&xposkogel>=ovalx1&&xposkogel<=ovalx1+60){
    ovaly1=1500;
    ovalyb1=1500;}
    this.repaint();
    public void actionPerformed2(ActionEvent b){
    if (b.getActionCommand().equals("button")){
    xpos2=xpos2-50;}
    if(b.getActionCommand().equals("button2")){
    xpos2=xpos2+50;
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    //ufo's
    g.setColor(Color.black);
    g.fillOval(ovalxb1,ovalyb1, 25,25);
    g.setColor(Color.orange);
    g.fillOval(ovalx1,ovaly1,width,height);
    g.setColor(Color.black);
    g.fillOval(ovalxb2,ovalyb2, 25,25);
    g.setColor(Color.orange);
    g.fillOval(ovalx2,ovaly2,width,height);
    g.setColor(Color.black);
    g.fillOval(ovalxb3,ovalyb3, 25,25);
    g.setColor(Color.orange);
    g.fillOval(ovalx3,ovaly3,width,height);
    g.setColor(Color.black);
    g.fillOval(ovalxb4,ovalyb4, 25,25);
    g.setColor(Color.orange);
    g.fillOval(ovalx4,ovaly4,width,height);
    g.setColor(Color.black);
    g.fillOval(ovalxb5,ovalyb5, 25,25);
    g.setColor(Color.orange);
    g.fillOval(ovalx5,ovaly5,width,height);
    g.setColor(Color.black);
    g.fillOval(ovalxb6,ovalyb6, 25,25);
    g.setColor(Color.orange);
    g.fillOval(ovalx6,ovaly6,width,height);
    //schietding
    g.fillRect(xpos2+350-17,317,6,40);
    g.setColor(Color.green);
    g.fillOval(xpos2+350-30,330,30,30);
    g.setColor(Color.black);
    g.fillRect(xpos2+350-40,350,50,height);
    //kogel
    g.fillRect(xposkogel+350-16,yposkogel,5,5);
    public class AnimationDemo{
    JFrame frame;
    Animation animation;
    void demo(){
    frame=new JFrame("**Spees Inveeders** All rights reserved (Dave Senden and Joeri Oomen)");
    animation=new Animation();
    frame.getContentPane().add(animation);
    frame.setSize(700,400);
    frame.setVisible(true);
    animation.start();
    public static void main(String[] args){
    AnimationDemo animationDemo=new AnimationDemo();
    animationDemo.demo();
    }

    Jukka, thanks a lot! The buttons now work! I have updated my code, but now my problem is to compare the position of the bullet with the position of the ufo. I have marked the part where I wrote my solution, but it doesn't really work, do you have any suggestions?
    Thanks.import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class Animation extends JPanel implements ActionListener{
        JButton button=new JButton("links");
        JButton button2=new JButton("rechts");
        int xpos=60;
        int xpos2=0;
        int height=15;
        int width=60;
        int dx=3;
        int dxshooter=3;
        int shoot=300;
        int ykogel=0;
        int dxkogel=6;
        int number=12;
        int xposkogel;
        int yposkogel;
        int ovalx1=xpos,ovalx2=xpos+100,ovalx3=xpos+200,ovalx4=xpos+300,ovalx5=xpos+400,ovalx6=xpos+500;
        int ovaly1=15,ovaly2=15,ovaly3=15,ovaly4=15,ovaly5=15,ovaly6=15;
        int ovalxb1=xpos+19,ovalxb2=xpos+19+100,ovalxb3=xpos+19+200,ovalxb4=xpos+19+300,ovalxb5=xpos+19+400,ovalxb6=xpos+19+500;
        int ovalyb1=5,ovalyb2=5,ovalyb3=5,ovalyb4=5,ovalyb5=5,ovalyb6=5;
        Timer fastTicker;
        Animation(){
        fastTicker=new Timer(25,this);
        void start(){
                         Listener ear = new Listener();
                         this.add(button);
                         button.setSize(100,50);
                         button.move(0,320);
                         button.addActionListener(ear);
                         this.add(button2);
                         button2.setSize(100,50);
                         button2.move(600,320);
                         button2.addActionListener(ear);
            fastTicker.start();
    class Listener implements ActionListener{
      public void actionPerformed(ActionEvent b)
        Object o =b .getSource();
        if (o == button){
          if(dxshooter==3){
              dxshooter=-3;}
        if (o == button2){
        if(dxshooter==-3){
            dxshooter=3;}
       public void actionPerformed(ActionEvent e){     
       yposkogel=312-ykogel;
       ovalx1=xpos;
       ovalx2=xpos+100;
       ovalx3=xpos+200;
       ovalx4=xpos+300;
       ovalx5=xpos+400;
       ovalx6=xpos+500;
       ovalxb1=xpos+19;
       ovalxb2=xpos+19+100;
       ovalxb3=xpos+19+200;
       ovalxb4=xpos+19+300;
       ovalxb5=xpos+19+400;
       ovalxb6=xpos+19+500;   
                  //bolletjesanimatie
                   if(e.getSource()==fastTicker){
                    ykogel+=dxkogel;
                    xposkogel=xpos2;
                    xpos2+=dxshooter;
                     if(ykogel>=3){
                     xposkogel=xposkogel;}          
                    //schietding
                        if (xpos2>240){
                                dxshooter=-3;}
                        if(xpos2<-210){
                            dxshooter=3;}
                   //kogelanimatie
                       if(ykogel>310){
                       ykogel=0;}
                   //COMPARING THE POSITION OF THE BULLET WITH THE UFO's
                if(yposkogel<=15){
                        if(xposkogel>=ovalx6&&xposkogel<=ovalx6+60){
                        ovaly6=1500;
                        ovalyb6=1500;}
                        if(xposkogel>=ovalx5&&xposkogel<=ovalx5+60){
                        ovaly5=1500;
                        ovalyb5=1500;}
                        if(xposkogel>=ovalx4&&xposkogel<=ovalx4+60){
                        ovaly4=1500;
                        ovalyb4=1500;}
                        if(xposkogel>=ovalx3&&xposkogel<=ovalx3+60){
                        ovaly3=1500;
                        ovalyb3=1500;}
                        if(xposkogel>=ovalx2&&xposkogel<=ovalx2+60){
                        ovaly2=1500;
                        ovalyb2=1500;}
                        if(xposkogel>=ovalx1&&xposkogel<=ovalx1+60){
                        ovaly1=1500;
                        ovalyb1=1500;}
                     this.repaint();
    public void paintComponent(Graphics g){
                 super.paintComponent(g);
                 //ufo's
                 g.setColor(Color.black);
                 g.fillOval(ovalxb1,ovalyb1, 25,25); 
                 g.setColor(Color.orange); 
                 g.fillOval(ovalx1,ovaly1,width,height);
                 g.setColor(Color.black);
                 g.fillOval(ovalxb2,ovalyb2, 25,25); 
                 g.setColor(Color.orange); 
                 g.fillOval(ovalx2,ovaly2,width,height);
                 g.setColor(Color.black);
                 g.fillOval(ovalxb3,ovalyb3, 25,25); 
                 g.setColor(Color.orange); 
                 g.fillOval(ovalx3,ovaly3,width,height);
                 g.setColor(Color.black);
                 g.fillOval(ovalxb4,ovalyb4, 25,25); 
                 g.setColor(Color.orange); 
                 g.fillOval(ovalx4,ovaly4,width,height);
                 g.setColor(Color.black);
                 g.fillOval(ovalxb5,ovalyb5, 25,25); 
                 g.setColor(Color.orange); 
                 g.fillOval(ovalx5,ovaly5,width,height);
                 g.setColor(Color.black);
                 g.fillOval(ovalxb6,ovalyb6, 25,25); 
                 g.setColor(Color.orange); 
                 g.fillOval(ovalx6,ovaly6,width,height);
                //schietding
                 g.fillRect(xpos2+350-17,317,6,40);
                 g.setColor(Color.green);
                 g.fillOval(xpos2+350-30,330,30,30);
                 g.setColor(Color.black);
                 g.fillRect(xpos2+350-40,350,50,height);
                //kogel
                 g.fillRect(xposkogel+350-16,yposkogel,5,5);     
                 public class AnimationDemo{
                     JFrame frame;
                     Animation animation;
                     void demo(){
                         frame=new JFrame("**Spees Inveeders** All rights reserved (Dave Senden and Joeri Oomen)");
                         animation=new Animation();
                         frame.getContentPane().add(animation);
                         frame.setSize(700,400);
                         frame.setVisible(true);
                         animation.start();
      public static void main(String[] args){
            AnimationDemo animationDemo=new AnimationDemo();
            animationDemo.demo();
            }

Maybe you are looking for

  • Deleting sub-folders on C: drive

    When I moved my music to an external drive last year, I didn't choose the preference, "Copy files to iTunes music folder when adding to library". I realize now that everything that I burned or bought is still going to the C: drive. I could really use

  • Printed a shared calendar with tasks

    I need to print my boss's daily calendar with the tasks listed on the right side, but although both his calendar are tasks are shared with me and I can view them, it won't let me print the calendar with the tasks from my outlook.  From other discussi

  • DHCP beginning address problem.

    Hi guys, I cannot understand how to configure my TC. I put exactly the same network settings as they were in the Airport Express to share the Internet connection. Everything works fine except the internet itself. The problem as I see it is that dhcp

  • Trasaction code for invoices detail which has hit the WBS element

    Hi All Usually my users receive a list of assets which were capitalized from AUC account through Project system. Generally charges are posted to WBS element and then users capitalize assets using that WBS element through settlement. Users have been a

  • Customer creation

    I have to create a customer using VD01 T-Code. This is as per the configuration guide. Steps to create the customer 1.Select the account group General Customers and define the customer F_CUST as follows: Sales Organization: 1000 Distribution Channel