Best way to add a score to a score box and total it up.

I am creating a game for children to make good food choices
for breakfast, lunch, dinner, and snacks. I need to have the food
choice add a value to a score box when clicked onto the plate and
subtract the same amount when clicked off. So far, all I have been
able to do is get the score to appear in the upper left hand
corner. When I can get the pancakes working properly, I will be
adding other foods which will do the same thing with different
numbers. The total score cannot go over 100. I am attaching the .as
code, but it is separate from the .fla and I'm not sure if I can
upload the .fla here.

That worked! Now, I have another problem I can't seem to
figure out--when I add another food, berries, all it is doing is
moving the pancakes and not itself! Here is the revised coding:
package
//import any class being used by this package
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.events.MouseEvent;
public class MealGame extends MovieClip
//altered version
var offPlate:Boolean; //variable for food off the plate
var gameScore:int = 0;
public function MealGame()
//Create a score field for the pancakes.
var gameScoreField:TextField = new TextField();
// set the position values
gameScoreField.x = 445;
gameScoreField.y = 530;
//Show the score field
addChild(gameScoreField);
var tf:TextFormat = new TextFormat();
var scoreBox:Object = getChildAt(numChildren-1);
//scoreBox.x = 445;
//scoreBox.y = 530;
//Create a new instance of the meal class.
var pancakes1:Pancakes = new Pancakes();
var berries1:Berries = new Berries();
//Display the food on this stage.
this.addChild(pancakes1);
this.addChild(berries1);
//Position the food item.
pancakes1.x = 11;
pancakes1.y = 42;
berries1.x = 211;
berries1.y = 396;
offPlate = true;
//make the food item a button
pancakes1.buttonMode = true;
pancakes1.addEventListener(MouseEvent.CLICK, onClick);
berries1.buttonMode = true;
berries1.addEventListener(MouseEvent.CLICK, onClick);
//toggle the food item to put on plate or off the plate
//toggle adding to the score or removing from the score
function onClick(event:MouseEvent):void
if(offPlate)
pancakes1.x = 119;
pancakes1.y = 380;
berries1.x = 515;
berries1.y = 55;
//add to score
gameScore = gameScore + 50;
gameScoreField.text = " " + String(gameScore);
tf.font = "Arial";
tf.bold = true;
tf.color = 0x000000;
tf.size = 32;
//Take this text formatting object; apply it to the
textfield
gameScoreField.setTextFormat(tf);
//toggle the offPlate value
offPlate = !offPlate;
else
pancakes1.x = 11;
pancakes1.y = 42;
//berries1.x = 211;
//berries1.y = 396;
//remove from score
gameScore = gameScore - 50;
gameScoreField.text = " " + String(gameScore);
tf.font = "Arial";
tf.bold = true;
tf.color = 0x000000;
tf.size = 32;
//tf.x = 426;
//Take this text formatting object; apply it to the
textfield
gameScoreField.setTextFormat(tf);
offPlate = !offPlate;
}

Similar Messages

  • What is the best way to add text to an image

    I used the draw ap div to add text to an image.  will that cause any problems?  If so, what is the best way to add text to an image?  Thanks!

    APDivs will kill your design unless you fully understand the css behind the scenes and plan accordingly. They really are completely unnecessary in the vast majority of situations.
    An easy way to add "web text over an image" would be to use the background-image attribute in css for a standard <div> tag, then just add the text within that same <div>.
    Something like this in the css (if you are using a 300x300 pixel image)...
    #yourdiv {
         background-image:url(yourpic.jpg);
         width:300px;
         height:300px;
    And then this in the html...
    <div id="yourdiv">Your text here</div>
    You would then position the <div> using css margins, floats and padding. Using position:absolute (APDivs) is typically something that will blow your design to pieces if the viewer changes their browser settings.

  • What is the best way to add hard disk space to macbook pro?

    I'm running out of disk space on my macbook pro. What is the best way to add disk space?

    another way of doing it is to replace your hard drive with a larger one.
    if you're technically capable, it takes 10 minutes for the swap and an hour minimum to clone your hard drive or do a data transfer.  all depends on how much data there is to trandfer or to clone.
    good luck.

  • What is the best way to add libraries to a project?

    What is the best way to add technologies to ADF? For example log4j. Or does the embedded logger have log4j features?

    HI,
    Hope helpful
    http://technology.amis.nl/blog/8380/manage-jdeveloper-external-libraries

  • What is the Best Way to add a shopping cart?

    What is the best way to add a shopping cart?
    Thanks.

    See that field at the top right that says "Search Forums"? Try Dreamweaver shopping cart. You'll get a lot of answers.

  • Best way to add a new section in the middle of a tune?

    hi,
    what's best way to add a new section in the middle of a tune? I think I came up with an interesting transition to a tune... what's the best way to try it out?
    please be specific. if it's just select all and cut and move - I already know that one. somehow, I bet there's a better way.
    thanks in advance...

    You should be able to enter the "in" and out" points in the transport bar. And then under the Region menu, choose "Cut/Insert time."
    So if, for instance, you go up to bar 32, and want to add 8 bars, enter 32 1 1 1 in the top transport place, and 40 1 1 1 in the second. Then select "Cut/Insert Time", and an 8 bar whole will be added to your song.
    Be aware that if there are overlapping MIDI notes found at that cut point, Logic will warn you about it, and give you some options. In this case, I think "Keep" would be what you'd want, but every situation is different...
    Hope that helps....

  • Best way to add new post link

    What would be the best way to add a "new post" link on the main homepage that links to the appropriate blog page. Ideally, I'd like to put a small photo too.
    Is the only way to manually add it every time I update, or is there a better way?
    Thanks, Jill

    You can do it any number of ways. Link a shape, link text, or link a photo to the appropriate blog page, using the Inspector from the tool bar at the bottom of the iWeb window.
    You are correct that the only way is to manually update each time. I don't know of any method to get the blog entries to auto update an indicator on the Home page in iWeb.
    I have a site for a current project I'm on that has a "Shot of the Day" link on the Home page. As the site has gotten large, I have a duplicate of the Domain file for this site that contains nothing but this Home page. I update the page and then simply swap out the files on the server with the updated ones. Makes opening, editing, and saving the changes faster and easier than publishing the entire site each time. Here's an example of how I placed the link on the Home page...
    Mark

  • Best way for add thousans items to listbox without freezing ui in wpf

    Hello guys.
    What is the best way for add thousands items (or even more) to Listbox without freezing UI.
    I search many post in the web but I don't understand how this posts writer wrote that code.
    I realized that ObservableCollection can contain 1000 items or even more and show that items to listbox just for few second without freezing UI but I don't Know how can I use that!
    Can you guys give me an example.
    thanks.

    If you bind an observablecollection you can add items to that from a background thread.  Then bind that to the itemssource.  I usually new up an observablecollection, add the items then set the bound property to  that.
    But I avoid thousands of items. 
    You should provide some sort of filter mechanism the user chooses a category or whatever and then fill with a maximum of 300 items.
    Users simply can't work with thousands of items.
    It is usually reading the data out  a database which takes the time rather than creating objects to bind.
    Hence this:
    protected async override void GetData()
    ThrobberVisible = Visibility.Visible;
    ObservableCollection<CustomerVM> _customers = new ObservableCollection<CustomerVM>();
    var customers = await (from c in db.Customers
    orderby c.CustomerName
    select c).ToListAsync();
    foreach (Customer cust in customers)
    _customers.Add(new CustomerVM { IsNew = false, TheEntity = cust });
    Customers = _customers;
    RaisePropertyChanged("Customers");
    ThrobberVisible = Visibility.Collapsed;
    That's making an asynchronous entity framework call.
    A list of customers is obtained.
    These are then wrapped in a customer viewmodel each.
    Finally the observablecollection Customers is set to this new collection and propertychanged raised to notify the view.
    The itemssource of a datagrid is bound to Customers.
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • Best way to format my 16GB flash drive for Mac and PC transferring large power point files?

    best way to format my 16GB flash drive for Mac and PC transferring large power point files?

    format flash drive in Exfat for transferring files between Mac and Pc.
    FORMAT TYPES
    FAT32 (File Allocation Table)
    Read/Write FAT32 from both native Windows and native Mac OS X.
    Maximum file size: 4GB.
    Maximum volume size: 2TB
    You can use this format if you share the drive between Mac OS X and Windows computers and have no files larger than 4GB.
    NTFS (Windows NT File System)
    Read/Write NTFS from native Windows.
    Read only NTFS from native Mac OS X
    To Read/Write/Format NTFS from Mac OS X, here are some alternatives:
    For Mac OS X 10.4 or later (32 or 64-bit), install Paragon (approx $20) (Best Choice for Lion)
    Native NTFS support can be enabled in Snow Leopard and Lion, but is not advisable, due to instability.
    AirPort Extreme (802.11n) and Time Capsule do not support NTFS
    Maximum file size: 16 TB
    Maximum volume size: 256TB
    You can use this format if you routinely share a drive with multiple Windows systems.
    HFS+ ((((MAC FORMAT)))) (Hierarchical File System, a.k.a. Mac OS Extended (Journaled) Don't use case-sensitive)
    Read/Write HFS+ from native Mac OS X
    Required for Time Machine or Carbon Copy Cloner or SuperDuper! backups of Mac internal hard drive.
    To Read HFS+ (but not Write) from Windows, Install HFSExplorer
    Maximum file size: 8EiB
    Maximum volume size: 8EiB
    You can use this format if you only use the drive with Mac OS X, or use it for backups of your Mac OS X internal drive, or if you only share it with one Windows PC (with MacDrive installed on the PC)
    EXFAT (FAT64)
    Supported in Mac OS X only in 10.6.5 or later.
    Not all Windows versions support exFAT. 
    exFAT (Extended File Allocation Table)
    AirPort Extreme (802.11n) and Time Capsule do not support exFAT
    Maximum file size: 16 EiB
    Maximum volume size: 64 ZiB
    You can use this format if it is supported by all computers with which you intend to share the drive.  See "disadvantages" for details.

  • What is the best way to create a read more/collapse text box on the homepage of a site?

    What is the best way to create a read more/collapse text box on the homepage of a site?

    I figured this out by using a lightbox. I set the trigger at the top of the box, hid all initially and added a close button. In the box that would have linked to the first thumbnail for the lightbox, I added a text box that said "read more"

  • TS1324 What is the best way to sync my Outlook 2010 to my iPhone and iPad

    What is the best way to sync my Outlook 2010 to my iPhone and iPad.

    Note, I'm on the latest iOS - not 6.1.1 as the original post suggests.

  • What is the best way to add external C++ code to LabView 6.1?

    I have various C++ class-based DLL's written with Visual Studio 6.0 and wish
    to create instances of these C++ classes and call their methods in LabView
    6.1. What is the best way to do this?
    It seems based on the little reading I have done that there are two choices:
    1. Wrap the C++ class as a simple COM control and use LabView's COM based
    VIs to create a COM object and access the methods of various interfaces.
    2. Wrap the C++ class methods as C functions and a "constructor" and
    "destructor" C function to create and destroy an instance of the class. Then
    use LabView's DLL call support.
    Which is best? What direction is LabView going to take that better supports
    the notion of C++ class libraries?
    Thanks,
    Te
    rry

    You could also try using a CIN. This is a tool that LabVIEW provides for interfacing with external code.
    The CINTools libraries of LabVIEW allow you to embed compiled C code into a particular Virtual Instrument (VI) using a CIN.
    In order for LabVIEW to be capable of calling compiled functions of C from a running VI, the code must be loaded and unloaded into memory at the same time as the VI code itself. LabVIEW uses object code in the form of a .lsb file which is generated by the C compiler from the C source code using the ntlvsbm.mak file. This ntlvsbm.mak file is included in the CINtools directory in the LabVIEW folder. You also must create another .mak file which includes parameter definitions for the ntlvsbm.mak file and also includes a call to the LabVIEW .mak file.
    The generic documentation for CINs only explains how to use them to call C compiled code from a LabVIEW VI. It shows several development environments such as Visual C++, but in essence it only allows the user to create .lsb files out of plain C source code ( .c ) through C compilers on those environments.
    The question now is how can I create .lsb files from C++ native source code using a C++ compiler. Furthermore, how can I create a .lsb file from several C++ source code files (.cpp) and make calls to C++ functions from a VI using CINs? The following explains how to do this:
    1) Drop a Code Interface Node (from the Advanced Subpalette of the Functions Palette) into the LabVIEW VI. Make sure to wire the inputs.
    2) Right-click on the CIN and choose "Create.c File...", then in the file dialog box specify a "name.cpp" file name. (very important: use .cpp extension)
    3) Then create a name.mak makefile (text file) and add the following lines :
    name=name_of_cpp_file_without_the_extension
    type=CIN
    cinlibraries=Kernel32.lib
    CINTOOLSDIR=path_to_cintools_directory
    !include <$(CINTOOLSDIR)\ntlvsb.mak>
    4) Go into Visual C++ and File>Open and open the .mak file. You can even Add the name.cpp file to the project to make it easier to edit. Select that name.cpp or open it as a text file in NotePad or and edit the prototypes of the CIN MgErr functions as shown below, adding extern "C" at the beginning of the line. extern "C" CIN MgErr CINRun(float64 *INPUT);3) Select Build.exe to create the "name.lsb" file. To import the .lsb into LabVIEW, right-click on the CIN and choose "Load Code Resource...". Then, choose the name.lsb file and it is ready to run!
    If you want to use several C++ source code files with .cpp extensions, then compile them in Visual C++ and link them to name.cpp and create a .lsb by modifying the name.mak as follows:
    name=name_of_cpp_file_without_the_extension
    otherobj=other_cpp_files_BUT_USING_.obj_extension
    type=CIN
    cinlibraries=Kernel32.lib
    CINTOOLSDIR=path_to_cintools_directory
    !include <$(CINTOOLSDIR)\ntlvsbm.mak>
    It's worth a try? I have also heard of using clusters to represent classes, so you could check that out.
    J.R. Allen

  • What is the best way to add "meta tags" in edge?

    Trying to add meta tags for search engines, what are the best ways to do this?

    With the latest version of Edge (3.0) is still the best practice to edit index.html or is there a better one?
    Y try for example...
    var meta1 = '<meta name="robots" content="index, follow" />';
    $(meta1).appendTo("head");
    ...in creationComplete or in document.compositionReady but I can't see these lines in index.html file, are stored in index_edgeActions.js file.
    But maybe that works to attach the meta tags with append to head because it does work fine (and neither are saved in the index.html):
    var favicon = "<link rel='shortcut icon' href='images/volicon.png' type='image/png'/>" ;
    $(favicon).appendTo("head");
    I don't know if Google detect meta tags stored in index_edgeAtions.js or is more recommended to modify index.html manually with notepad.
    Maybe the best practice are save and publish Edge project with a name different than index (for example project.an and project.html) and to create an index.html manually with meta tags, code of Google Analytics and Google Tag Manager, etc., and with HTML meta http-equiv Attribute for to redirect immediately to project.html generate with Edge (remember disallow project.html in robots.txt). In this way is not necessary to modify the index.html file each time that we publish.
    How do you see?

  • Best way to add mass unorganized mp3 library to iTunes to stream on AppleTV

    Ok so I have a fairly large mp3 collection(well over 100 GB).  It is somewhat organized.  It is all on an external HDD under the folder music then from there there are subfolders for genres, then bands, then albums.  I am not sure I want to add all of it to my itunes library since there is a lot of it I never use, but I would like to add a good chunk of it to the itunes library so I can stream it to my appletv in the other room.  I am trying to figure out the best way to do this. If I click "add folder to library" it only lets me select the Main Music folder instead of the subfolders inside.  Any suggestions on how to simplify a mass add to the library would be much appreciatted.  Thanks in advance.

    If I click "add folder to library" it only lets me select the Main Music folder instead of the subfolders inside.
    That is not correct.  When you click File > Add Folder to LIbrary, it opens a dialog from which you can navigate to any folder.  If it happens to start with Music, then double-click to open until you find the folder you want, and then click Select.
    Try it first with a small folder so you can see how it arranges the music within iTunes.  Once you are happy with it, start doing slightly larger batches.

  • Best way to add numbers or layout multiple pages

    I have a ticket that needs to be numbered. It is small enough to go 5 up on a sheet that is 8.5 x 11.
    Each ticket needs to be numbered.
    I can make a master page and add all of the numbers that way and then make a pdf.
    What is the best way to get the numbers on tickets that are printing 5 up on a sheet and I can print through a copier?

    There are many ways to do this:
    1. create single page tickets, auto-numbered, and use imposition feature of copier (if available and access to)
    2. use data merge with numbered list, and produce multiple record layout to create a 5-up document
    3. create a 5-up template with threaded text frames for numbering, import a numbered list that flows through document

Maybe you are looking for

  • AC3 "The base specified is a native class..."??

    Hello, I'm having a problem with linking one of my symbols to my document class.  I went under Properties in my symbol drop-down list and put the correct base class in their (flash.display.MovieClip), however it keeps giving me this error when I clic

  • Dynamic columns in ALV

    Dear Experts, I want to display dynamc columns in ALV, how it possible. venkey

  • Camera Raw 4.1 Fails to Install Completely

    Just installed CS3 on a Windows Xp, SP2 system. All of the updates downloaded successfully, all installed successfully except Camera Raw 4.1. Tried it four times on my system. Then tried to download and install through Bridge with the same result. Th

  • Annoying default landscape orientation!!!

    I like to use my TouchPad in landscape mode resting on my desk, propped up by the case with the speakers away from me (or towards the top).  When I go go full screen video on youtube, it rotates upside down, and when I leave full screen or go to card

  • Problems printing PDF-X3 out of Scribus

    Hello everybody, I'm trying to print a PDF-X3 out of Scribus. The X3-compatiliby-check seems to have no problems, but the Distiller says: %%[ ProductName: Distiller ]%% %%[Page: 1]%% %%[Page: 2]%% %%[Page: 3]%% %%[ Error: undefined; OffendingCommand: