ActionScript 3.0 :: Squares In Random Midpoint Displacement Algorithm
Sep 3, 2011
I'm trying to make a plasma fractal (as a self-challenge, I made the sierpinski triangle, Koch snowflake, Mandelbrot set, Julia set, and dragon fractal. If you want the code, PM/reply.) Here's the code of frame 1:
I have a picture on the stage covered by 12 squares (sq1, sq2, sq3.......sq12) When the movie opens I want the squares to move down, but i want a random sequence ( 3, 9, 2, 12...........8). I already made de function for the movement:
I am making a game where red squares spawn on the right side of the screen. So far the red squares spawn all the way up and down the height of the stage. The problem is that I want the red squares to spawn only in areas randomly below a certain height of the stage This is the code so far enemy.x = 470 ; enemy.y = Math.random() * stage.stageHeight; This code makes the red squares spawn all the way up and down the height of the stage.
I have 2 points you can drag. A draw a line between them. I have a textbox that displays the distance between the 2 points. How can I have the textbox "attach" itself to the midpoint of the line and stay there as the points are dragged? A file is attached and you can see it here [URL].
PHP Code: var item:MovieClip; var dragOffsetX:int; var dragOffsetY:int; var itemOffsetXY:int; //add event listeners to all dots [Code] .....
I have 2 points you can drag. A draw a line between them. I have a textbox that displays the distance between the 2 points. How can I have the textbox "attach" itself to the midpoint of the line and stay there as the points are dragged?a file is attached and you can see it here [URL]
PHP Code:
var item:MovieClip; var dragOffsetX:int; var dragOffsetY:int; var itemOffsetXY:int;
I've tried in vein to understand displacement maps; I can find nothing on "The Internet" that teaches me what I need to learn. Now I'm looking to all you smart-types to solve my problem for me! All I want to is take an image (a rectangle) and make it look like it's going off into the distance (trapezoid-like), getting smaller from left to right. This doesn't even need to animate, I just need two states: straight-on and trapezoid-like -- think iTunes album art browser minus the bells & whistles. I know this can be accomplished with a displacement map, but I know not how to get 'er done.
The way my test works, I draw a path on a displacement map using the mouse, and this displacement is applied to the same image every frame (i.e., the displaced image of the last frame is displaced again). Colors are flowing along the path as they should, with one problem: the displaced pixels always turn transparent after a few seconds.At first I thought this had something to do with the DisplacementMapFilterMode, so I tried setting it to "COLOR" using an opaque bright blue, while the stage behind my warped image is a highlighter green. Nope, the FilterMode color is only used for pixels sampled off the image, while my interior pixels were turning completely transparent of their own accord. I tried removing the alpha channel from my distorted image, and then the pixels would just turn black instead of transparent.
So, now I'm stumped. I've viewed my displacement map to make sure it looks right, I've tried setting the displacement scale to low and high numbers, and I've checked the channel assignments, all to no avail. Here's my code, and I've attached the .fla as well, so you can see what's happening. If you run the file, just make your mouse is located in the center of the frame before it starts, or you'll end up dragging the blue fill color in from off the screen.
Code: // "spider" is the name of a named movie clip instance containing // an image on the stage, having the same dimensions as the stage
I have an mc that is displaced. Within this movie clip is a text box that moves about but it is being displaced along with the rest of the mc. Is there anyway to find a position inside the displaced mc and translate that to root coordinates.
I am trying create a displacement effect using this code, but i am getting these error, not able to solve it!import flash.display.BitmapData;
var damper = new flash.display.BitmapData(128, 128, false, 128); var result = new flash.display.BitmapData(128, 128, false, 128); var result2 = new flash.display.BitmapData(256, 256, false, 128);
I'm trying to use the displacement filter with a jpeg image instead of a gradient map. My images are: 1) Background: men2.jpg 2) Map image: men2BN.jpg (same as above, but grayscale and blurred) 3) The image to be displaced: star5_mc
I'm using this tutorial to create buttons with displacement mapping for my simple game menu. These buttons need to be clickable; i.e. once you click on them you move to a different frame. Everything works fine on the first frame, but when I click to the next frame the displacement map disappears and will not apply to the buttons on that frame. Plus, when I click my "back" button to return to Frame 1, the displacement effect has disappeared entirely.
This is the code which is in the base "Game" class, which links to the main Flash file.
It calls the JitteryButton class, another external class, which I don't think is the problem, but I can post if if necessary. It's very similar to the one in the tutorial. Also, I need to add different buttons on other frames of the menu, but if I call them in this external class, it doesn't recognise them.
can anyone spot why this might stop working like it does? I was thinking about instead of using "Game" as an external Actionscript file, I could actually write it into Flash as Actionscript on a layer - would this work?
I'm using a DisplacementMapFilter to created a globe-like effect on a flat map. My problem is, I also want to sync some labels to this map. I have the x/y coordinates for their locations on the flat map, but I need to map them to the now-displaced image.
I would like to be able to do this using the BitmapData that contains the displacement map, so that changing the Bitmap changes both the displacement filter and the label locations. Also, the labels will not be static, and accuracy is fairly important.
i got this script from this tutorial. I tried to convert it from AS2 to AS3, but it seems like the displacement filter is only applied once for some reason. After that, the bitmap isn't updated.[code]
I am trying to make displacement map for perspective correction, but so far my math goes wrong. Here's what I've got; as you see, some lines are not preserved.
I had a quick question about displacement... I just have a circle that changes shape and size and I wondered if there was a way to apply some kind of displacement filter to it, so that ANYTHING under this circle movieclip is distorted by the displacement. (think of a magnifying glass).
i am trying to make my text appear wavy using displacement maps. i've attached the file. Please check it out and tell me how to do the following three things with it:
i need to ensure that the text doesnt get cut at the top when it goes out of bounds.i need to create a gradient with more variations. that is, right now its going from 0x000080 to 0x0000FF to 0x000080. so i need to make it go like: 0x000080 - 0x0000FF - 0x000080 - 0x0000FF - 0x000080.i need to be able to vary the size of the gradient box so that it perfectly fits the movieclip that i apply it tohow do i do it? could anyone please make those changes and attach the file back? or just tell me how to do it?
I have a multilingual project (currently 13 languages), which uses many different font variations of "Helvetica Neue", mostly bold, condensed and regular cuts from the LinoType Pro font set ( which includes western european characters) and the same for cyrillic. We will probably add chinese and japanese variations in the future. I have set up the project to use different CSS stylesheets and separately load the fonts for each version, depending on which language the user selects, so I can have different line heights, kerning and/or font sizes to make everything keep the original look, even if the fonts look nothing alike.
All of this works well, except for one problem: For some reason, all cyrillic letters seem to be displaced. They appear 2-3 pixels below the correct base line, and actually protrude across the textfield's bottom border, even when the field is set to autosize. When I use textfield.getCharBoundaries(), all values seem to be correct, even though they obviously aren't rendered correctly.To make everything look neat, I could of course manually move all problematic textfields up or down according to language and font size, but I was wondering if there was some way to prevent or at least detect this kind of displacement in order to automatically handle the adjustments - the Flash Player should have some sort of information on how things are rendered, shouldn't i
I found a tutorial on how to make a cool water effect in as3 using bitmap data and a displacement filter. It works great but it is very heavy on the computer.
here is my code
Code: var bmd:BitmapData = new BitmapData(700, 398); var dmf:DisplacementMapFilter = new DisplacementMapFilter(bmd, new Point(0,0), 1, 2, 10, 30); var p1:Point = new Point(0, 0); var p2:Point = new Point(0, 0);
how to perform a search in XML, so I use the above method, kinda hard code I know...for example, I try to search " keyIn:String = "BR1014"; " means I wanna search BR1014 in 4 XML files, so I load the XML info into an array, and using for loop to loop the XML array (in this case TitleArray1[i], TitleArray2[i]...) and compare it with keyIn (which store the value BR1014), some how the value is located in TitleArray4[i] which have the length of 12 (trace(TitleArray4[i].length) = 12)
so everytime I run it, I will overwrite abc 12 times... and out put 12 time the abc value, in this case BR1014 was located in TitleArray4[3], so the 4th output of "abc" is BR1014 but others is all 999...
CREATE TABLE RecipeDB ( RecipeID INT PRIMARY KEY AUTO_INCREMENT, Name VARCHAR,[code]........
I also have an actionscript, in which I have ingArr:Array of ingredient strings.Now, I would like to realize the following queries here:
1) Select (all fields) one recipe which has the most of ingredients from the array. If more than one record have the same amount of matches, then divide the number of matches by total number of ingredients in recipe and return the one with the highest ratio. If there are no matches return nothing.
2) As above, but return 10 recipes with the most matches and do not perform check for equal number of matches. Sort the results by the number of matches.
I'm trying to do a transition that you've probably seen many times. Transitioning one image to another using a grid of squares where each square fades at a slightly different time.I've made a complex movie clip made up of several other movie clips with all the squares fading at the rate I'm looking at. When I just play the color squares it works fine, but the minute I turn that master movie clip into a mask for the image I loose the transition/fade completely--just an on off thing.
I have a problem with arranging some thumbs in column when I resize the stage. The problem is that it is arranging the last square in line half outside the stage and you can see only a half.
How do you go about drawing only the outline of squares using drawTriangle. Currently I am using lineStyle to draw my lines but obviously that outlines each triangle. I know i can just draw Squares out using drawRect with no fill but that seems like a waste.
Now I could do with some hints as to how this should be done Hopefully someone will help me out here.
Ok, basically I have a map (a jpg/gif file), which should be divided into squares (like a chessboard). Each square has a coordinate (X, Y) and other pictures should be shown on top of a map square - like a small house or something (also a jpg/gif file).
It should also be possible to hide some (most) of the squares from view - like with a black square on top or whatever. Perhaps Flash should also make some lines between each square to divide them.
Furthermore only a part of the map should be shown through a window (using a mask, I guess) as the map could be large and buttons at the edge could be used to scroll the map.
I would like to link the red squares to the blue square in 3D with CS4 only (please no papervision or sandy...)I'm very closed to the solution but I still have a wrong z (visible when you move the mouse to a corner for instance)
I learned about the date class yasterday and made a lil app that will tell me when the next recess at school will be. It worked great when I ran it at home, but now when I try to run it at school all the letters in the textfields displays as squares, the numbers still work tho. The only difference I can think of is that at home i use CS5 and at school is use CS4, the font is embedded in the fla.
I want to stimulate sea wave,but I have no idea about it. Is there an example code for it? I know as3 can make many good graphics and text effect, so I want to learn it eagerly,but I don't know which book should I read. Anyone could introduce a good book for me about as3 algorithm? More example code are better in the book.