Hi friends
If you know me, you would also know that I was working AS2 and I can do almost anything with AS2, but Im migrating to AS3 and I’m a newbe.
considering that, I realized, this error is happen when something that not suppose to be Null, be Null. but I can’t figure it out in my project, even after debugging!
Here is what’s happened:
I used this guy class of frames fade transition and it works fine on one of my frames but on another frame it works but with this error!!
My declaration which gives me error:
Fade.fadeIntoFrame(root,stage,"step2");
well root and stage are predefined! “step2” is my frame label! I have same situation on my previous frame too! I cant figure it out! what should I do?
my whole code:
//mainMenu Frame
stop();
//EVENT LISTENERS
tt_btn.addEventListener(MouseEvent.CLICK,onClick1);
uw_btn.addEventListener(MouseEvent.CLICK,onClick1);
ec_btn.addEventListener(MouseEvent.CLICK,onClick1);
pp_btn.addEventListener(MouseEvent.CLICK,onClick1);
ut_btn.addEventListener(MouseEvent.CLICK,onClick1);
//EVENT HANDLERS;
function onClick1(event:MouseEvent):void
{
switch (event.target)
{
case tt_btn :
Fade.fadeIntoFrame(root,stage,"tT");
break;
case uw_btn :
gotoAndStop("uW");
break;
case ec_btn :
gotoAndStop("eC");
break;
case pp_btn :
gotoAndStop("rP");
break;
case ut_btn :
gotoAndStop("uT");
break;
}
}
//tt Frame
stop();
b0_btn.addEventListener(MouseEvent.CLICK,onClick2);
b1_btn.addEventListener(MouseEvent.CLICK,onClick2);
b2_btn.addEventListener(MouseEvent.CLICK,onClick2);
b3_btn.addEventListener(MouseEvent.CLICK,onClick2);
b4_btn.addEventListener(MouseEvent.CLICK,onClick2);
b5_btn.addEventListener(MouseEvent.CLICK,onClick2);
b6_btn.addEventListener(MouseEvent.CLICK,onClick2);
b7_btn.addEventListener(MouseEvent.CLICK,onClick2);
b8_btn.addEventListener(MouseEvent.CLICK,onClick2);
b9_btn.addEventListener(MouseEvent.CLICK,onClick2);
next_btn.addEventListener(MouseEvent.CLICK,onClick2);
prev_btn.addEventListener(MouseEvent.CLICK,onClick2);
del_btn.addEventListener(MouseEvent.CLICK,onClick2);
function onClick2(event:MouseEvent):void
{
var num:String = new String("");
error_txt.text = "";
switch (event.target)
{
case b0_btn : num = "0"; break;
case b1_btn : num = "1"; break;
case b2_btn : num = "2"; break;
case b3_btn : num = "3"; break;
case b4_btn : num = "4"; break;
case b5_btn : num = "5"; break;
case b6_btn : num = "6"; break;
case b7_btn : num = "7"; break;
case b8_btn : num = "8"; break;
case b9_btn : num = "9"; break;
case del_btn :
capacity_txt.text = capacity_txt.text.substring(0,capacity_txt.text.length - 1);
break;
case prev_btn :
Fade.fadeIntoFrame(root,stage,"mainMenu");
break;
case next_btn :
if ((capacity_txt.text.length==0) || (capacity_txt.text == "0"))
{
error_txt.text = "No Capacity Entered";
}
else if (Number(capacity_txt.text) > 240)
{
error_txt.text = "Maximum Capacity Overflow";
}
else
{
Fade.fadeIntoFrame(root,stage,"step2");
}
break;
}
if (capacity_txt.text.length < 3) //This is line 76 which error says
{
if ((capacity_txt.text == "0")&&(num!=""))
{
capacity_txt.text = num;
}
else
{
capacity_txt.text += num;
}
}
}
And the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at NewProject_fla::MainTimeline/onClick2()[NewProject_fla.MainTimeline::frame5:76]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at NewProject_fla::MainTimeline/onClick2()[NewProject_fla.MainTimeline::frame5:76]