Page 1 of 1

Run code mid vissual effect ?

Posted: Fri Jun 24, 2011 10:04 am
by doobox
Hi there,

I wonder if this is possible.

I am trying to construct my card 1 to minimize the size of my app.
So i want to show / hide certain groups (menu) on the mid transition of the flip effect.

What i have here, gives the user a dodgy look at the menu switching out.
If i could run the two lines that show the new menu and hide the old, right in the middle of the flip effect. It would look like there was an actual card change.

Code: Select all

on mouseUp
   visual effect flip right 
   go card 1
   wait 500 milliseconds -- deos not work as the wait does not begin until after transition
   hide group "UploadMenu" -- i want to run these two lines mid transition
   show group "MainMenu"
   put "Upload was canceled" into  field "timeStamp" 
end mouseUp
Without that wait, you still get a glimpse of the menu switching out either before or after the transition, depending where i put it.

Kind regards
Gary

Re: Run code mid vissual effect ?

Posted: Fri Jun 24, 2011 10:26 am
by SparkOut
Not sure if it's what you want to achieve but you should be able to do something like

Code: Select all

on mouseUp
   go card 1
   hide group "UploadMenu" with visual effect flip
   show group "MainMenu" with visual effect flip
   put "Upload was canceled" into  field "timeStamp" 
end mouseUp
which sounds like it might be near what you want to do. You can give different controls different effects, and you can also stack effects to create combinations which will be applied in order.

Re: Run code mid vissual effect ?

Posted: Fri Jun 24, 2011 11:15 am
by doobox
Hi there,

Thanks for that, i was not aware that you could do the effects on individual controls.
I thought it was just an ios addition for the whole card. Nice to know.

The code you posted is not really what i was hoping for though.
I am not really looking to animate the menu switch.
I just hoped i could time the switch at the precise moment the card is visible in the window as 1px wide. You know "when it is exactly mid flip".

This way it would appear as if we were going to an entirely new card, as the user would not see the menu switch at all (being as it would occur, while the card is 1px wide).

It seems to me, with some toying around with that small snippet. That the code halts for the duration of the flip. i am wrong on that..?

Ps: in case you are not aware from the snippet. I am flipping from card 1 to card 1.

Re: Run code mid vissual effect ?

Posted: Fri Jun 24, 2011 11:26 am
by doobox
Just to elaborate on my reason for attempting this.

I assume that re-constructing the same card is going to save greatly on my app size, as it is quite heavy with custom image controls.

I have noticed in this first attempt at developing an ios app in live code that, re using the same image on a different card from the image inspector, duplicates the image in the inspector.
And i assume that will then be saved the the root of the app again.
So if i end up with say 4 cards, with for identical header images, i will end up with 4 identical, differently named images in the root of the app.

I have a gut feeling there will be a way to reference the first instance of the image from anywhere within the app.
Maybe someone could show me an example of that, if that is the case.

Thanks..!

Re: Run code mid vissual effect ?

Posted: Fri Jun 24, 2011 11:14 pm
by ctflatt
doobox:

Store your images in a folder at the same directory level as your app.

Place the image on your card using the File>New Referenced Control>Image File...

Select the image.

Place on as many cards as you like... the image is stored outside the stack in your image directory.

Be sure to include the image directory in the Standalone Application Settings under the Copy Files icon.

This should work to keep the file size down on image-heavy apps where several images are repeated.

HTH,

Todd

Re: Run code mid vissual effect ?

Posted: Sat Jun 25, 2011 3:49 am
by doobox
Hi Todd,

Thank You..!

I figured i could do that. But as with everything else today, i had hoped i was missing something really live code related.
Kinda takes the fun out of the image library /inspector.

Now to figure out how to load the images into memory, only when it is possible to navigate to that card.
I figure if i have say ten cards, but only three are reachable with one click from a given card, i need not load the images until i am 1 click away.

Again i am making assumptions that otherwise all the images in the project will load at startup (taking quite some time)

Re: Run code mid vissual effect ?

Posted: Sat Jun 25, 2011 4:09 am
by jacque
Now to figure out how to load the images into memory, only when it is possible to navigate to that card.
I figure if i have say ten cards, but only three are reachable with one click from a given card, i need not load the images until i am 1 click away.

Again i am making assumptions that otherwise all the images in the project will load at startup (taking quite some time)
You don't need to worry about any of that. LiveCode handles it all for you and is very intelligent about what and when it loads things. In general, the engine won't load an image until it needs to display it. It handles all memory management, you don't need to do anything. You can affect card loading speed marginally by setting an image's alwaysBuffer property to false, but the default works well and unless you have specific reasons to change it, I wouldn't mess with it.

Basically you can just reference each image object and forget about it.

Re: Run code mid vissual effect ?

Posted: Sat Jun 25, 2011 9:47 am
by ctflatt
doobox:

The only time LC loads all images by default is when they are placed directly on cards, as the entire stack is entirely loaded into memory before displaying the first card. Referencing your images in this manner doesn't add to the overall size of the stack, so it loads more quickly.

As jacque pointed out, LC handles the loading/unloading of images for you.

Have fun!

:Todd