ActionScript 3.0 :: 4 By 4px Stage Grid For Drawing Dots?
Jan 13, 2011
flash and at the risk of sounding like an idiot, here goes.My question is:How can I make it so that the stage is divided up into a grid of 4 by 4px spaces that can be filled with a color after a click?So far I have some code that lets you draw a 4 by 4px dot but the dots can overlap because there is no grid:
dot.addEventListener(Event.ENTER_FRAME, do_stuff);
/*dot is a movie clip of a 4x4 black dot*/
function do_stuff(event:Event):void
[code].....
View 4 Replies
Similar Posts:
Nov 30, 2007
I am drawing some circles with a bit of code like this:
Code:
for (var i = 0; i<=1; i++){
for(var j = 0; j<= 1; j++){
this.drawMyCircle(radius,i*a,j*b);
}}
//a and b being the gap between the columns and rows
What I would like to do is add some metadata to each point I create, containing the centre coordinates for that dot (e.g. i*q, j*b). I have no idea about this part. Then with an onRelease event on a given dot , I can get the location. I have never dynamically made an event firing object. My goal is to be able to draw lines between two clicked dots. Unfortunately I have to do this dynamically so I can introduce a bit of variety.
View 1 Replies
Oct 7, 2009
I've almost got a bit of flash finished, The .swf so-far is here: [URL]. For some reason the file won't attach but the important bit of code I have so-far is below. I need to make a line to literally 'connect the dots', each of which is one end of a movieclip, I know it needs to boil down to ' line x,y, to (movieclipname)x,y, but cannot work it out!
time.onChanged = function() {
if(time.text.length == 4) {
var hours:Number = parseInt(time.text.substr(0,2),10);
hours *= 60;
var minutes:Number = parseInt(time.text.substr(2,2),10);
[Code] ......
View 3 Replies
May 19, 2010
I have the raster of dots on white background. I would like it when I DragOver each dot it becomes white so it looks like you are actually drawing white line by erasing the dots. Ive somehow found the way how to do it by making it transparent when I rollover. But it doesnt work with dragover. How to do it only when I hold down the mouse button and drag my mouse over the dots?
This is the script assigned to MC with one black dot (I copied this MC with one dot into another MC and multiplied it to have the raster):
this.onRollOver = function () {
this._alpha = 0;
} this.onPress = function () {
this._alpha = 50;
}
I've tried also this, but it doesn't work:
var erasepoint = false;
this.onMouseDown = function(){erasepoint = true;}
this.onMouseUp = function(){erasepoint = false;}
this.onRollOver = function () {
if(erasepoint){
this._alpha = 0;
}}
View 6 Replies
Nov 20, 2009
What's the easiest way to draw a hex grid algorithmically? How should I present them in data?
For example, in a square grid, I could just save x-y coordinates..
View 2 Replies
Jun 28, 2010
I would like to create a proportional grid. Basicly rects with same width and dotted lines as borders (no fill): It should be on full stage width and reacting on resizing (single grid rects should stay in size) only becomming less or more grids (stage width resizing smaller or larger).Some Example Sites that use such grids [URL]
View 3 Replies
Oct 14, 2010
I'm looking for the most efficient possible way of drawing an 8 x 4 grid (960x600 total size). Each square of the grid has a variable alpha and the grid is redrawn every enter frame. The problem is my application is doing a lot already and I'm looking for the most efficient way to execute this loop 32 times (possible more in fact) per frame without overloading processor.
Code:
private function init():void {
var dimensions : Array = [ 0, 0, 960, 600 ];
var gridRaw : Array = [ 8, 4 ];
var stageRect : Rectangle = new Rectangle( Number( dimensions[0] ), Number( dimensions[1] ), Number( dimensions[2] ), Number( dimensions[3] ) );
[Code] .....
I'm under the impression there could be better ways of drawing the shapes straight to BitmapData without using Sprites, or maybe I'm doing something wrong about memory usage as I can see memory going up and down in a cycle.
View 5 Replies
Apr 19, 2007
I have a slideshow of images, all being loading via Action Script, i have 20 thumbnail that load up into a strip with this code.
xmlPhotos.onLoad = function() {
for (var i:Number = 0; i<xmlPhotos.firstChild.childNodes.length; i++) {
makeAThumb(i);
[Code]....
Okay my problem is i cant work out how to load them into a 5 x 4 grid, with a 10 px gap between them, is this possible? How can i acheive this all through Action Script?
View 1 Replies
Jul 22, 2009
Is it possible to export the image on the stage with the interface's grid included?
View 1 Replies
May 30, 2011
I'm trying to achieve a thumbnail gallery which basically reduces it number of columns (and increases number of rows) when the stage is being resized down.The columns number as default 5, but after resizing down the stage this number is calculated like this:[code]My question is how can I reorder the the columns and rows from the onStageResize function.[code]
View 4 Replies
Jan 12, 2010
I tried to erase whatever was drawn on the stage by using a similar function in a recent previous post but I'm not getting it.when I try to use it an error says that this is no longer supported. I tried addChildAt() and inserted different Num but it only erased everything including my button.the current code is:
var drawing:Boolean = false;
this.graphics.lineStyle(5,0x000000);this.graphics.moveTo(mouseX,mouseY);
this.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);stage.addEventListener(MouseEvent.MOUSE_DOWN, onDown, false,0,true);stage.addEventListener(MouseEvent.MOUSE_UP, onUp, false,0,true);
[code]....
View 2 Replies
Oct 11, 2010
I'm currently trying to debug a problem in Flex 4, in where a component is firing a custom event with its local coordinates translated to global coordinates (i.e. localToGlobal) and another component (in a separate "branch" of the display list hierarchy) recieves such event and uses it as a part of an animation, via globalToLocal. It should be a simple, coordinate-transformation system but it is not working.I'm trying to debug this, by using AS3's drawing API to draw circles where the Points should be.Here is the dispatching component (Component A in the image below):
// Check where is the local x,y
this.graphics.beginFill(0x0000FF);
this.graphics.drawCircle(this.x,this.y, 10);[code].......
One would expect the three circles (Red, Green and Blue) to correspond, each being drawn just before the event dispatch and one (green) on event listening. What actually happens is:
Blue circle is drawn where you would expect it.
Red circle is never drawn (hence, my question on drawing on the stage in Flex 4)
Green circle is drawn in an un-expected place.
EDIT: Here is an image that explains the relationship between components and where are the dots being drawn:
View 1 Replies
Nov 5, 2010
I started working with AS3 a month ago, I know the basics and stuff, but I can't do that much. The user would draw lines by clicking on the stage. The code works exactly as I wanted it to, but it is on AS2 . I tried, but I can't 'convert' it to AS3. I would like to know how this code would work on AS3! Here's the download link of the .fla, so you can see better what I mean: [URL].
View 3 Replies
Jan 13, 2010
I keep trying to change the code so that I can control the area for drawing. The attached code is where I left of after many tries. The movie clip box_mc is being called from the library.
View 3 Replies
Mar 31, 2011
I'm drawing with Flash's brush tool and the marks I make are appearing not just where I draw them, but also in the timeline or elsewhere on the stage. It goes away if I minimize and restore, but this is a big time-waster.
View 1 Replies
Jan 29, 2012
I have a little problem with counting all elements on stage. Flash, unfortunately is counting all objects on the stage without drawn objects (all shapes, including drawing objects, rectangles etc) all missed. Is there any way to count them?
View 2 Replies
Dec 4, 2009
I got this code from [URL]; it writes an image to stage as a way of tile it.
holidaytile is an instance of a Gif Image.
But I want to change the Alpha so that my top layer shows through it, and I can't seem to figure out how to do that.
import flash.display.BitmapData;var tile:BitmapData = BitmapData.loadBitmap("holidaytile");this.beginBitmapFill(tile);
[Code]....
View 3 Replies
Sep 29, 2010
I need to use a Timer for time controlled animation, time the drawing to occur every 500 milliseconds & Draw 20 circles in total. I also need to make sure the circles are completely drawn inside the limits of the stage...
import flash.events.TimerEvent;
import flash.utils.Timer;
// creates a new hundred-second Timer, ticks every 250 milliseconds
var faster_minuteTimer:Timer = new Timer(250, 6);
// designates listeners for the interval and completion events
[Code] .....
View 2 Replies
Jul 28, 2011
I have a little snippet of code that allows the user to create a line with the mouse, and clears the line if they end up touching the hitbox with the mouse, while they're drawing the line. It works fine when it's just thrown onto the main timeline. However, when I try to encapsulate it within a movie clip, it suddenly doesn't work. At all. Are there any suggestions as to why this is happening? Here's the code.
[Code]....
View 13 Replies
Jul 15, 2004
This time round i need to get the pattern drawn on the drawing board to be repeated on another area of the stage.I need it to be repeated 4x4 tile.
View 1 Replies
Feb 3, 2012
I'm currently working with the OLAPDataGrid component and got stuck at a relatively simple task: I want to style the last row of the grid differently from the rest, so my cell item renderer needs to know whether he's rendering the last row with content in the overall grid, including those rows currently not rendered because they are outside the visible grid space. AdvancedGridListData's rowIndex property only gets me the row index of the renderer relative to the range of visible grid rows, i.e. when I scroll down the grid, a data item with an index greater than 0 gets the rpw index = 0.
View 2 Replies
Oct 8, 2008
Someone told me once that every function in Flash has some associated actionscript being executed behind the scenes, e.g. converting a graphic to a symbol or drawing a pentagon on the stage. This person also told me that there is somewhere in which you can view said ActionScript as it's being executed. How can I do this? I deem such a feature necessary to do the projects I have been given, especially having very little experience with AS.
View 1 Replies
Oct 9, 2009
I need to create a simple multiplication grid where children will fill the grid. Its an empty grid at the begining, when they start the time start as well.Its a grid of 10 x 10. when they enter the last number, the grid should show what they did wrong and the time they spend. It's an idea of how it could work but if anyone has something that looks like this.
View 6 Replies
Jul 5, 2011
I want to make a square grid of fixed side length but varying grid number using code.That is, the number of grids should be specified by the user (say 3*3) and after pressing a button, the stage should be broken into 3*3 grids.I don't want any code, just a method on how to do it. I have tried it by using simple loops but the method just fails for no reason I can figure.
View 5 Replies
Mar 31, 2010
Whenever I add paddingRight to a column in the flex grid, it adds the padding to the header as well.Is anyone familiar with how I can add paddingRight just to the column and not to the header? Below is the column code where I was specifying the padding.
<mx:DataGridColumn width="60" headerText="Type" dataField="Grade" headerStyleName="headerLeft" textAlign="left" draggable="false" resizable="false" headerRenderer="GridHeaderRenderer" paddingRight="5"/>
View 1 Replies
Mar 19, 2007
I really like the thumbnail gallery for its simplicity and beauty. But I would like to ad or vertical scroller (I'm unable to find it here too, maybe I'm blind, just I'm more at the end of my seeking options) or a make a grid thumbnails, that will show 2 columns of thumbs and 5 pictures in each columns, then under the 2 columns i would like to ad a sort of arrow or button that if my gallery have more then 10 pictures it will go on the next thumbnail list. I'm not looking for any extra fading effects or special movements. Just would love to have a single thumbnail grid on side, with option to have lists of thumbnails by 10 if there is more then 10 pictures or so.
View 14 Replies
Sep 24, 2009
I have a mx:Grid component in my flex application. But I would like to resize it by clicking and dragging in the border. This component doesn't allow doing that.I want to put a panel in each gridItem of this Grid component and resize it.
View 1 Replies
Jun 24, 2008
I'm building a small editor that allows users to place electrical components onto a grid so that they can see how electricity works. I have built a grid using an array and for loops and attach movieclips dynamically to that grid. What I want the moviclips to do is to look in the four spaces either side of itself i.e. up, down,left and right.I have managed to pull the grid coordinates out of the grid which enables me to tell the clip which grid space to look at but have been unable to successfully get the code to work.Here is my code:
myGrid = [[1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,1],[code]....
View 1 Replies
Nov 9, 2010
i've tried to simulate a pencil tool, for drawing above a imagem, but the drawing is below the picture. How fix it?
[Code]....
View 3 Replies
Jul 22, 2009
Basically I've got a reasonably complex drawing object in a fla and I want to reproduce it in a class definition using the drawing api. However obviously this is a tedious task, so is there some trick or automated method of doing this?
Last time I needed to do this it was a drawing of an arrow and I ended up writing down x,y,width,height values for everything but this one has curves in it which I don't have experience with drawing anyway.
View 2 Replies