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.

Exemple<br />

L'exemple suivant modifie la propriété hors limites alpha pour la mettre à 0x00FF00 sur le<br />

clip existant filteredMc quand un utilisateur clique sur celui-ci.<br />

import flash.filters.DisplacementMapFilter;<br />

import flash.display.BitmapData;<br />

import flash.geom.Point;<br />

import flash.geom.Matrix;<br />

import flash.geom.ColorTransform;<br />

var filteredMc:MovieClip = createDisplacementMapRectangle();<br />

filteredMc.onPress = function() {<br />

var filter:DisplacementMapFilter = this.filters[0];<br />

filter.scaleY = 25;<br />

filter.mo<strong>de</strong> = "color";<br />

filter.alpha = .25;<br />

this.filters = new Array(filter);<br />

}<br />

function createDisplacementMapRectangle():MovieClip {<br />

var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000,<br />

"radial");<br />

var filter:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap,<br />

new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000);<br />

}<br />

var txtBlock:MovieClip = createTextBlock();<br />

txtBlock._x = 30;<br />

txtBlock._y = 30;<br />

txtBlock.filters = new Array(filter);<br />

return txtBlock;<br />

function createGradientBitmap(w:Number, h:Number, bgColor:Number,<br />

type:String, hi<strong>de</strong>:Boolean):BitmapData {<br />

var mc:MovieClip = this.createEmptyMovieClip("mc", 1);<br />

var matrix:Matrix = new Matrix();<br />

matrix.createGradientBox(w, h, 0, 0, 0);<br />

mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55,<br />

0x99], matrix, "pad");<br />

mc.lineTo(w, 0);<br />

mc.lineTo(w, h);<br />

mc.lineTo(0, h);<br />

mc.lineTo(0, 0);<br />

mc.endFill();<br />

(hi<strong>de</strong> == true) ? mc._alpha = 0 : mc._alpha = 100;<br />

528 Chapitre 2: Classes <strong>ActionScript</strong>

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

Saved successfully!

Ooh no, something went wrong!