Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
With the ever-growing number of devices and different form factors, the implementation of Splash screen in Flex 4.5 was simply not going to scale. Adobe has created a brand-new component with the name of SplashScreenImage for Flex 4.6. SplashScreenImage was specifically designed to let us specify different Splash screens based on the specific device and orientation. To create this new dynamic Splash screen, all we have to do is create a new MXML file based on Splash screen image and then add multiple instances of Splash screen image source that define what asset to use, based on the DPI, or dots per inch, or screen resolution of the device.
Let's explore how to do this. So the first thing I'm going to do is open up Flash Builder of course, and I'm going to import a new project, and I'm going to import here, under Starting, 1-9.fxp. And then I'm going to click Finish and here's my 1.9.fxp, and you'll see here that I have some assets here. I have some different California flags, all PNG files, but one designed for 160 dots per inch, one designed for 240 devices, and another designed for 320. And then I have another California flag designed specifically for tablet devices.
I have a components folder that's already here, and then I have a default package with my SplashScreen.mxml. And you can see again just a very simple application tag, nothing in here, and it's being targeted here for a device with an application dpi of 160. Okay, so inside of my components package, I'm just going to build a brand-new component. Ao I'm going to say New > MXML Component inside of the components, and I'm going to call this MySplashScreen, okay. And then what I'm going to do is I'm going to utilize the SplashScreenImage control, so I'm just going to search for the SplashScreenImage.
Okay, and I'm going to inherit from this SplashScreenImage that you see here. So I'm going to click Finish, and this is going to build me a new component. Notice it says SplashScreenImage up here, so of course, it's inheriting from that. And then what I'm going to do is below the Declarations tag, I'm just going to add in a SplashScreenImageSource. So here, I'm going to simply say s:SplashScreenImageSource and I'm going to say okay.
If the dpi of the device is 160, I'm going to simply specify the source and I'm going to utilize this image. So here, I'm going to say source and we will embed this into our application, so I'll say @Embed, and I'll simply just say quote, dot, dot, and I'll say assets, which of course is my assets folder right here, and I'll say assets califlag160.png and I will close off the quote there, and then close that off as well.
So what I'm going to do is just, to save myself some typing, I'll simply just take this code, copy it, and paste that in right here, and then I'll say OK. So for a dpi of 240, let's pull in my 240 image. Perfect. And then here, I'll say for dpi of 320, and then the califlag here will of course specify 320. And then I will just paste one more time here, okay, and then instead of saying dpi here, we're going to say minResolution. And I'll say minResolution of 960, and then I'm going to simply specify my source and in this case instead of saying califlag, we're going to go to my calitablet PNG.
So again, I'll say calitablet.png, and this will be appropriate for tablet devices here. So I have my minResolution 960, the source Embed, and I have that there. Make sure your SplashScreenImage is saved, and then after this has been created, let's go back to my SplashScreenImage here, and what I want you to do is simply assign the class image to the SplashScreenImage in your main application tag. So here we're going to simply just say SplashScreenImage and I'm going to simply assign that class instance in my main application tag.
So here I'm going to simply say SplashScreenImage is equal to components.MySplashScreen, like so. All right, hit Save, and let's go ahead and test this on some different devices. So now if I say Run Configurations, and I go to my Mobile Application, we'll try--let's see what happens if I test this on an iPad. So I'm going to click here, and you should see the tablet image pops up as our Splash screen, and we saw a tablet image there.
Well, let's try it now on an Apple iPhone 3GS, the first-generation iPhone here. So I'm going to click there, and that's 160 dpi, so you can see that pulls in. Okay and let's now try it on an Apple iPhone 4 and see what happens there. And that's a 320 dpi. So you can see, depending on the device, it's going to pull in the appropriate image directly, so again, a huge enhancement here to the Splash screen image and very, very powerful.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 99857 Viewers
56 Video lessons · 112982 Viewers
71 Video lessons · 81811 Viewers
131 Video lessons · 39261 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.