Carry out hitTest with two child

I've been trying to carry out hitTest with the two child. They are namely enemy and weapon. However, it seems not working. I had been attempting to sort it out myself and searched the Internet but I got no idea of how to solve it. Please help if you know it! Many thanks!
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function enterFrameHandler(event:Event)
     if (char_mc.x + char_width > stage.stageWidth)
          char_mc.x = stage.stageWidth - char_width;
     else if (char_mc.x-char_width<0)
          char_mc.x = char_width;
     if (char_mc.hitTestObject(enemy))
          char_mc.gotoAndPlay(31);
          stage.removeEventListener(KeyboardEvent.KEY_UP, KeyUpHandler);
          stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
          stage.removeEventListener(KeyboardEvent.KEY_DOWN, charControl);
          new_x = 0;
          removeChild(enemy);
     if (weapon.hitTestObject(enemy))
          removeChild(enemy);

After I tried tracing the collision, it showed there was no collision detected. I would paste all the code here for your convenience. Thanks!
P.S. In this game, you can control the character movement by clicking left or right on keyboard. And attack the enemy by pressing spacebar. It is expected when the weapon hit the enemy, the enemy will disappear.
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
stop();
var pressKey:Boolean=false;
var dx:Number;
dx = char_mc.x;
var new_x:Number = 0;
var char_width:Number = char_mc.width / 2;
var mp:Number = 1000;
var enemy:Enemy = new Enemy();
addChild(enemy);
enemy.x = 820;
enemy.y = 150;
var weapon:Weapon = new Weapon();
var mpTimer:Timer = new Timer(25);
mpTimer.start();
stage.addEventListener(Event.ENTER_FRAME, refreshX);
stage.addEventListener(KeyboardEvent.KEY_DOWN, charControl);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
mpTimer.addEventListener(TimerEvent.TIMER, addMP);
function addMP(event:TimerEvent)
     if (mp < 1000)
          mp +=  1;
     else{
          mp=1000;
function enterFrameHandler(event:Event)
{mpText.text= "MP: " + String(mp);
     if (char_mc.x + char_width > stage.stageWidth)
          char_mc.x = stage.stageWidth - char_width;
     else if (char_mc.x-char_width<0)
          char_mc.x = char_width;
     if (char_mc.hitTestObject(enemy))
          char_mc.gotoAndPlay(31);
          stage.removeEventListener(KeyboardEvent.KEY_UP, KeyUpHandler);
          stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
          stage.removeEventListener(KeyboardEvent.KEY_DOWN, charControl);
          new_x = 0;
          removeChild(enemy);
     if (weapon.hitTestObject(enemy))
          removeChild(enemy);
          trace("success");
function charControl(event:KeyboardEvent)
     switch (event.keyCode)
          case Keyboard.RIGHT :
               new_x = 4;
               char_mc.play();
               break;
          case Keyboard.LEFT :
               new_x = -4;
               char_mc.play();
               break;
          case Keyboard.SPACE :
          if(mp>150 && pressKey==false){
               var weapon:Weapon = new Weapon();
               addChild(weapon);
               weapon.x = char_mc.width*1.75 + char_mc.x;
               weapon.y = 190;
               mp-=150;
               pressKey=true;
               break;
function KeyUpHandler(event:KeyboardEvent)
     switch (event.keyCode)
          case Keyboard.RIGHT :
               new_x = 0;
               char_mc.stop();
               break;
          case Keyboard.LEFT :
               new_x = 0;
               char_mc.stop();
     pressKey=false;
function refreshX(event:Event)
     dx = char_mc.x;
     char_mc.x = dx + new_x;

Similar Messages

  • Master table with two child tables in ADF Framework

    Hi,
    I'm trying to implement single master with two detail tables using oracle adf framework of Jdev 11.1.1.4.0. I'm able to do single master-detail by using view link but unable to achieve nested details block i.e., master with nested child blocks.
    I created Query based view object of Master and two query based view objects as details. Then I created two view link for master with first child and another view link for master with second child. Even then in my data controls I see as two different components which is incorrect.
    Please let me know how to create a data control for an example shown below:
    Fruits [MASTER]
    --- Details of Fruits as adf table
    -- Apples [FIRST CHILD]
    ---- Details of Apples as adf table
    -- Oranges [SECOND CHILD]
    ---- Details of Oranges as adf table
    Regards,
    Amar.

    You need two viewLinks
    Fruits->Apples
    Fruits->Oranges
    Then in the data model you pick the Fruits entry that has:
    Fruits
    |--->Apples
    You stand on Fruits and you shuttle the Oranges to be under it from the left.
    If you'll use the default HR schema you'll see this type of relation for Employees:
    https://blogs.oracle.com/shay/entry/master_with_two_details_on_the

  • Filling temporary table with two other tables.

    Hi everyone,
    In an start routine, I would like to do the following :
    read values in an internal table, save it in temporary table tab1.
    read values in an internal table (the same with a different request) and save it in temporary table tab2.
    save with no duplicate keys and in a sorted table tab3 the result of the two tables.
    I have coded like this, but it doesn't work, since the final table is empty.
    Indeed, the system says it is tried to insert a duplicate key. How is it possible using instruction INSERT ?
        DATA : t_agence_1 TYPE SORTED TABLE OF ty_agence
                       WITH UNIQUE KEY /BIC/C_AGENCE2
                       WITH HEADER LINE.
        DATA : t_agence_2 TYPE SORTED TABLE OF ty_agence
                       WITH UNIQUE KEY /BIC/C_AGENCE2
                       WITH HEADER LINE.
        DATA : t_agence TYPE SORTED TABLE OF ty_agence
                       WITH UNIQUE KEY /BIC/C_AGENCE2
                       WITH HEADER LINE.
    SELECT * FROM /BIC/PC_AGENCE2
          INTO CORRESPONDING FIELDS OF TABLE t_agence_1
          FOR ALL ENTRIES IN DATA_PACKAGE
               WHERE CALMONTH = DATA_PACKAGE-CALMONTH
               AND /BIC/C_AGENCE2 = DATA_PACKAGE-/BIC/C_AG1
               AND objvers = 'A'.
         IF sy-subrc = 0.
           INSERT LINES OF t_agence_1 INTO TABLE t_agence.
         endif.
       SELECT * FROM /BIC/PC_AGENCE2
          INTO CORRESPONDING FIELDS OF TABLE t_agence_2
          FOR ALL ENTRIES IN DATA_PACKAGE
               WHERE CALMONTH = DATA_PACKAGE-CALMONTH
               AND /BIC/C_AGENCE2 = DATA_PACKAGE-/BIC/C_AG2
               AND objvers = 'A'.
       IF sy-subrc = 0.
              INSERT LINES OF t_agence_2 INTO TABLE t_agence.
       endif.
    Thanks if you can help !
    regards
    fred
    Edited by: Christophe BELIN on Dec 5, 2008 3:43 PM

    Shanon,
    You would handle the parent with two child tables exactly the same way you would a parent with one child.
    1) Bring in all 3 tables through the Database Expert.
    2) On the Links Tab, place the parent table on the left of the window and the two child tables to the right (yes there is a reason for doing this).
    3) Delete any CR generated links between the tables.
    4) "Draw" a link that starts from the parent table to the 1st child table and then again, from the parent to the 2nd child.
    a. I'm assuming that you know which fields to link on.
    b. No links between children.
    5) Once you have both links in place right click them and change the "Link Type" to "Left Outer Join"
    a. The reason for doing this: It allows ALL of the parent records to come through, even if they do not have any matching records in
    one or both of the child tables.
    Hope this helps,
    Jason

  • Unable to carry out MRP for make-to-order

    Dear All,
    I have a six level Bill of Material ( BOM ) .I am using planning strategy 20 make-to-order producton.
    There is no stock for any of these materials.
    Now when i try to run mrp on sales order basis it is not planning for all the levels of the BOM.The MRP Stops planning at 3 or 4th level.The MRP Run does not give any error.
    Is there any setting to carry out MRP out MRP for all level of BOM?
    I checked the setting in 0001 plant and compared them with my plant they are same.THE SYSTEM IS DOING MRP IN 0001 PLANT FOR ALL LEVELS
    so pleses help me on these issue.
    Regards
    Prashant

    Hy Prashant,
    If you want to carry out MRP with MD50 for all levels of BOM then check this things,
    For all the BOM components (up to last level) check in MRP 4 view of Material master
    - Individual / Collective - It should be Individual or Individual/Collective.
    If is maintain as Collective then you will not get planing Proposals though MD50.
    - For all BOM headers Materials (Fert , Halb ) check in MRP 4 view for MRP for Dependent requirement should be maintain as Dependent requirement are Planned
    Check the above things and if not maintain then maintain it and then run MRP with MD50.You will get the Planing proposals for all levels of BOM.
    Regards,
    Dhaval

  • Adjusting brightness with two 24" LED Cinema Displays

    I'm wondering if there are any other Mac Pro users out there with two 24" LED Cinema Displays? If so, are you able to adjust the brightness of both displays? For me, no matter which brightness slider I adjust in System Preferences, only the brightness of one of the displays is adjusted.
    I originally created a thread last September:
    http://discussions.apple.com/thread.jspa?threadID=2160532
    If you have this problem too, please report it to <http://bugreporter.apple.com/>. My original Radar bug was #7222745, and it was found to be a duplicate of #6828443. Based on the IDs, I'd say this has been a known issue for at least a year.
    Thanks,
    Patrick

    I filed a bug report at bugreporter.apple.com, and received a pretty quick reply:
    This is a follow up to Bug ID# 7222745. After further investigation it has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 6828443. The original bug number being used to track this duplicate issue can be found in the State column, in this format: Duplicate/OrigBug#.
    Looks like I'm S.O.L. until they fix this!

  • Unable to carry out calculation of keyfigure with it's total summation taken on keyfigure

    Hi,
    For a requirement, we are trying to calculate division of a keyfigure with it's total summation of key figure.
    For example:
    Sales Office
    Order Reason
    Invoice Volume
    MRV Volume
    % of MRV Volume to total invoice volume
    % of MRV Volume to total MRV volume
    1504
    A1
    10
    2
    (2/90) = 2.22
    (2/27) = 7.40
    A2
    5
    3
    3.33
    11.11
    A3
    20
    10
    11.11
    37.03
    A4
    30
    5
    5.55
    18.51
    A5
    25
    7
    7.77
    25.92
    Total
    90
    27
    30
    100
    Here, Sales office and order reason are dimensions.
    Invoice volume and MRV volume are key figures.
    Following are the formula used to calculate other two keyfigures.
    % of MRV Volume to total invoice volume =  MRV Volume / Total ( Invoice Volume ) * 100
    % of MRV Volume to total   = MRV Volume / Total ( MRV Volume) * 100
    Kindly help us to get calculation of above two keyfigures to be carried out through BEx query designer.
    I tried out aggregation at order reason on Invoice volume, MRV Volume by creating two new formula keyfigures with the aggregation, but couldn't get desired output.
    Regards,
    Antony Jerald.

    Hi Antony,
    Use the same formula for these two keyfigures in BEx with SUMGT instead of Total.
    % of MRV Volume to total invoice volume =  MRV Volume / SUMGT ( Invoice Volume ) * 100
    % of MRV Volume to total   = MRV Volume / SUMGT ( MRV Volume) * 100
    Regards,
    Srilakshmi B

  • How do you carry out an event if a job finishes with a return code 4?

    Hi
    A job which would complete successfully in SAP via the SM36 scheduler completes with an 'Error' in Redwood CPS because there are errors within the spool and it ends with a return code 4.
    We don't want this to error in Redwood CPS, so we have set the return code mapping to Completed with entries of 0 and 4.
    I.e. whether or not there is an error in the spool, the job will complete successfully in Redwood CPS.
    However, we want to be alerted if there are errors in the spool.
    How do we do this? The manual says "A job can raise one or more events when the job gets a specific job status or return code" - where is this set? I can see on the 'Event' tab of a job definition you can raise an Event when the job enters a specific status, but I only want to raise an event (or carry out a step / send an email etc) if I get a return code 4 (none of the job statuses are relevant) - how can I do this?
    Thanks
    Ross

    Hi Anton
    Thanks for that. However, it's a bit more complicated...
    I have a job chain with 2 steps. Any one of the two steps can have an error in the spool which by default in Redwood CPS result in the job ending in status Error. I don't want this, as the second step should still run if the first step ran okay with with errors in the spool (but shouldn't run at all if the 1st step fails completely). I.e. setting 'on Error goto step 2' or having no dependancy at all is not what we want.
    Therefore, I set the return code mapping on Completed to return codes 0 and 4. I.e. if step 1 has an error in the spool (return code 4) it still ends as 'Completed' and step 2 runs.
    Our problem is that we want to be alerted if there is a return code 4 (error in the spool). I tried as you suggested by entering on the 'Raise Event' tab of the job chain to raise an event on status 'Error' with a return code of 4. But no event was raised. I think this is because the return code mapping is setting the status to 'Completed' (on return code 0 or 4) BEFORE the software checks the status; i.e. the status is actually 'Completed' (rc=4) and not 'Error' (rc=4) so an event is not raised.
    Ideally I want to set the Event to be raised on status 'Completed' with a return code 4 - but when I select 'Completed' the 'Error Code' box is greyed out.
    I.e. can't set this - I can only set on a generic 'Completed' and I don't want to raise a message if the status is Completed but the return code is 0....
    Any ideas??
    Ross

  • I currently have a mbp with two internal hard drives ( took super drive out) which for a video editor like myself is a dream I can edit video anywhere, my question can I order a new mbp with 2 internal flash drives?

    I currently have a mbp 2.3 gighuz intel core 7 16 gig of ram with two internal hard drives ( took super drive out) which for a video editor like myself is a dream I can edit video anywhere, my question can I order a new mbp with 2 internal flash drives?

    I wouldn't think so because the newer ones with Retina displays don't have an internal SuperDrive that can be replaced. Therefore the newer logic boards wouldn't have the two SATA/SATA Express connections on the logic board.
    At least that was the case as of 2012. I've seen newer ones and they also don't have a SuperDrive.

  • Is there a way to find out how long my child has been playing with my ipad

    Is there a way to find out how long my child has been playing with my ipad???  He has been getting up before me in the morning and in the evening he is super tired and I'm wondering how early he has been getting up????

    No way to see exactly how long the iPad has been used but you may want to consider using parental controls.
    iOS: Understanding Restrictions (parental controls)

  • *The operation cannot be carried out with this node type*

    Hi Friends,
    My requirement is :
    PO in IS retail system--(IDOC ORDERS)--Sales Order processing-->Sales order in AFS system
    where AFS is apparel footwear solution used in retail industries.
    Now I have created PO in IS-retail system , and IDOC is successfully generated .
    After this I am checking this IDOC in AFS system thru  tcode BD87 for processing but getting error mesage in next screen when I am executing BD87 after putting the IDOC number.
    The operation cannot be carried out with this node type
    Message no. B1891
    Diagnosis
    Node types such as logical system, inbound and outbound IDocs or filter nodes are used only for the structure and for information. They cannot
    be used for processing and display functions.
    Any pointers .
    Regards
    Ashu

    a

  • HT1920 I have two accounts with iTunes, I would like to make one account out of the two?

    I have two accounts with iTunes, I would like to make one out of the two?

    Welcome to the Apple Community.
    You can't.
    You can't merge accounts or transfer content.

  • Firefox 4 does not support zoom-in/out with two fingers on Windows 7 with a multi-touch scrren, IE8 does.

    I have a HP 2740p notebook with multi-touch support. With IE8, I can zoom-in/out the web page with two fingers, but I can not with Firefox 4. It seems that FF4 only support basic touch (scroll with finger)

    Some prefs have been reset to empty values.
    You can check and change these prefs on the <b>about:config</b> page
    browser.gesture.pinch.in cmd_fullZoomReduce
    browser.gesture.pinch.in.shift cmd_fullZoomReset
    browser.gesture.pinch.out cmd_fullZoomEnlarge
    browser.gesture.pinch.out.shift cmd_fullZoomReset
    See also:
    * http://kb.mozillazine.org/about%3Aconfig

  • My ipad will not sync with all my music and films in my itunes library. I have just carried out a restart and sync again but still not showing all my music or films.

    My ipad will not sync with my library in itunes, i have music and films in my itunes library but they will not transfer to my ipad. I have just carried out a restart to factory settings and then sync of my back up but still no joy. Any suggestions?

    Have you selected the content to sync to your iPad in your sync settings in iTunes. The content that you want to transfer must be selected (checked or "ticked") to sync out will not transfer when you sync.
    For instance - if you want to sync music....
    Connect the iPad to the computer and launch iTunes.
    Click on the iPad name on the left side under devices.
    Click on the Music Tab on the right.
    Click on the albums or playlists that you want to sync - or the entire library if you like.
    Click on the Sync Music Heading.
    Click on Apply in the lower right corner of iTunes
    This applies to all content that you want to transfer from iTunes to your iPad. Make the selections in the appropriate tabs in the iTunes window on the right.

  • HT204370 My movies' audio isnt 5.1 as the description says. when I check out their info it says they are 2 channel. I have tried with two movies already and the audio description said Dolby 5.1

    My movies' audio isnt 5.1 as the description says. when I check out their info it says they are 2 channel. I have tried with two movies already and the audio description said Dolby 5.1

    Actually, try this instead. On the apple tv, under settings > Audio > Dolby digital
    Change it From AUTO (default) to ON
    That worked for me. All my eyetv encodes have stereo and 5.1 tracks. For some reason the auto option forces stereo. Setting it to ON forces the 5.1.
    Everything sounds nice again! It's just stupid that apple puts AUTO for the default and that setting results in stereo not 5.1.

  • I have recently installed Mavericks and since then I have been unable to shut down or log out of my mac.  I work with two screens and now I seem to have programmes at the top of both screens which I didn't before.  any advice?

    I have recently installed Mavericks on my desk top and since then I have been unable to switch off my computer without crashing it. I work with two screen and now I seem to have the menu bar on the second screen as well which I did not have before.  Can you please help me?

    Dr Bettina, I had similar problems with Mavericks. I installed it on a Mini and a 13" MacBook Pro. I can't speak to your disdplay issues, but I can confirm the inability to logout, shut down, or restarft without a forced, power button shut down. I can also report frequent System Prefs freezes and finder issues, like folder contents taking half a minuite or more to render, or not appearing at all. And while a few Adobe CC apps actually ran faster, InDesign ran like molasses uphill in Decemner.
    I tried uninstalling or disabling numerous 3rd party apps and pref panes. I unplugged everything but the keyboard, ran DiskWarrier, repaired permissions, did fsck -f, trashed various preference files, reinstalled the OS... You name it, and I tried it — short of a potion using eye of newt.
    After two days of totally hosed productivity, I restored OS 10.8.5 on the Mini so I could actually get some work done. However, I've decided to leave Mavericks on the MBP as a sort of crash dummy, and will install and thoroughly test all updates until stability has been achieved. Then — and only then — will I upgrade the Mini to Mavericks, even if it means waiting 'til a .2 or even .3 update.
    Good luck to you...

Maybe you are looking for