Control Array Element '#' Doesn't Exist [SOLVED! :)]

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Control Array Element '#' Doesn't Exist [SOLVED! :)]

Postby 3dgamer » Wed Apr 15, 2009 6:26 am

Hi there,

I was wondering if any one knows why sometimes an error message stating: "Control array element '3' doesn't exist" (please see below), would show up? I get this error message infrequently, but it still is there and I have to get rid of it before doing my final compilation.

This error message occurs whenever I am accessing the hotspot with this particular code:

Code: Select all
If stop_video_a = 1 Then
StopVideo1
ElseIf stop_video_b = 1 Then
StopVideo2
ElseIf stop_video_c = 1 Then
StopVideo3
ElseIf stop_video_d = 1 Then
StopVideo4
End If


Whenever one of these 4 videos are playing, their variables are set to "1". Then when the player leaves the room, the hotspot with the code stops the video (that is, if it hasn't stopped already). So basically what this code does is stop any video that is running to prevent "bleed over" when going to another frame. It actually works very well, except for when this message occasionally pops up. I can go through a few sessions without this popping up, but then it does pop up. :(

Any clues?

Thanks in advance!
Attachments
array_3_issues.jpg
array_3_issues.jpg (40.52 KiB) Viewed 4583 times
Last edited by 3dgamer on Sun Apr 19, 2009 7:47 am, edited 1 time in total.
3DGamer
User avatar
3dgamer
Expert Member
 
Posts: 301
Joined: Mon Dec 15, 2008 7:12 am

Postby Mystery » Wed Apr 15, 2009 6:41 am

There is a similar question in another thread:
http://www.adventuremaker.com/phpBB2/vi ... php?t=4763

I'm not sure if this is the same issue, but it could be. Maybe reading through it will give you some ideas :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby 3dgamer » Wed Apr 15, 2009 6:55 am

Thank you, Mystery! :) Yes, this is basically identical to the problem I have been dealing with.

I just tried it and so far, so good. :) A bit more testing will be the proof, but it looks like it might be fixed, now, with the resolution found in that thread. Will plan to report back later and let you know how things go.

Again, thanks for the link. :)
3DGamer
User avatar
3dgamer
Expert Member
 
Posts: 301
Joined: Mon Dec 15, 2008 7:12 am

Postby Mystery » Wed Apr 15, 2009 6:57 am

You're welcome 3dgamer :)
I hope that the issue has been permanently fixed :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby mercedes » Wed Apr 15, 2009 7:20 am

Hey 3D..:D

Normally, control element errors 1 , 2 or 3 etc..Means you have called for it in a code..and they no longer exist or never existed at all..
Be it a hotspot(3) or Text(3).. in this case, I would think-- Your 3rd video,..

If you scroll down to the end of the link Mystery gave, you will see a better way of coding for sound/video ---- stopping it within the same code--[ Juhuwoorps post] :D


By the way is this a new game..Or the same one..

Edit** I just seen both your posts--posting at the same time..:P
Great minds think alike!~
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby 3dgamer » Thu Apr 16, 2009 7:27 am

Hey Mercedes, :)

mercedes wrote:Hey 3D..:D

Normally, control element errors 1 , 2 or 3 etc..Means you have called for it in a code..and they no longer exist or never existed at all..
Be it a hotspot(3) or Text(3).. in this case, I would think-- Your 3rd video,..

If you scroll down to the end of the link Mystery gave, you will see a better way of coding for sound/video ---- stopping it within the same code--[ Juhuwoorps post] :D


Thank you for the extra info and advice because unfortunately, the quick fix I did, did not resolve the issue. :( <sigh> The things you point out explain things better... I will look at the thread again that Mystery pointed me to, take a look at my code, make adjustments and see what I can find...


mercedes wrote:By the way is this a new game..Or the same one..


Yep, same one. :)

mercedes wrote:Edit** I just seen both your posts--posting at the same time..:P
Great minds think alike!~


...just trying to give some positive feedback to let them know that the thread, though posted several weeks ago, was helpful. :)

Thanks again for your help. Will let you know what happens...
3DGamer
User avatar
3dgamer
Expert Member
 
Posts: 301
Joined: Mon Dec 15, 2008 7:12 am

Postby mercedes » Thu Apr 16, 2009 8:28 am

Hey... :D

Also wanted to mention;

It could also be something being called for the 3rd time..Which could be a variable as well..For instance if u call for say someone to click a hotspot 4 times..and the third variable is missing..It would say control element 3 --can't be found..

I know i mention your 3rd video..but it could be any third element--within that hotspot..or within that frame as well..If u have something in the advanced/procedure and its called for when the frame loads~..:)

I hope it soon works for u..!~

Peace
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby 3dgamer » Thu Apr 16, 2009 9:44 am

Hey Mercedes!

mercedes wrote:Hey... :D

Also wanted to mention;

It could also be something being called for the 3rd time..Which could be a variable as well..For instance if u call for say someone to click a hotspot 4 times..and the third variable is missing..It would say control element 3 --can't be found..

I know i mention your 3rd video..but it could be any third element--within that hotspot..or within that frame as well..If u have something in the advanced/procedure and its called for when the frame loads~..:)

I hope it soon works for u..!~

Peace


Thanks for the extra advice, Mercedes, because I believe you are hitting the nail on the head there. :) I was able to narrow it down to the 3rd hotspot where a variable is being called multiple times.

Just to set the code flow up for you; in my 3rd hotspot I have a variable that is keeping count of the clicks. After three clicks, then another variable is set that triggers another hotspot. When I load a saved game where either the third click is not engaged yet or after the third click has been engaged, I get the error message.

Here is what I have in the 3rd hotspot monitoring the three clicks:

Code: Select all
PlayVideo1 GetPath(2) + "video.avi", 410, 240, 80, 80, False
inspect_VAR = inspect_VAR - 1
If inspect_VAR = -3 Then
Action.CreateTimedEvent 7, "inspect_item=1"
End If


Btw, every time the hotspot is clicked another variable is also set:
Code: Select all
stop_video_a=1


Then with this variable set, the hotspot that leads to a new frame has the following code:

Code: Select all
If stop_video_a=1 Then
StopVideo1
Else
stop_video_a=0
End If


This is so the video will stop when going to a different frame.

(Yes, it is a little different from Juhu's, but I tried something similar and it still gave the same results:

Code: Select all
If stop_video_a=1 Then
StopVideo1
stop_video_a=0
End If


)

So, in theory, the video should stop if it is being played. It does (so that part is good), but I do get the error message if I load a saved game that occurred right before or after the 3 clicks, if I attempt to go to the hotspot with the "StopVideo1" command in it. So the clicks that have already taken place are not being acknowledged from the saved game. :(

Any guidance with this?

Thanks! :D
3DGamer
User avatar
3dgamer
Expert Member
 
Posts: 301
Joined: Mon Dec 15, 2008 7:12 am

Postby mercedes » Fri Apr 17, 2009 2:39 am

Hey..:D

Hm..Have you tried to put something in the frame's properties....Or from project properties..when a saved game is loaded..You did try Juhu's way and u still seen the error messages..?
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby juhuwoorps » Fri Apr 17, 2009 7:05 am

Do you have declared the stop_video_a variable as VBS variable?
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby 3dgamer » Fri Apr 17, 2009 7:46 am

Hey there... :)

mercedes wrote:Hey..:D

Hm..Have you tried to put something in the frame's properties....Or from project properties..when a saved game is loaded..You did try Juhu's way and u still seen the error messages..?


Yes, yes, yes, and yes. ;) Same thing no matter what.

juhuwoorps wrote:Do you have declared the stop_video_a variable as VBS variable?


Yep, all are declared as VBS Variables.


I think I am a little closer to finding what the problem is, though.

What I did was save a game after two clicks and then open it up to see if I could see any anomalies in the code and what I found was very interesting. In the section for the code counting the clicks I found the following:

Code: Select all
inspect_VAR
-2
0
2


The strange thing is that no other variable in my saved game has three lines except this variable.

I also tried it in a different test game. I used basically the same code setup for counting the clicks and saved the game after one click. But look what I go as far as code in the saved game:

Code: Select all
"count"
1
0
0
1


There are four lines associated with this variable. So it seems that AM is creating this extra lines of info (array?) for some reason.

The real test is that I need to set up the video in the test game the exact same way (using external folder) and insert a stop video command to see what happens, but it is getting late, so I will do that later and report back.

Thank you both for the help. :)
3DGamer
User avatar
3dgamer
Expert Member
 
Posts: 301
Joined: Mon Dec 15, 2008 7:12 am

Postby mercedes » Fri Apr 17, 2009 8:34 pm

Hey..3D

I'm trying to imagine this, so can u set it up a bit..
How many videos do u have..and how many hotspots--play video..and also stop it..with variables..:)

So far I think you have 4 videos..not sure about how many hotspots..

That is if u want too, I figure maybe one of us can try it on our side...:D
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby 3dgamer » Fri Apr 17, 2009 11:40 pm

Hi Mercedes,

mercedes wrote:....How many videos do u have..and how many hotspots--play video..and also stop it..with variables..:)


Well, in that frame there are 4 videos. There are also 4 hotspots associated with those videos. There is only one hotspot, right now, that I have the "StopVideo" command in (because that one goes to another frame). But there is a total of 9 hotspots in that frame.

Hth some...

...will try to type more later with some more information, but gotta run for now...

Thanks! :)

-----------------------[EDIT 1]-------------------------------------


Okay, I think I am getting closer to what exactly the issue is. I Googled this error message and one person stated it was due to "...trying to access element (#) of a control array that has not yet been loaded...." - http://www.tech-archive.net/Archive/VB/microsoft.public.vb.controls/2004-08/0232.html. Also I read in another place where someone reset their variable and it worked for them - http://www.xtremevbtalk.com/showthread.php?t=13790

I think this is happening to my code. The play video/click counter hotspot is not being loaded at loadgame time, before the hotspot containing the "StopVideo" code is accessed. But if I load a game and access the hotspot containing the play video/click counter variable, and then access the hotspot with the "StopVideo", I don't get the error message.

So it seems that I need some way to either reset the counter variable upon loadgame, or somehow load the counter information so AM will recognize it after a saved game has been loaded. But the question now is how to do it.

Any clues?

Thanks. :)


-----------------[EDIT 2]-----------------------------------

Okay...something just came to mind...it is a non-VBS approach which may work for this...I'll let you all know...

Cya...

-----------------[EDIT 3]-----------------------------------

Okay, after many hours of trial and error, I found that there is no real non-VBS approach to solving this problem. I also tried practically every permutation of VBS coding that I knew (which is relatively small since I am just learning). However, through much brain agonizing and prayer (literally), I think that I have found a solution that should tackle this problem once and for all (and for other Control Array issues, as well). I tested this solution out several times and I can't get it to display the "Control array element '3' doesn't exist" error message any more.

So what I did in order to resolve the error message for the "Control array element '3' doesn't exist" problem was to...[drum roll]...load the control that allegedly did not exist! ;) Okay, I know that really is not profound but I suspected earlier that I had to do this, but I didn't know how. It loads when you access it during game play, but coming from a loaded game, the control just isn't accessed before being called upon in a hotspot that uses code that is dependent on it in some way. So I literally loaded the control in the hotspot that was calling it, and voila! :)

So just for a mini-tutorial for future reference with similar issues, when you get a "Control array element '#' doesn't exist" error message, try the following:

1) Go to the VBS Procedure (Advanced) link (found in the main menu on the left) and look for the control array number in the "PlayVideo" Sub Routine code (or other applicable "LoadControl" code). In my case it is number "3". This corresponds to the following code in my VBScript Global Procedures:

Code: Select all
Action.LoadControl MediaPlayerObject(3)


2) Highlight and copy the code.

3) Then go to the frame that the error is occurring (the same frame where you clicked the hotspot that showed that error message) and open up the "Properties" of the offending hotspot.

4) Go to the "Advanced" tab and paste the code in at the top.

5) Then play the game as usual and it should work now with no more error message. :)

I haven't tried it at the Frame Properties > Advanced Tab level, but it should work (in the theory) I would imagine. I am just glad I finally got it to work in the offending hotspot, so I'm not touching it! ;)

Well, trying to resolve this issue has been one grueling ordeal, to say the least. Hopefully, though, the approach I used will be applicable to other control array issues so that other AM game devs. won't have to use up so much time like I did. But I am happy now! :D

Again, thanks you guys [ okay, okay, you "gals" and one "guy";) ] for steering me in the right direction. :D

Take care and happy coding! ;)
3DGamer
User avatar
3dgamer
Expert Member
 
Posts: 301
Joined: Mon Dec 15, 2008 7:12 am


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

cron