AS3 Events Handler Error #1069: Property update not found - actionscript-3

I made this function according tutorial in youtube by: PointClickWin
public function Ship (){
trace ("made ship")
(1) addEventListener(Event.ENTER_FRAME,onEnter);
}
function onEnter( (2) e:Event){
}
and in my Game Class like this
var ships = new Array();
public function Game()
{
trace("Made A Game");
ships = new Array();
addEventListener(Event.ENTER_FRAME,loop);
}
function loop(e:Event)
{
if (numChildren<10)
{
var s = new Ship();
addChild(s);
s.x = Math.random() * stage.stageWidth;
s.y = Math.random() * stage.stageHeight;
s.rotation = Math.random() * 360;
ships.push(s);
}
for (var count=0; count<ships.length; count ++)
{
(3) ships[count].update();
}
}
so, in this case pointclick say's that he want to manually updating the loop function in the ship class from the Game class, And he remove the eventlisteners in the ship class he put the coment like this //addEventListener(Event.ENTER_FRAME,loop); and put the .update(); after ships.[count] finnaly the function became like this
function onEnter () {
}
i got an error at
Game/loop()
this is the error message " ReferenceError: Error #1069: Property update not found on Ship and there is no default value.
at Game/loop()"
Any Body can Help Me?? Please , Thankz
oww in parentheses () im just put a point to be understanding for anybody.

Related

Make three MovieClips appear and disappear inside a snowglobe when shaken

I used a creative cow tutorial to create my own snow globe that moves and snow reactivates - it really is a great tutorial.
What I'm trying to do is Change between 3 Movie clips in the ActionScript - But each time I add my movie clip names - Or try and add a simple visibility code I break my snow globe actions.
I have my MovieClip instances named friendsSceneThree, BuddiesSceneTwo and HatsOffSceneOne. I would think they'd be good but somewhere I'm missing something. Right now I can't get the code to even SEE The movieclips I'm getting a simple:
TypeError: Error #1006: value is not a function.at SnowGlobeContainer/update()
Down in the 'if drag' Update is where I'd like to Change from One MClip to the Next.
What Am I Not Seeing?!?! Any help would be greatly appreciated! Thanks
Here is the ActionScript:
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.geom.Point;
public class SnowGlobeContainer extends Sprite {
public var snowForeground:SnowGeneratorCircle;
public var snowBackground:SnowGeneratorCircle;
public var friendsSceneThree:MovieClip;
public var buddiesSceneTwo:MovieClip;
public var hatsOffSceneOne:MovieClip;
public var drag:Boolean = false;
public var over:Boolean = false;
public var startPos:Point = new Point;
public var mouseDownOffset:Point = new Point;
public var bounds:Rectangle = new Rectangle;
public var vel:Point = new Point(0,0);
public var pos:Point = new Point(x,y);
public var old:Point = new Point(x,y);
public var gravity:Number = 5+(Math.random()*1);
public var restitution:Number = 0.5;
public var friction:Number = 0.9;
public function SnowGlobeContainer() {
// save some initial persistant properties
startPos.x = this.x;
startPos.y = this.y;
old.x = this.x;
old.y = this.y;
bounds.x = 0;
bounds.y = 0;
bounds.width = 600;
bounds.height = startPos.y;
// add mouse interaction listeners and show the cursor on rollover
this.mouseChildren = false;
this.useHandCursor = true;
this.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
this.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
this.addEventListener(Event.ENTER_FRAME, update);
}
protected function onMouseOver(e:MouseEvent=null):void { over = true; }
protected function onMouseOut(e:MouseEvent=null):void { over = false; }
protected function onMouseDown(e:MouseEvent=null):void {
// Save the offset of your mouse when you first start dragging. Same functionality as startDrag(false)
mouseDownOffset.x = mouseX;
mouseDownOffset.y = mouseY;
drag = true;
}
protected function onMouseUp(e:MouseEvent=null):void {
vel.x = vel.y = 0;
pos.x = x;
pos.y = y;
drag = false;
}
public function update(e:Event):void {
// this if/else statement controls the mouse over and out instead of using event listeners
if(mouseY < -175 || mouseY > 175 || mouseX < -175 || mouseX > 175){
if(over) onMouseOut();
}else{
if(!over) onMouseOver();
}
if(drag){
// drag around..
this.x = parent.mouseX - mouseDownOffset.x;
this.y = parent.mouseY - mouseDownOffset.y;
// keep this thing on the table :)
if(y >= bounds.height) y = bounds.height;
// if you "shake" or move the mouse quickly, we are going to reset the snow particles
var d:Point = new Point(Math.abs(old.x - x), Math.abs(old.y - y));
if(d.x > 50 || d.y > 50 ){
snowForeground.reset();
snowBackground.reset();
friendsSceneThree.visible = false;
}
// update the history position
old.x = x;
old.y = y;
vel.y = (y-old.y)/2;
}else{
// if you drop this object it should have a bit of realistic falling..
vel.y += gravity;
pos.y += vel.y;
// bounce
if(pos.y > bounds.height){
pos.y = bounds.height;
vel.y *= -(Math.random()*restitution);
}
y = pos.y;
}
}
}
}
I appreciate the help -- If you haven't noticed I'm new to all of this scripting. I'm looking in on lynda.com and other forums. the SnowGeneratorCircle.as is:
package {
import flash.display.Sprite;
import flash.events.Event;
public class SnowGeneratorCircle extends Sprite {
var totalFlakes:int = 500;
var flakes:Array = new Array();
public function SnowGeneratorCircle() {
addSnowFlakes();
addEventListener(Event.ENTER_FRAME, update);
}
protected function addSnowFlakes():void{
for(var i:int=0; i<totalFlakes; i++){
var f:SnowFlake = new SnowFlake();
addChild(f);
flakes.push(f);
}
}
public function reset():void{
for(var i:int=0; i<totalFlakes; i++){
var f:SnowFlake = flakes[i];
f.reset();
}
}
public function update(e:Event=null):void {
for(var i:int=0; i<totalFlakes; i++){
var f:SnowFlake = flakes[i];
f.update(0);
}
}
}
}
I debugged - didn't clean up the code, because every time I did - it broke the actions. So I left the code with the double spacing. That's how it went in when I copied and pasted from the tutorial anyway.
Here's the error on line 173 - which is the MovieClip I'd like to have change.
Attempting to launch and connect to Player using URL /Volumes/Lacie Biggest S2S/GRaid/Veronica
/V/Rubio/Work/SUBARU/SnowGlobe Subaru/SnowGlobeAnima/snowGlobeShakev3.swf
[SWF] Volumes:Lacie Biggest S2S:GRaid:Veronica:V:Rubio:Work:SUBARU:SnowGlobe >Subaru:SnowGlobeAnima:snowGlobeShakev3.swf - 468081 bytes after decompression
TypeError: Error #1006: value is not a function.
at SnowGlobeContainer/update()[/Volumes/Lacie Biggest S2S/GRaid/Veronica/V/Rubio/Work/SUBARU
/SnowGlobe Subaru/SnowGlobeAnima/SnowGlobeContainer.as:173]
I just don't know how to get the actionscript to find my MovieClips and then swap them out wt each shake of the globe.

as3 1119: Access of possibly undefined property getters/setters

It would be amazing if someone could expand on the current answer, Thanks.
full error
Line 22 1119: Access of possibly undefined property CharacterX through a reference with static type flash.display:DisplayObject.
I'm trying to set a variable for the object shark, that is already defined in the object character
First time using setters in flash, so I might not be doing this right.
code I'm using to set the variable I tried to comment out the stuff I thought was irrelevant to this issue, not actually commented out in real code.
var character:Character;
//var bullet:Bullet=null;
//var bullets:Array = new Array();
//var enemies:Array = new Array();
//character=new Character(bullets);
addChild(character);
var shark:Shark=new Shark();
addChild(shark);
//var enemy:Enemy=null;
////var i:int;
//for (i=0; i<10; i++) {
//enemy = new Enemy(Math.random()*stage.stageWidth, Math.random()*stage.stageHeight);
//addChild(enemy);
// enemies.push(enemy);
//}
//stage.addEventListener(Event.ENTER_FRAME, colTest);
//function colTest(e:Event ):void {
// if(character.hitTestObject(turtle)){
// character.gotoAndStop("Turtle");
// }
//}
shark.setT(character.x, character.y)
class in which I'm attempting to define a variable using the function above.
package
{
import flash.display.*;
import flash.events.*;
public class Shark extends MovieClip
{
var CharacterX:Number = 0;
var CharacterY:Number = 0;
public function Shark()
{
this.x = 300;
this.y = 200;
addEventListener(Event.ENTER_FRAME,playGame);
}
public function setT(characterx:Number,charactery:Number){
CharacterX = characterx - this.x;
CharacterY = charactery - this.y;
}
function playGame(event:Event):void
{
var ease:int = 20;
var speed:int = 10;
var targetX:int = root.CharacterX - this.x;
var targetY:int = root.CharacterY - this.y;
var rotation = Math.atan2(targetY,targetX) * 180 / Math.PI;
cut code off here, didn't want to make a code dump can get you anything that might be relevant just ask.
Here is a pastebin of all of the code if it might help,
Shark class:
Actions on Frame 1:
Character class
Let me start by saying I can't spot the exact problem here, but I have some ideas. Your error 1999 says that something of the type display object is trying to change your variable. This happens a lot when you use parent.myMethod() because parent is typed as display object. You would fix this by typecasting like (parent as MovieClip).myMethod
In your case I don't see the exact source of this problem. But you could try using this.characterX in your setT function

Incorrect number of arguments. Expected 2

I'm making a game where you are a soccer goalie and the ball(brazuca) keeps on falling down and you have to collect it, but I keep getting the incorrect number of arguments error. I'm fairly new to coding and I know that the error means something unexpected happened in the brackets where the error happened but I can't figure out how to fix it. It would be great if anyone can help me with this issue.
class Gamescreen2
package
{
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.*;
import flash.ui.Mouse;
import flash.media.SoundChannel;
public class Gamescreen2 extends MovieClip
{
public var goalie:GoaliePlay;
var gameMusic:GameMusic;
var gameChannel:SoundChannel;
var speed:Number;
//public var army:Array;
public var army2:Array;
//public var gameTimer:Timer;
public var gameTimer2:Timer;
public static var tick:Number;
public static var score:Number;
public function Gamescreen2()
{
goalie = new GoaliePlay();
addChild (goalie);
gameMusic = new GameMusic;
gameChannel = gameMusic.play(0,999);
score = 0;
//army = new Array();
army2 = new Array();
//gameTimer = new Timer(25);
gameTimer2 = new Timer(25);
//gameTimer.addEventListener(TimerEvent.TIMER, onTick);
gameTimer2.addEventListener(TimerEvent.TIMER, onTick);
gameTimer2.start();
tick = 0;
}
public function onTick(timerEvent:TimerEvent):void
{
tick ++;
if (Math.random() < 0.05)
{
var randomX:Number = Math.random() * 550;
var goalieB= new GoalieB(0,0);
army2.push (goalieB);
addChild (goalieB);
}
for each (var goalieB:GoalieB in army2)
{
goalieB.moveDownABit();
if(goalieB.y == 420)
{
score--
trace(score);
this.scoreTxttwo.text = score.toString();
}
if (goalie.collisionArea.hitTestObject(goalieB))
{
goalieB.x == 550;
score += 10;
}
if (score < 1)
{
score = 0;
}
}
}
}
}
class BrazucaPlay
package
{
import flash.display.MovieClip;
public class BrazucaPlay extends MovieClip
{
var speed:Number;
public function BrazucaPlay(startX:Number, startY:Number)
{
x = startX;
y = startY;
speed = Math.random();
}
public function moveDownABit():void
{
//two speed enemies
if (speed >= .25)
{
y = y + 3;
}
}
}
}
Might be the constructor of your GameMusic class.
gameMusic = new GameMusic;
You should have brackets like so:
gameMusic = new GameMusic();
Same with this line:
var newBrazuca = new BrazucaPlay;
Should be:
var newBrazuca = new BrazucaPlay();
If, after adding brackets () you still receive the error, then you should check your custom classes BrazucaPlay and GoaliePlay and make sure their constructors aren't expecting parameters. Also check this function: brazuca.moveDownABitB().
The constructor is the function that is named after the class and is what first runs when instantiate an object. So you do var newBrazuca = new BrazucaPlay(); there is a constructor function in the BrazucaPlay class that would look something like this:
public function BrazucaPlay(){
//some code.
}
If that function actually looked something like this:
public function BrazucaPlay(myParameter:String){ }
Then that would throw the error you're getting because it's expecting you to pass a parameter to it (in this case a string like new BrazucaPlay("blah blah blah"))
EDIT
Now that you've posted more code, the cause is quite clear. The constructor of your BrazucaPlay class is expecting two arguments (a starting x/y position). So when you instantiate a new BrazucaPlay instance, you are required to pass it those two parameters:
var newBrazuca = new BrazucaPlay(0,0);//you need to pass two numbers (starting x and y)
If you don't want to do this, you can change the code to make those parameter OPTIONAL.
//this makes the parameters default to 0 if no value is passed in
public function BrazucaPlay(startX:Number = 0, startY:Number = 0)
{
x = startX;
y = startY;
speed = Math.random();
}
Welcome, user. Okay, a couple of things...
First, just so you know, we need the entire error, as CyanAngel said. It helps us prevent digging through the entire code. (For more tips about getting started, go to stackoverflow.com/help)
Second, this is what your error message means: You are passing the wrong number of arguments (values) to a function. The function requires exactly two, and you're passing more or less than you should.
This is why we need the error: it has the line number of the error, letting us/you narrow in on it directly.

Some errors in flash AS3 game, almost completed with lot of effort and help received

First I really want to thank you for all the help you have given me so far, since I did not know anything about AS3 (basics gotoAnd stuff only) I came to Stackoverflow searching for some code already made but I was encouraged by some members to make the code by myself, now after almost 2 weeks and thanks to a lot of great people my soccer penalty kick game is almost finished, I really love this place.
I know I have to work on some collisions and other stuff since currently the game is not the best (remember I’m just a newbie), but Unfortunately while checking the game functioning by playing it over and over again, I have found the following:
1- When you get 3 fails, then game is over and a play again button appears after some animation, you click on it and everything seems to be fine, but when you continue playing the second time you reach 3 fails, when you click the button a new cursor appears??? Please help
2- I tried millions of times to make the ball move with speed and to animate its trajectory but was unable to make it, any help on this will be highly appreciated. I have speed variables and gravity but I didn’t know how to use them
3- I'm getting a actionscript error related to a removeChild, I tried many times removing some lines but I´m unable to fix it.
4- I'm using too many timers, I don't know if this is recommendable.
Here is the .fla file https://rapidshare.com/files/1702748636/kicks.fla just in case anybody want to try the game (this is really simple since it is my 1st AS project) and want to help me with the code and help me improving the game, and here is the code if somebody does not need to get into the file (I know this place is full of really smart people), once I finish it I know I will be able to do a lot of stuff with AS3.
var score:Number;
var angle:Number;
var speed:Number;
var cursor:MovieClip;
var failed:Number;
var ballRotation:Boolean = false;
function initializeGame( ):void
{
ball.x = 296.35;
ball.y = 353.35;
score=0;
failed=0;
cursor = new Cursor();
addChild(cursor);
cursor.enabled = true;
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
}
function dragCursor(event:MouseEvent):void
{
cursor.x = this.mouseX;
cursor.y = this.mouseY;
}
initializeGame();
var mouse = this.Mouse;
function kick(evt:Event)
{
removeChild(cursor);
pateador_mc.play();
var timer:Timer = new Timer(500,1);
timer.addEventListener(TimerEvent.TIMER, delayedAction);
timer.start();
function delayedAction(e:TimerEvent)
{
moveBall();
}
}
speed=-100000;
var ease:int = 100;
var gravity:Number = 0.5;
function moveBall()
{
var targetX:Number = mouseX;
var targetY:Number = mouseY;
var angle = Math.atan2(targetY,targetX);
ball.x = mouseX + Math.cos(angle);
ball.y = mouseY + Math.sin(angle) ;
ballRotation = true;
stage.removeEventListener(MouseEvent.CLICK, kick);
if (ballRotation==true)
{
keeper.gotoAndStop(1 + Math.floor(Math.random() * keeper.totalFrames));
ball.play();
}
if (ball.hitTestObject ( keeper)){
ball.y=keeper.x-ball.height- ball.width;
trace ("Tomela");
}
if (ball.hitTestObject(goalie) && ball.y>69 /*&& ball.y<178 && ball.X>139 && ball.x<466*/)
{
gol_mc.play();
score ++;
showScore();
var timer3:Timer = new Timer(3000,1);
timer3.addEventListener(TimerEvent.TIMER, delayedAction3);
timer3.start();
function delayedAction3(e:TimerEvent)
{
ball.x = 296.35;
ball.y = 353.35;
stage.addEventListener(MouseEvent.CLICK, kick);
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
addChild(cursor);
keeper.gotoAndStop(1);
}
}
else
{
fails_mc.play();
failed++;
var timer2:Timer = new Timer(3000,1);
timer2.addEventListener(TimerEvent.TIMER, delayedAction2);
timer2.start();
function delayedAction2(e:TimerEvent)
{
ball.x = 296.35;
ball.y = 353.35;
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
addChild(cursor);
keeper.gotoAndStop(1);
}
trace(failed);
if (failed==3) {
gameFinished();
trace("YOU LOST");
}
}
function showScore():void{
goles_txt.text ="" +score;
}
trace (score);
function gameFinished(){
gameOver.play ();
stage.removeEventListener(MouseEvent.CLICK, kick);
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
timer2.stop();
Mouse.show();
this.mouseX=cursor.x ;
this.mouseY=cursor.y;
again_btn.addEventListener(MouseEvent.MOUSE_DOWN, playAgain);
}
function playAgain():void{
gameOver.gotoAndPlay(31);
fails_mc.gotoAndStop(1);
keeper.play();
var timer4:Timer = new Timer(1000,1);
timer4.addEventListener(TimerEvent.TIMER, delayedAction3);
timer4.start();
function delayedAction3(e:TimerEvent)
{
initializeGame();
}
}
}
I’ll really appreciate it guys , I promise I won’t be bothering again for a long time
1/3.
Problem 1 & 3 are the same problem. Looks like your trying to remove the cursor from the stage (removeChild) every click (so it will error after the first click because it's no longer a child of anything). Your adding it back on your delayedAction2 which doesn't run unless your hit test is true and only after 3 seconds. On initialize game you create a whole new cursor and add that to the stage which is why you get a duplicate after the first game.
Rather than removeChild the cursor, it might better to just set it's visibility to false/true and only create it once.
You'll need to use an EnterFrame handler, or timer, or tween for this. I can post an example later.
I can't figure out why you're using timers at all or need to delay your functions, except maybe to allow time for the kick animation?
You're code is very disorganized, naming functions things like 'delayedAction' is bad as it doesn't really tell you anything about the purposed of the function. You also have way too much functions inside of other functions. Here is a quick refactoring of your code I've done to hopefully teach a few things. I've also added the tween for the ball animation.
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
var score:Number;
var cursor:MovieClip;
var failed:Number;
var ballRotation:Boolean = false;
var ballTweenX:Tween;
var ballTweenY:Tween;
var targetCursor = new Cursor(); //only want one of these and you want it to exist the whole time so keep out here.
addChild(targetCursor);
initializeGame();
function initializeGame( ):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
ball.x = 296.35;
ball.y = 353.35;
score=0;
failed=0;
targetCursor.visible = true;
Mouse.hide();
}
function dragCursor(event:MouseEvent):void
{
targetCursor.x = this.mouseX;
targetCursor.y = this.mouseY;
}
function kick(evt:Event)
{
//removeChild(targetCursor);
targetCursor.visible = false;
pateador_mc.play();
stage.removeEventListener(MouseEvent.CLICK, kick); //move this here, because you don't the option kick again while already kicking
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragCursor); //added this, you probably don't want the target moving after the click...
setTimeout(moveBall, 500);//cleaner and more efficient than using a timer for a one time delayed call.
}
function moveBall()
{
var targetX:Number = mouseX;
var targetY:Number = mouseY;
var angle = Math.atan2(targetY,targetX);
targetX = mouseX + Math.cos(angle);
targetY = mouseY + Math.sin(angle) ;
ballRotation = true;
ballTweenX = new Tween(ball, "x", null, ball.x, targetX, .3, true);
ballTweenY = new Tween(ball, "y", null, ball.y, targetY, .3, true);
ballTweenY.addEventListener(TweenEvent.MOTION_FINISH, ballTweenDone,false,0,true);
if (ballRotation==true)
{
keeper.gotoAndStop(1 + Math.floor(Math.random() * keeper.totalFrames));
ball.play();
}
}
function stopBallTween():void {
ballTweenX.stop();
ballTweenY.stop();
}
function ballTweenDone(e:TweenEvent):void {
if (ball.hitTestObject ( keeper)){
ball.y=keeper.x-ball.height- ball.width;
trace ("Tomela");
}
if (ball.hitTestObject(goalie) && ball.y>69 /*&& ball.y<178 && ball.X>139 && ball.x<466*/)
{
gol_mc.play();
score ++;
showScore();
}else
{
fails_mc.play();
failed++;
trace(failed);
if (failed==3) {
gameFinished();
trace("YOU LOST");
return; //added this because you don't want the rest of this function running if it's a game over
}
}
setTimeout(resetShot, 3000); //you had the code I put in resetShot repeated twice
trace(score);
}
function resetShot():void {
ball.x = 296.35;
ball.y = 353.35;
targetCursor.visible = true;
keeper.gotoAndStop(1);
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
stage.addEventListener(MouseEvent.CLICK, kick);
}
function showScore():void{
goles_txt.text ="" +score;
}
function gameFinished(){
gameOver.play();
stage.removeEventListener(MouseEvent.CLICK, kick);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
Mouse.show();
//this.mouseX=cursor.x ;
//this.mouseY=cursor.y; //These are read only properties, your can't set the mouse position...
again_btn.addEventListener(MouseEvent.MOUSE_DOWN, playAgain);
}
function playAgain(e:Event = null):void{
gameOver.gotoAndPlay(31);
fails_mc.gotoAndStop(1);
keeper.play();
setTimeout(initializeGame, 1000);
}

Bubble pop game Actionscript: defining ToString() method through a reference with a static type class

Hello I have the actionscript code here for a bubble popping game. When the game starts, bubbles fall down from the top of the game to the bottom and score is kept for the most bubbles clicked or popped in 30 seconds.
The size of the bubble is defined by the initialize method in the code, and uses ToString() to calculate the score. ToString gives me a 1061: Call to a possibly undefined method Random through a reference with static type uint. This error which I cannot figure out where it comes from.
If anyone with experience in AS3 could give me some pointers to my faults, I would greatly appreciate it. Thank You.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.media.Sound;
public class Ball extends MovieClip{
static public var burstCounter: uint;
private var vx: Number;
private var vy: Number;
private var gravity: Number;
private var stageWidth;
private var stageHeight;
private var bubble:Ball = new Ball();
private var score: uint=0;
public function Ball() {
bubble.addEventListener(Event.ADDED_TO_STAGE, initialize)
bubble.addEventListener(MouseEvent.CLICK, burst)
bubble.addEventListener(Event.ENTER_FRAME, dropping)
}
public function initialize (e:Event):void
{
bubble.x = Math.random() * stageWidth;
bubble.y = 0;
stageWidth = stage.stageWidth;
stageHeight = stage.stageHeight;
bubble.vx = Math.random() * 2 - 1;
bubble.vy = Math.random() * 2 + 1;
gravity = 0.1;
var sizeScale = Math.random() * 1.2 + .6;
bubble.scaleX = bubble.scaleY = sizeScale;
score = (10 / sizeScale);
scoreValue.text = score.ToString();
var colorTran = new ColorTransform();
colorTran.color = Math.random() * 0xFFFFFF;
transform.colorTransform = colorTran;
addChild(bubble);
}
function dropping(e: Event) :void
{
x += vx;
y += vy;
vy += gravity;
if((x<0) || (x>stageWidth) || (y<0) || (y>stageHeight))
{
if(parent != null)
{
parent.removeChild(this);
}
removeEventListener(Event.ENTER_FRAME, dropping)
}
}
function burst (e:Event):void
{
var ballonPopping: Sound = new BalloonPopping();
bubble.removeEventListener(Event.ADDED_TO_STAGE, initialize);
bubble.removeEventListener(Event.ENTER_FRAME, dropping);
removeChild(bubble);
ballonPopping.play();
burstCounter += score;
}
}
}
Try Math.random() instead...
You need to change each occurrence of
Math.Random()
to
Math.random()
note the lowercase r
Or...since it looks like you just edited this question for ToString()
Try
toString()
Notice how similar the errors are. You're tying to call a method that doesn't exist on both of these. Capitalization matters VAR is not the same as var
uint doesn't have a ToString() method either, but it has a toString().
Case is important in method names. :)
Be mindful that casing does matter when naming & calling properties or methods.
ActionScript uses pascalCasing for its members, including static ones. Constants use ALL_CAPS.
I can't think of any class members in ActionScript that use CamelCasing like you've been doing - as far as I'm aware, there aren't any.