Study Flash's painting function __flex

Source: Internet
Author: User

In fact, the painting function of the code is relatively simple, it depends on whether you know. You need to dodge a few points of attention:

1, FLEX4 Application class can no longer use Addchild to add UI components, but to use AddElement (spritevisualelement) to add

Note that spritevisualelement this class is in Spark.core.SpriteVisualElement, the IDE does not automatically display the smart hint of the location of the package, which requires us to manually input. The specific post code is as follows:

Import mx.events.FlexEvent;
Import Flash.geom.Matrix;
Import mx.core.UIComponent;
Import spark.core.SpriteVisualElement;

Private Function Appcomphandler (event:flexevent): void
{
var testgrp:testgraphics = event.target as testgraphics;

var sprve:spritevisualelement = new Spritevisualelement;

var filltype:string = gradienttype.linear;
var colors:array = [0xff0000, 0x0000ff];
var alphas:array = [1, 1];
var ratios:array = [0x00, 0xFF];
var Matr:matrix = new Matrix ();
Matr.creategradientbox (20, 20, 0, 0, 0);
var spreadmethod:string = Spreadmethod.pad;
Sprve.graphics.beginGradientFill (Filltype, colors, alphas, ratios, Matr, Spreadmethod);
Sprve.graphics.drawRect (0,0,100,100);

This.addelement (Sprve);
}

Comrades, study hard.

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.