MovieClip.Color

I can't change  property Color of the component Movie Clip in my program? Compiler didn't found the error but when my program run color Movie Clip doesn't change. Help me, please

if you have a movieclip with instance name or reference name mc, use:
var ct:ColorTransform = mc.transform.colorTransform;
ct.color = 0x9999cc;
mc.transform.colorTransform = ct

Similar Messages

  • Change movieClip color or size based on player score

    Hello Everyone,
    My students and I worked throught a nice tutorial on a basic pong game that keeps score (http://as3gametuts.com/2011/03/19/pong-1/). But now we are trying to figure out how to modify a movieclip's color and/or size based on the score. This idea was suggested by one of my students, the tutorial does not provide instructions for the color and/or size change so I figured I'd ask for help here.
    The symbol we want to change is named "paddle" with the instance name of "playerPaddle" and we want to change it based on the value of a var named "playerScore".
    Thanks for your help and have a great day,
    Todd

    Ned,
    Thanks for the reply.
    I want to reduce the playerPaddle by 20% when the playerScore reaches 5.
    also
    I want to change the playerPaddle color to red when the playerScore reaches 2.
    Thanks again for your help,
    Todd
    var ballSpeedX:int = -3;
    var ballSpeedY:int = -2;
    var cpuPaddleSpeed:int = 3;
    var playerScore:int = 0;
    var cpuScore:int = 0;
    init();
    function init():void
              stage.addEventListener(Event.ENTER_FRAME, loop);
    function calculateBallAngle(paddleY:Number, ballY:Number):Number
              var ySpeed:Number = 5 * ( (ballY-paddleY) / 25 );
              trace(ySpeed);
              return ySpeed;
    function updateTextFields():void
              playerScoreText.text = ("Player Score: " + playerScore);
              cpuScoreText.text = ("CPU Score: " + cpuScore);
    function loop(e:Event):void
              if( playerPaddle.hitTestObject(ball) == true ){
                        if(ballSpeedX < 0){
                                  ballSpeedX *= -1;
                                  ballSpeedY = calculateBallAngle(playerPaddle.y, ball.y);
              } else if(cpuPaddle.hitTestObject(ball) == true ){
                        if(ballSpeedX > 0){
                                  ballSpeedX *= -1;
                                  ballSpeedY = calculateBallAngle(cpuPaddle.y, ball.y);
              if(cpuPaddle.y < ball.y - 10){
                        cpuPaddle.y += cpuPaddleSpeed;
              } else if(cpuPaddle.y > ball.y + 10){
                        cpuPaddle.y -= cpuPaddleSpeed;
              playerPaddle.y = mouseY;
              //check if top of paddle is above top of screen
              if(playerPaddle.y - playerPaddle.height/2 < 0){
                        playerPaddle.y = playerPaddle.height/2;
              //check if bottom of paddle is below bottom of screen
              } else if(playerPaddle.y + playerPaddle.height/2 > stage.stageHeight){
                        playerPaddle.y = stage.stageHeight - playerPaddle.height/2;
              ball.x += ballSpeedX;
              ball.y += ballSpeedY;
              //because the ball's position is measured by where its CENTER is...
              //...we need add or subtract half of its width or height to see if that SIDE is hitting a wall
              //first check the left and right boundaries
              if(ball.x <= ball.width/2){ //check if the x position of the left side of the ball is less than or equal to the left side of the screen, which would be 0
                        ball.x = ball.width/2; //then set the ball's x position to that point, in case it already moved off the screen
                        ballSpeedX *= -1; //and multiply the ball's x speed by -1, which will make it move right instead of left
                        cpuScore++; //increase cpuScore by 1
                        updateTextFields();
              } else if(ball.x >= stage.stageWidth-ball.width/2){ //check to see if the x position of it's right side is greater than or equal to the right side of the screen, which would be 550
                        ball.x = stage.stageWidth-ball.width/2; //and set the x position to that, in case it already moved too far of the right side of the screen
                        ballSpeedX *= -1; //multiply the x speed by -1 so that the ball is now moving left
                        playerScore++; //increase playerScore by 1
                        updateTextFields();
              //now we do the same with the top and bottom of the screen
              if(ball.y <= ball.height/2){ //if the y position of the top of the ball is less than or equal to the top of the screen
                        ball.y = ball.height/2; //like we did before, set it to that y position...
                        ballSpeedY *= -1; //...and reverse its y speed so that it is now going down instead of up
              } else if(ball.y >= stage.stageHeight-ball.height/2){ //if the bottom of the ball is lower than the bottom of the screen
                        ball.y = stage.stageHeight-ball.height/2; //reposition it
                        ballSpeedY *= -1; //and reverse its y speec so that it is moving up now

  • Movieclip color transform

    Hello,
    I am building a Smile Face application.
    Where you choose a menu item and an object or "movieclip" is
    placed on the stage. You can drag and drop the object, take it to
    the trash and change the color on any of the objects on the stage
    at any time.
    I have 2 problems that I am looking for guidance on.
    1. The code I use to change the color of the object is bulky.
    As it is, depending upon the amount of objects you have in
    the menu,
    the code could grow to a painful amount making it difficult
    to manage.
    I am looking for a way to better my existing code, by
    upgrading it to a more advanced method.
    I have attached my code here.
    If anyone could help steer me in the right direction, I would
    appreciate it.
    Thanks,
    Matthew

    Thanks for the answer Rob.
    It works perfect.
    I apologize for my last tread not making much sense.
    I have one question, that I would like to find the answer to.
    Is there anyway to create this function.
    for (j in partsList) {
    partsList[j].onPress = choosePart;
    Without it being an onPress, onRelease, onRollOver or
    onRollOut function?
    I ask, because I am incorporating
    the "GreenSock transform manager"
    which is already using the onPress and onRelease function for
    the partsList.
    http://blog.greensock.com/transformmanageras2/)
    Hope that makes sense,
    Thanks.

  • Changing MovieClip Colors

    I have a simple mc of a rectangle in a library with linkage
    that I bring to the stage with an attachMovieClip. I want to change
    the fill color of the rectangle. All the examples I have seen look
    like you have to draw an object line by line with a beginfill
    before the first line and an endfill when your done. Isn't there an
    easier way?

    I did the setRbg and it worked, but it killed the bevel on
    it. No problem, I just broke the mc into two separate mcs and used
    a knockout on the bevel, so I didn't have to mess with the bevel
    filter programatically. thanks kglad.

  • Showing a movie clip

    Hi. I've added a video clip to a web page. It is a quicktime
    movie. At the bottom of the frame is a video controller (Stop,
    Forward, FF, RW). Is there a way to remove that controller from the
    bottom of the frame, and either place it somewhere else, or add a
    separate control somewhere else?
    This shows the current implementation in which the controls
    get in the way of the picture:
    Video Clip

    Yes, the ColorPicker would be great, except as far as I can tell there's no way to assign names to the colors in my custom data provider. The user needs to know the name of the color (eg. P01 - Wisteria), but the ColorPicker only shows the hex values. Unless there's a way to change that?
    Repasting the two code chunks from above, which didn't display properly:
    Works, but doesn't show swatches:
    TileList.addEventListener(Event.CHANGE, changeColor);
    var colorBox:ColorTransform = new ColorTransform();
    function changeColor(e:Event):void{  
       colorBox.color = tileList.selectedItem.data;
       box_mc.transform.colorTransform = colorBox; }
    Shows swatches, but doesn't work:
    var aBoxes:Array = new Array(); var i:uint = 0;
    var printColorHex:Array = new Array(0xfac9c2, 0xFF0000, 0x0000CC, 0x00CC00, 0xFFFF00);
    var printColorNames:Array = new Array("R-01 Pale Coral", "Cranberry", "Sky", "Forest", "July");
    var dpPrintColors:DataProvider = new DataProvider();
    for(i=0; i < printColorHex.length; i++) {
         aBoxes[i] = new MovieClip();
         drawBox(aBoxes[i], printColorHex[i]);    // draw box w next color in array
         dpPrintColors.addItem( {label:printColorNames[i], source:aBoxes[i]} );
    aTl.dataProvider = dpPrintColors;
    function drawBox(box:MovieClip,color:uint):void {
                 box.graphics.beginFill(color, 1.0);
                 box.graphics.drawRect(0, 0, 140, 60);
                 box.graphics.endFill();       

  • I need to make a list of 700  dvds that can be updated alphabetically as I attain new ones. I'm new at computers, bought an iMac (with Lion). What application or software will do this for me the easiest?

    I need to make list of 700+ dvds that can be updated alphabetically as I attain more. I'm new at computers, lbought an iMac (with Lion). What application or software will do this for me the easiest?

    Yes, the ColorPicker would be great, except as far as I can tell there's no way to assign names to the colors in my custom data provider. The user needs to know the name of the color (eg. P01 - Wisteria), but the ColorPicker only shows the hex values. Unless there's a way to change that?
    Repasting the two code chunks from above, which didn't display properly:
    Works, but doesn't show swatches:
    TileList.addEventListener(Event.CHANGE, changeColor);
    var colorBox:ColorTransform = new ColorTransform();
    function changeColor(e:Event):void{  
       colorBox.color = tileList.selectedItem.data;
       box_mc.transform.colorTransform = colorBox; }
    Shows swatches, but doesn't work:
    var aBoxes:Array = new Array(); var i:uint = 0;
    var printColorHex:Array = new Array(0xfac9c2, 0xFF0000, 0x0000CC, 0x00CC00, 0xFFFF00);
    var printColorNames:Array = new Array("R-01 Pale Coral", "Cranberry", "Sky", "Forest", "July");
    var dpPrintColors:DataProvider = new DataProvider();
    for(i=0; i < printColorHex.length; i++) {
         aBoxes[i] = new MovieClip();
         drawBox(aBoxes[i], printColorHex[i]);    // draw box w next color in array
         dpPrintColors.addItem( {label:printColorNames[i], source:aBoxes[i]} );
    aTl.dataProvider = dpPrintColors;
    function drawBox(box:MovieClip,color:uint):void {
                 box.graphics.beginFill(color, 1.0);
                 box.graphics.drawRect(0, 0, 140, 60);
                 box.graphics.endFill();       

  • Error #1009: Help needed

    Hello everyone,
    I'm looking for some help with an error I'm getting:
    Error #1009: Cannot access a property or method of a null object reference
    Now, I know approximately what it means, I just can't find where exactly the problem is or how to fix it.
    I must warn tho, my code is a bit chaotic, had a rough start and now I'm just trying to finish before the deadline, and with my time left I'm gonna clean up the code.
    I think it's best if I send the entire flash project in a zip so if you are willing to help just let me know how to reach you
    Thanks in advance.
    Davey

    I fixed the errors, not getting any anymore, think the problem was adding an event listener to a button on stage in the subclass constructor. Seeing as I first call the function and then pass the button from main class to sub class, the button wasn't set yet ( I think ). However, the errors are gone, but my event listeners don't seem to be doing anything. I'll paste all my code
    Main.as, the classes used for this are:addClasses(), removeEvents(), addEvents(), addButtonEvents(), menuKeuzeNext(it just calls addClasses when input control is finished)
    [AS]
    package
        import flash.display.MovieClip;
        import flash.display.Shape;
        import flash.display.DisplayObject;
        import flash.geom.ColorTransform;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.display.*;
          import flash.net.*;
        public class Main extends MovieClip
           //XML wordt ingeladen en geprocessed in aparte klasse
           //private var xmlLoad = new XMLLoad;
            //Variabelen om XML in te laden
                private static var url:String = "drawings.xml";
                private var contentXML:XML;
                private var contentXMLURL:URLRequest;
                private var contentXMLLoader:URLLoader;
            //Arrays om data van XML in op te slaan
                private var titles:Array = new Array;
                private var authors:Array = new Array;
                private var locations:Array = new Array;
                private var currentChoice:uint = 0;
                public var naam:String = new String;
                public var bedragString:String = new String;
                public var bedrag:uint = new uint;
            //swf loader variabelen
                private var drawRequest:URLRequest;
                private var drawLoader:Loader = new Loader();
            //Alle objecten die in de movieclip inputMenu zitten beschikbaar maken
                private var naamInput:TextField;
                private var bedragInput:TextField;
                private var naamLeegmc:MovieClip
                private var naamLeeg:TextField;
                private var bedragLeegmc:MovieClip;
                private var bedragLeeg:TextField;
            //Klassen voor draw en erase laden in frame 2
                public var eraserClass:Eraser;
                public var spraycanClass:Spraycan;
            //Welke tool is momenteel actief?
                public static var activeEvents:Array;
            public function Main():void
                stop();
                /*Event listeners worden toegevoegd in de Action layer, per frame.
                Als je ze niet inlaadt bij de bijbehorende frame krijg je errors
                   omdat de buttons waar je de event listener aan hangt, zogezegt nog niet bestaat)*/
                //addEventListeners();
                XMLLoad();
            private function addClasses():void
                eraserClass = new Eraser();
                eraserClass.setDrawBoard(drawBoard);
                eraserClass.setButton(eraser);
                eraserClass.setDrawSize(drawSize);
                trace("if");
                spraycanClass = new Spraycan();
                spraycanClass.setDrawBoard(drawBoard);
                spraycanClass.setButton(spraycan);
                spraycanClass.setDrawSize(drawSize);
                spraycanClass.setColorsMC(colors);
                spraycanClass.setSizePanel(sizePanel);
                addButtonEvents();
            //removeEventListeners voor van actieve tool te wisselen
            public static function removeEvents():void
                if(activeEvents != null)
                    for(var i = 0; i < activeEvents.length; i++)
                        if(activeEvents[i].movieclip.hasEventListener(activeEvents[i].type))
                        activeEvents[i].movieclip.removeEventListener(activeEvents[i].type, activeEvents[i].listener);
                    activeEvents = new Array();
                    trace("niet leeg");
                } else {
                    trace("leeg");
            //addEventListeners voor actieve tool te starten
            public static function addEvents(movieclip:MovieClip,type:String, listener:Function):void
                activeEvents = new Array();
                movieclip.addEventListener(type,listener);
                activeEvents.push({movieclip:movieclip, type:type, listener:listener});
            public function addButtonEvents():void
                eraser.addEventListener(MouseEvent.MOUSE_DOWN, eraserClass.eraserTool);
                spraycan.addEventListener(MouseEvent.MOUSE_UP, spraycanClass.spraycanTool);
                colors.addEventListener(MouseEvent.MOUSE_UP, spraycanClass.chooseColor);
                sizePanel.addEventListener(MouseEvent.MOUSE_UP, spraycanClass.changeDrawSize);
            private function menuKeuzeBack(event:MouseEvent):void
                inputMenu.visible = false;
            public function callMenu(event:MouseEvent):void
                inputMenu.visible = true;
                MovieClip(inputMenu).keuzeStart.addEventListener(MouseEvent.MOUSE_UP, menuKeuzeNext);
                MovieClip(inputMenu).keuzeAnnuleer.addEventListener(MouseEvent.MOUSE_UP, menuKeuzeBack);
                hideAlerts();
            private function hideAlerts():void
                MovieClip(inputMenu).naamLeegmc.visible = false;
                MovieClip(inputMenu).naamLeeg.visible = false;
                MovieClip(inputMenu).bedragLeegmc.visible = false;
                MovieClip(inputMenu).bedragLeeg.visible = false;
            private function menuKeuzeNext(event:MouseEvent):void
                hideAlerts();
                naam = MovieClip(inputMenu).naamInput1.text;
                bedragString = MovieClip(inputMenu).bedragInput1.text;
                bedrag = int(bedragString);
                //alle invoer alerts terug op onzichtbaar zetten voor als men bv naam verbeterd heeft maar bedrag nog steeds incorrect is, anders blijft alert van naam ook staan.
                //invoercontrole
                if(naam == "")
                    showAlert("leeg", "naam")
                } else if(naam.length > 30)
                    showAlert("te lang", "naam");
                if(bedrag == 0)
                    showAlert("Bedrag is leeg", "bedrag");
                } else if(bedrag < 2.5)
                    showAlert("Bedrag moet minstens 2,5 euro zijn", "bedrag");
                if(naam.length < 30 && bedrag > 2.5 && naam !="")
                    gotoAndStop(2);
                    inputMenu.visible = false;
                    newImageMC.visible = false;
                    addClasses();
            private function showAlert(error, input):void
                if (input=="naam")
                    MovieClip(inputMenu).naamLeeg.text = "Naam is " + error;
                    MovieClip(inputMenu).naamLeegmc.visible = true;
                    MovieClip(inputMenu).naamLeeg.visible = true;
                if (input=="bedrag")
                    MovieClip(inputMenu).bedragLeeg.text = error;
                    MovieClip(inputMenu).bedragLeegmc.visible = true;
                    MovieClip(inputMenu).bedragLeeg.visible = true;
            private function prevDrawing(event:MouseEvent):void
                //Als je bij de eerste foto bent en je drukt op vorige afbeelding kom je op de laatste, anders ga je eentje terug
                if(currentChoice == 0)
                    currentChoice = titles.length-1;
                } else {
                    currentChoice -= 1;
                processXML();
            private function nxtDrawing(event:MouseEvent):void
                //Als je bij de laatste foto bent en je drukt op volgende afbeelding kom je op de eerste, anders ga je eentje vooruit
                if(currentChoice == titles.length-1)
                    currentChoice = 0;
                } else {
                    currentChoice += 1;
                processXML();
            private function newUserF(event:MouseEvent):void
                newImageMC.visible=true;
                MovieClip(inputMenu).naamInput1.text = "";
                MovieClip(inputMenu).bedragInput1.text = "";
                MovieClip(newImageMC).newImageB.addEventListener(MouseEvent.MOUSE_UP, newImage);
                MovieClip(newImageMC).currentImageB.addEventListener(MouseEvent.MOUSE_UP,currentImage);
            private function newImage(event:MouseEvent):void
                gotoAndStop(1);
                //addEventListeners();
                processXML();
            private function currentImage(event:MouseEvent):void
                MovieClip(newImageMC).newImageB.removeEventListener(MouseEvent.MOUSE_UP, newImage);
                MovieClip(newImageMC).currentImageB.removeEventListener(MouseEvent.MOUSE_UP,currentImage) ;
                newImageMC.visible = false;
                inputMenu.visible = true;
            public function XMLLoad():void
                //XML inladen en naar functie xmlLoaded gaan wanneer deze ingeladen is
                contentXMLURL = new URLRequest(url);
                contentXMLLoader = new URLLoader(contentXMLURL);
                contentXMLLoader.addEventListener(Event.COMPLETE, xmlLoaded);
            private function xmlLoaded(event:Event):void {
                //XML in variabele steken
                contentXML = new XML(event.target.data);
                contentXML.ignoreWhite = true;
                for (var i = 0; i < contentXML.DRAWING.length(); i++)
                    titles[i] = contentXML.DRAWING[i].TITLE;
                    authors[i] = contentXML.DRAWING[i].AUTHOR;
                    locations[i] = contentXML.DRAWING[i].LOCATION;
                processXML();
            private function processXML():void
                titleText.text = titles[currentChoice];
                authorText.text = authors[currentChoice];
                if (drawLoader.stage)
                    choiceBoard.removeChild(drawLoader);
                if (currentChoice == 0)
                } else {
                    drawRequest = new URLRequest(locations[currentChoice]);
                    drawLoader.load(drawRequest);
                    drawLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
            private function loadComplete(event:Event):void
                choiceBoard.addChild(drawLoader);
                drawLoader.x= -421/2;
                drawLoader.y= -297/2;
                drawLoader.content.height = 297;
                drawLoader.content.width = 421;
    [/AS]
    Spraycan.as, class for drawing
    [AS]
    package
        import flash.display.MovieClip;
        import flash.display.Shape;
        import flash.display.DisplayObject;
        import flash.display.BitmapData;
        import flash.events.MouseEvent;
        public class Spraycan extends MovieClip
            private var sprayCan:Shape;
            private var spraycan:MovieClip;
            //Ik gebruik de bitmapdata om de RGB waarde te krijgen
            private var colorsBmd:BitmapData;
            //Vars voor kleur te kiezen.
            private var pixelValue:uint;
            private var activeColor:uint = 0x663399;
            private var drawSize:MovieClip;
            private var colors:MovieClip;
            private var sizePanel:MovieClip;
            private var drawBoardmc:MovieClip;
            public function Spraycan():void
            /*public function eventLists():void
                spraycan.addEventListener(MouseEvent.MOUSE_UP, spraycanTool);
                colors.addEventListener(MouseEvent.MOUSE_UP, chooseColor);
                sizePanel.addEventListener(MouseEvent.MOUSE_UP, changeDrawSize);
                Main.addButtonEvents(spraycan, MouseEvent.MOUSE_DOWN, spraycanTool);
                Main.addButtonEvents(colors, MouseEvent.MOUSE_DOWN, chooseColor);
                Main.addButtonEvents(sizePanel
            public function spraycanTool(e:MouseEvent):void
                //convert movieclip 'colors' naar bitmapdata
                convertToBMD();
                //Actieve tool stoppen
                Main.removeEvents();
                //Listeners toevoegen aan het 'board' MovieClip, om er in te tekenen
                Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, startSpraycan);
                Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, stopSpraycan);
            private function startSpraycan(e:MouseEvent):void
                sprayCan = new Shape(); // nieuwe shape zodat die altyd vanboven ligt (in geval van vorige tekenen, ...)
                drawBoardmc.addChild(sprayCan); // shape toevoegen aan het 'board' movieclip
                sprayCan.graphics.moveTo(mouseX, mouseY); //verplaatst de tekenpositie naar de muis positie
                sprayCan.graphics.lineStyle(drawSize.width, activeColor); // zet de dikte van het penseel naar de lijndikte van de shapeSize movieclip
                drawBoardmc.addEventListener(MouseEvent.MOUSE_MOVE, drawSpraycan); // voegt een listener toe aan de volgende functie
            private function drawSpraycan(e:MouseEvent):void
                sprayCan.graphics.lineTo(mouseX,mouseY); //tekent een lijn van de huidige muis positie naar de verplaatste muispositie
            private function stopSpraycan(e:MouseEvent):void
                drawBoardmc.removeEventListener(MouseEvent.MOUSE_MOVE, drawSpraycan); //stopt het tekenen
            private function convertToBMD():void
                colorsBmd = new BitmapData(colors.width, colors.height);
                colorsBmd.draw(colors);
            public function chooseColor(e:MouseEvent):void
                pixelValue = colorsBmd.getPixel(colors.mouseX, colors.mouseY); //slaagt de geklikte RGB waarde op in de variabele pixelValue
                activeColor = pixelValue
            public function changeDrawSize(e:MouseEvent):void
                if (drawSize.width >=50)
                    drawSize.width = 1;
                    drawSize.height = 1;
                else
                    drawSize.width += 5;
                    drawSize.height = drawSize.width;
            public function setDrawBoard(board):void
                drawBoardmc = board;
            public function setButton(toolButton):void
                spraycan = toolButton;
            /*public function setActive(activeTool):void
                active = activeTool;
            public function setDrawSize(drawsize):void
                drawSize = drawsize;
            public function setColorsMC(colorsmc):void
                colors = colorsmc;
            public function setSizePanel(sizepanel):void
                sizePanel = sizepanel;
    [/AS]
    Eraser.as, class to erase
    [AS]
    package
        import flash.display.MovieClip;
        import flash.display.Shape;
        import flash.display.DisplayObject;
        import flash.display.BitmapData;
        import flash.events.MouseEvent;
        public class Eraser extends MovieClip
            private var eraser:Shape;
            private var drawBoardmc:MovieClip;
            private var eraserB:MovieClip;
            //private var active:String;
            private var drawSize:MovieClip;
            //private var spraycan:Spraycan;
            public function Eraser():void
            /*public function eventLists():void
                eraserB.addEventListener(MouseEvent.MOUSE_UP, eraserTool);
                eraserB.addEventListener(MouseEvent.MOUSE_OVER, function(){gotoAndStop(2);}) ;
                eraserB.addEventListener(MouseEvent.MOUSE_OUT, function(){gotoAndStop(1);});
            public function eraserTool(e:MouseEvent):void
                //actieve tool afsluiten
                Main.removeEvents();
                //eraserB.addEventListener(MouseEvent.MOUSE_UP, function(){gotoAndStop(2);});
                //listeners
                Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, startEraser);
                Main.addEvents(drawBoardmc, MouseEvent.MOUSE_DOWN, stopEraser);
            private function startEraser(e:MouseEvent):void
                eraser = new Shape();
                drawBoardmc.addChild(eraser);
                eraser.graphics.moveTo(mouseX, mouseY);
                eraser.graphics.lineStyle(drawSize.width, 0x000000);
                drawBoardmc.addEventListener(MouseEvent.MOUSE_MOVE, drawEraser);
            private function drawEraser(e:MouseEvent):void
                //if (board.width > mouseX && board.height > mouseY) {
                eraser.graphics.lineTo(mouseX, mouseY);
            function stopEraser(e:MouseEvent):void
                drawBoardmc.removeEventListener(MouseEvent.MOUSE_MOVE, drawEraser);
            /*private function quitActiveTool():void
                switch (active)
                    case "Spraycan" :
                        drawBoardmc.removeEventListener(MouseEvent.MOUSE_DOWN, spraycan.startSpraycan);
                        drawBoardmc.removeEventListener(MouseEvent.MOUSE_UP, spraycan.stopSpraycan);
                    case "Eraser" :
                        drawBoardmc.removeEventListener(MouseEvent.MOUSE_DOWN, startEraser);
                        drawBoardmc.removeEventListener(MouseEvent.MOUSE_UP, stopEraser);
                    default:
            public function setDrawBoard(board):void
                drawBoardmc = board;
            public function setButton(toolButton):void
                eraserB = toolButton;
            /*public function setActive(activeTool):void
                active = activeTool;
            public function setDrawSize(drawsize):void
                drawSize = drawsize;
    [/AS]

  • When user enters and exits one movieclip, button changes color

    Hello,
    I currently have a slideshow-style navigation site.  There are five buttons on the bottom and when the user clicks each button, it triggers a nested movieclip to play.  I would like the button to be highlighted when the corresponding movieclip is playing, but when they click another button and another movieclip plays, I want the button to go back to its original color.
    The problem is that the movieclips that are playing are nested two levels down and the buttons have to be on the main timeline.  I think I might need an event listener to see if a certain nested movieclip is playing, to know to change the button color.  It seems to easy but I can't figure it out, thanks for any help!

    Hi again!  Sorry, I keep changing my mind on whether I've figured this out or not.  Now I need the buttons to become disabled when they are highlighted and active.  I tried putting a:  btns[i].enabled = false;  in the else part of the for-else statement and it didn't work.  Where would I put that kind of code?  Thanks!
    stop();
    //attach sounds
    Sound1 = new Sound();
    Sound1.attachSound("Sound1");
    Sound2 = new Sound();
    Sound2.attachSound("Sound2");
    Sound3 = new Sound();
    Sound3.attachSound("Sound3");
    //buttons
    //nav buttons
    b1.onRelease = function() {
        gotoAndStop(1);
        stopAllSounds()
        activeBtn(b1);
    b2.onRelease = function() {
        gotoAndStop(2);
        stopAllSounds();
        activeBtn(b2);
    b3.onRelease = function() {
        gotoAndStop(3);
        stopAllSounds();
        activeBtn(b3);
    //array for highlighted button state
    var btns:Array = [b1, b2, b3];
    function activeBtn(mc:MovieClip):Void{
       for(var i:Number=0; i<btns.length; i++){
          if(btns[i]!=mc){
             btns[i].gotoAndStop("inactive");
          }else{
             btns[i].gotoAndStop("active");

  • Please HELP! Hex Color Code MovieCLip

    Hi!
    How can i get the hex color code of a movieclip?
    Thanks a lot!

    To do it at runtime you can use something like the following, where mc representa whatever the instance name of your movieclip is...
    import flash.display.BitmapData;
    var bmd:BitmapData = new BitmapData(mc.width,mc.height);
    bmd.draw(mc);
    var pixelValue:uint = bmd.getPixel(1, 1); // specify a point where the color is
    trace(pixelValue.toString(16)); // this outputs the hex color value

  • Movieclip's children disappear on color transform

    I have a movieclip where I create a child display object
    (another MovieClip) in the constructor and show it with
    addChild();. However, later on in the code I modify the tint of the
    parent MovieClip using colorTransform. The child object then
    vanishes. Even if I do a removeChild/addChild after the tinting, it
    does not show. I don't understand why this is happening.. tint
    should just modify the color of everything, not hide children,
    right? See attached code for the way I am showing the child and
    changing the tint.

    Thanks for the tip. Now I remember... applying a color to a
    movie clip doesn't apply it to the final composition of all the
    children but to each child individually. I fixed it by creating the
    objects I wanted to display outside of the movieclip and just
    displaying them on top of it so they were technically separate but
    appear visually together.

  • Change color part of movieclip

    Is it possible to change the color of a part of a movieclip?
    Ad exemply: if I have a movieclip that's a cube... and every
    face has a different color, how can I change the color of a
    specific face?
    I have to use nested movieclip?
    thanks a lot.

    yes, a nested clip would be my suggestion. Essentially
    Cube_mc.side_1_mc.Color_Clip where side_1_mc has a mask layer for
    only the portion you want visible, and a layer to put the color
    clip.

  • How Do I change color randomly of a MovieClip in a Timer event?

    I have created a MovieClip named "Target" and called it from actionscript. Inside this movie clip I have created an 'action' layer and written the code in it:
    import fl.motion.Animator;
    import fl.motion.MotionEvent;
    var this_xml:XML = <Motion duration="30" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
        <source>
            <Source frameRate="12" x="202" y="169.15" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="Target">
                <dimensions>
                    <geom:Rectangle left="-32.05" top="-30.85" width="64.05" height="61.7"/>
                </dimensions>
                <transformationPoint>
                    <geom:Point x="0.5003903200624512" y="0.5"/>
                </transformationPoint>
            </Source>
        </source>
        <Keyframe index="0" tweenSnap="true" tweenSync="true">
            <tweens>
                <SimpleEase ease="0"/>
            </tweens>
        </Keyframe>
        <Keyframe index="29" scaleX="2.096" scaleY="2.096"/>
    </Motion>;
    var this_animator:Animator = new Animator(this_xml, this);
    this_animator.play();
    this_animator.addEventListener(MotionEvent.MOTION_END, removeTarget);
    function removeTarget(event:MotionEvent):void
        this.parent.removeChild(this);
    In the main timeline I also have created another 'action' layer and written the code like this:
    var timer:Timer;
    var targetCount:uint;
    var container:MovieClip;
    function initGame():void
        container = new MovieClip();
        addChild(container);
        targetCount = 10;
        timer = new Timer(1000, targetCount);
        timer.addEventListener(TimerEvent.TIMER, generateTarget);
        timer.start();
    function generateTarget(event:TimerEvent):void
        var target:MovieClip = new Target();
         target.x = Math.random() * stage.stageWidth;
        target.y = Math.random() * stage.stageHeight;
        container.addChild(target);
    initGame();
    Now I can get 10 animating circles in different places of the stage after every second. And every circles will leave the stage after completing the animation. Though I have given 'pink' color in that circle, that's why its generating with 'pink' color always. How do I change the color of each circle while it will generate?
    Regards
    Dipesh Pal.

    I have tried in this way......
    function generateTarget(event:TimerEvent):void
        var target:MovieClip = new Target();
        var colorT:ColorTransform = new ColorTransform();
        colorT.redOffset = Math.round(Math.random() * 510) - 255;
        colorT.greenOffset = Math.round(Math.random() * 510) - 255;
        target.transform.colorTransform = colorT;
        target.x = Math.random() * stage.stageWidth;
        target.y = Math.random() * stage.stageHeight;
        container.addChild(target);
    but its not working......
    infact i have used function 'circleColor' which holds this random color transform.... and call that function from 'generateTarget' function also....but it doesnt work too...
    then how do I change the color of every circle which is randomly generating in the stage....?

  • Printing of movieclip without stage color

    Greetings all,
    I have a flash stage which is in grey color. I have a blank movieclip which is in light pink in bgcolor. Can anyone tell me why when I tried to print the movieclip, my paper background will be printed grey? Is it because of my flash stage color? How do I fix this? (my original paper is white in color)
    Thanks for your time,
    -Zainuu

    Hi kglad, I will be putting a datagrid inside the printClip movieclip
    printClip.addChild(dg);
    and I will need to print out all the data inside the datagrid, so I need those values to ensure that all data will be printed (if datagrid verticial scroll policy is TRUE)
    is there other ways? Resizing of the rectangle properly or set to print no background color?
    whole script:
    for (var i = 0; i < 30; i ++)
        dp.addItem({no:i+1, Winner_Name:"Name_Name_Name_Name_Name_Name_"+(i+1), Prize_Title:"Title_Title_Title_Title_Title_Title_Title_"+(i+1),      Prize_Name:"PrizeName_PrizeName_PrizeName_PrizeName_PrizeName_"+(i+1)});
                SampleData.push(dp);
    myDataGrid.columns= ["no","Winner_Name","Prize_Title","Prize_Name"];
    myDataGrid.getColumnAt(0).width = 50;
    myDataGrid.getColumnAt(1).width = 160;
    myDataGrid.getColumnAt(2).width = 170;
    myDataGrid.getColumnAt(3).width = 170;
    myDataGrid.dataProvider = dp;
    myDataGrid.setSize(463, 178);
    myDataGrid.horizontalScrollPolicy = ScrollPolicy.ON;
    clickme.addEventListener(MouseEvent.CLICK, clickmeFn)
    var printClip:MovieClip = new MovieClip();
    clickme2.visible = false;
    clickme2.enabled = false;
    function clickmeFn(e:MouseEvent){
              //creates a moveclip and a datagrid to print
              var dg:DataGrid;
              printClip.graphics.beginFill(0xFFFF2FF);
              printClip.graphics.drawRect(0, 0, 100, 100);
              printClip.graphics.endFill();
              printClip.x = 0;
              printClip.y = 0;
              addChild(printClip);
              this.setChildIndex ( printClip , this.numChildren - 1 );
              printClip.visible = true;
              dg = new DataGrid();
              dg.move(0, 0);
              dg.setSize(570, 178);
              dg.rowHeight = 40
              dg.rowCount = myDataGrid.length ;
              dg.columns = ["no","Winner_Name","Prize_Title","Prize_Name"];
              dg.getColumnAt(0).width = 50;
              dg.getColumnAt(1).width = 160;
              dg.getColumnAt(2).width = 170;
              dg.horizontalScrollPolicy = ScrollPolicy.OFF;
              dg.verticalScrollPolicy = ScrollPolicy.OFF;
              dg.dataProvider = dp;
              printClip.addChild(dg);
              // Assign cellRenderers.
              var col1:DataGridColumn = new DataGridColumn();
              col1 = dg.getColumnAt(1);
              col1.cellRenderer = MultiLineCell;
              // Assign cellRenderers.
              var col2:DataGridColumn = new DataGridColumn();
              col2 = dg.getColumnAt(2);
              col2.cellRenderer = MultiLineCell;
              // Assign cellRenderers.
              var col3:DataGridColumn = new DataGridColumn();
              col3 = dg.getColumnAt(3);
              col3.cellRenderer = MultiLineCell;
              //print button activated
              clickme2.visible = true;
              clickme2.enabled = true;
              this.setChildIndex ( clickme2 , this.numChildren - 1 );
              clickme2.addEventListener(MouseEvent.CLICK, clickmeFn2)
    function clickmeFn2(e:MouseEvent){
              printDG();
    function printDG(){
        var my_pj = new PrintJob();
        var myResult = my_pj.start();
        if (myResult) {
            var clipHeight = printClip.height;
            var _pageHeight = my_pj.pageHeight;
            var numPages = Math.ceil(clipHeight/_pageHeight);
                        var xMargin = -20;
            var _yMin = 0;
                        var _yMax = 0;
            for(var i:int=0;i<numPages ;i++){
               _yMax = _yMin + _pageHeight;
                           my_pj.addPage(printClip,new Rectangle(xMargin,_yMin, my_pj.pageWidth, _pageHeight));
                           _yMin = _yMax;
            my_pj.send();
            my_pj=null;
    The reason I got clickmeFn2 is because if I call printDG(); at the end of clickmeFn, it prints nothing. I have no idea why is that so...
    Thanks,
    -Zainuu

  • Color transform reloads movieclip

    I have a movie clip with 4 frames. I programatically create 3
    instances of it, and send each one to a different frame. If I later
    apply a color transform to one of the clips, it plays through all
    the frames and goes back to it's correct frame. Why does it do
    that, and can I stop it from doing that?
    Thanks

    After more inspection, I've figured out it's not the
    colorTransform causing the problem, it's turning a drop shadow
    filter on or off...
    Not sure how much code I would need to attach, but that's
    where the problem is.
    Thanks.

  • Fill color in movieclip

    with (myClip) {
    moveTo(0,0);
    lineTo(50,0);
    lineTo(50,100);
    lineTo(0,100);
    lineTo(0,0);
    this creates shape which is empty .
    I want to fill the shape created after i have set a certain
    parameter to
    true. How to do that with movieclip.
    beginFill not usable since it starts filling just from
    begining.

    not solving the goal yet.
    "clbeech" <[email protected]> wrote in
    message
    news:fevtpu$5q6$[email protected]..
    > OK, here's the code again with variable names as you
    have, although I
    > don't
    > believe you should use 'x' as the numeric value, since
    it is an Object
    > keyword
    > property, it still seems to function just fine. If
    '_root.mc['subMc'+x]'
    > was
    > coming to undefined, it may be that you were calling the
    function previous
    > to
    > the instance being instatiated on the timeline. make
    sure you call the
    > 'fillColor' function after the MC has been drawn.
    >
    >
    > stop();
    > import flash.display.BitmapData;
    >
    > var x = 0;
    > var mc = this.createEmptyMovieClip('mc', 0);
    > mc["subMc"+x] = mc.createEmptyMovieClip('subMc'+x, 0);
    >
    > mc["subMc"+x].moveTo(0,0);
    > mc["subMc"+x].lineTo(50,0);
    > mc["subMc"+x].lineTo(50,100);
    > mc["subMc"+x].lineTo(0,100);
    > mc["subMc"+x].lineTo(0,0);
    > mc["subMc"+x]._x = 40;
    > mc["subMc"+x]._y = 40;
    >
    > //trigger this from you're conditional
    > fillClip(_root.mc["subMc"+x], '0xFFFF0000');
    >
    > function fillClip(clip, paint) {
    > var bmp = new BitmapData(clip._width, clip._height,
    false, paint);
    > clip.attachBitmap(bmp, 0);
    > bmp.draw();
    > }
    >

Maybe you are looking for

  • Newbie: problems with drivers

    Hello everybody. I am running an application under Linux, and I have a SQLServer running in another machine, but in the same LAN. The server's name is 'stardual.stardomain' and the database name is 'market'. How can my application work with the datab

  • Database Performance Problem

    Hi, I am running Oracle10g in Windows and i have SGA - 289406976 Fixed Size- 1248576 Variable Size - 96469696 Database Buffer - 184549376 Redo Buffer - 7139328 i am enclosing the init.ora file for better understanding # Cache and I/O db_block_size=81

  • Condition judgement in Query Designer

    Hi,gurus. I want to realize the function as follows: If VALUE <= 0 then display VALUE as 0. if VALUE >0 then display VALUE. How to realize that in query designer? I've tried to create a formular but I can not find IF condition in Functions. Thanks,fo

  • How to do Server 2012 R2 Network Policy Server MAC Authentication without adding ad users?

    I have a Network Policy Server running on Server 2012 R2.  I have set it up to do certificate and PEAP authentication for our 802.1x wireless authentication and that works great. Now I want to add a policy to this server so I can also do MAC address

  • Transparency printing on non-PostScript device

    In InDesign CS6, a psd with transparent background prints correctly on a non-PostScript device when placed over another PSD file but when placed over a solid filled rectangle prints within a whte box. Why does this occur and is there a way to make it