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.

this.bloomSeason = param_bloomSeason;<br />

}<br />

// Create methods to return property values, because best practice<br />

// recommends against directly referencing a property of a class<br />

function getLeafType():String {<br />

return leafType;<br />

}<br />

function getBloomSeason():String {<br />

return bloomSeason;<br />

}<br />

}<br />

Dans un fichier <strong>de</strong> script externe ou dans le panneau Actions, utilisez l'opérateur new pour<br />

créer un objet Plant.<br />

var pineTree:Plant = new Plant("Evergreen", "N/A");<br />

// Confirm parameters were passed correctly<br />

trace(pineTree.getLeafType());<br />

trace(pineTree.getBloomSeason());<br />

L'exemple suivant crée une classe intitulée ImageLoa<strong>de</strong>r. Le constructeur ImageLoa<strong>de</strong>r<br />

réclame trois paramètres.<br />

// Filename ImageLoa<strong>de</strong>r.as<br />

class ImageLoa<strong>de</strong>r extends MovieClip {<br />

function ImageLoa<strong>de</strong>r(image:String, target_mc:MovieClip, init:Object) {<br />

var listenerObject:Object = new Object();<br />

listenerObject.onLoadInit = function(target) {<br />

for (var i in init) {<br />

target[i] = init[i];<br />

}<br />

};<br />

var JPEG_mcl:MovieClipLoa<strong>de</strong>r = new MovieClipLoa<strong>de</strong>r();<br />

JPEG_mcl.addListener(listenerObject);<br />

JPEG_mcl.loadClip(image, target_mc);<br />

}<br />

}<br />

Dans un fichier <strong>de</strong> script externe ou dans le panneau Actions, utilisez l'opérateur new pour<br />

créer un objet ImageLoa<strong>de</strong>r.<br />

var jakob_mc:MovieClip = this.createEmptyMovieClip("jakob_mc",<br />

this.getNextHighestDepth());<br />

var jakob:ImageLoa<strong>de</strong>r = new ImageLoa<strong>de</strong>r("http://www.helpexamples.com/flash/<br />

images/image1.jpg", jakob_mc, {_x:10, _y:10, _alpha:70, _rotation:-5});<br />

Voir également<br />

Instruction dynamic<br />

Instructions 203

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

Saved successfully!

Ooh no, something went wrong!