Search Results

Search found 86 results on 4 pages for 'mousey'.

Page 3/4 | < Previous Page | 1 2 3 4  | Next Page >

  • Flash AS3 blur or liquify part of an image with mouse

    - by hamlet
    Hi, I am very beginner in flash. I want to load an image, show a cursor over the image and on mousedown I want to blur that actual part of the image. (e.g you can blur your face on the image and then save the new image). I can delete parts of the image with white line, but I would like to blur it instead // LIVE JPEG ENCODER 0.3 // from bytearray.org import asfiles.encoding.JPEGEncoder; import flash.external.ExternalInterface; ExternalInterface.addCallback("flash_saveImage", inflash_saveImage); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleComplete); loader.load(new URLRequest(loaderInfo.parameters._filename)); //loader.load(new URLRequest("b.jpg")); var container_mc:MovieClip = new MovieClip;//create movieclip function handleComplete(e:Event):void { addChild(container_mc); var bitmapData:BitmapData = Bitmap(e.target.content).bitmapData; var matrix:Matrix = new Matrix(); container_mc.graphics.clear(); container_mc.graphics.beginBitmapFill(bitmapData, matrix, false); //container_mc.graphics.beginFill(0xFFFFFF,0); container_mc.graphics.drawRect(0, 0, bitmapData.width, bitmapData.height); container_mc.graphics.endFill(); swapChildren(container_mc, pencil); container_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDrawing); container_mc.addEventListener(MouseEvent.MOUSE_UP, stopDrawing); container_mc.addEventListener(MouseEvent.MOUSE_MOVE, makeLine); } stage.addEventListener(MouseEvent.MOUSE_MOVE, moveCursor); Mouse.hide(); function moveCursor(event:MouseEvent):void { pencil.x = event.stageX; pencil.y = event.stageY; } function startDrawing(event:MouseEvent):void{ container_mc.graphics.lineStyle(20, 0xFFFFFF, 1); container_mc.graphics.moveTo(mouseX, mouseY); container_mc.addEventListener(MouseEvent.MOUSE_MOVE, makeLine); } function stopDrawing(event:MouseEvent):void{ container_mc.removeEventListener(MouseEvent.MOUSE_MOVE, makeLine); } function makeLine(event:MouseEvent):void{ container_mc.graphics.lineTo(mouseX, mouseY); } function inflash_saveImage ( ):void { var myURLLoader:URLLoader = new URLLoader(); var myBitmapSource:BitmapData = new BitmapData ( container_mc.width, container_mc.height ); // render the player as a bitmapdata myBitmapSource.draw ( container_mc ); // create the encoder with the appropriate quality var myEncoder:JPEGEncoder = new JPEGEncoder( 80 ); // generate a JPG binary stream to have a preview var myCapStream:ByteArray = myEncoder.encode ( myBitmapSource ); var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream"); var myRequest:URLRequest = new URLRequest ( "save.php" ); myRequest.requestHeaders.push (header); myRequest.method = URLRequestMethod.POST; myRequest.data = myCapStream; myURLLoader.load ( myRequest ); } Thanks, hamlet

    Read the article

  • Flex Drag and Drop

    - by James_Dude
    Hi I am trying to do a flex drag and drop. It is very similar to this first example. http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_7.html The problem is that event.currentTarget.mouseX,mouseY is showing the position where I put the mouse down rather than the position where I had finished dragging. I am just wondering why this could be? If there is a short answer?

    Read the article

  • Canvas scalable arc position

    - by Amay
    http://jsfiddle.net/cs5Sg/11/ I want to do the scalable canvas. I created two circles (arcs) and one line, when you click on circle and move it, the line will follow and change position. The problem is when I added code for resize: var canvas = document.getElementById('myCanvas'), context = canvas.getContext('2d'), radius = 12, p = null, point = { p1: { x:100, y:250 }, p2: { x:400, y:100 } }, moving = false; window.addEventListener("resize", OnResizeCalled, false); function OnResizeCalled() { var gameWidth = window.innerWidth; var gameHeight = window.innerHeight; var scaleToFitX = gameWidth / 800; var scaleToFitY = gameHeight / 480; var currentScreenRatio = gameWidth / gameHeight; var optimalRatio = Math.min(scaleToFitX, scaleToFitY); if (currentScreenRatio >= 1.77 && currentScreenRatio <= 1.79) { canvas.style.width = gameWidth + "px"; canvas.style.height = gameHeight + "px"; } else { canvas.style.width = 800 * optimalRatio + "px"; canvas.style.height = 480 * optimalRatio + "px"; } } function init() { return setInterval(draw, 10); } canvas.addEventListener('mousedown', function(e) { for (p in point) { var mouseX = e.clientX - 1, mouseY = e.clientY - 1, distance = Math.sqrt(Math.pow(mouseX - point[p].x, 2) + Math.pow(mouseY - point[p].y, 2)); if (distance <= radius) { moving = p; break; } } }); canvas.addEventListener('mouseup', function(e) { moving = false; }); canvas.addEventListener('mousemove', function(e) { if(moving) { point[moving].x = e.clientX - 1; point[moving].y = e.clientY - 1; } }); function draw() { context.clearRect(0, 0, canvas.width, canvas.height); context.beginPath(); context.moveTo(point.p1.x,point.p1.y); context.lineTo(point.p2.x,point.p2.y); context.closePath(); context.fillStyle = '#8ED6FF'; context.fill(); context.stroke(); for (p in point) { context.beginPath(); context.arc(point[p].x,point[p].y,radius,0,2*Math.PI); context.fillStyle = 'red'; context.fill(); context.stroke(); } context.closePath(); } init(); The canvas is scalable, but the problem is with the points (circles). When you change the window size, they still have the same position on the canvas area, but the distance change (so the click option fails). How to fix that?

    Read the article

  • Flex 4, chart, Error 1009

    - by Stephane
    Hello, I am new to flex development and I am stuck with this error TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.charts.series::LineSeries/findDataPoints()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\series\LineSeries.as:1460] at mx.charts.chartClasses::ChartBase/findDataPoints()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\chartClasses\ChartBase.as:2202] at mx.charts.chartClasses::ChartBase/mouseMoveHandler()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\chartClasses\ChartBase.as:4882] I try to create a chart where I can move the points with the mouse I notice that the error doesn't occur if I move the point very slowly I have try to use the debugger and pint some debug every where without success All the behaviours were ok until I had the modifyData Please let me know if you have some experience with this kind of error I will appreciate any help. Is it also possible to remove the error throwing because after that the error occur if I click the dismiss all error button then the component work great there is the simple code of the chart <fx:Declarations> </fx:Declarations> <fx:Script> <![CDATA[ import mx.charts.HitData; import mx.charts.events.ChartEvent; import mx.charts.events.ChartItemEvent; import mx.collections.ArrayCollection; [Bindable] private var selectItem:Object; [Bindable] private var chartMouseY:int; [Bindable] private var hitData:Boolean=false; [Bindable] private var profitPeriods:ArrayCollection = new ArrayCollection( [ { period: "Qtr1 2006", profit: 32 }, { period: "Qtr2 2006", profit: 47 }, { period: "Qtr3 2006", profit: 62 }, { period: "Qtr4 2006", profit: 35 }, { period: "Qtr1 2007", profit: 25 }, { period: "Qtr2 2007", profit: 55 } ]); public function chartMouseUp(e:MouseEvent):void{ if(hitData){ hitData = false; } } private function chartMouseMove(e:MouseEvent):void { if(hitData){ var p:Point = new Point(linechart.mouseX,linechart.mouseY); var d:Array = linechart.localToData(p); chartMouseY=d[1]; modifyData(); } } public function modifyData():void { var idx:int = profitPeriods.getItemIndex(selectItem); var item:Object = profitPeriods.getItemAt(idx); item.profit = chartMouseY; profitPeriods.setItemAt(item,idx); } public function chartMouseDown(e:MouseEvent):void{ if(!hitData){ var hda:Array = linechart.findDataPoints(e.currentTarget.mouseX, e.currentTarget.mouseY); if (hda[0]) { selectItem = hda[0].item; hitData = true; } } } ]]> </fx:Script> <s:layout> <s:HorizontalLayout horizontalAlign="center" verticalAlign="middle" /> </s:layout> <s:Panel title="LineChart Control" > <s:VGroup > <s:HGroup> <mx:LineChart id="linechart" color="0x323232" height="500" width="377" mouseDown="chartMouseDown(event)" mouseMove="chartMouseMove(event)" mouseUp="chartMouseUp(event)" showDataTips="true" dataProvider="{profitPeriods}" > <mx:horizontalAxis> <mx:CategoryAxis categoryField="period"/> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="profit" form="segment" displayName="Profit"/> </mx:series> </mx:LineChart> <mx:Legend dataProvider="{linechart}" color="0x323232"/> </s:HGroup> <mx:Form> <mx:TextArea id="DEBUG" height="200" width="300"/> </mx:Form> </s:VGroup> </s:Panel> UPDATE 30/2010 : the null object is _renderData.filteredCache from the chartline the code call before error is the default mouseMoveHandler of chartBase to chartline. Is it possible to remove it ? or provide a filteredCache

    Read the article

  • Convert OpenGL code to DirectX

    - by Fredrik Boston Westman
    First of all, this is kind of a follow up question on @byte56 excellent anwser on this question concerning picking algorithms. I'm trying to convert one of his code examples to directX 11 however I have run into some problems ( I can pick but the picking is way off), and I wanted to make sure I had done it right before moving on and checking the rest of my code. I am not that familiar with openGl but I can imagine openGl has different coordinations systems, and functions that alters how you must implement to code a bit. The getPickRay function on the answer linked is what I'm trying to convert. This is the part of my code that I think is giving me trouble when converting from openGl to directX Because I'm unsure on how their different coordination systems differs from one another. PRVecX = ((( 2.0f * mouseX) / ClientWidth ) - 1 ) * tan((viewAngle)/2); PRVecY = (1-(( 2.0f * mouseY) / ClientHeight)) * tan((viewAngle)/2); Another thing that I am unsure about is this part: XMVECTOR worldSpaceNear = XMVector3TransformCoord(cameraSpaceNear, invMat); XMVECTOR worldSpaceFar = XMVector3TransformCoord(cameraSpaceFar, invMat); A couple of notes: The mouse coordinates are already converted so that the top left corner of the client window would be (0,0) and the bottom right (800,600) ( or whatever resolution you would have) The viewAngle is the same angle that I used when setting the camera view with XMMatrixPerspectiveFovLH. I removed the variables aspectRatio and zoomFactor because I assumed that they were related to some specific function of his game. To summarize it up to questions : Does the openGL coordination system differ in such a way that this equation in the first of my code examples wouldn't be valid when used in DirectX 11 ( with its respective screen coordination system)? Is the openGL method Matrix4f.transform(a, b, c) equal to the directX method c = XMVector3TransformCoord(b,a)? (where a is a matrix and b,c are vectors). Because I know when it comes to matrices order is important.

    Read the article

  • Java Slick2d - How to translate mouse coordinates to world coordinates

    - by Corey
    I am translating in my main class render. How do I get the mouse position where my mouse actually is after I scroll the screen public void render(GameContainer gc, Graphics g) throws SlickException { float centerX = 800/2; float centerY = 600/2; g.translate(centerX, centerY); g.translate(-player.playerX, -player.playerY); gen.render(g); player.render(g); } playerX = 800 /2 - sprite.getWidth(); playerY = 600 /2 - sprite.getHeight(); Image to help with explanation I tried implementing a camera but it seems no matter what I can't get the mouse position. I was told to do this worldX = mouseX + camX; but it didn't work the mouse was still off. Here is my Camera class if that helps: public class Camera { public float camX; public float camY; Player player; public void init() { player = new Player(); } public void update(GameContainer gc, int delta) { Input input = gc.getInput(); if(input.isKeyDown(Input.KEY_W)) { camY -= player.speed * delta; } if(input.isKeyDown(Input.KEY_S)) { camY += player.speed * delta; } if(input.isKeyDown(Input.KEY_A)) { camX -= player.speed * delta; } if(input.isKeyDown(Input.KEY_D)) { camX += player.speed * delta; } } Code used to convert mouse worldX = (int) (mouseX + cam.camX); worldY = (int) (mouseY + cam.camY);

    Read the article

  • With Slick, how to change the resolution during gameplay?

    - by TheLima
    I am developing a tile-based strategy game using Java and the Slick API. So far so good, but I've come to a standstill on my options menu. I have plans for the user to be able to change the resolution during gameplay (it is pretty common, after all). I can already change to fullscreen and back to windowed, this was pretty simple... //"fullScreenOption" is a checkbox-like button. if (fullScreenOption.isMouseOver(mouseX, mouseY)) { if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) { fullScreenOption.state = !fullScreenOption.state; container.setFullscreen(fullScreenOption.state); } } But the container class (Implemented by Slick, not me), contrary to my previous beliefs, does not seem to have any resolution-change functions! And that's pretty much the situation...I know it's possible, but i don't know how to do it, nor what is the class responsible! The AppGameContainer class, used on the very start of the game's initialization, is the only place with any functions for changing the display-mode that I've found so far, but it's only used at the very start, and i haven't found a way to travel back to it from my options menu. //This is my implementation of it... public static void main(String[] args) throws SlickException { AppGameContainer app = new AppGameContainer(new Main()); // app.setTargetFrameRate(60); app.setVSync(true); app.setDisplayMode(800, 600, false); app.start(); } I can define it as a static global on the Main, but it's probably a (very) bad way to do it...

    Read the article

  • Java Slick2d - Mouse picking how to take into account camera

    - by Corey
    When I move it it obviously changes the viewport so my mouse picking is off. My camera is just a float x and y and I use g.translate(-cam.cameraX+400, -cam.cameraY+300); to translate the graphics. I have the numbers hard coded just for testing purposes. How would I take into account the camera so my mouse picking works correctly. double mousetileX = Math.floor((double)mouseX/tiles.tileWidth); double mousetileY = Math.floor((double)mouseY/tiles.tileHeight); double playertileX = Math.floor(playerX/tiles.tileWidth); double playertileY = Math.floor(playerY/tiles.tileHeight); double lengthX = Math.abs((float)playertileX - mousetileX); double lengthY = Math.abs((float)playertileY - mousetileY); double distance = Math.sqrt((lengthX*lengthX)+(lengthY*lengthY)); if(input.isMousePressed(Input.MOUSE_LEFT_BUTTON) && distance < 4) { if(tiles.map[(int)mousetileX][(int)mousetileY] == 1) { tiles.map[(int)mousetileX][(int)mousetileY] = 0; } } That is my mouse picking code

    Read the article

  • Facing a character towards the mouse

    - by ratata
    I'm trying to port a simple 2d top down shooter game from C++(Allegro) to Java and i'm having problems with rotating my character. Here's the code i used in c++ if (keys[A]) RotateRight(player, degree); if (keys[D]) RotateLeft(player, degree); void RotateLeft(Player& player, float& degree) { degree += player.rotatingSpeed; if ( degree >= 360 ) degree = 0; } void RotateRight(Player& player, float& degree) { degree -= player.rotatingSpeed; if ( degree <= 0) degree = 360; } And this is what i have in render section: al_draw_rotated_bitmap(player.image, player.frameWidth / 2, player.frameHeight / 2, player.x, player.y, degree * 3.14159 / 180, 0); Instead of using A-D keys i want to use mouse this time. I've been searching since last night and came up to few sample codes however noone of them worked. For example this just made my character to circle around the map: int centerX = width / 2; int centerY = height / 2; double angle = Math.atan2(centerY - mouseY, centerX - mouseX) - Math.PI / 2; ((Graphics2D)g).rotate(angle, centerX, centerY); g.fillRect(...); // draw your rectangle Any help is much appreciated.

    Read the article

  • How do I convert mouse co-ordinates in Slick2d java?

    - by Trycon
    I'm really new in Java and I really want to how do I convert the mouse clicks to co-ordinates in game. My game moves its images so that the camera could stay with the character. I follwed thenewboston tutorials. I have been modifying new codes for smoother gameplay. I have been searching the web for tutorials. This is one of the codes: PosGameX=MouseX+0; PosGameY=MouseY+0; I have not try this code but, I really think this would not work. The website I have visited, I think, is not good for coding. My gameplay is that when the mouse clicks on a position. It would try to get the co-ordinates(Mouse) and convert it to game co-ordinates. And I really want to know how do I make my mouse clicks to game co-ordinates? FOR MORE INFO: Searches: How Do I translate game co-ordinates? How Do I translate mouse to game co-ordinates? AND PLEASE! Do not give me algebra. I have really forgotten those.

    Read the article

  • processing: convert int to byte

    - by inspectorG4dget
    Hello SO, I'm trying to convert an int into a byte in Processing 1.0.9. This is the snippet of code that I have been working with: byte xByte = byte(mouseX); byte yByte = byte(mouseY); byte setFirst = byte(128); byte resetFirst = byte(127); xByte = xByte | setFirst; yByte = yByte >> 1; port.write(xByte); port.write(yByte); According to the Processing API, this should work, but I keep getting an error at xByte = xByte | setFirst; that says: cannot convert from int to byte I have tried converting 128 and 127 to they respective hex values (0x80 and 0x7F), but that didn't work either. I have tried everything mentioned in the API as well as some other blogs, but I feel like I'm missing something very trivial. I would appreciate any help. Thank you.

    Read the article

  • Placement coordinates of bitmapData in AS3

    - by TheDarkIn1978
    i've programatically created a vector graphic (rect), repositioned the graphic, and set up an MOUSE_MOVE eventListener to trace color information of the graphic using getPixel(). however, the bitmapData is placed at 0,0 of the stage and i don't know how to move it so that it matches the graphic's location. var coloredSquare:Sprite = new GradientRect(200, 200, 0xFFFFFF, 0x000000, 0xFF0000, 0xFFFF00); coloredSquare.x = 100; addChild(coloredSquare); var coloredSquareBitmap:BitmapData = new BitmapData(coloredSquare.width, coloredSquare.height, true, 0); coloredSquareBitmap.draw(coloredSquare); coloredSquare.addEventListener(MouseEvent.MOUSE_MOVE, readColor); function readColor(evt:Event):void { var pixelValue:uint = coloredSquare.getPixel(mouseX, mouseY); trace(pixelValue.toString(16)); }

    Read the article

  • $().mouseMove <-- Empty selector in jQuery 1.4

    - by Matrym
    The following bit of code breaks in the upgrade to jquery 1.4: $().mousemove( function (e) { defaults.mouseX = e.pageX; defaults.mouseY = e.pageY; }); }; What appeared to be a reasonable fix was adding "html" as the selector, ex: $("html"). The fix works fine - except now when the user mouses off the page, it doesn't register the mouse position beyond the boundaries. When attempting to use the mouse position for a drag, for example, the amount of movement beyond the screen is really important. Anyone got any ideas? Thanks in advance.

    Read the article

  • Flash Hates Me. Error #1009: Cannot access a property or method of a null object reference

    - by sol
    I simply create a movie clip, put it on the stage and give it an instance name of char. Here's my document class, simple as can be: public class Test extends MovieClip { public function Test() { char.x = 1315; char.y = 459; addEventListener(Event.ENTER_FRAME, mouseListen); } private function mouseListen(e:Event) { char.x = mouseX; char.y = mouseY; } } And I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.me::Test/::mouseListen() How in the world is it possible that it knows what "char" is in the constructor but not in the mouseListen function? What else could it be?

    Read the article

  • Java: Friendlier way to get an instance of FontMetrics

    - by Martijn Courteaux
    Hi people, Is there a friendlier way to get an instance of FontMetrics than FontMetrics fm = Graphics.getFontMetrics(Font); I hate this way because of the following example: If you want to create in a game a menu and you want all the menuitems in the center of the screen you need fontmetrics. But, mostly, menuitems are clickable. So I create an array of Rectangles and all the rectangles fits around the items, so when the mouse is pressed, I can simply use for (int i = 0; i < rects.length; i++) if (rects[i].contains(mouseX, mouseY)) { ... } But to create the rects I also need FontMetrics for their coordinates. So this mean that I have to construct all my rectangles in the paint-method of my menu. So I want a way to get the FontMetrics so I can construct the Rectangles in a method called by the constructor. Hope you understand. Thanks in advance.

    Read the article

  • Lock mouse in center of screen, and still use to move camera Unity

    - by Flotolk
    I am making a program from 1st person point of view. I would like the camera to be moved using the mouse, preferably using simple code, like from XNA var center = this.Window.ClientBounds; MouseState newState = Mouse.GetState(); if (Keyboard.GetState().IsKeyUp(Keys.Escape)) { Mouse.SetPosition((int)center.X, (int)center.Y); camera.Rotation -= (newState.X - center.X) * 0.005f; camera.UpDown += (newState.Y - center.Y) * 0.005f; } Is there any code that lets me do this in Unity, since Unity does not support XNA, I need a new library to use, and a new way to collect this input. this is also a little tougher, since I want one object to go up and down based on if you move it the mouse up and down, and another object to be the one turning left and right. I am also very concerned about clamping the mouse to the center of the screen, since you will be selecting items, and it is easiest to have a simple cross-hairs in the center of the screen for this purpose. Here is the code I am using to move right now: using UnityEngine; using System.Collections; [AddComponentMenu("Camera-Control/Mouse Look")] public class MouseLook : MonoBehaviour { public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 } public RotationAxes axes = RotationAxes.MouseXAndY; public float sensitivityX = 15F; public float sensitivityY = 15F; public float minimumX = -360F; public float maximumX = 360F; public float minimumY = -60F; public float maximumY = 60F; float rotationY = 0F; void Update () { if (axes == RotationAxes.MouseXAndY) { float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX; rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = Mathf.Clamp (rotationY, minimumY, maximumY); transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); } else if (axes == RotationAxes.MouseX) { transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0); } else { rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = Mathf.Clamp (rotationY, minimumY, maximumY); transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0); } while (Input.GetKeyDown(KeyCode.Space) == true) { Screen.lockCursor = true; } } void Start () { // Make the rigid body not change rotation if (GetComponent<Rigidbody>()) GetComponent<Rigidbody>().freezeRotation = true; } } This code does everything except lock the mouse to the center of the screen. Screen.lockCursor = true; does not work though, since then the camera no longer moves, and the cursor does not allow you to click anything else either.

    Read the article

  • Cursor image to the center on mouseout

    - by Milla
    Hi all! I'm a real noobie with flash and I was wondering if somebody could help me with this one. I have this actionsript 3 code, where the cursor image "ball_mc" follows the mouse's position with a slight delay: stage.addEventListener(Event.ENTER_FRAME,followBall); function followBall(event:Event):void { var dx:int = ball_mc.x - mouseX; var dy:int = ball_mc.y - mouseY; ball_mc.x -= dx / 5; ball_mc.y -= dy /5; } 1) How can I get the cursor image automatically return to the center of the stage on mouseout? As of now, it stays at the position where the mouse leaves the stage. 2) How can I reverse the movement of the mouse? So that when I, for example, move mouse to the right, the cursor image would move to the left? And when moving the mouse up, the image would go down. The stage is 800 x 250 pixels, in case that makes any difference.

    Read the article

  • Set scaleX property on a Sprite without altering the child inside

    - by grammar
    Is this possible? My site is set up with next and prev buttons on the right and left sides respectively, and as you roll over either of the hit areas around the buttons a Sprite fades in which contains a TextField that describes the next page. Said Sprite calls the StartDrag() method, so it follows the mouse within the bounds, which is all fine and dandy on the left side of the page. Adobe, however, seems to have forgotten to put a way to dynamically alter the registration point of a Sprite, MC, whatever else, so when you roll over the right side of the page, the sprite is displayed from the top left and is mostly off the stage. Trying to hack this problem I have tried numerous things ( classes written by others, other hacks) and the best that I have found is to use the scaleX method on the Sprite, changing the scale to -1. This, of course, makes the Sprite seem like it's reflected from its normal point, which means all its children show up backwards. Is there anyway I can use this hack without it altering the text? OR Does anyone know a different way to go about displaying a Sprite from another corner? Any way to make a Sprite fade in and follow the mouse on the LEFT HAND side of the mouse pointer? Thank you very much in advance. Here is a snippet to give an idea of what's happening: naxtPage.labelBG.scaleX = -1; nextPage.labelBG.startDrag( true, nextHitRect ); nextPage.labelBG.x = nextPage.labelBG.parent.mouseX; nextPage.labelBG.y = nextPage.labelBG.parent.mouseY; Cheers

    Read the article

  • paintComponent on JPanel, image flashes and then disappears

    - by mark
    I have a JApplet (MainClass extends JApplet), a JPanel (ChartWindow extends JPanel) and a Grafico class. The problem is that the Grafico class instance has 2 JPanel that should show 2 images (1 for each panel) but the images are shown and after a little while they disappears: instead of them i get a gray background (like an empty JPanel). This happens for every repaint() call (that are made in the ChartWindow class) the MainClass init() contains chartwindow=new ChartWindow(); add(chartwindow) chartwindow has a Grafico instance. it's the ChartWindow's paintComponent (override) paintComponent(Graphics g) { super.paintComponent(g); Image immagineGrafico=createImage(grafico.pannelloGrafico.getWidth() ,grafico.pannelloGrafico.getHeight()); Image immagineVolumi=createImage(grafico.pannelloVolumi.getWidth() ,grafico.pannelloVolumi.getHeight()); Graphics2D imgGrafico=(Graphics2D)immagineGrafico.getGraphics(); Graphics2D imgVolumi=(Graphics2D)immagineVolumi.getGraphics(); grafico.draw(imgGrafico,imgVolumi,mouseX,mouseY); ((Graphics2D)grafico.pannelloGrafico.getGraphics()).drawImage(immagineGrafico,0,0,this); ((Graphics2D)grafico.pannelloVolumi.getGraphics()).drawImage(immagineVolumi,0,0,this); } grafico's JPanels are added this way in the ChartWindow's constructor grafico=new Grafico() ................ add(grafico.pannelloGrafico); add(grafico.pannelloVolumi); Tell me if you need more information, thank you very much :-)

    Read the article

  • Keeping the number of objects and event-listeners on stage as low as possible

    - by DevEight
    Hello. I am creating a site with lots of big scrollable text-boxes in it. Each text-box object contained some text, and two buttons to scroll up/down with. The scroll buttons each had an event listener so the text moved when you clicked them. These text-boxes were stacked on-top of each other with all except one having an alpha of 0. If I wanted to change which text-box is active I move it to the front and call a small TweenLite animation. To the left (outside of the text-box objects) I have an object similar to a menu. It also has about 12 or so event-listeners (one for every button). This turns out cause A LOT of lag an it's very troublesome for my laptop to run it. What I need help with doing is to reduce the number of event-listeners on the stage and also the amount of text-boxes. What I was thinking was to add the text-boxes using AS so I only have 1 on the stage at a time but I couldn't figure out how to do it. I also thought it might be better to just use 1 big event-listeners and from mouseX and mouseY decide which button the user is trying to push. Are there any better alternatives to this? And if so, please elaborate on how to do it.

    Read the article

  • Exception when click DataGridview tab c#, .Net 4.0

    - by Nguyen Nam
    My winform app have two tab and multi thread, one is main tab and other is log tab. I only use log tab to show logs in a datagridview control. Exception is random occurred when click to log tab (Not click to row or colunm), i have try but can not find anyway to fix it. This is the error log: Message : Object reference not set to an instance of an object. Source : System.Windows.Forms TargetSite : System.Windows.Forms.DataGridViewElementStates GetRowState(Int32) StackTrace : at System.Windows.Forms.DataGridViewRowCollection.GetRowState(Int32 rowIndex) at System.Windows.Forms.DataGridView.ComputeHeightOfFittingTrailingScrollingRows(Int32 totalVisibleFrozenHeight) at System.Windows.Forms.DataGridView.GetOutOfBoundCorrectedHitTestInfo(HitTestInfo& hti, Int32& mouseX, Int32& mouseY, Int32& xOffset, Int32& yOffset) at System.Windows.Forms.DataGridView.OnMouseMove(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseMove(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.DataGridView.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Message : Object reference not set to an instance of an object. Source : System.Windows.Forms TargetSite : Void ClearInternal(Boolean) StackTrace : at System.Windows.Forms.DataGridViewRowCollection.ClearInternal(Boolean recreateNewRow) at System.Windows.Forms.DataGridView.OnClearingColumns() at System.Windows.Forms.DataGridViewColumnCollection.Clear() at System.Windows.Forms.DataGridView.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.Windows.Forms.TabControl.Dispose(Boolean disposing) at System.ComponentModel.Component.Dispose() at System.Windows.Forms.Control.Dispose(Boolean disposing) at System.Windows.Forms.Form.Dispose(Boolean disposing) Update status code: private void updateMessage(int index, string message) { try { this.dgForums.Rows[index].Cells["ColStatus"].Value = message; System.Windows.Forms.Application.DoEvents(); } catch { } }

    Read the article

  • Cancel text selection on textinput in Flex

    - by Michael
    So the real problem is the lack of an onReleaseOutside function. I found some examples of how to bypass this during a drag function but it was not applicable for a text input. The problem is that when a user selects some text in textinput and mouses off the application area and then mouses up, I'm getting a problem that the textinput keeps thinking that the mouse down is actively selecting text in the textinput and continually overwrites the characters being entered in the textinput. You can test this at http://palermo.infusedindustries.com [ in the search bar of the live store on the page, type some text, then highlight it all and don't let up on the mouse until you are outside the store. I finally hacked some junk together so I can tell if the mouse goes off the stage using some code like var x = stage.mouseX; var y = stage.mouseY; if(x < 0 || y <0 || x >stage.stageWidth || y > stage.stageHeight) I'd like to just make the textinput stop thinking it should be highlighting text so that even if the user scrolls out of the applet and mouses up that the text input still overwrites what is in the search bar and functions as normal. I can't seem to find any events or ways to tell the Flex text field to stop thinking that the mouse is down and that the user is done selecting text.

    Read the article

  • Zoom in on a point (using scale and translate)

    - by csiz
    I want to be able to zoom in on the point under the mouse in canvas with the mouse whell, like when zooming on maps.google. I'd like straight code as I've been working on this for 5h+ Something to start with: <canvas id="canvas" width="800" height="600"></canvas> <script type="text/javascript"> var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); var scale = 1; var originx = 0; var originy = 0; function draw(){ context.fillStyle = "white"; context.fillRect(originx,originy,800/scale,600/scale); context.fillStyle = "black"; context.fillRect(50,50,100,100); } setInterval(draw,100); canvas.onmousewheel = function (event){ var mousex = event.clientX - canvas.offsetLeft; var mousey = event.clientY - canvas.offsetTop; var wheel = event.wheelDelta/120;//n or -n var zoom = 1 + wheel/2; scale *= zoom; originx += 0;//??? originy += 0;//??? context.scale(zoom,zoom); context.translate(0,0);//??? } </script>

    Read the article

  • TypeError: Error #1009: Cannot access a property or method of a null object reference. at RECOVER_fyp1_fla::MainTimeline/abc1()

    - by user2643323
    TypeError: Error #1009: Cannot access a property or method of a null object reference. at RECOVER_fyp1_fla::MainTimeline/abc1() Hi, what does this mean? Can anybody figure it out? Thanks. Code: swatter.addEventListener(Event.ENTER_FRAME,abc1); Mouse.hide(); function abc1(e:Event) { swatter.x = mouseX; swatter.y = mouseY; enter code here mosq1.y = mosq1.y + 2; mosq2.y = mosq2.y + 3; mosq3.y = mosq3.y + 4; mosq4.y = mosq4.y + 5; mosq5.y = mosq5.y + 6; if (mosq1.y > 640) { mosq1.y = -50; } if (mosq2.y > 640) { mosq2.y = -50; } if (mosq3.y > 640) { mosq3.y = -50; } if (mosq4.y > 640) { mosq4.y = -50; } if (mosq5.y > 640) { mosq5.y = -50; } if(swatter.hitTestObject(mosq1)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq1.parent.removeChild(mosq1); } if(swatter.hitTestObject(mosq2)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq2.parent.removeChild(mosq2); } if(swatter.hitTestObject(mosq3)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq3.parent.removeChild(mosq3); } if(swatter.hitTestObject(mosq4)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq4.parent.removeChild(mosq4); } if(swatter.hitTestObject(mosq5)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq5.parent.removeChild(mosq5); } } enter code here

    Read the article

  • Flood fill algorithm for Game of Go

    - by Jackson Borghi
    I'm having a hell of a time trying to figure out how to make captured stones disappear. I've read everywhere that I should use the flood fill algorithm, but I haven't had any luck with that so far. Any help would be amazing! Here is my code: package Go; import static java.lang.Math.*; import static stdlib.StdDraw.*; import java.awt.Color; public class Go2 { public static Color opposite(Color player) { if (player == WHITE) { return BLACK; } return WHITE; } public static void drawGame(Color[][] board) { Color[][][] unit = new Color[400][19][19]; for (int h = 0; h < 400; h++) { for (int x = 0; x < 19; x++) { for (int y = 0; y < 19; y++) { unit[h][x][y] = YELLOW; } } } setXscale(0, 19); setYscale(0, 19); clear(YELLOW); setPenColor(BLACK); line(0, 0, 0, 19); line(19, 19, 19, 0); line(0, 19, 19, 19); line(0, 0, 19, 0); for (double i = 0; i < 19; i++) { line(0.0, i, 19, i); line(i, 0.0, i, 19); } for (int x = 0; x < 19; x++) { for (int y = 0; y < 19; y++) { if (board[x][y] != YELLOW) { setPenColor(board[x][y]); filledCircle(x, y, 0.47); setPenColor(GRAY); circle(x, y, 0.47); } } } int h = 0; } public static void main(String[] args) { int px; int py; Color[][] temp = new Color[19][19]; Color[][] board = new Color[19][19]; Color player = WHITE; for (int i = 0; i < 19; i++) { for (int h = 0; h < 19; h++) { board[i][h] = YELLOW; temp[i][h] = YELLOW; } } while (true) { drawGame(board); while (!mousePressed()) { } px = (int) round(mouseX()); py = (int) round(mouseY()); board[px][py] = player; while (mousePressed()) { } floodFill(px, py, player, board, temp); System.out.print("XXXXX = "+ temp[px][py]); if (checkTemp(temp, board, px, py)) { for (int x = 0; x < 19; x++) { for (int y = 0; y < 19; y++) { if (temp[x][y] == GRAY) { board[x][y] = YELLOW; } } } } player = opposite(player); } } private static boolean checkTemp(Color[][] temp, Color[][] board, int x, int y) { if (x < 19 && x > -1 && y < 19 && y > -1) { if (temp[x + 1][y] == YELLOW || temp[x - 1][y] == YELLOW || temp[x][y - 1] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } if (x == 18) { if (temp[x - 1][y] == YELLOW || temp[x][y - 1] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } if (y == 18) { if (temp[x + 1][y] == YELLOW || temp[x - 1][y] == YELLOW || temp[x][y - 1] == YELLOW) { return false; } } if (y == 0) { if (temp[x + 1][y] == YELLOW || temp[x - 1][y] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } if (x == 0) { if (temp[x + 1][y] == YELLOW || temp[x][y - 1] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } else { if (x < 19) { if (temp[x + 1][y] == GRAY) { checkTemp(temp, board, x + 1, y); } } if (x >= 0) { if (temp[x - 1][y] == GRAY) { checkTemp(temp, board, x - 1, y); } } if (y < 19) { if (temp[x][y + 1] == GRAY) { checkTemp(temp, board, x, y + 1); } } if (y >= 0) { if (temp[x][y - 1] == GRAY) { checkTemp(temp, board, x, y - 1); } } } return true; } private static void floodFill(int x, int y, Color player, Color[][] board, Color[][] temp) { if (board[x][y] != player) { return; } else { temp[x][y] = GRAY; System.out.println("x = " + x + " y = " + y); if (x < 19) { floodFill(x + 1, y, player, board, temp); } if (x >= 0) { floodFill(x - 1, y, player, board, temp); } if (y < 19) { floodFill(x, y + 1, player, board, temp); } if (y >= 0) { floodFill(x, y - 1, player, board, temp); } } } }

    Read the article

< Previous Page | 1 2 3 4  | Next Page >