Copy link to clipboard
Copied
Hey there
After searching in the www founding nothing helpfull I decided to ask here...
I need to create a dynamic pixel grid controlled by a slider. That means I need
a grid (for example 10x10 rectangles) and you should be able to scale it (by the slider)
for example to a 100x100, 50x50, etc. rectangles grid...could you please help me how
to do this or do you know where I can find a similar code? Thank you so much!
- estimola -
1 Correct answer
compare what you're doing with: http://www.kglad.com/Files/forums/Untitled-1.fla
Copy link to clipboard
Copied
i actually recognized it just at the moment that my answer goes to the post... sorry for that 😕
yeah i already found out that it's almost impossible to draw (in my case) 25 000 litte rectangles...
i've tried another thing...just zooming into the grid – it's okay for my use in the programm and
it works quite perfect i just have a few problems with matching it to my application...but hopefully i
can solve this last problem with your help i'm optimistic
btw: isn't it possible to edit a post/thread? cause it was not my intent to post this email
Copy link to clipboard
Copied
hey there once again
i did a new code that zooms in and out my grid with the help of a slider. the grid works perfect with
a ready-made slider, but not with my own what's wrong in my code? i think it's just a little thing
that's not working, but i don't know what...
please help
thanks!
here's my code:
var pattern:BitmapData = createPatternOffset( [0xFF0000, 0x00FF00, 0x0000FF] );
//var drawPattern:int = map(sliderG.x, sliderG.x, sliderG.x+sliderG.width, 0, 100);
// this is where the code of my slider starts
sliderG.thumb.addEventListener(Event.CHANGE, f);
sliderG.thumb.liveDragging = true;
sliderG.thumb.buttonMode = true;
sliderG.thumb.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownGHandler);
sliderG.thumb.addEventListener(MouseEvent.MOUSE_UP, mouseUpGHandler);
sliderG.thumb.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveGHandler);
function mouseDownGHandler(event:MouseEvent):void {
sliderG.thumb.startDrag(false, sliderG.bahn);
}
function mouseUpGHandler(event:MouseEvent):void {
sliderG.thumb.stopDrag();
}
function mouseMoveGHandler(event:MouseEvent):void {
var sliderMax:Number = 400;
var sliderMin:Number = 0;
function moveSlider(event:MouseEvent):void {
sliderG.thumb.x = Math.max( sliderMin, Math.min( sliderMax, mouseX) );
dispatchEvent(new Event(Event.CHANGED, true, true));
}
}
f();
// here is the code of the pixel grid
function f(e:Event=null):void
{
var sf:Number = 100 / sliderG.thumb.value;
graphics.clear();
drawPattern(graphics,100, 30, 300, 300, sf, sf, false);
}
function createPatternOffset(cols:Array, transparency:Boolean=false):BitmapData
{
var len:int = cols.length;
var bd:BitmapData = new BitmapData(len,len,transparency,0);
for (var y:int = 0; y<len; ++y)
{
for (var x:int = 0; x<len; ++x)
{
bd.setPixel32(x, y, cols[(x-y+len)%len] | (transparency? 0: 0xFF000000));
}
}
return bd;
}
function drawPattern(canvas:Graphics, x:Number, y:Number, width:Number, height:Number, scaleX:Number=1, scaleY:Number=1, smoothing:Boolean=false):void
{
canvas.beginBitmapFill(pattern, new Matrix(scaleX, 0, 0, scaleY, x, y), true, smoothing);
canvas.drawRect(x, y, width, height);
canvas.endFill();
}
//pixel grid end
Copy link to clipboard
Copied
can't anyone help me quickly? it's really kind of urgent
btw (what i forgot): the slider is convoluted like this: i created "sliderG", inside is the "thumb" and "bahn" as the way the thumb should move...
thanks!
Copy link to clipboard
Copied
The latest question is a new topic. You should create a new thread.


-
- 1
- 2