cancel
 

 

Job type :

Zip Code :

community forums

Featuring over 100 topics of interest to DoItYourselfers.

How to Use the System Capabilities Object

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Video Transcript

So now, we have declared our variables, let us look at some functions for working with these variables. We are going to use a built in function in Flash called trace to see what this variables contain. So it is simple a case of typing the word trace, open parenthesis and whatever we put inside this parenthesis will be trace out the output window. In this case, we are going to type bHasMP3 and close brackets. If we run this right now bHasMP3 is now value. We have not said it we only just declare it.

Let us set bHasMP3 with some values. Let us go back to the line above, I am going to add in a character term and we are going to set a variable. This time we do not have to use the var because that just declaring the variable. We are going to use a variable name bHasMP3 and simply use the equals and whatever we put here bHasMP3 will take on the value of. Now, we are going to use some action script that is specific to Flash Light. It is going to be action script that interrogates the device that this will swf file is being played on and to do this we use the system object, system.capabilities and you can see we are getting some great coding in here as well as to what we might type.

This is system capabilities we are looking for is for the existence of an MP3 decoder on the device. So it is actions scripts, bHasMP3. System capability has MP3 or returns the Boolean either true or false and that is good because bHasMP3 is a variable has been data type to a Boolean. So let us go and test that movie and see what happens. We can go either control test movie or you can hit control enter. We have now got our mobile emulator but no device. I am just maximized this to full screen.

If we have not chosen the device through the device settings properties then we can do that quickly through the emulator. Just click on the link on the right and we get a device settings dialog. I am just going to choose the N70 and click ‘okay'. Now, we get our mobile emulator with the content from our game in place and you can see on the left that we have got output window. I am just going to move that into the middle a bit more and you can resize it just like any other window. And you can see in the output window, we have got the word "true" so this is the variables value that we have traced out.

Let us close our emulator and close out our output window too. We are going to do a similar thing now without sHas4Way string variable. Let us get back to our actions panel and underneath this code, we are going to type we are going to type in some new actions script. We are going to set the variable sHas4Way to another system capabilities return values. So System.capabilities and this time the action we are looking for is has4WayKeyAS. You can see my actions panel that the code is word wrapping so you might want to resize the actions panel, but I am just going to leave it the way this for the time being.

So we set the Variable sHas4Way, so let us try tracing that at just the same way as we did before using the trace function. So let us test that movie and see what we get, action script error. This is what happens in our output window when there is something wrong with our action script and it is pretty good outputting exactly where our error occurs in terms of the same number, the layer and the line number. This time it is telling us that we have got a type mismatch in assignment. So where we have got a Boolean it was expecting a string. Do you remember we set sHas4Way as a String? Well we have tried to set it as a Boolean now and action script is not locking it.

Let us go back to a code and let us change this. We can use some other pre-built functions in flash to change strings into numbers and number into strings or even Boolean as well. So we want to change sHas4Way into a String. So our system.capalitie.has4WayKeyAS is currently Boolean. We just need to enclose it in the string function. There, we have got string open parenthesis, the same action script before close parenthesis. So this means that whatever it returned from system capabilities has4WatKeyAS is being co
So now, we have declared our variables, let us look at some functions for working with these variables. We are going to use a built in function in Flash called trace to see what this variables contain. So it is simple a case of typing the word trace, open parenthesis... click to read more


Your Winter Home Checklist

sponsored articles of the day

diy centers

Research and explore a wealth of wisdom on these topics