Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




This Pattern To AS



Hello,

http://theremedy.be/scrap/starsAs.gif

I'm looking for some clues here to generate this kind of pattern using Actionscript.
Probably it's gotta be a "star" attached from the library then generated on stage randomly with colordifference, scaling and skewing.

*Note how the pattern should follow the specified path.

Is it possible? Is it hard to do?

Appreciate any help.



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 07-01-2004, 04:46 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

MVC Pattern
Is there any MVC Pattern samples available for Flash 8(AS2)?





























Edited: 02/11/2008 at 01:08:34 AM by kamsky

This Pattern To AS
Hello,

http://theremedy.be/scrap/starsAs.gif

I'm looking for some clues here to generate this kind of pattern using Actionscript.
Probably it's gotta be a "star" attached from the library then generated on stage randomly with colordifference, scaling and skewing.

*Note how the pattern should follow the specified path.

Is it possible? Is it hard to do?

Appreciate any help.

Pattern Code
ok,
i have a background pattern, this pattern is made up of dimond shapes, each dimond shape is a movie clip named
"mc-dimond". one of the dimonds is a button, named "b-dimond" now what i want to do is when this button is pressed, each dimond in the pattern needs to change tint in a wave.
now how would i have to do this, i dont want to give each dimond in the pattern an instance name, would an array work for this?, but how?
any help would be great!
thank you.

How To FIll With Pattern
How can I fill the background or a box with a pattern. I'd like to create a "TV scanline" background. For example, in Photoshop I can create a pattern then fill an area with that pattern. Thanks!

Pattern Recognition
Hi,
I am doing a project that involves scanning a black and white(and gray) image of a palm and running it through tests to find out where the lines are. Then comparing the lines to a database of possibilities to output a result closest to the database examples.
Like a fortune teller kind of thing.
Any one have any ideas how to read pixels to compare to stored information on pixels?

Thanks
Jay

Backround Pattern
can someone tell me how you get a pattern like this website in flash? I want to be able to do the drop shadow behind the Main MC and also have the pattern repeat to the edges of whatever size the browser is.

http://www.walltowallrecording.com

thanks in advance.

Non-regular Pattern
I would like to get an information if it is possible to do in
FlashMX 2004 that the sequence of multimedial CD would not have a shape of square or rectangle but a non-regular pattern without frame.

Thanks for your answer

Duplicate Pattern
I'm new to AS3 and coding in general, but can someone post a sample code that would duplicate a movieclip after every half second? And after each movieclip is duplicated, it's rotated and at a different x and y coordinate where it forms a sea shell type pattern? Thanks

Detecting A Pattern
Hi all I am creating a bingo game in my learning curve to learn actionscript.
I have 6 cards set up on the stage as seperate movie clips and 25 dynamic text boxes on each with random numbers in each. What I was hoping was if someone could direct me to a tutorial or how to do pattern detection on each card, any line, 4 corners, Letter I etc etc. So that the game can determine if bingo has been achieved. I have all my blotters and every thing working now and this is the last step but do not have a clue where to start. Any help will be greatly appreicated.

Pattern Generator
I have absolutely no idea what this is, but I enjoyed making it.

Design Pattern (MVC)
Hello everyone and Happy new year !

I am trying to apply the MVC pattern to a tile based game.
I have trouble to understand at which level I should apply the MVC logic.

For the moment what I've created, it's a class TileGame, this class is
used to initialize the application.

In this class I instantiate my MapModel and MapView class.
When my map is displayed, the MapView class dispatches an event.
This event triggered the instantiation of my HeroModel, HeroView and
my GameControl.
( I had an other problem at this point, I needed a reference to the
movie clip – hero – for the calculation in my model, the movie clip is
created in the HeroView….. the MVC does not allow us to pass
information from the view to the model, so I choose to use the
GameControl to pass this info to the HeroModel …. I hope it's a good
workaround).

For the moment my GameControl only affect the movement of the Hero but
at the end it would also affect the position of the map (tiles), it
means that the HeroModel would have to update the HeroView and the
MapView …it looks a bit dodgy to me ….

So I am a bit lost… Should my MVC be apply to an other level ….the
Model regrouping the MapModel and the HeroModel for example?

Thanks for your help.
Sibylhun

Help With A Design Pattern
Hi,

I'm hoping someone can help me, as I'm a newbie to ActionScript (and Flash as well, frankly). I need to be able to create a movie that dynamically reads the URLs of images from an XML file and then populates the images on the screen, with some animation connected to the images.

I'm using loadMovie() to load the images, and that works like a champ. But I can't figure out how to "pre-define" an animation when I'm loading the images at run-time. I tried onEnterFrame() to do some basic fade-in/fade-out animation using _alpha, and that worked, but it seems like I could only call onEnterFrame() one time.

Can I call onEnterFrame() in subsequent frames, one per layer? Or should I be using some other "on" method? I sure could use some design help, obviously.


Thanks in advance,

Stan McFarland

RegExp Pattern Help
Hi all,

I'm trying to construct a RegExp pattern to use, but having no luck.

I'm tryng to match all digits [0-9] in a string that are not a part of a tag sequence.

i.e.
"this is a number 45 and th3r3 are <b0ld> numb3rs </b0ld> everywh3re 99!"

The pattern should match all digits except the ones inside a tag.

Does anyone have a solution for this?

Thanks.

Pattern Matching?
Has anybody ever seen actionscript code to implement pattern matching (i.e., regular expression matching)?

i have a PERL script that i desperately need to port to actionscript (it's a copy of the PHP unserialize() function--very useful). the problem is that it relies on pattern matching.

any help would be much appreciated. here' some of the PERL code...

PHP Code:



  if ( $string =~ /^a:(d+):({(.*)})$/s )
  {
      print "Unserializing complex array ($string)"        if ($SERIALIZE_DBG);

    my $keys  = $1 * 2;          #keys in this serialized array
    my @chars = split(//, $2);    #turn the data into an array of chars
    undef $string;            #to save memory.

    return unserialize_sub( {}, $keys, @chars);
  } 

Pattern Fill
Hi all,

I want to fill a selected area with a graphic selected by a user from a thumbnail gallery of patterns. For this i am importing that selected pattern (.jpg) in a movieclip and duplicating that movie clip (say 15 times) to cover the whole area to be filled.
Now the problems is flash is loading the same image separately for 15 times, hence taking so much time to have 15 instances of the same small image.

Is there any way to have that image to be loaded only once and we can reuse it as many times as we want to?

Pattern In Flash.
Hi everyone! I have created a pattern(all by myself!) and now I want it to display as a background in my glorious website. In dreamweaver I just assign it as a picture, but I want to publish the site in flash, and when I edit the html, and insert my pattern as image, but then my pattern is just visible on the outside of my swf(my swf's background is all white..)

Please help me on this one, I am utterly stuck!! JR

Replicating A Pattern
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. Any idea??

Need Some Pattern Recognizing Help..
Hey all,

Again, I ran into trouble making tetris. Please take a look at the swf attached. None of the controls work yet - press the blue button to start/pause.

Take a look at it, and you'll see that some blocks go through others (which isn't supposed to happen). The blocks are managed into arrays of "yes" or "no". If the blocks below the current moving tetris block are "no", then that current tetris block will continue moving down. If "yes", it will become purple and initiate a new tetris block.

Now, please feel free to browse through the fla to see the structure. Test the movie in Flash and look at the check "yes" or "no" process with the traced commands.

Something is seriously wrong, and I don't know what. There seems to be a pattern of the blocks that go through others, but I can't find it out. (the swf may need to be run 2 or 3 times before a bug appears).

Thanks for your time!

Sound Pattern
Movie
http://www.ramieb.com/fla/flash_dump/soundpattern.swf

Fla
http://www.ramieb.com/fla/flash_dump/soundpattern.fla

Was messing about with a pesudo random pattern generator and the sound object to see what would happen, the sound pattern will change or morph over time......

interesting results, thought id share them

Ramie

Problem With Bg Pattern
Im trying to make a bg pattern fill the browser from flash. It does that now, but if you resize the browser to a larger size the pattern doesn't keep on appearing (understand?).
Plus, I've got this white frame around the edges of the browser... I want that to disappear

I don't think it should be so hard, but I didn't manage to figure it out. I've attached the files

Peace!

MVC Pattern And Delete
Hi,

I'm having a problem when trying to delete a small MVC app. I destroy all assets, remove the observers and delete the class objects, but it still seems to be stuck in memory.

Any help with dissolving a MVC relationship and assets from memory would be greatly appreciated.

Thanks!

Replicating A Pattern
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. Any idea??

Need Some Pattern Recognizing Help..
Hey all,

Again, I ran into trouble making tetris. Please take a look at the swf attached. None of the controls work yet - press the blue button to start/pause.

Take a look at it, and you'll see that some blocks go through others (which isn't supposed to happen). The blocks are managed into arrays of "yes" or "no". If the blocks below the current moving tetris block are "no", then that current tetris block will continue moving down. If "yes", it will become purple and initiate a new tetris block.

Now, please feel free to browse through the fla to see the structure. Test the movie in Flash and look at the check "yes" or "no" process with the traced commands.

Something is seriously wrong, and I don't know what. There seems to be a pattern of the blocks that go through others, but I can't find it out. (the swf may need to be run 2 or 3 times before a bug appears).

Thanks for your time!

Sound Pattern
Movie
http://www.ramieb.com/fla/flash_dump/soundpattern.swf

Fla
http://www.ramieb.com/fla/flash_dump/soundpattern.fla

Was messing about with a pesudo random pattern generator and the sound object to see what would happen, the sound pattern will change or morph over time......

interesting results, thought id share them

Ramie

Pattern Fills
Hello,

Is there a way to create a pattern fill in Flash?
for example, if I want to create a shape and fill it with a black and white checkers board..  
What's the way to do it ?

Thanks,

Y.

Fullscreen Pattern
hi!

i want my flash to be window filling no mather what res. No problem, but only when having a regular fill color as background clip. It stretches to the edge
But i want to use a digonal stripe pattern in my background. How do i do this?

btw, don't have to be diagonal lines, can also be a grid or something liek that. Just don't want to resize it, i want it to tile like it would in html.

thanks.

Pattern Editor
Im building a pattern editor in flash (kinda like fruity loops). The general idea is that you can load a sample and click on one of 16 buttons to place the sound in relation to time. The editor is time based, so the movie isnt dependant on framerate. This way i can let the usre determine the speed of playback. There is a problem however. Probably caused by the flashplayer the editor doesnt run as tight as the real thing (fruity). Im talking about a difference in milliseconds here but its obvious enough.

Is there anything I can do to solve this?

THNX
Jan

Randomize Pattern
I'd like aan action script to random a pattern with 2 movieclips. The movieclips are both square 20x20 pixels, but they have a different color. Let's say I want 15 squares (movieclips) on the x axes en 8 on the y axes.
Each time you load, the pattern will looks different, not in the form (15 squares x 8 squares) but in color impression.
I have to work with speciaal colors, is not possible voor what I need to randomize the value of r, g, b.

Thanks

worfoual

How May I Create A 5x5 Pattern With One Single Mc?
How may I create a 5x5 pattern with one single mc?

mc:

o

5x5 pattern:

o o o o o
o o o o o
o o o o o
o o o o o
o o o o o

Pattern Background Problem
HI all,
Im working on a website at the minute and have a pattern background at 800X600 pixels but when the browser is made bigger. Say 1024X768 I have a white border that fills the gap how can I solve this problem as simple as possible, without a pop up

Thanks

Background Pattern In Flash
hello, i'm working on my new site and i'd like to try to make it all in flash... but i have a problem... i want to make a background pattern so that the viewer doesnt have to download a giant image... but is it posible?!
also there must come more tiles when the user resizes the browser window because the site is full screen.. i was thinking about something with duplicateMovieClip() but ik can't figure out how to do it...

by the way could you also check out the menu bar...(link) when you click at one side of the bar it will go to an other side of the screen... does it work well and doesn't it take to much cpu?!

i hope that anyone can help me!

Putting Pattern Background In My SWF
Hi,
Im making a new web site (all in flash) and im trying to do something new (for me).
i want the site to have a background like this (see file included),
my question is -
should i just put it on the lower Layer in the SWF,
should i load it and then put it,
is there any other option?

any other suggestions are most welcome,
Avi.

Pattern Mangles On Import
im bringing in a shot from PS that has a dotted pattern of 1 pixel squares across it and when i export the flash movie, there is a glitch in the pattern. it joins two rows of dots when there is supposed to be a space there. any idea how to get around this type of thing. i have redone the pattern in photoshop and its not in the original.

Fill In Pattern Problem..
Hello everyone...

ok here...I just make a draggable bg pattern..which is work ok...my problem is how to fill in the "mc1" or "mc2" with this bg pattern...is it I have to duplicate it..?..when it being drop in "_droptarget"...my second problem is how to remove my previous drag pattern type if I drag a new pattern into the "_droptarget"....

this is my file u guys can take look at it...

http://www.geocities.com/mrkiey/drag.fla


Code:
stop();

for (j=0;j<11;j++){
this["p"+j].jvar = j;
//trace(this["p"+j].jvar);
this["p"+j].onPress = loadPaten;
this["p"+j].onRelease = this["p"+j].onReleaseOutside = dropMe;
}



function loadPaten(pttn){
this.thisDrag = new Object();
this.thisDrag = _root.attachMovie(this.jvar,this.jvar,400+this.jvar);
this.thisDrag._x= _root._xmouse;
this.thisDrag._y= _root._ymouse;
this.thisDrag._xscale=200;
this.thisDrag._yscale=200;
startDrag(this.thisDrag);
}

function dropMe(){
this.thisDrag._xscale=100;
this.thisDrag._yscale=100;
stopDrag();
trace(_droptarget);

}
tq again

[F8] Loading SWF In A Pattern And By Priority..
Hi all..

k.. What i have is a Main movie that has a list component which loads label names and data numbers from an xml file.. when i select an item from the list the name and data will show in a dynamic txt field.. next to that txtfield i have a button which loads a swf file with a countdown script into a container MC on the stage.. this swf gets the name and number values from the txt fields and starts to count down from the number it just got from the the txt field.. when it has finished counting.. it deletes itself..

What i want is the ability to press the button again and then load another instance of the swf into the same container.. but in a pattern and by priority.. ect. if MC 2 finishes its countdown it will delete itself.. and the other MC's will relocate by priority (from the one which has been loaded first to the one loaded last.. something like this below:

-- MC 1 -- -- MC 5 -- -- MC 9 --
-- MC 2 -- -- MC 6 --
-- MC 3 -- -- MC 7 --
-- MC 4 -- -- MC 8 --

and so on...

How do i do something like this..? and is it possible at all.? any ideas??
thx in advance

PS. sry for my bad spelling and unclear description.. i hope you understand what i mean...

Spiral Pattern With DuplicateMovieClips
I'm practicing working with rotation and patterns in flash, im working on createing a simple spiral pattern, using duplicateMovieClips. I was hoping to achieve clips starting at the center and getting progressively bigger.

At the moment i have the starting at the center and scale thing down but i cant seem to create a spiral pattern. The best i have achieved is a circle, can someone point me in the right direction.


setProperty('newclip' + i, _x, 200);
setProperty('newclip' + i, _y, 550);
setProperty('newclip' + i, _rotation, 360/30*i);

Is this approach overly simplistic for what im trying to achieve?

Design Pattern Advice
Ok, I know I'm not posting code, but I want some theoretical advice.

I want to build a modular listbox which will allow me to load different items in depending on the situation .Sometimes just text, sometimes a thumbnail with text, sometimes a tiny looping flv etc, but only one kind at a time.

It seems to make sense to me that the items loaded in can be mcs linked to their own separate classes which give them the rellevent functionality. But my problem is that if I make a manager class to attatch the items, how can I then control which item class I want to instantiate without hard-coding it into the class.

Should I write the manager class then create a different Subclass for each kind of item?

Thanks

Plot MCs In Circular Pattern
I want to be able to input a number into a variable, such as:


Code:
var totalClips:Number = 10
The code will then plot 10 MCs in a circular pattern. My code below sort of does this except I cannot just enter in how many clips I want. Can anyone steer me into the right direction? Thanks!

Here is my code on the timeline:

Code:
MovieClip.prototype.DrawCircle = function(x:Number, y:Number, r:Number) {
var c1 = r*(Math.SQRT2-1);
var c2 = r*Math.SQRT2/2;
this.moveTo(x+r, y);
this.curveTo(x+r, y+c1, x+c2, y+c2);
this.curveTo(x+c1, y+r, x, y+r);
this.curveTo(x-c1, y+r, x-c2, y+c2);
this.curveTo(x-r, y+c1, x-r, y);
this.curveTo(x-r, y-c1, x-c2, y-c2);
this.curveTo(x-c1, y-r, x, y-r);
this.curveTo(x+c1, y-r, x+c2, y-c2);
this.curveTo(x+r, y-c1, x+r, y);
};

var radius:Number = 120;
for (var i = 0; i<360; i++) {
if (i%36 == 0) {
var mc:MovieClip = this.createEmptyMovieClip("mc"+i, i);
mc.lineStyle(8, 0x000000, 100);
mc.DrawCircle(Stage.width/2, Stage.height/2, 25);
mc._x = radius*Math.cos(i*Math.PI/180);
mc._y = radius*Math.sin(i*Math.PI/180);
}
}

Advice On An AS3 Pattern Book
Hey,
I'm currently getting a little stuck with project that have like loads of classes all doing stuff standalone or connected to each other, so I really need to start getting into design patterns all the way. Theres a few books on amazon for AS3 design patterns.
Anyone got any suggestions ?

thx alot

Recommend A Design Pattern
Hi

I'm setting out to creating a logging application. I wanted to give proper oo and design patterns ago and I was hoping somebody might be able to reccommend one to based on my requirements?

Basically I'll have a logger that collects data and then sends it to a server.

The logging types or classes if you will are

log user info

log environment info

log interaction info

log content info

log session info

My initial inkling would be to go for a strategy pattern. Or would a design pattern even be necessary for this?

Whats your 2 cents ?

Once I get this done I'm going to post a case study/tutorial on it

MVC Pattern With Multiple Models
Every design pattern article on MVC which I have read doesn't take the concept very far into more complex programs. In particular, I'm talking about multiple models. I'm guessing someone out there has written such a thing, but I'll be damned if I can find it. So, here is a conundrum I faced and the solution I went for, and I'd like to know what people think in case what I've done is completely ridiculous.

So as far as I'm concerned, a clickable button is a view, right? Ok, so what if we have a tabbable bar, with a collection of buttons. Again, that's a view. So far, no surprises. The tabbed view contains many button views, and has a model which stores which button is selected. when a new button is selected, the tabbed view informs its child button views that all except the one just clicked should deselect themselves. Examples I've seen of this problem essentially pass the tabbable model to each button view to use as their model as well. But to me, this makes no sense at all. Buttons have their own, individual states to worry about - they need their own model!

So for example, each of my buttons has an id. This needs to be stored somewhere. Either I store it in the View class and break the MVC concept, or I create a model for each button and store it there (and plenty more besides!). If I use individual models for each button, the buttons no longer have access to the tabbable model any more, meaning the questions are:
1-How does the button inform the tabbable bar that it has been selected?
2-How do the buttons then get informed about which of them is now in a selected state and which isn't?

So regarding #1, I decided that of course all behaviour should go in the controller class. And so basically I created a controller class which takes two models; one for the view which it controls, and one special one to access the tabbable model. With that, when a button is selected the controller will take the id from the button model and send it to the tabbable model to say it's now selected.

Now as for #2, I could PUSH the information from the tabbable model as part of the update event, which the button views would hear and then act on accordingly. However, firstly I don't like the push method much (but that's another discussion), but more importantly remember the buttons have their own model, which includes things like which state the button is in. And so one way or another the state of the button model(s) have to change as a result of the tabbable model updating which button is selected. So to cater for this I added an array of all the button models to the tabbable model. When the tabbable model changes its selected button, it goes to each of the buttons models and tells them which state they need to be in. As a result of this, each button model dispatches an update event to their views. This seems logical to me: let's change the data first by going straight to the place where it is stored. The state change will invoke a view change, as normal.

So, what about that? I'd appreciate some guidance because like I said I've never seen an example which takes MVC to its logical conclusion, with many views and many models. Of course the easiest way would be to have one model, but this makes no sense to me in a complex application - why should I store the states of buttons in a model accessible to the whole program, when only the buttons themselves need to know that information? In the app which I'm writing at the moment, I've a main model which is a singleton and that will contain any info relevent to different, unrelated parts of the program. But views can also have their own model too, which can talk directly to each other if necessary.

Have I done something really, really bad? Advice appreciated, and if you've read all of it then thank you!

Scaling Background Pattern
I have made a repeating pattern using AS and a Movieclip vector called Wallpaper (see below).

I plan to have the swf fill the browser window, and this should work fine for that. When people click on a button, I want the view to "zoom in" by scaling to 200% and setting the x and y coordinates appropriately.

How can I do this with the repeating pattern, because the way I have made it is a series of movieclips. Is there a better way to make it so it is just one movieclip I can control the scale and position of?

Thanks


ActionScript Code:
tileWallpaper = function () {
tileWidth = 200;
tileHeight = 200;
x_max = Math.round(Stage.width/tileWidth);
y_max = Math.round(Stage.height/tileHeight);
for (x=0; x<=x_max; x++) {
for (y=0; y<=y_max; y++) {
bg = _root.attachMovie("Wallpaper", "bg"+x+y, this.getNextHighestDepth());
bg._x = tileWidth*x;
bg._y = tileHeight*y;
bg._width = tileWidth;
bg._height = tileHeight;
}
}
};
tileWallpaper();

Pixel Pattern Tile
is there an easy way how to make pattern tile in flash, similar to one in photoshop: Edit > Fill > Pattern or in Html?
i know how to make it with AS (for loops, duplicating MC), i just wonder if there is another way ...

thx

Find A Pattern In A String
I need to extract portions of text, separated by a identifier from a string in a Dymanic text box and display using another check box.

Is there any Function in Flash like Instring() function available in VB.

Can any one help me,
My advance thanks

Repating Background Pattern
How do I create a repeating pattern background that I made in Photoshop into Flash MX?

Gesture/Pattern Recognition
I'm going through this excellent article about gesture recognition: http://www.gamedev.net/reference/articles/article2039.asp#

It is working fairly well so far, but I'm only up to the part where it simplifies the drawn gesture.

Basically you create an array of the points you draw (in my case with a mouse drag).

Then to simplify the gesture you want to make some smaller number of evenly spaced points along that shape. So that you come out with, say 32 or some such number of points.

The algorithm presented basically starts adding up the distances between each point and when it gets to a distance greater than or equal to 1/32 of the total length it copies that point into the new spaced array.

This would work great if my original array had points that were spaced fairly consistently. But both with onMouseMove and onEnterFrame I get far to disparate spacing of my points. If I draw very slowly and carefully I get nice even spacing, but even a moderate mouse drag is not even.

Anybody with me so far?

I do know a brute force kind of solution and that would be to do some kind of average length for all the segments and then go through and split any overtly long lengths into to segments. It is just some trig and a splice.

I'm just wondering if anybody has any other recommendations?

You can see what it looks like with the attached code. Past it into a Frame action on frame 1. And have a small dot of one color set to export as dot and a small dot of another color set to export as oDot.








Attach Code

function Point(x:Number, y:Number) {
this.x = x;
this.y = y;
return this;
}
//
// Set Up the drawing area
//
var drawPad:MovieClip = this.createEmptyMovieClip("drawPad", 100);
drawPad.createEmptyMovieClip("bg", 100);
with (drawPad.bg) {
beginFill(0x00ff00, 25);
moveTo(0, 0);
lineTo(550, 0);
lineTo(550, 600);
lineTo(0, 600);
lineTo(0, 0);
endFill();
}
var drawArea:MovieClip = this.createEmptyMovieClip("drawArea", 101);
with (drawArea) {
beginFill(0x00ff00, 50);
moveTo(0, 0);
lineTo(550, 0);
lineTo(550, 600);
lineTo(0, 600);
lineTo(0, 0);
endFill();
}
drawPad.setMask(drawArea);
drawPad.onPress = function() {
this.clear();
thePoints = new Array();
p0 = new Point(_xmouse, _ymouse);
this.moveTo(p0.x, p0.y);
thePoints.push(p0);
this.lineStyle(2, 0xff0000, 100);
this.onMouseMove = function() {
var p = new Point(_xmouse, _ymouse);
thePoints.push(p);
this.lineTo(p.x, p.y);
};
};
drawPad.onRelease = drawPad.onReleaseOutside=function () {
delete this.onMouseMove;
// work on a copy of the array
normalizeGesture(thePoints);
myArray = spacePoints(thePoints);
testSpacing();
};
function normalizeGesture(points:Array):Array {
//work on a copy of the array
var xMin:Number = points[0].x;
var yMin:Number = points[0].y;
var xMax:Number = points[0].x;
var yMax:Number = points[0].y;
for (var i = 1; i<points.length; i++) {
var pt = points[i];
if (xMin>pt.x) {
xMin = pt.x;
}
if (yMin>pt.y) {
yMin = pt.y;
}
if (xMax<pt.x) {
xMax = pt.x;
}
if (yMax<pt.y) {
yMax = pt.y;
}
}
var gWidth:Number = xMax-xMin;
var gHeight:Number = yMax-yMin;
// empty or single point stroke! no gesture here
if (gWidth == 0 && gHeight == 0) {
return null;
}
var sFactor:Number = (gWidth>=gHeight) ? 1/gWidth : 1/gHeight;
//
// TEMP TESTING THING
//
SCALE = sFactor;
for (var i = 0; i<points.length; i++) {
var pt = points[i];
pt.x *= sFactor;
pt.y *= sFactor;
}
}
function spacePoints(points:Array):Array {
var pointsPerStroke:Number = 12;
var spacedPoints:Array = new Array();
//get length of original stroke
var gestureLength:Number = 0;
for (var i = 1; i<points.length; i++) {
var dx:Number = points[i].x-points[i-1].x;
var dy:Number = points[i].y-points[i-1].y;
gestureLength += Math.sqrt(dx*dx+dy*dy);
}
var newSegLen:Number = gestureLength/(pointsPerStroke-1);
//
//The first point goes back in
//
spacedPoints.push(points[0]);
//
//traverse along points in the original gesture
//calculate distance as you go. When the distance is far enough
//add a point to the new space gesture array.
var endOldDist:Number = 0;
var startOldDist:Number = 0;
var newDist:Number = 0;
var curSegLen:Number = 0;
for (var i = 1; i<points.length; i++) {
var excess:Number = endOldDist-newDist;
if (excess>=newSegLen) {
newDist += newSegLen;
var ratio:Number = (newDist-startOldDist)/curSegLen;
var tmpX:Number = (points[i].x-points[i-1].x)*ratio+points[i-1].x;
var tmpY:Number = (points[i].y-points[i-1].y)*ratio+points[i-1].y;
spacedPoints.push(new Point(tmpX, tmpY));
} else {
var dx:Number = points[i].x-points[i-1].x;
var dy:Number = points[i].y-points[i-1].y;
curSegLen = Math.sqrt(dx*dx+dy*dy);
startOldDist = endOldDist;
endOldDist += curSegLen;
}
}
trace("original: "+thePoints.length+", spaced: "+spacedPoints.length);
return spacedPoints;
}
//
//
function testSpacing() {
for (var i = 0; i<myArray.length; i++) {
drawPad.attachMovie("dot", "dot"+i, 5000+i, {_x:myArray[i].x/SCALE, _y:myArray[i].y/SCALE});
}
for (var i = 0; i<thePoints.length; i++) {
drawPad.attachMovie("oDot", "oDot"+i, 1000+i, {_x:thePoints[i].x/SCALE, _y:thePoints[i].y/SCALE});
}
}

Pixel Pattern Tile
is there an easy way how to make pattern tile in flash, similar to one in photoshop: Edit > Fill > Pattern or in Html?
i know how to make it with AS (for loops, duplicating MC), i just wonder if there is another way ...

thx

Drawing A Chalk Pattern In Swf?
i found a drawing component, but i want a texture, like chalk.

has anyone seen this? know how to do it? i assume it's done with a mask.

thanks

Create A Grid Pattern
Hello, I am working on this flash header for a website...

http://www.videolinktechnologies.com/movie.swf

I need some kind of decoration in the background instead of just having solid blue...

Anyone know how to make a "grid pattern" in the background?

I turned on the grid and traced the lines... but the lines keep snapping to each other and it takes forever... especially if you use small squares...

Any ideas? Or anyone know how to make a grid of squares easily?

thanks

Copyright © 2005-08 www.BigResource.com, All rights reserved