Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Checking a device's capabilities

From: Building Mobile Apps for Multiple Devices with Flash Professional

Video: Checking a device's capabilities

Understanding the capabilities and constraints of devices will really go a long way in making your app the best it can be. So what we are going to do is I am going to go ahead and show you how to check out all of the capabilities of the actual device the contents running on, and then you can start to make decisions based on that information. So what I am going to do first off is go to help, launch the Flash Help. In the Flash Help go ahead and do a search on Capabilities and then select flash.system.Capabilities from the ActionScript 3.0 Reference.

Checking a device's capabilities

Understanding the capabilities and constraints of devices will really go a long way in making your app the best it can be. So what we are going to do is I am going to go ahead and show you how to check out all of the capabilities of the actual device the contents running on, and then you can start to make decisions based on that information. So what I am going to do first off is go to help, launch the Flash Help. In the Flash Help go ahead and do a search on Capabilities and then select flash.system.Capabilities from the ActionScript 3.0 Reference.

So here it gives me this class, the Capabilities class, I can scroll down and see all of the various properties and click into each one of these, but really what you want to use the help for most of all are the code snippets that you get in here. So there are examples as I scroll clear down to the bottom, there's one right in here and it's the CapabilitiesExample.as files right here. It will go ahead and use the Capabilities object and put that information in the text field as well as put it in a trace statement.

So this is nice, I can go ahead and take this code, select it all, right-click, copy it and now I can jump into Flash. Let me minimize to help, back in Flash, I am going to go ahead and create a new file. In this case it's going to be an ActionScript 3.0 Class, remember it's called CapabilitiesExample, just like that, click OK and when I do that notice that it actually puts that name right in there.

So you do need to name the file appropriately and paste the code in there appropriately. So when I paste it in there, it gives me all my code and it still says CapabilitiesExample. So let me save this file and I'm going to go ahead and save it into this com folder, in this folder called utils, short for utilities, because this is something that I can actually use over-and-over again. It's not really specific to this project. Okay, this is an ActionScript file, click Save, and there it is.

Now keep in mind since I put it in that folder and I want to use it in the Monster.fla I need to change the package. So right up here, for the package, since it is in the com folder and end up type-in com.utils, and that's all I need to do. So I need to make sure the folder structure is set up right in here separated by Periods. So that looks good. I will save it.

So that package is created, it has this class right in here, and now I want to go ahead and use that in my Monster. fla, in fact, if I edit that class definition, I can take a look at this import statement. It's already pointing to this other class that I have created, that really I need to type-in import com, there it is. I can select that, Period. Now there are those three folders. I can select utils, just like that, and lastly CapabilitiesExample.

So now I am importing that entire package, but I want to use that CapabilitiesExample class. So I will just scroll down and right where I create all these various variables and instantiate some different items I can go ahead and instantiate that CapabilitiesExample. So I am going to go ahead and type-in private var, cap for capabilities, type-in CapabilitiesExample that shows up in my code hinting I can select it, equals new CapabilitiesExample.

All right, so we will go ahead and create a new CapabilitiesExample object based on that class. So I am going to save it and I am going to go back to my example ActionScript file because if I take a look, it actually is going to create this text field, and if I hit F4, we can take a look at this code a little easier. It's going to create this text field and put all of this information in a text field. And that's fine but I don't really want to have that displayed in my apps so I am going to select all of that code, in fact cleared out here to this addChild and I'm just going to delete it, because I don't want that code to appear in my app.

What I do want to see are all these trace statements, so in here I can start to get all of the information whether it's the pixelAspectRatio, screenColor, the DPI, the Resolution whatever I want to get I can go ahead and get that from these trace statements. Also keep in mind this is an AIR for mobile app, I can go ahead and uncomment these lines as well to get the cpuArchitecture, the languages things like that. So these are all the trace statements that I want to go ahead and see in my app.

Now the key thing here is I want to go ahead and debug this on my device. So I am going to save this file and I am going to go to debug and I am going to debug this on my device by USBs. When I do this, it's going to go ahead and give me all of those trace statements. Here we can see it running on my connected Android device, this is my app and really what I have done is I've implemented all these trace statements. That's going to go ahead and ping this device and figure out all the capabilities that this device can do.

So that's what it looks like on my device, let's go ahead and check it out in Flash Professional. Here it is, in Flash Professional you can see it changed my workspace to the Debug mode, in fact, if I just expand this out a little more and scroll up, you can see all of those trace statements that it's getting from my device. So as I scroll down I can see all of its capabilities, the manufacturer, so I can tell it's on an Android or an iOS device gives me the pixelAspectRatio. This is interesting; I start to get the Resolution of the device for 480x800, I can get the DPI, so the dots per inch or pixels per inch, as I scroll down I can even get the language.

So this is great, based on this information I can actually start to swap out some of the content if I want. So I can adjust the interface like I'm doing but I can more intelligently ping the device and say for instance if it's a device that is showing Spanish, I can change my language and all of the text in my app to Spanish. So you can see how powerful this is being able to get those system capabilities and then start to adjust your content based on the capabilities of the device.

Show transcript

This video is part of

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Building Mobile Apps for Multiple Devices with Flash Professional.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.