# Change gradient in sprite from library

**URL:** <https://forum.kirupa.com/t/change-gradient-in-sprite-from-library/285702>\
**Category:** flash\
**Created:** [April 4, 2009, 9:06am UTC](https://forum.kirupa.com/t/change-gradient-in-sprite-from-library/285702 "2009-04-04T09:06:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaedo](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@Shaedo](https://forum.kirupa.com/u/Shaedo)\
**Post date:** [April 4, 2009, 9:06am UTC](https://forum.kirupa.com/t/change-gradient-in-sprite-from-library/285702/1 "2009-04-04T09:06:54Z")

</div>

Hi, thanks for taking the time to look at my problem. I would like to be able to make changes to a colour gradient of a sprite from my library, as opposed to one drawn dynamically.  
So the code I thought would look something like this:

```auto
 
var radType:String = GradientType.RADIAL;
var radMatrix:Matrix = new Matrix();
radMatrix.createGradientBox(120,120);
 
var radColours:Array = [0x3174d0, 0x15396f];
var radAlphas:Array = [1, 1];
var radRatios:Array = [0, 255];
var myLibrarySprite:spriteInLibrary = new spriteInLibrary();
 
myLibrarySprite.graphics.beginGradientFill(radType, radColours, radAlphas, radRatios,radMatrix);
 
addChild(myLibrarySprite);

```

I’ve been using essentially this code (plus a bit for say drawing a square) happily to gradient fill sprites that are dynamically drawn

Any help is appreciated.  
Pointers towards tutorials that do this or corrections to my code or just  
[FONT=Times New Roman][SIZE=3]reassurance[/SIZE][/FONT] that it’s possible.

I dont get any errors from this.  
I have tried adding myLibrarySprite.graphics.clear() but that does not make a difference.
