03.07.2013 Views

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

Guide de reference du langage ActionScript 2.0 - PowWeb

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Disponibilité : <strong>ActionScript</strong> 1.0 ; Flash Player 7<br />

Paramètres<br />

name:String - Nom <strong>du</strong> style à extraire.<br />

Valeur renvoyée<br />

Object - Objet style ; dans tous les autres cas null.<br />

Exemple<br />

L'exemple suivant charge <strong>de</strong>s styles à partir d'un fichier CSS, analyse la StyleSheet, puis<br />

affiche les noms <strong>de</strong> style et les valeurs <strong>de</strong>s propriétés dans le panneau <strong>de</strong> sortie. Créez un<br />

fichier <strong>ActionScript</strong> appelé StyleSheetTracer.as et entrez le co<strong>de</strong> suivant dans le fichier :<br />

import TextField.StyleSheet;<br />

class StyleSheetTracer {<br />

// StyleSheetTracer.displayFromURL<br />

// This method displays the CSS style sheet at<br />

// the specified URL in the Output panel.<br />

static function displayFromURL(url:String):Void {<br />

// Create a new StyleSheet object<br />

var my_styleSheet:StyleSheet = new StyleSheet();<br />

// The load operation is asynchronous, so set up<br />

// a callback function to display the loa<strong>de</strong>d StyleSheet.<br />

my_styleSheet.onLoad = function(success:Boolean) {<br />

if (success) {<br />

StyleSheetTracer.display(this);<br />

} else {<br />

trace("Error loading style sheet "+url);<br />

}<br />

};<br />

// Start the loading operation.<br />

my_styleSheet.load(url);<br />

}<br />

static function display(my_styleSheet:StyleSheet):Void {<br />

var styleNames:Array = my_styleSheet.getStyleNames();<br />

if (!styleNames.length) {<br />

trace("This is an empty style sheet.");<br />

} else {<br />

for (var i = 0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!