Grab Image

Monkey Forums/Monkey Programming/Grab Image

darky000(Posted 2013) [#1]
Hello,

I am getting this error during runtime:
Monkey RunTime Error: TypeError: Cannot Read property "f_x" of undefined

Here's a snippet of the code that causes the error:
[codebox]
Field ctr:int = 30
Field whiteghost:int = 0
 
If whiteghost <> 360 Then
	If whiteghost = (4 * 60) + ctr Then
		For Local foe:= EachIn foes
			foe.img = char.GrabImage(2 * 24, 4 * 24, 24, 24, 2, Image.MidHandle)
		Next
		
		ctr += 30
											
	ElseIf whiteghost = (4 * 60) + ctr-15 Then
		For Local foe:= EachIn foes
			foe.img = char.GrabImage(0 * 24, 4 * 24, 24, 24, 2, Image.MidHandle)
		Next
	EndIf
						
	whiteghost += 1
EndIf

[/codebox]
I am trying to recreate pacman and I keep changing the image when they start blinking while they are animating. Any other images I change which doesn't cause a series of changes won't cause this error. What might be a solution to this? I have been stumped in this area for a long time trying to figure it out. Can someone also explain why this is happening?


MikeHart(Posted 2013) [#2]
Are you sure that it is that code part? The line number you get is not the line inside the monkey script, it is in the build code file. f_ is a prefix of a class field. The field x wasn't found. Your script doesn't use x at all so it must be something else I think.


darky000(Posted 2013) [#3]
Hi Mike. Thanks for replying quickly on my problems all the time.

If it helps, I'm using your fantomEngine with the latest version and MonkeyPro 63b. I tried disabling all my graphics method to test it and just activated this snippet and the CreateAnimImage on all foes. It sometimes can go about two counts in the loop before reaching the error.


MikeHart(Posted 2013) [#4]
It also helps to activate strict mode via a STRICT statement at the top of your script. Please add this if you haven't already.


darky000(Posted 2013) [#5]
Yes I have STRICT activated.


MikeHart(Posted 2013) [#6]
I'm using your fantomEngine with the latest version and MonkeyPro 63b

Please update to Monkey V69 at least.

If you can't figure it out, then you can send me the project to

mike (a t ) whiteskygames (d ot) com

if you want and I can have a look tonight.

This code snipped doesn't use any method from fE so I would be surprised if there is something that breaks it.


darky000(Posted 2013) [#7]
Ok sure... I don't mind at all. I'll try to tinker with it more though and thanks.


MikeHart(Posted 2013) [#8]
After you update, make sure you delete the build folder.


darky000(Posted 2013) [#9]
I've sent you the mail