Copy link to clipboard
Copied
iam making a game and i almost finish except one error i couln.t get it
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.
in out put and its keep moving
.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at admin1/onEnterFrame()
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@37b404c1 to flash.events.MouseEvent.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at admin1/onEnterFrame()
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@37b40511 to flash.events.MouseEvent.
can somebody help me to fix it
here is my first code in admin1 object
package{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
public class admin1 extends MovieClip
{
var moves:Boolean;
var points:Number;
var SCREAMING:screaming
var SOUNDCHANNEL:SoundChannel
var vx:Number;
var EATING:eating;
var CHIDORI:chidori
var WIND:wind;
public function admin1(){
addEventListener(Event.ADDED_TO_STAGE,onAddedToStage)
}
public function onAddedToStage(event:Event):void
{
stop()
if (currentFrame ==20)
gotoAndStop(1)
WIND = new wind;
SOUNDCHANNEL = WIND.play(0,1000)
CHIDORI = new chidori
EATING = new eating
SCREAMING = new screaming
SOUNDCHANNEL = new SoundChannel
score.restrict = "0-9";
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .5;
fireball1.alpha = .5;
points=0;
hero1.stop();
quizz.stop();
animal1.stop();
evil1.stop();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
fireball1..addEventListener(MouseEvent.CLICK, onfireball1);
burger1.addEventListener(MouseEvent.CLICK, onburger1);
b1.visible = false
b2.visible = false
b3.visible = false
c1.visible = false
c2.visible = false
c3.visible = false
d1.visible = false
d2.visible = false
d3.visible = false
e1.visible = false
e2.visible = false
e3.visible = false
f1.visible = false
f2.visible = false
f3.visible = false
a1.addEventListener(MouseEvent.CLICK, onmouseclicka1);
a2.addEventListener(MouseEvent.CLICK, onmouseclicka2);
a3.addEventListener(MouseEvent.CLICK, onmouseclicka3);
b1.addEventListener(MouseEvent.CLICK, onmouseclickb1);
b2.addEventListener(MouseEvent.CLICK, onmouseclickb2);
b3.addEventListener(MouseEvent.CLICK, onmouseclickb3);
c1.addEventListener(MouseEvent.CLICK, onmouseclickc1);
c2.addEventListener(MouseEvent.CLICK, onmouseclickc2);
c3.addEventListener(MouseEvent.CLICK, onmouseclickc3);
d1.addEventListener(MouseEvent.CLICK, onmouseclickd1);
d2.addEventListener(MouseEvent.CLICK, onmouseclickd2);
d3.addEventListener(MouseEvent.CLICK, onmouseclickd3);
e1.addEventListener(MouseEvent.CLICK, onmouseclicke1);
e2.addEventListener(MouseEvent.CLICK, onmouseclicke2);
e3.addEventListener(MouseEvent.CLICK, onmouseclicke3);
f1.addEventListener(MouseEvent.CLICK, onmouseclickf1);
f2.addEventListener(MouseEvent.CLICK, onmouseclickf2);
f3.addEventListener(MouseEvent.CLICK, onmouseclickf3);
addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
}
public function onRemovedFromStage(event:Event):void
{
//Remove the onEnterFrame event if
//this object is removed from the stage
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
trace("Dungeon removed");
}
public function onEnterFrame(event:Event):void
{
if (points == 0 ){
volt.alpha = .3
fireball1.alpha = .3;
fireball1.enabled = false;
burger1.alpha = .3;
burger1.enabled = false;
}
if (points == 1 ){
fireball1.alpha = .3;
fireball1.enabled = false;
burger1.alpha = 1;
burger1.enabled = true;
}
if (herobar.width == 80){
hero1.gotoAndStop(1);}
if (herobar.width == 60){
hero1.gotoAndStop(2);}
else if (herobar.width == 40){
hero1.gotoAndStop(3);}
else if (herobar.width == 20){
hero1.gotoAndStop(4);}
else if (herobar.width == 0){
hero1.gotoAndStop(5);}
if(evilbar.width == 40)
evil1.gotoAndStop (2)
else if (evilbar.width == 0){
evil1.gotoAndStop(3);}
}
public function onmouseclicka1 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
else if (points==1){
fireball1.alpha = .3;
fireball1.enabled = false;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
removeEventListener (MouseEvent.CLICK,onmouseclicka1)
quizz.gotoAndStop(2);
animal1.gotoAndStop(2);
removeChild(a1)
removeChild(a2)
removeChild(a3)
b1.visible = true
b2.visible = true
b3.visible = true
herobar.width -= 20;
play();
}
public function onmouseclicka2 (event:MouseEvent):void
{
points++
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
removeEventListener (MouseEvent.CLICK,onmouseclicka2)
quizz.gotoAndStop(2);
animal1.gotoAndStop(2);
removeChild(a1)
removeChild(a2)
removeChild(a3)
b1.visible = true
b2.visible = true
b3.visible = true
herobar.width -= 20;
}
public function onmouseclicka3 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
removeEventListener (MouseEvent.CLICK,onmouseclicka3)
quizz.gotoAndStop(2);
animal1.gotoAndStop(2);
removeChild(a1)
removeChild(a2)
removeChild(a3)
b1.visible = true
b2.visible = true
b3.visible = true
herobar.width -= 20;
}
public function onmouseclickb1 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
else if (points==1){
fireball1.alpha = .3;
fireball1.enabled = false;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.frame.gotoAndStop(3);
animal1.gotoAndStop(3);
removeChild(b1)
removeChild(b2)
removeChild(b3)
c1.visible = true
c2.visible = true
c3.visible = true
herobar.width -= 20;
}
public function onmouseclickb2 (event:MouseEvent):void
{
points++
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(3);
animal1.gotoAndStop(3);
removeChild(b1)
removeChild(b2)
removeChild(b3)
c1.visible = true
c2.visible = true
c3.visible = true
herobar.width -= 20;
}
public function onmouseclickb3 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
quizz.gotoAndStop(3);
animal1.gotoAndStop(3);
removeChild(b1)
removeChild(b2)
removeChild(b3)
c1.visible = true
c2.visible = true
c3.visible = true
herobar.width -= 20;
}public function onmouseclickc1 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
else if (points==1){
fireball1.alpha = .3;
fireball1.enabled = false;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(4);
animal1.gotoAndStop(4);
removeChild(c1)
removeChild(c2)
removeChild(c3)
d1.visible = true
d2.visible = true
d3.visible = true
herobar.width -= 20;
}
public function onmouseclickc2 (event:MouseEvent):void
{
points++
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(4);
animal1.gotoAndStop(4);
removeChild(c1)
removeChild(c2)
removeChild(c3)
d1.visible = true
d2.visible = true
d3.visible = true
herobar.width -= 20;
}
public function onmouseclickc3 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
quizz.gotoAndStop(4);
animal1.gotoAndStop(4);
removeChild(c1)
removeChild(c2)
removeChild(c3)
d1.visible = true
d2.visible = true
d3.visible = true
herobar.width -= 20;
}public function onmouseclickd1 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
else if (points==1){
fireball1.alpha = .3;
fireball1.enabled = false;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(5);
animal1.gotoAndStop(5);
removeChild(d1)
removeChild(d2)
removeChild(d3)
e1.visible = true
e2.visible = true
e3.visible = true
herobar.width -= 20;
}
public function onmouseclickd2 (event:MouseEvent):void
{
points++
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(5);
animal1.gotoAndStop(5);
removeChild(d1)
removeChild(d2)
removeChild(d3)
e1.visible = true
e2.visible = true
e3.visible = true
herobar.width -= 20;
}
public function onmouseclickd3 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
quizz.gotoAndStop(5);
animal1.gotoAndStop(5);
removeChild(d1)
removeChild(d2)
removeChild(d3)
e1.visible = true
e2.visible = true
e3.visible = true
herobar.width -= 20;
}public function onmouseclicke1 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
else if (points==1){
fireball1.alpha = .3;
fireball1.enabled = false;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(6);
animal1.gotoAndStop(6);
removeChild(e1)
removeChild(e2)
removeChild(e3)
f1.visible = true
f2.visible = true
f3.visible = true
herobar.width -= 20;
}
public function onmouseclicke2 (event:MouseEvent):void
{
points++
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(6);
animal1.gotoAndStop(6);
removeChild(e1)
removeChild(e2)
removeChild(e3)
f1.visible = true
f2.visible = true
f3.visible = true
herobar.width -= 20;
}
public function onmouseclicke3 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
quizz.gotoAndStop(6);
animal1.gotoAndStop(6);
removeChild(e1)
removeChild(e2)
removeChild(e3)
herobar.width -= 20;
}
public function onmouseclickf1 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
else if (points==1){
fireball1.alpha = .3;
fireball1.enabled = false;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(7);
animal1.gotoAndStop(7);
removeChild(f1)
removeChild(f2)
removeChild(f3)
herobar.width -= 20;
}
public function onmouseclickf2 (event:MouseEvent):void
{
points++
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";}
if (points< 0){
points = 0;
}
trace(points)
quizz.gotoAndStop(7);
animal1.gotoAndStop(7);
removeChild(f1)
removeChild(f2)
removeChild(f3)
herobar.width -= 20;
}
public function onmouseclickf3 (event:MouseEvent):void
{
points--
if (points == 1 ){
burger1.enabled = true;
burger1.alpha = 1;
}
if ( points == 2 || points == 3 || points == 4 || points == 5 || points == 6){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
quizz.gotoAndStop(7);
animal1.gotoAndStop(7);
removeChild(f1)
removeChild(f2)
removeChild(f3)
herobar.width -= 20;
}
public function onfireball1(event:MouseEvent):void{
if ( points >= 2 ){
points -= 2
evilbar.width -=40
SOUNDCHANNEL = SCREAMING.play();
}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
}
public function onburger1(event:MouseEvent):void{
if (points == 1 ){
burger1.alpha = .3;
fireball1.alpha = .3;
burger1.enabled = false;
fireball1.enabled = false;
herobar.width +=20
SOUNDCHANNEL = EATING.play()
points--
}
if ( points >= 2 ){
burger1.enabled = true;
fireball1.enabled = true;
burger1.alpha = 1;
fireball1.alpha = 1;
herobar.width +=20
points--
SOUNDCHANNEL = EATING.play()
}
else if (points==0){
burger1.enabled = false;
fireball1.enabled = false;
burger1.alpha = .3;
fireball1.alpha = .3;
}
if (herobar.width >= 80){
herobar.width = 80}
score.text = String(points);
if (score.text < "0" ){
score.text = "0";
}
if (points< 0){
points = 0;
}
}
}
}
and there is another in the main class
here
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
public class gamekkooooo extends MovieClip {
public function gamekkooooo() {
stop()
addEventListener(Event.ENTER_FRAME, onEnterFrame);
begin.a1.addEventListener(MouseEvent.CLICK, onmouseclicka1);
}
public function onEnterFrame (event:MouseEvent):void
{
if (currentFrame == 27)
begin.stop()
}
public function onmouseclicka1 (event:MouseEvent):void
{
begin.play()
}
}
}
i hope you guys can help me i realy couldn.t fix it alone
thank you
the error means that something is not initialised in onEnterFrame of admin1.as and it's on line 108
I think this is
volt.alpha = .3
(please confirm this for me if it's different paste line 108 here.)
the error means that volt has not been initialised and it loops because it's in onEnterFrame (you can see that from the error) and onEnterFrame is called on every frame.
Copy link to clipboard
Copied
go to File->Publish Settings->Flash and tick permit debugging under advanced
run the and code again and repaste the output here
I did spot one mistake so far
in class gamekkooooo
public function onEnterFrame (event:MouseEvent):void
should be
public function onEnterFrame (event:Event):void
Copy link to clipboard
Copied
lol yeah i just forget that point in gamekoo class
but still there is problem when it runs
here
(i did what you say in advanced premet)
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at admin1/onEnterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at admin1/onEnterFrame()
TypeError: Error #1009: Cannot access a property or method
and keep looping i dont know why?
thank you again brother
Copy link to clipboard
Copied
the error means that something is not initialised in onEnterFrame of admin1.as and it's on line 108
I think this is
volt.alpha = .3
(please confirm this for me if it's different paste line 108 here.)
the error means that volt has not been initialised and it loops because it's in onEnterFrame (you can see that from the error) and onEnterFrame is called on every frame.
Copy link to clipboard
Copied
i removed it but still problem??
here what am doing
iam making a game with quiz if you answer this question correct you will get 1 point or if it worng you will lose 1 point then your health bar will be less and the frames should moves (for game effect) and here is the problem when it moves
can i send the files to you ? it will be clear more than writing i guess
thank you again