About running environment capabilities

Source: Internet
Author: User

Flash. system. capabilities in as3.
Class has many static methods to return information about players and computers, such as operating systems, languages, audios and videos. Using capabilities
Property determines the type of the device owned by the user, and can provide as many users as possible with appropriate content. More useful is to notify the server to send a suitable SWF file or notify SWF
File playback mode.

Detect Player versions

Version

Attribute specifies the Flash Player platform and version information.

Trace ("version:" + capabilities. Version); // my computer returns version: Win 9, 0, 45, 0

Here, we need to explain that the returned data is: the major version number of the platform, the minor version number, and the internal version number. We can see that my flash player is 9.0.
Detection Operating System

OS attributes

Specify the current operating system

Trace ("OS:" + capabilities. OS); // Windows XP
Apple also returns a version number. We can do something based on the system, such as loading different start pictures.
VaR OS: String = system. capabilities. OS. substr (0, 3 );

If (OS = "win "){

// Load the Microsoft icon or...

} Else if (OS = "Mac "){

// You can see a drop of Apple

} Else {

//...

}
Detect player types




Playertype

Specifies the player type.
Trace ("playertype:" + capabilities. playertype); // The following four results may be returned:

"StandAlone"
For independent Flash Player
"External"
Used for External Flash Player or in testing mode
"PlugIn"
Used for Flash Player browser plug-ins
"ActiveX"

Used for the Flash Player ActiveX Control used by Microsoft Internet Explorer
If we use scripts for interaction, we must know whether the player is running in IE or other browsers. If it is running independently, I am sorry that the script is invalid.
If (flash. system. capabilities. playertype = "plugin "){

// What is executed in the browser except IE

}

Else if (flash. system. capabilities. playertype = "ActiveX "){

// As executed in IE

}

Else {

// Others

}
Detection System Language


language


System Language
Trace ("language:" + capabilities. Language); // ZH-CN

As the name suggests, if we want to make an international flash, we will use it to detect different languages and then load different SWF files.
VaR LANG: String = system. capabilities. Language. substr (0, 2 );

// Create an array of Supported languages

VaR supportedlanguages: array = ["en", "es", "FR"];

// Set the default language.

VaR uselang: String = "en ";

// Loop matching. If this parameter is found, set uselang.

For (var I: Int = 0; I <supportedlanguages. length; I ++ ){

If (supportedlanguages [I] = Lang ){

Uselang = Lang;

Break;

}

}

// Load the corresponding flash

VaR movieurl: String = "mymovie _" + uselang + ". SWF ");

Detection display settings

Of course this is useful! Actually it's very simple. FG
Trace ("screenresolutionx:" + capabilities. screenresolutionx); // 1280

Trace ("screenresolutiony:" + capabilities. screenresolutiony); // 960





OK. We can do a lot of useful things to know the screen size.
We can load content of different sizes as needed.
VaR resx: Int = flash. system. capabilities. screenresolutionx;

VaR Resy: Int = flash. system. capabilities. screenresolutiony;

If (resx <= 240) & (Resy <= 320 )){

VaR URL: String = "main_pocketpc.swf ";

}

Else {

VaR URL: String = "main_shorttop.swf ";

}

Loader. Load (New URLRequest (URL ));

The resolution can also be centered in your pop-up window:
VaR resx: Int = flash. system. capabilities. screenresolutionx;

VaR Resy: Int = flash. system. capabilities. screenresolutiony;

// Set the window width and height

VaR winw: Int = 200;

VaR winh: Int = 200;

// Set the start coordinate of the window

VaR winx: Int = (resx/2)-(winw/2 );

VaR winy: Int = (Resy/2)-(winh/2 );

// Create code and pass it to urlloader. Load ()

// Open the new browser window

VaR jscode: String = "javascript: void (

Newwin = Window. Open ('HTTP: // www.person13.com/', "+

"'Newwindow', 'width =" + winw +

", Height =" + winh + "," +

"Left =" + winx + ", Top =" + winy + "'));";

// Use the urlloader object to call JavaScript Functions

Urlloader. Load (New URLRequest (jscode ));





Detect Device audio

Hasaudio




Specifies whether the player is running on a system with audio functions.

Hasmp3

The specified player runs on a system with an MP3 decoder.
Trace ("hasmp3:" + capabilities. hasmp3); // true

Trace ("hasaudio:" + capabilities. hasaudio); // true


Because the sound file is very large, for the network. We usually avoid users without audio from downloading audio files.
// Only when the speaker is available, it can be used as a. SWF with audio.

If (flash. system. capabilities. hasaudio ){

Content = "sound.swf ";

} Else {

Content = "silent.swf ";

}

// The Real-Time System can play audio, which does not mean it can play MP3. Therefore, when MP3 content is published

The Flash. system. capabilities. hasmp3 attribute detects the target device.

If (flash. system. capabilities. hasmp3 ){

VaR URL: URLRequest = new URLRequest ("sound.mp3 ");

Sound = new sound (URL );

Sound. Play ();

} Else {

// Code to load an external. SWF containing a ADCP sound

}

Detect Device videos

Hasembeddedvideo

Specifies whether the player supports video embedding.

Hasstreamingvideo

Specifies whether the player supports video streams.
First, check whether the user can play the video stream. If false is returned, then check whether embedded videos are supported.
If (flash. system. capabilities. hasstreamingvideo ){

// Play the video stream

}

Else if (flash. system. capabilities. hasembeddedvideo ){

// Download the SWF file of the embedded video

}

Else {

//

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.