B4J Code Snippet Splash Screen

Simple sub to create a splash screen.

splash.gif
B4X:
Sub ShowSplashScreen
   Dim sp As Form
   sp.Initialize("sp", 600, 600)
   sp.SetFormStyle("TRANSPARENT")
   sp.BackColor = fx.Colors.Transparent
   'change image here
   CSSUtils.SetBackgroundImage(sp.RootPane, File.DirAssets, "B4R_512_512_transparent.png")
   sp.Show
   sp.RootPane.Alpha = 0
   sp.RootPane.SetAlphaAnimated(500, 1)
   Wait For (sp.RootPane) sp_AnimationCompleted
   Sleep(3000)
   sp.RootPane.SetAlphaAnimated(1000, 0)
   Wait For (sp.RootPane) sp_AnimationCompleted
   sp.Close
   CallSubDelayed(Me, "Splash_Complete")
End Sub

Project is attached.

Edit: sp.Close was missing.
 

Attachments

  • Splash.zip
    15.4 KB · Views: 1,062
Last edited:

gvoulg

Member
Licensed User
Longtime User
getting this error when running the program
Waiting for debugger to connect...
Program started.
Αυγ 23, 2017 1:39:33 ΜΜ com.sun.javafx.css.parser.CSSParser term
WARNING: CSS Error parsing '*{-fx-background-image:url(file:/C:/Program%20Files%20(x86)/Anywhere%20Software/B4J/Projects/B4J/Files/B4R_512_512_transparent.png);-fx-background-size:stretch;}: Unexpected token 'file:/C:/Program%20Files%20' at [1,23]
Regards
George
 

luke2012

Well-Known Member
Licensed User
Longtime User
Simple sub to create a splash screen.

View attachment 58487
B4X:
Sub ShowSplashScreen
   Dim sp As Form
   sp.Initialize("sp", 600, 600)
   sp.SetFormStyle("TRANSPARENT")
   sp.BackColor = fx.Colors.Transparent
   'change image here
   CSSUtils.SetBackgroundImage(sp.RootPane, File.DirAssets, "B4R_512_512_transparent.png")
   sp.Show
   sp.RootPane.Alpha = 0
   sp.RootPane.SetAlphaAnimated(500, 1)
   Wait For (sp.RootPane) sp_AnimationCompleted
   Sleep(3000)
   sp.RootPane.SetAlphaAnimated(1000, 0)
   Wait For (sp.RootPane) sp_AnimationCompleted
   sp.Close
   CallSubDelayed(Me, "Splash_Complete")
End Sub

Project is attached.

Edit: sp.Close was missing.

Is there a XUI SplashScreen ?
 
Top