Having nothing but errors today! It would be sooo nice to get a bit of help with this one.
I am calling external child swfs for an AIR app; SUPER SIMPLE - calling them with a button, and removing them with a "home" button, that's it. But I get these errors and I cannot publish, even a test, without crashing the entire system. Please help! I have been stuck on this, literally, for weeks!
this is the error:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at pocketDinos_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame_20_1()
[pocketDinos_fla.MainTimeline::frame162:18]
Test Movie terminated.
And this is what I assume is causing the problem on the main timeline (this is ALL the code on the main timeline):
stop();
//home button
button_home.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_01_1,false,0,true);
function fl_ClickToLoadUnloadSWF_01_1(event:MouseEvent):void
{
removeChild(fl_ProLoader_01);
fl_ProLoader_01.unloadAndStop();
fl_ProLoader_01 = null;
}
button_home.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndStopAtFrame_01_1,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_1(event:MouseEvent):void
{
removeChild(fl_ProLoader_01);
}
button_home.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds_01_1,false,0,true);
function fl_ClickToStopAllSounds_01_1(event:MouseEvent):void
{
SoundMixer.stopAll();
}
button_home.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndStopAtFrame_01_2,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_2(event:MouseEvent):void
{
gotoAndStop("home");
}
//back to time period button
back_to_triassic.addEventListener(MouseEvent.CLICK,
fl_ClickToLoadUnloadSWF_01_2,false,0,true);
function fl_ClickToLoadUnloadSWF_01_2(event:MouseEvent):void
{
removeChild(fl_ProLoader_01);
fl_ProLoader_01.unloadAndStop();
fl_ProLoader_01 = null;
}
back_to_triassic.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndStopAtFrame_01_3,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_3(event:MouseEvent):void
{
removeChild(fl_ProLoader_01);
}
back_to_triassic.addEventListener(MouseEvent.CLICK,
fl_ClickToStopAllSounds_01_2,false,0,true);
function fl_ClickToStopAllSounds_01_2(event:MouseEvent):void
{
SoundMixer.stopAll();
}
back_to_triassic.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndStopAtFrame_01_4,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_4(event:MouseEvent):void
{
gotoAndStop("TRI_home");
}
//start button
start_button_TRI_coelophysis.addEventListener(MouseEvent.CLICK,
fl_ClickToLoadUnloadSWF_01_3,false,0,true);
import fl.display.ProLoader;
import flash.events.Event;
var fl_ProLoader_01:ProLoader;
function fl_ClickToLoadUnloadSWF_01_3(event:MouseEvent):void
{
if(fl_ToLoad_01)
{
fl_ProLoader_01 = new ProLoader();
fl_ProLoader_01.load(new URLRequest("dinofilms/triassic_coelophysis.swf"));
fl_ProLoader_01.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete_01)
addChild(fl_ProLoader_01);
fl_ProLoader_01.x = 0;
fl_ProLoader_01.y = 144;
}
else
{
if(fl_ProLoader_01!=null) {
removeChild(fl_ProLoader_01);
fl_ProLoader_01.unloadAndStop();
fl_ProLoader_01 = null;
}
}
fl_ToLoad_01 = !fl_ToLoad_01;
}
function onComplete_01(e:Event):void {
e.currentTarget.content.addEventListener(Event.ENTER_FRAME,OEF_01);
}
function OEF_01(e:Event):void {
if(e.currentTarget.currentFrame==e.currentTarget.totalFrames) {
e.currentTarget.stop();
e.currentTarget.removeEventListener(Event.ENTER_FRAME,OEF_01);
removeChild(fl_ProLoader_01);
fl_ProLoader_01.unloadAndStop();
fl_ProLoader_01 = null;
}
}
In your function fl_ClickToGoToAndStopAtFrame_01_1 you say removeChild(fl_ProLoader_01); but you also call it in function fl_ClickToLoadUnloadSWF_01_1. Both functions are assigned to the same MovieClip/Button, so it will give an error that it is null, on line 18 where you call removeChild on the same MovieClip/Button again.
I think it got solved!
stop();
//home button
button_home.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndStopAtFrame_01_1,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_1(event:MouseEvent):void
{
if(fl_ProLoader_01 && fl_ProLoader_01.stage){
fl_ProLoader_01.parent.removeChild(fl_ProLoader_01);}
gotoAndStop("home");
}
button_home.addEventListener(MouseEvent.CLICK, fl_ClickToStopAllSounds_01_1,false,0,true);
function fl_ClickToStopAllSounds_01_1(event:MouseEvent):void
{
SoundMixer.stopAll();
}
//back to time period button
back_to_triassic.addEventListener(MouseEvent.CLICK,
fl_ClickToGoToAndStopAtFrame_01_3,false,0,true);
function fl_ClickToGoToAndStopAtFrame_01_3(event:MouseEvent):void
{
if(fl_ProLoader_01 && fl_ProLoader_01.stage){
fl_ProLoader_01.parent.removeChild(fl_ProLoader_01);}
gotoAndStop("TRI_home");
}
back_to_triassic.addEventListener(MouseEvent.CLICK,
fl_ClickToStopAllSounds_01_2,false,0,true);
function fl_ClickToStopAllSounds_01_2(event:MouseEvent):void
{
SoundMixer.stopAll();
}
However, I still am having the problem that the child files are not loading on the device itself - strange - they load fine on "test" export, but not when I publish to device (in this case ios). Does anyone have any ideas?
Related
I have an error saying:
Type 'GameManager' already defines a member called 'Update' with the same parameter types
Error message in Unity
This is my code
Your code looks like this:
void Update() {
...
}
void Update() {
...
}
You can only have one Update() definition. They should be merged into one.
Ok. like others said what you're trying is using GameObject like a method.
And it's not gonna work that way.
The Error you're getting now is caused by duplicated Update().
Try Change first Update() to Start()
Edited my codes below.
try below codes
void Start()
{
SelectZombie(selectedZombie);
}
void Update()
{
if(Input.GetKeyDown("left"))
{
GetZombieLeft();
}
if(Input.GetKeyDown("Right"))
{
GetZombieRight();
}
if(Input.GetKeyDown("up")){
}
}
void GetZombieLeft()
{
if (selectedZombiePosition == 0)
{
SelectZombie(zombies[3]);
}
else
{
GameObject newZombie = zombies[selectedZombiePosition - 1];
SelectZombie(newZombie);
}
}
void GetZombieRight()
{
if (selectedZombiePosition == 3)
{
SelectZombie(zombies[0]);
}
else
{
SelectZombie(zombies[selectedZombiePosition + 1]);
}
}
I have seen the same question with an answer, but unfortunately I haven't fully understood how to address the issue, as I get a null reference exception.
I try to have 2 coroutines run simultaneously. Each is from a different base class. They both are identical, apart from the class's name and activation key (one is Up Arrow and the other Down Arrow).
public IEnumerator DetectArrow()
{
if (Input.GetKey(KeyCode.UpArrow))
{
if (PrintMessage == null)
{
PrintMessage += SendMessage;
}
}
return null;
}
public void SendMessage()
{
print("I am B.");
PrintMessage = null;
}
I try to run something such as this for the entire run (from a parent class):
void Update ()
{
if (b.PrintMessage != null)
{
b.PrintMessage();
}
if (a.PrintMessage != null)
{
a.PrintMessage();
}
}
So I'm not quite sure how to solve this. Thanks for the help.
Anyone have any tips/code snippets for preventing more than one copy of a custom X++ form from being opened at a time?
Best case: Attempt to open another copy of the form, and the original gains focus
Acceptable: User receives a notice that the form is already open
you could insert the code below into the form's init method.
If you have any questions to the code don't hesitate to ask!
public void init()
{
#define.CACHE_OWNER ('MyForm')
#define.CACHE_KEY_INSTANCE ('Instance')
FormRun existingForm()
{
;
if (infolog.globalCache().isSet(#CACHE_OWNER, #CACHE_KEY_INSTANCE))
{
return infolog.globalCache().get(
#CACHE_OWNER, #CACHE_KEY_INSTANCE);
}
return null;
}
void registerThisForm()
{
;
infolog.globalCache().set(#CACHE_OWNER, #CACHE_KEY_INSTANCE, this);
}
boolean isAlreadyOpened()
{
;
return existingForm() ? !existingForm().closed() : false;
}
void activateExistingForm()
{
;
existingForm().activate(true);
}
;
super();
if (isAlreadyOpened())
{
activateExistingForm();
this.close();
}
else
{
registerThisForm();
}
}
Add the following code to the init method of the form as follows. No other changes are required.
public void init()
{
#define.CACHE_OWNER('MyForm')
int hWnd;
super();
if (infolog.globalCache().isSet(#CACHE_OWNER, curUserId()))
{
hWnd = infolog.globalCache().get(#CACHE_OWNER, curUserId());
}
if (WinApi::isWindow(hWnd))
{
element.closeCancel();
WinAPI::bringWindowToTop(hWnd);
}
else
{
infolog.globalCache().set(#CACHE_OWNER, curUserId(), element.hWnd());
}
}
I've little trouble with my simple game.
I'm using this code for menu control:
#pragma strict
var isIZADJI=false;
function OnMouseEnter()
{
renderer.material.color=Color.red;
}
function OnMouseExit()
{
renderer.material.color=Color.white;
}
function OnMouseUp()
{
if(isIZADJI)
{
Application.Quit();
}
else
{
Kontrola_Zivota.ZIVOTI=3;
Application.LoadLevel(1);
}
}
When I click "Play Again" it works fine but when I click "Exit" it just load first level.
Any help here?
I just thought I'd expand on the solution:
I was reading through your code and I see that what you were looking for was a way to identify which button was clicked. I would like to expand on your answer for anyone who want's to know what your solution was. The way to solve this is to create a string variable to check the name of the thing you are clicking (assuming this is GUI Button) and then to change the state of the var isIZADJI based on that eg:
// izlaz[croatian] = exit[english]
// First create a string var for the name of button/GUI/object
var nameOfButton : String;
function OnMouseUp()
{
if(!(nameOfButton == "izlaz"))
{
isIZADJI = false;
}
else
{
isIZDAJI = true;
}
// And then now you can add the rest of your code to quit or load a level
if(isIZADJI)
{
Application.Quit();
}
else
{
Kontrola_Zivota.ZIVOTI=3;
Application.LoadLevel(1);
}
}
I hope this helps anyone else with this problem.
I am creating a facebook application with the help of Facebook graph API in Actionscript3. For some weird reason 2 days ago Facebook.addJSEventListener decided not to call the callback function anymore.
Here is my code:
static public function ConnectToApp(sAppID_:String , sPermissions_:String, sRedirectURL_:String):void
{
sAppID = sAppID_;
sPermissions = sPermissions_;
sRedirectURL = sRedirectURL_;
Facebook.init(sAppID, loginHandler);
}
static private function loginHandler(objectSession_:Object,objectFail_:Object):void
{
if( objectSession_ == null)
{
ExternalInterface.call("redirect",sAppID, sPermissions,sRedirectURL);
}
Facebook.addJSEventListener('auth.statusChange', detectLogin);
}
static private function detectLogin(userInfo_:Object):void
{
if (userInfo_.status == "connected")
{
iUserStatus = Globals.FB_USER_CONNECTED;
iUserID = userInfo_.authResponse.userID;
Facebook.api('/me' ,getMeHandler);
Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
sProfilePicURL = Facebook.getImageUrl(iUserID.toString());
loadMyPicture();
}
else if (userInfo_.status == "not_authorized")
{
iUserStatus = Globals.FB_USER_NOT_AUTHORIZED;
}
else
{
iUserStatus = Globals.FB_USER_NOT_CONNECTED;
}
}
Facebook.init is calling the loginHandler callback function but Facebook.addJSEventListener('auth.statusChange', detectLogin); decides not to.
Thank you in advance for all the help.
I was able to get it to work. I did the following code change:
static public function ConnectToApp(sAppID_:String , sPermissions_:String, sRedirectURL_:String):void
{
sAppID = sAppID_;
sPermissions = sPermissions_;
sRedirectURL = sRedirectURL_;
Facebook.init(sAppID, loginHandler);
}
static private function loginHandler(objectSession_:Object,objectFail_:Object):void
{
if( objectSession_ == null)
{
ExternalInterface.call("redirect",sAppID, sPermissions,sRedirectURL);
return;
}
GetAllInfo();
}
static private function GetAllInfo():void
{
iUserStatus = Globals.FB_USER_CONNECTED;
iUserID = int(Facebook.getAuthResponse().uid);
Facebook.api('/me' ,getMeHandler);
Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");
sProfilePicURL = Facebook.getImageUrl(iUserID.toString());
loadMyPicture();
}
So basically now I'm not adding an event listener that calls a callback function when the user is connected, if the session is not ready I redirect and return... when the session is ready I automatically start getting the information.
I am not sure if I will ever get a problem where I start asking for the info before fully logging in but so far I did a lot of tests and it seems to work.
If anyone has a better solution please let me know.