-
HELP ME PLEASE - Error codes and my assignment is over the deadline:O
Can someone help me please?
can you tell me how to fix this error code?
The first error is:
Call to a possibly undefined method Spider1_mc.
The code is:
var thisMC:MovieClip = new Spider1_mc();
The next one is:
Access of undefined property thisMC.
the code is
thisMc.addEventListener(Event.ENTER_FRAME, spider1MoveHandler);
The next one is:
Access of undefined property Spider1MC
The code is:
if (spider1MC.x > stageWidth) {
The next one is:
Access of undefined property Spider1MoveHandler
The code is:
Spider1MC.removeEventListener(Event.ENTER_FRAME, Spider1MoveHandler);
Thankyou so much
I really appreciate it!
Corey!
-
.
Hi,
Without having anymore of your code, you do have some upper case letters where lower case are needed and vice versa.
You also have the clip named as spider1MC when it should be called thisMC.
Perhaps this might help you sort it out.
PHP Code:
var thisMC:MovieClip = new Spider1_mc();
addChild(thisMC);
thisMC.addEventListener(Event.ENTER_FRAME, spider1MoveHandler);
function spider1MoveHandler(e:Event):void
{
if (thisMC.x > stage.stageWidth)
{
trace("I'm here");
thisMC.removeEventListener(Event.ENTER_FRAME, spider1MoveHandler);
}
}
-
Originally Posted by fruitbeard
Hi,
Without having anymore of your code, you do have some upper case letters where lower case are needed and vice versa.
You also have the clip named as spider1MC when it should be called thisMC.
Perhaps this might help you sort it out.
PHP Code:
var thisMC:MovieClip = new Spider1_mc();
addChild(thisMC);
thisMC.addEventListener(Event.ENTER_FRAME, spider1MoveHandler);
function spider1MoveHandler(e:Event):void
{
if (thisMC.x > stage.stageWidth)
{
trace("I'm here");
thisMC.removeEventListener(Event.ENTER_FRAME, spider1MoveHandler);
}
}
Thankyou!
That got rid of them errors, now i am left with one error which says Scene 1, Layer 'Layer 5', Frame 5 1084: Syntax error: expecting rightbrace before end of program.
I will show you all of my code for that.
Any help would be appreciated!
Corey
PHP Code:
stop();
stage.focus = stage;
Hammer.x=mouseX;
Hammer.y=mouseY;
Hammer.mouseEnabled = false;
stage.addEventListener(MouseEvent.MOUSE_MOVE,redrawCursor);
Mouse.hide();
function redrawCursor(event:MouseEvent):void
{
Hammer.x = event.stageX;
Hammer.y = event.stageY;
}
stop();
var cDepth:int= 100;
var xSpeed:Number = 4;
var stageWidth:Number = stage.stageWidth;
var stageHeight:Number = stage.stageHeight;
stage.addEventListener (Event.ENTER_FRAME, main);
function main(event:Event):void{
createSpider1();
}
function createSpider1():void{
if (randRange(0, 10) == 0){
var thisMC:MovieClip = new Spider1_mc();
addChild(thisMC);
cDepth++;
thisMC.x = -thisMC.width;
thisMC.speed = xSpeed;
thisMC.y = randRange(thisMC.height, stageHeight-thisMC.height);
thisMC.name = "Spider1" + cDepth;
thisMC.addEventListener(Event.ENTER_FRAME, spider1MoveHandler);
addChild(thisMC);
}
}
function spider1MoveHandler(event:Event):void {
var Spider1MC:MovieClip = event.currentTarget as MovieClip;
function spider1MoveHandler(e:Event):void
{
if (thisMC.x > stage.stageWidth)
{
removeChild(Spider1MC);
trace("I'm here");
thisMC.removeEventListener(Event.ENTER_FRAME, spider1MoveHandler);
}
}
function randRange(minNum:Number, maxNum:Number):Number {
return (Math.floor(Math.random()*(maxNum - minNum + 1)) +minNum);
}
-
.
Hi,
It's sometimes easier for us if you attach your *.fla, but here goes, perhaps this or similar
PHP Code:
stop();
stage.focus = stage;
Hammer.x = mouseX;
Hammer.y = mouseY;
Hammer.mouseEnabled = false;
stage.addEventListener(MouseEvent.MOUSE_MOVE,redrawCursor);
stage.addEventListener(Event.ENTER_FRAME, main);
Mouse.hide();
function redrawCursor(event:MouseEvent):void
{
Hammer.x = event.stageX;
Hammer.y = event.stageY;
}
var cDepth:int = 100;
var xSpeed:Number = 4;
var stageWidth:Number = stage.stageWidth;
var stageHeight:Number = stage.stageHeight;
var thisMC:MovieClip = new Spider1_mc();
function main(event:Event):void
{
createSpider1();
}
function createSpider1():void
{
if (randRange(0, 10) == 0)
{
addChild(thisMC);
cDepth++;
thisMC.x = - thisMC.width;
thisMC.speed = xSpeed;
thisMC.y = randRange(thisMC.height,stage.stageHeight - thisMC.height);
thisMC.name = "Spider1" + cDepth;
thisMC.addEventListener(Event.ENTER_FRAME, spider1MoveHandler);
}
}
function spider1MoveHandler(event:Event):void
{
var Spider1MC:MovieClip = event.currentTarget as MovieClip;
if (thisMC.x > stage.stageWidth)
{
removeChild(Spider1MC);
trace("I'm here");
thisMC.removeEventListener(Event.ENTER_FRAME, spider1MoveHandler);
}
}
function randRange(minNum:Number, maxNum:Number):Number
{
return (Math.floor(Math.random()*(maxNum - minNum + 1)) +minNum);
}
-
Originally Posted by fruitbeard
Hi,
It's sometimes easier for us if you attach your *.fla, but here goes, perhaps this or similar
PHP Code:
stop(); stage.focus = stage;
Hammer.x = mouseX; Hammer.y = mouseY; Hammer.mouseEnabled = false;
stage.addEventListener(MouseEvent.MOUSE_MOVE,redrawCursor); stage.addEventListener(Event.ENTER_FRAME, main);
Mouse.hide();
function redrawCursor(event:MouseEvent):void { Hammer.x = event.stageX; Hammer.y = event.stageY; }
var cDepth:int = 100; var xSpeed:Number = 4; var stageWidth:Number = stage.stageWidth; var stageHeight:Number = stage.stageHeight; var thisMC:MovieClip = new Spider1_mc();
function main(event:Event):void { createSpider1(); }
function createSpider1():void { if (randRange(0, 10) == 0) { addChild(thisMC); cDepth++; thisMC.x = - thisMC.width; thisMC.speed = xSpeed; thisMC.y = randRange(thisMC.height,stage.stageHeight - thisMC.height); thisMC.name = "Spider1" + cDepth; thisMC.addEventListener(Event.ENTER_FRAME, spider1MoveHandler); } }
function spider1MoveHandler(event:Event):void { var Spider1MC:MovieClip = event.currentTarget as MovieClip; if (thisMC.x > stage.stageWidth) { removeChild(Spider1MC); trace("I'm here"); thisMC.removeEventListener(Event.ENTER_FRAME, spider1MoveHandler); } }
function randRange(minNum:Number, maxNum:Number):Number { return (Math.floor(Math.random()*(maxNum - minNum + 1)) +minNum); }
How do i attach that? haha im new here
I done what you said and i had another error which says line 23: Call to a possibly undefined method Spider1_MC.
Thankyou though!
-
.
Hi,
I believe it's because you need to have a clip in the library with "Spider1_mc" as it's linkage name.
To attch a file use the paperclip icon/image
-
Originally Posted by fruitbeard
Hi,
I believe it's because you need to have a clip in the library with "Spider1_mc" as it's linkage name.
To attch a file use the paperclip icon/image
You were right and it worked !
Thankyou!
However, when i go to upload it says that it has failed, would it be worth uploading it to mediafire and sending you the link?
Also do you know how i can get the Spider to move across the screen?
Corey
-
.
Hi,
If you got it working there is no need to make a link to your file, however if you are stuck with something else then please do so, explaining what you need to achieve (with key press, on it's own etc etc), I thought you already had this part done!!!
-
i wasn't sure haha, i got this code off my tutor (well the first code i shown you) and i did'nt even think about it, i know i should probably have it already done but i really dont know how to do it.
This is the link to my file https://www.mediafire.com/?6t15u9zi3jo6m1y
Thankyou and sorry for asking for everything
You're amazing haha
Corey
-
.
Hi,
You attached the file without the fixes that we just made
-
-
.
Hi,
I'm not exactly sure what you would like help with, do you actually want us to make it for you?
there are no errors anymore either and it is your homework/project
Last edited by fruitbeard; 04-30-2014 at 12:02 PM.
-
I'd love that, BUT i can't ask you to do everything haha.
IF you can; Can you make the two Spiders move to the end?
and then off the screen?
Corey
-
.
Hi,
I will hint toward it, both spiders on the stage need to be named differntly (not the same)
PHP Code:
function spider1MoveHandler(event:Event):void { Spider1.x += 2; Spider2.x += 2; }
-
Thankyou,
If i receive the error 'Access to undefined property spider1'
and also 'Access to undefined property spider2'
Is this because i need to name them differently?
and also 'Access to undefined property event'
Cheers
Corey
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|