Notifications
Clear all

[Closed] new rollout and bitmap

Hi,

this is my function to call a new rollout to appear:

	fn previewAsset img = (	-- function to open Asset Preview Window
		format "this is the image: %
" img
		rollout previewAsset "Asset Preview" width:300 height:300 (
		bitmap __IMG "" bitmap:img pos:[10,10] width:280 height:280
		)createDialog previewAsset
	)

It fails with this error:

– Runtime error: Bad free thunk local member index when accessing local: img <<

But when I use some exact image in the function it works fine, eg:

	fn previewAsset = (	-- function to open Asset Preview Window
		format "this is the image: %
" img
		rollout previewAsset "Asset Preview" width:300 height:400 (
		bitmap __IMG "" bitmap:@"path_to_the_image" pos:[10,10] width:280 height:280
		)createDialog previewAsset
	)
	
	previewAsset ()

It looks like the function doesn’t know what are any of the variables that are put inside the new rollout, but are set outside of it.

How can I make this to work?

What I want is a fuction to be able to call some path and will open some rollout. I need this as a function because I want to call it in an existing rollout. So sth like this: press a button > new floater appears with a bitmap

5 Replies

To make it simpler to see:

fn funcX x = (
	format "this is x: %
" x
	rollout test "" width:200 height:200 (
		edittext _text text:x
	)createDialog test
)
	
funcX "test"
1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

To make the answer simpler to see :):

fn funcX x = (
	format "this is x: %
" x
	test = rollout test "" width:200 height:200 (
		edittext _text
	)
        test._text.text = x
        createDialog test
)
	
funcX "test"

the function and the rollout defined inside the function live in different scopes. there is nothing that passes a reference of the function scope to the rollout scope. so the only way is to feed rollout properties after its creation

Ok I got rid of the function and managed to get this to work.

	rollout snapshotBar "Snapshot" width:320 height:320 (
		bitmap __IMG fileName:imgName pos:[15,15] width:280 height:280
		on snapshotBar open do (
			print imgName
		)
	)

than in the button I make:

	on __Assets rightClick obj do (
		imgName = substring __Assets.selected 1 (__Assets.selected.count-8)
		imgName = Paths[obj] + imgName +  "info.jpg"

		-- this is a piece from my code, this just gets the proper path to the image
	
		previewAssetFloater = newRolloutFloater "Asset Preview" 320 320
		addRollout snapshotBar previewAssetFloater
	
		imgName = #()
		gc()
	)

This works great, but two issues now.

#1 – How do I close with a command the previewAssetFloater window? I used both
try(destroyDialog previewAssetFloater)catch() and closeRolloutFloater but both are not working. Which is strange because I’m sure yesterday before I went to sleep closeRolloutFloater was working fine

#2 – To get different images in the previewAssetFloater I need to reload the whole script and I dont want this. I’m opening the rollout on the button, so thats why I added this

imgName = #()

at the end of the button code to make it sure that every time it loads the rollout it gets a new image. However it does not work, I only get the image at first opening, then I get empty bitmap space. If I remove this line I always get the same image, no matter what the value imgName is

Ok, you were right, forgot about this denisT. The fileName needs to be updated after the craeation, so…

	rollout snapshotBar "Snapshot" width:320 height:320 (
		bitmap __IMG fileName:imgName pos:[15,15] width:280 height:280
		on snapshotBar open do (
			__IMG.fileName = imgName
			print imgName
			imgName = ""
		)
	)

is working ok. Still some glitches, sometimes it gets the same pic but I believe I can fix it.

However I still dont know how to close this window with a command