Stack fade-In

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Stack fade-In

Post by keyless » Wed Mar 18, 2009 9:01 pm

I want to have a stack fade into view. I remember seeing or having a clip of code that used BlendLevel to fade the Stack into view smoothly. Can't seem to find now though.

I've experimented with a repeat down to 0, but my results haven't worked proper, or looked choppy.

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed Mar 18, 2009 9:18 pm

Hi keyless, the bit of code I was shown uses a repeat but there isn't any choppiness, and also its a fade out, so I guess fade in should be okay with the first line reversed. Plus you'll have to set your stack as transparent first, of course:

Code: Select all

on preOpenCard
Set the blendLevel of stack "Registration" to 100
end preOpenCard

on openCard
   repeat with BlendOut = 100 to 0 step 2
        set the blendlevel of stack "Registration" to BlendOut
        wait 10 milliseconds
    end repeat
end openCard
Hope that does the job for you (but if that's the code you had anyway, I expect there must be something else needed for a fade in...)

:)

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Wed Mar 18, 2009 10:17 pm

First, Thanks for the script, it is similar to what I was trying, but more refined. The one I think I had before had some calculation for the wait, but I suspect this will be fine if I can get it to work.

everything about that script looks right, but when I put it in a stack, no fade in, I just see the card flash quick but nothings comes up. Blendlevel appears to stay at 100.

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Wed Mar 18, 2009 11:52 pm

That's mighty odd, I can't get a fade in to work either, even from a button press (and with a correction):

Code: Select all

repeat with BlendOut = 100 down to 0 step 2 
Something missing here, I suppose but unfortunately I don't know what...

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Mar 19, 2009 12:58 am

If it's an effect for a standalone, then this might work in the main stack script:

Code: Select all

on startup
   set the visible of this stack to false
   lock screen
   set the blendLevel of this stack to 100
   set the visible of this stack to true
   unlock screen
   send "blendIn 98" to this stack
end startup

on blendIn pBlendLevel
   set the blendLevel of this stack to pBlendLevel
   subtract 2 from pBlendLevel
   if pBlendLevel >= 0 then
      send "blendIn" && pBlendLevel to this stack in 15 milliseconds
   end if
end blendIn
If you want to open a substack or another card, then you can "go invisible" card or stack and in the preOpenCard/preOpenStack handler kick off the blend level and invisibility before starting the blendIn handler. Doing it that way, even with the lock screen and setting of invisibility I can't avoid getting a quick flicker of the stack being displayed and then made invisible.

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Thu Mar 19, 2009 3:43 am

Thanks Sparkout, your script works great, fade in is nice and smooth.

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Mar 24, 2009 5:48 pm

I found a way to make the preOpenStack method work without the flicker. (Doing it all in the preOpenStack makes it go a bit lala.) This works nicely here:

Code: Select all

on preOpenStack
   set the visible of this stack to false
end preOpenStack

on openStack
   set the blendLevel of this stack to 100
   set the visible of this stack to true
   send "blendIn 99" to this stack
end openStack

on blendIn pBlendLevel
   set the blendLevel of this stack to pBlendLevel
   subtract 1 from pBlendLevel
   if pBlendLevel >= 0 then
      send "blendIn" && pBlendLevel to this stack in 15 milliseconds
   end if
end blendIn

Post Reply