Trying to get AS3 game to keep score of user points and not loop when added to Flash CS4 website
Here is my scripting (seperated into two pages) the font in red is causing the drama so far:
package
import flash.display.Sprite;
public class Easymind extends Sprite //Class Definition
private var timer:Timer;
private var count:uint;
private var prevCount:uint;
private var scoreText:TextField;
private var score:uint;
public function Easymind () //Constructor function
init();
private function init():void
var gift:Gift = new Gift();
gift.x = Math.random() * stage.stageWidth; // is the same as (0 to 0.99) * 550
gift.y = Math.random() * stage.stageHeight; // is the same as (0 to 0.99) * 576
addChild(gift);
scoreText = new TextField();
scoreText.x = 500;
scoreText.y = 10;
scoreText.width = 20;
addChild(scoreText);
stage.addEventListener(MouseEvent.MOUSE_DOWN, kill);
timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, addGifts);
timer.start();
private function addGifts(eTimerEvent)
prevCount = count;
count ++;
for (var i:uint = prevCount; i < count; i++)
var gift:Gift = new Gift();
gift.name = "gift" + i;
gift.x = Math.random() * stage.stageWidth; // is the same as (0 to 0.99) * 550
gift.y = Math.random() * stage.stageHeight; // is the same as (0 to 0.99) * 576
addChild(gift);
private function giftShower()
if (this.numChildren > 250)
timer.stop();
var i:int = this.numChildren;
while(i--)
removeChildAt(i);
addChild(scoreText);
SECOND ActionSript PAGE
package
import flash.display.MovieClip;
import flash.events.*;
import flash.utils.Timer;
import flash.text.*;
public dynamic class Gift extends MovieClip
private var dx:Number = Math.random() * 10; // make gift scurry
private var dy:Number = Math.random() * 10;
public function Gift ()
this.gotoAndStop(Math.ceil(Math.random() * 4));
this.addEventListener(Event.ENTER_FRAME, scurry);
stage.addEventListener(MouseEvent.MOUSE_DOWN, kill);
public function scurry (e:Event)
if (this.x < 0 || this.x > 550)
this.dx *= -1;
if (this.y < 0 || this.y > 576)
this.dy *= -1;
this.x += this.dx; // make gift scurry
this.y += this.dy;
public function die()
this.removeEventListener(Event.ENTER_FRAME, scurry);
parent.removeChild(this);
private function kill (e:MouseEvent):void
if(e.target is Gift)
e.target.die();
score += 10;
scoreText.text = score.toString();
and as i mentioned, what's the problem related to that code. the reason i ask is because that code shouldn't compile. specifically,
stage.addEventListener(MouseEvent.MOUSE_DOWN, kill);
timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, addGifts);
timer.start();
is incorrect. and
private function addGifts(eTimerEvent)
prevCount = count;
count ++;
for (var i:uint = prevCount; i < count; i++)
var gift:Gift = new Gift();
gift.name = "gift" + i;
gift.x = Math.random() * stage.stageWidth; // is the same as (0 to 0.99) * 550
gift.y = Math.random() * stage.stageHeight; // is the same as (0 to 0.99) * 576
addChild(gift);
private function giftShower()
is incorrect.
if you don't have a problem with your code compiling, then copy your code and paste it into this forum.
Similar Messages
-
HT4796 how do I keep the same user account and not make a new one when transferring music?
How do I transfer files using the migration assistant and not create a new user profile? I am transferring from Win 7 to Mountain Lion and now the only way I see my music in Itunes is to flip to the new user account created. I am the only one using my mac and its a bit of a pain switching users to listen to music. Any thoughts?
Drag the iTunes folder over manually instead of using the Migration Assistant, or drag the other account's home folder to the desktop, authenticate yourself, and move the music into your main account's iTunes library.
(71926) -
I have home videos from a Sony DCR-HC20 and am trying to get them onto my IMac in itunes or imovie and I have it plugged in with a USB and don't know where it is or what to do next.
Hello, not certain, but turn the Camera onto Play if it has such a setting, does it show up in iMovie then?
-
The updated iPhoto program is cumbersome. I am trying to create a Christmas card and can't figure out how to get the fold of the card on the left and not on the top of the card. I had no trouble with this for the past two years. Can someone help?
Click on the Layout button lower right and choose a Vertical lyout from the dropdown
-
I am trying to get my iPad to print from hp air printer and it only prints on photo paper. How do I fix it to print on paper. I already put setting to copy on printer but it prints blank.
Thank you everyone. I figured it out. I thought that you can use regular paper to print pictures from photos on Ipad. This is not possible. I was able to use regular print paper to print from my mail. My problem is solved!!
-
I was typing an email to friend. I put the ipad down to answer the door and came back a few minutes later and the screen had gone blank and when I tried to get the message that I was typing back I could not find it. The message contained a lot of text and pictures. How can I find it? I have looked in drafts.
Perform a Reset... Try again...
Reset ( No Data will be Lost )
Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
Wait for the Apple logo to Appear...
Usually takes about 15 - 20 Seconds... ( But can take Longer...)
Release the Buttons... -
Hi, I'm using my Ipad 2 trying to get Dance Department's podcast onto my itunes, I already paid the money(bought it on the website) they sent me a link, saying I should copy that link into my Itunes. Advanced>add podcast url. but on the Ipad where do I go?
You don't do it on your iPad. You do it on iTunes on your computer. You might, I suppose, on you iPad, try using an app like Instacast or Downcast. They might also work.
-
I'm trying to get the home sharing set up on my iPhone and iPad and they aren't responding
I'm trying to get the home sharing set up on my iPhone and iPad and they aren't responding
I can upgrade to an Iphone 5 three days early with Verizon? I already have verizon contract, update is on the 20th
-
I have tried downloading ios7 but my phone keeps showing the usb sign and i tunes sign
i have tried downloading ios7 but my phone keeps showing the usb sign and i tunes sign
That is almost always because the phone was hacked to unlock it from the original carrier.
-
i updated itunes 11.1 yesterday and now im trying to get my music on itunes to sync onto my iphone 4s but when i connect it through usb...Itunes is saying " waiting for changes to be applied"? so i dont know what to do cause i just want to sync my music from itunes to my iphone 4s
I had the same problem and the fix was so easy that I felt a little silly after spending 2 hours with an Apple Technician. At the end of it all, what I had to do was make sure ALL music was deleted from my iPhone 5 by going into usage and clearing out the music folder. All I had to do then was turn my phone off and turn it back on again. I had not done this after my phone upgraded to the new 7.0 IOS. What's the first thing you do when experiencing computer problems? Reboot! It fixed my problem and now my iPhone 5 synchs perfectly when I had it connected to my computer. I am also on iTunes version 11.1.
-
I am trying to access a forum for which you need a username and password but it keeps telling me the username/password i've entered are incorrect. Bizarrely, when I enter the same username/password combination on my iPad, it grants access without any problem.
What could be causing this, is it an issue with cookies, caches or similar. How can I resolve it? The forum administrator is at a loss as to what the problem is.Try the following steps in Safari to see if they help:
1) First try clearing the Safari cache. To do this pull down the Safari menu and select 'Empty cache...', then try logging into the site again.
2) If the issue continues then reset Safari by pulling down the Safari menu and select'Reset Safari...'. You will be presented with a list of items that can be reset. I suggest selecting the 'Reset saved names and passwords', and 'Remove all website data' options at a minimum.
Here is a list of the options and what they do. I pulled it from the Safari help page.
Clear history:
Clears the list of webpages you viewed.
Reset Top Sites:
Clears any changes you made to Top Sites, such as adding or pinning sites. If you also clear your history, your Top Sites page reverts to showing the webpage previews displayed when you first installed Safari.
Remove all webpage preview images:
Clears any thumbnail images Safari saved of webpages you viewed.
Clear the Downloads window:
Clears the list of files you downloaded from websites. Only the names are removed; the files themselves are still on your disk until you remove them.
Remove all website icons:
Removes website icons, which are small graphics that help identify sites on the Internet. You see them in the Safari address field and bookmarks list, and other places. These icons are stored on your computer.
Remove saved names and passwords:
Removes user names and passwords that Safari automatically fills in at websites that require them (if the AutoFill feature is turned on).
Remove other AutoFill form text:
Removes some personal information, such as telephone numbers, that Safari uses to automatically fill in forms on webpages (if the AutoFill feature is turned on). Removing AutoFill information does not remove information from your address book.
Close all Safari windows:
If you don’t close all Safari windows, someone could use the Back and Forward buttons to view the webpages you visited.
Reset all location warnings:
Clears any information websites saved about your location.
Remove all website data:
Removes cookies, tracking information, and other data that websites stored on your computer. -
Why does the English keep defaulting back to US and not British
Why does the English keep defaulting back to US and not British.
This is clear enough it does what it says in English British EnglishWhere do you get this problem?
Is this with the spell checking dictionary or with the language setting?
*Tools > Options > Content > Languages
If you do not keep changes after a restart or otherwise have problems with preferences, see:
*http://kb.mozillazine.org/Preferences_not_saved -
How do you swap an image in the timeline but keep the in/out points and opacity settings?
Hi There,
We have a file which consists of a bunch of still images that get updated each year - the edits never change.
Is there an edit type that will allow us to swap the images our for new ones but keep the in/lout points and opacity changes? We've looked at all the edit types (overwrite, insert etc) but they don't seem to swap stuff out.
We had also been naming the new files the same as the old ones and reconnecting the media but this is now causing issues.
Any help or pointers in the right direction would be much appreciated.
Cheers
BenClick on the new image in the browser, so that it is selected, and the type Command + C to copy it.
Next, click on the clip in the timeline that you want to replace with the image you just copied (preserving your in and out points and opacity settings) and type Option + V to bring up the Paste Attributes Dialog Box.
In the Paste Attributes Dialog box, check the box for Contents and leave the remainder of options unchecked.
Uncheck the Scale Attribute Times option as well.
Click OK, and the image should now be replaced on the timeline with the in/out and opacity changes preserved.
MtD -
On Yahoo Mail...and ONLY Yahoo Mail..I get a 404 error after entering my user name and password. This doesn't happen with IE, just Firefox, and just Yahoo Mail. I tried uninstalling and reinstalling FF; no change. Yahoo was absolutely no help whatsoever; can you solve the mystery? Thanks
HI Emmet,
thanks so much for your posts back. I really appreciate it and yes that does help to know that you could not get it working.
I did have some success, in removing the SSL Authentication checkbox in the smtp server settings - I found that this allowed my friend to be able to send mail from the mail app via his sbcglobal (yahoo) account.
So that did help but of course the messages do not have ssl encryption and I'm not sure how big a deal that is for an individual. He is able to receive mail but unless the SSL authentication box is unchecked, he cannot send.
i hope that helps anyone out there also!
Thanks also for the tip about sparrow - yes I have heard of it and it is very popular, he may end up using that in the end.
Thanks again, much appreciated.
Felix -
How can I restore my data from iCal? I didn't make any backup, but I use time machine with an external HD. I deleted iCal when I deleted my gmail account. I have tried to restore, but I can only restore the iCal software and not the data.
So what is your question?
If you forgot your encryption password:
Warning: Make sure it's a password you will remember or write it down for safekeeping. If you encrypt an iPhone backup in iTunes and forget your password, you can't restore from backup and your data will be unrecoverable.
If you can't remember the password and want to start again, you must perform a full software restore and chooseset up as a new device when iTunes prompts you to select the backup from which to restore.
The above comes from here:
http://support.apple.com/kb/HT4946
Maybe you are looking for
-
How do you get the camera information to show up in Camera Calibration in Lightroom 5
I have a Nikon D7000, I am trying to get the information to show up in the profiles of Camera Calibration. It shows up in my metadata in the library module but not in the Camera Calibration. I am looking at a RAW photo too, so it should be there.
-
I have just installed the latest software for the iphone4 - I have retained all the data EXCEPT the Contacts have all disappeared - can I get back ?
-
How to permanently disable Windows Defender?
Windows Defender won't stay disabled. I searched through the threads and saw several others have had this problem but the issue has apparently never been resolved. I removed Windows Defender from startup using MSCONFIG, disabled it from the GUI tha
-
Dear all, Is it possible to maintain the cost of equipment, if yes the in which t code i can see it.(i don't want from the FI or CO module) i want to see it in PM module. Is it possible?
-
Credit Memo with Open Receivable flag 'N'
Hi, I am stuck in a problem here. I applied a credit memo to an invoice , both transaction type had open receivable set to 'N'. Now this credit memo application hasn't created a row in ra_receivable_applications_all, neither ar_payment_schedules_all