Flex _ hide the secret of show object_beauty;

Source: Internet
Author: User

=> Maskapp. mxml

<? XML version = "1.0" encoding = "UTF-8"?>
<S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009"
Xmlns: S = "Library: // ns.adobe.com/flex/spark"
Xmlns: MX = "Library: // ns.adobe.com/flex/mx"
Xmlns: aspackage = "aspackage .*"
Minwidth = "955" minheight = "600" creationcomplete = "initfun (event )"
Pagetitle = "thestudioofcenyebao">

<FX: SCRIPT>
<! [CDATA [
Import MX. Events. flexevent;

Private function initfun (Event: flexevent): void
{
// Initialization
}
]>
</FX: SCRIPT>

<FX: declarations>
<! -- Non-visual element -->
</FX: declarations>

<S: vgroup width = "320" Height = "230" horizontalcenter = "0" verticalcenter = "0">
<Aspackage: mysprite id = "mysprite"/>
</S: vgroup>
</S: Application>

=> Mysprite.

Package aspackage
{
Import flash. display. gradienttype;
Import flash. display. loader;
Import flash. display. Sprite;
Import flash. Geom. matrix;
Import flash.net. URLRequest;

Import MX. Core. uicomponent;

Public class mysprite extends uicomponent
{
/**
* Attribute */
Public static const imgurl: String = "Public/img/girl.jpg ";

/**
* Constructor
*/
Public Function mysprite ()
{
/**
* Photo loading */
VaR Loader: loader = new loader ();
VaR URL: URLRequest = new URLRequest (imgurl );
Loader. Load (URL );
This. addchild (loader );

/**
* Draw an elliptical shape */
VaR oval: SPRITE = new sprite ();

VaR colors: array = [0x000000, 0x000000]; // black;
VaR Alphas: array = [1, 0]; // opacity _ gradient from large to small;
VaR ratios: array = [0,255]; // array of the color distribution ratio;

VaR matrix: matrix = new matrix (); // conversion matrix;
/* Parameter: width, height, rotation degree, X in the upper left corner of the rectangle, Y in the upper left corner of the rectangle */
Matrix. creategradientbox (200,100, 0,-100,-50 );

Oval. Graphics. begingradientfill (gradienttype. Radial, colors, Alphas, ratios, matrix );
Oval. Graphics. drawellipse (-100,-50,200,100 );
// The coordinates in the upper left corner of the rectangle must be the same as those in the matrix;
Oval. Graphics. endfill ();
This. addchild (Oval );

/**
* Set cache */
Loader. cacheasbitmap = true;
Oval. cacheasbitmap = true;

Loader. Mask = oval;
// Cover;

Oval. startdrag (true );
// Move;
}
}
}

=> Materials used:

Girl.jpg

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.