How do I add custom style to custom AS3 component via .css file?

Hi all,
I have created a flex application which displays a custom component I created in actionscript. My custom component is just an extended canvas component which displays a gradient background. When I add the component to my flex app, see code below, the component works great.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="http://localhost/mycomps">
    <ns1:GradientCanvas fillColors="[#ffffff, #000000]" />
</mx:Application>
However, I also want to support css styles to add the gradient colors to my component, like so
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="http://localhost/mycomps">
    <mx:Style source="test.css" />
    <ns1:GradientCanvas styleName="gradientCanvas" />
</mx:Application>
test.css
.gradientCanvas {
    fill-colors: #ffffff, #000000;
When I try this my component doesn't display a gradient. I have followed the tutorials online that I could find but it seems to be the same example from Adobe repeated on multiple site and it doesn't work.
My component code is added below, if anyone could show me how to get this to work it would be much appreciated.
Thanks in advance,
Xander
GradientCanvas.as
package mycomps {
    import flash.display.GradientType;
    import flash.geom.Matrix;
    import mx.containers.Canvas;
    import mx.styles.CSSStyleDeclaration;
    import mx.styles.StyleManager;
    public class GradientCanvas extends Canvas {
        private static var classConstructed:Boolean = constructStyle();
        public function GradientCanvas() {
            super();
            this.width = 100;
            this.height = 20;
        private static function constructStyle():Boolean {
            var style:CSSStyleDeclaration = StyleManager.getStyleDeclaration("GradientCanvas");
            if (style) {
                if (style.getStyle("fill-colors") == undefined) {
                    style.setStyle("fill-colors", [0xffffff, 0x000000]);
            } else {
                style = new CSSStyleDeclaration();
                style.defaultFactory = function():void {
                    this._fillColours = [0xffffff, 0x000000];
                StyleManager.setStyleDeclaration("GradientCanvas", style, true);
            return true;
        override public function styleChanged(styleProp:String):void {
            super.styleChanged(styleProp);
            if (styleProp == "fill-colors") {
                this._fillColours = getStyle("fill-colors");
                this._fillColoursChanged = true;
                this.invalidateDisplayList();
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            if (this._fillColoursChanged == true) {
                var direction:Number = 90 * (Math.PI / 180);
                var matrix:Matrix = new Matrix();
                matrix.createGradientBox(unscaledWidth, unscaledHeight, direction, 0, 0);
                graphics.clear();
                graphics.beginGradientFill(GradientType.LINEAR, this._fillColours, [1,1], [0, 255], matrix, "pad", "rgb", -1);
                graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
                graphics.endFill();
                this._fillColoursChanged = false;
        [Inspectable(category="Gradient", type="Array", format="Color", name="Fill Colours")]
        private var _fillColours:Array;
        private var _fillColoursChanged:Boolean = false;
        public function get fillColours():Array {
            return this._fillColours;
        public function set fillColours(value:Array):void {
            this._fillColours = value;
            this._fillColoursChanged = true;
            this.invalidateProperties();
            this.invalidateDisplayList();

Never mind, I've discovered how to do it for myself.
Thanks...

Similar Messages

  • How can I add a new message(custom text message) to the holiday approval em

    How can I add a new message(custom text message) to the holiday approval email-notification sent to the manager?
    TIA

    The answer is 'not very easily', unless the information you want to display is the employee's leave balances. In 12.1.3 Oracle have delivered functionality that allows you to include the leave balances in the approval notifications out-the-box, ie, without customization.
    For any other information you're probably going to have to customize the standard delivered HRSSA workflow. Within this workflow, the Leave of Absence functionality uses the Notify Approver (Embedded) (HR_APPROVER_NTF) notification. The body of this notification is set to the Notify Approver (Embedded) (HR_NTF_EMBEDDED_REGION) attribute. This in turn defaults to:
    JSP:/OA_HTML/OA.jsp?OAFunc=-&HR_EMBEDDED_REGION-&NtfId=-&#NID-
    So essentially you can change the HR_APPROVER_NTF notification. The problem with changing this notification is that it's generic - it's used for all SSHR functions and not just Leave of Absence. That means you have to make other, more substantial, customizations to the workflow to ensure the changes you make only applies to LOA.
    The other option is to personalize the review page (ie, the region referenced in &HR_EMBEDDED_REGION) to include whatever messages you want. But that means they'll appear on the Review page and all LOA approval notifications and that might not be what you want.
    It's usually better to live with what Oracle deliver and find an alternative solution! What's the content of the message you want to include?

  • How do I add a zoom function to a digital magazine (.swf file) in InDesign CS6?

    Hi,
    Im creating an interactive digital magazine for our company which will go on the iPad, but also online for computers.
    The iPad (.folio) has zoom functions, but on screen (.swf) the magazine is very static and peaple can't zoom and scroll (the zooming buttons function in InDesign doesn't work here).
    So, how do I add a zoom function to a digital magazine (.swf file) in InDesign CS6?
    (I read older posts regarding this problem in CS5... It's not possible for me to purchase an additional product for that. I have Flash, if there is a tutorial on how to do it, that'd be helpful too)
    Thanks for your help!
    Best regards!

    Although the help implies this should work, and I've seen it written in a book to do things this way, it's not how I do things:
    var content_req1:URLRequest = new URLRequest("text/hales.txt");
    var content_ldr:URLLoader = new URLLoader(content_req1);
    content_ldr.addEventListener(Event.COMPLETE, onComplete1);
    Instead, try:
    var content_req1:URLRequest = new URLRequest("text/hales.txt");
    var content_ldr:URLLoader = new URLLoader();
    content_ldr.addEventListener(Event.COMPLETE, onComplete1);
    content_ldr1.load(content_req1);

  • How to get all paragraphs style and their fonts of a  indesign file and write all info with para info into txt file with scripting

    how to get all how to get all paragraphs style and their fonts of a  indesign file and write all info with para info into txt file with scriptingstyle and their fonts of a  indesign file and write all info with para info into txt file with scripting

    I write the script this one works
              var par=doc.stories.everyItem().paragraphs.everyItem().getElements();
      for(var i=par.length-1;i>=0;i--)
           var font=par[i].appliedParagraphStyle.name;
            var font1=par[i].appliedFont.name;
             var size=par[i].pointSize;
            WriteToFile (par[i].contents  +   "\r" +  "Style  : " + font  + "\r" +  "FONT1  : " + font1  + "\r" +  "Size  : " + size  + "\r", reportFilePath);
                            function WriteToFile(text, reportFilePath) { 
        file = new File(reportFilePath); 
        file.encoding = "UTF-8"; 
        if (file.exists) { 
            file.open("e"); 
            file.seek(0, 2); 
        else { 
            file.open("w"); 
          file.writeln(text);  
        file.close(); 
    Thanks for all your support

  • How can I add a pause after each photo to my flash file?

    How can I add a break to my sequence of photos on a flash file.
    I created a flash with different photos and I want each one to stay on the stay for about a minute before moving away.
    How do I do this? Please help

    //Timers are measured in milliseconds
    var minuteTimer:Timer = new Timer(60000);
    minuteTimer.addEventListener(TimerEvent.TIMER, exchangePhoto);
    function exchangePhoto(e:Event):void{
         //put your code of exchanging your photo here
    //you have to start the timer explicitly, when your app starts
    minuteTimer.start();

  • How do I add PDFs to a custom bokshelf?

    I have created several bookshelves and want to add specific items to specified bookshelves. However, it seems that items are added to the Library and then have to be dragged to the specific bookshelf. This means I have to find a single item among several hundred that appear in the All Items window, and drag that one to the appropriate bookshelf.
    If this is the case, it is back to front. I should be able to add items to a particular one of my bookshelves, and Adobe adds it to the Library.
    Am I missing something?

    If anyone has got the answer, please? I've got the same problem. It's nice I've got the option of bookshelves but How can I put my books on the right shelves?
    I miss it too.

  • How do I add cell-style wireless to my iPad 2?

    When I bought my iPad 2 it was set up for wifi, but not for the same kind of wireless iteret connection I get with my cell phone? Now I want to add that, but when I called the phone company, they said my iPad 2 didn't have an "IMEI" number. Can I add whatever it takes to my iPad 2 to get cell-style wireless connections to the interet? Thank you.

    You do not connect it to the device at all. It is free standing. My MIFI2200 is about the size of a deck of playing cards. It's just like having a "non-wired" mobile router at your disposal. I just keep mine in my shirt pocket, or place it on the table next to me.
    There are rechargeable as well, or you can even charge in a wall socket them while using them if you like.
    Take a look at some of these.
    https://www.google.com/search?q=MIFI2200#hl=en&spell=1&q=MIFI+2200&sa=X&ei=-jWQU Mm9CIeB0QHQ8YHoDA&ved=0CB4QBSgA&bav=on.2,or.r_gc.r_pw.r_qf.&fp=f2e38c1d654cf6c9& bpcl=36601534&biw=981&bih=603

  • How do I add multiple emails to a Contacts group from a file?

    I have a weekly newsletter I send out to a few hundred people. Their email addresses are all stored in a text file. I want to create a Group to use with Mac Mail, but I don't know how to import the list into an existing Group. I tried creating a CSV file with only the email addresses (that's all I have), but Contacts wouldn't import it, didn't recongize the file as CSV. (I did add a comma to the end of each email.)
    How do I create a Group in Contacts? And can I then use that group in Mac Mail?
    thanks
    Scott

    I did figure this out, sort of, by adding a tab character to the beginning of each email address in my text file. Contact then let me import it, and I could select the field for the email address. So I've imported my list as a group of 700+ emails.
    BUT now when I try and add that Group in the To: or Cc: or Bcc: fields in mail, it just disappears when I type it.
    Any idea what's up with that?
    thanks
    Scott

  • How do I add and delete music to my ipad via itunes?

    Some songs in my library is not highlighted and when I move them to the ipad it won't transfer. Deleting  songs is one big issue too. Mark a song and press del or backspace doesn't work either. If someone could tell me how to add movies to itunes from my HDD.  Uses 10.5.1.42 version of itunes on a win 7 laptop.
    Would appreciate any help:)

    I just add movies to the playlist I sync with my ipad thats how I handle both music and movies

  • How can you change the style of a flash tabnavigator with css

    I'd like to change the colors of a tabnavigator in flash
    form.
    I found an example how to change the layout for a panel but
    it doesn't inherate it to my tabnavigator.
    Here a simple example for a panel that works:
    quote:
    <cfsavecontent variable="contentPanelStyle">
    panelBorderStyle:'roundCorners';
    backgroundColor:#EFF7DF;
    headerColors:#CBEC84, #B0D660;
    </cfsavecontent>
    <cfform name="myform" width="420" format="Flash"
    timeout="100" >
    <!--- skinned --->
    <cfformgroup type="panel" label="With styles"
    style="#contentPanelStyle#" width="400">
    <cfinput type="text" name="someinput" label="your name"
    />
    </cfformgroup>
    </cfform>
    Actually, I just want to colorize my tabnavigator items
    (don't want even a panel around it). How can I do this, as example
    with the same colors like the panel?
    pawel

    Found 1 solution for the active Tab
    quote:
    <cfform name="myform" width="420" format="Flash"
    timeout="100" >
    <cfformgroup type="tabnavigator"
    style="themeColor:##CC0000;">
    <cfformgroup type="page" label="Tab 1">
    <cfinput type="text" name="someinpu1t" label="your name"
    />
    </cfformgroup>
    <cfformgroup type="page" label="Tab 2">
    <cfinput type="text" name="someinput2" label="your name"
    />
    </cfformgroup>
    </cfformgroup>
    </cfform>
    But still, how do I controll the colors of the inactive Tab
    and the highlight Tab (rollover mouse)?
    pawel

  • How can you add images and text to UIScrollBar Component

    I can only add the text, can't add images. Also how can you make paragraphs out of long text in a UIScrollBar?
    Thanks.

    Hi,
    UIScrollBar Component can be attached to a dynamic text filed and the text field can be set to Render Text as HTML option which in turn can display both text & images(using <img> tags).
    Refer http://www.flashvalley.com/fv_tutorials/loading_HTML_in_a_dynamic_text_field/page2.php that may help you getting what do you want
    Thanks!

  • How do I add the filename as an overlay on a PDF file compiled from images?

    I am creating pdf files from digital camera images and want to add the filename as a visible overlay (ie either in Header/Footer or as a watermark).  I can find all other alternatives eg Bates numbering, customised Header/Footer etc), but cannot find a solution to adding each image's filename to the image.  I can do it in Bridge but not Acrobat.

    Acrobat does not preserve the original filename information of images.
    You should it in another application (Photoshop?) and then import the final
    image into Acrobat.

  • How do you add a water mark to multiple images within multiple files?

    I am having real trouble in trying to add a water mark to multiple images (mixture of jpegs and tiffs) within multiple file.
    I have used the Batch processing tool, but this hasn't worked or has been inconvenient, asking me to resave each individual file.
    If anyone can help or suggest another way of doing this, that would be great!
    Thanks
    Becca

    Are you using Russell Brown's script for placing watermarks?  Also you mentioned, "Within multiple file."  Did you mean multiple folders?  The batch processor has a check box for applying process to multiple folders.  What itsn't working - exactly?

  • How do I add a line (graphic) as a Component to a JPanel

    I'm using swing, and the line-component should be used in the JPanel with plenty of buttons. Therefor it is important that it is as small as possible, with no large background.

    The line is just a line from x1,x2 to y1,y2.
    The point is that I do not want to use drawLine(), i preferable want to use setBounds, so that I can just add the component to the contentPane like a Jbutton.
    I want my class to be a variant of something like this:
    public class Line extends JComponent {
    int x1,x2,y1,y2;
    public Line(int X1,int X2,int Y1,int Y2) {
    x1 = X1;
    x2 = X2;
    y1 = Y1;
    y2 = Y2;
    public void paint(Graphics g){
    super.paintComponent(g);
    //g.setColor(Color.white);
    //g.fillRect(0,0,getWidth(),getHeight());
    // g.drawLine(x1,x2,y1,y2);
    }

  • How do I add flash cs4 game with AS3 to flash cs4 website??

    I have created a game in flash with ActionScript 3 and now want to add it to a website I have created with pages seperated into keyframes. Ideally, I am trying to have the game start when a link on the home page is selected. I would also like the users to be able to download the game themselves??? Any ideas for a flash novice??

    Thank you so much!!! I just added it with a UI Loader Component! Worked really well... although it looks like doing that picked up an issue with some of my code? It's now looping over and over again and the counter within my game (for giving players their score - highlighted in red), is not working?If you are a AS3 guru any help would be greatly appreciated, otherwise thank you so much for your earlier tips
    package
        import flash.display.MovieClip;
        import flash.events.*;
        import flash.utils.Timer;
        import flash.text.*;
        public dynamic class Gift extends MovieClip
            private var dx:Number = Math.random() * 10; // make gift scurry
            private var dy:Number = Math.random() * 10;
            public function Gift ()
                this.gotoAndStop(Math.ceil(Math.random() * 4));
                this.addEventListener(Event.ENTER_FRAME, scurry);   
                stage.addEventListener(MouseEvent.MOUSE_DOWN, kill);
            public function scurry (e:Event)
                if (this.x < 0 || this.x > 550)
                    this.dx *= -1;
                if (this.y < 0 || this.y > 576)
                    this.dy *= -1;
                this.x += this.dx; // make gift scurry
                this.y += this.dy;
            public function die()
                this.removeEventListener(Event.ENTER_FRAME, scurry);
                parent.removeChild(this);
            private function kill (e:MouseEvent):void
                if(e.target is Gift)
                    e.target.die();
                    score += 10;
                    scoreText.text = score.toString();

Maybe you are looking for

  • How can I remove an e-mail address from iphoto 9.5.1

    I have one bad e-mail address in Iphoto and it wont let me correct it or enter an alternat e-mail address for that person. I have erased the offending address from gmail and any other place I could find it but could do it in iphoto.

  • Currency Translation based on Last Day of the Acquistion month

    Dear all,             Request to help me in understanding how we can calculate the currency translation rate as per the last day if the acquistion month.. For Example if the  Acquistion date : 01/01/2008 (mm/dd/yyyy) the currency translation should h

  • How to set up 2560 x 1080 resolution on mac pro 2007

    Hello I have a mac pro 2007 and need to install a new screen Dell U2913WM with display 2560 x 1080 ( ultra-sharp wide monitor) However It does not exist in the display preferences and the CD provided does bot have installation software for Mac. What

  • Scheduled update of partners to site customers (KNVP partner functions)

    Hello all We have a need to change customer master partner function so that the definion of the needed changes is done in beforehand but the actual updating of change sis done on a certain time. The reason for this is that the amount of needed change

  • ACR use of workdisk and scratchdisk when batch processing images

    I am setting up a new PC optimized for PS, and I and pondering on the optimal disk setup for ACR when I batch process several images: Alternative 1 2 physical disk in raid 0 with 2 partitions, partition 1 for scratch and the second for images to work