AS3 move image as the mouse moves - actionscript-3

This probably will be very easy for some, but I am stuck on this. I have a map in a movieclip(mc_map) on stage and a small square which acts as a mask to the really bigger size of the same map. What I am want to do is that when I move the mouse on the mc_map(eg: say my cursor is on New York), the small sqaure window will unhide the same area, or will move that bigger image such that the same area is shown under the square mask. I also want to add another cursor(or crosshair) to the stage which is live only in the area of the square and replicates the position of mouse on map. Any help on this will be great thanks.

There are a lot of tutorials on this type of "magnify" effect. See if this one helps: http://www.flashuser.net/flash-actionscript-as3/create-a-magnifying-glass-in-actionscript-3-0.html

Related

Actionscript 3, constrain "character" within bounds

So basically I have this point and clik game, the character moves where you click but I'd like to constrain its movements within a certain area, this could be easy if this area was a rectangle but to give a more tridimensional look to the backgroung i need this area to be more complex
see this image (blue= background, pink= bounding area (the floor)) :
any idea?

Flash Slider Component

I just started learning flash on my own and I decided to make a cool little image gallery (somewhat of a family album). When I test the movie the first image loads in the center. Below the image are little thumbnail sized buttons which can be clicked and the image will load in the center. Since I am going to be incorporating a lot of photos I would like to use a Slider (left to right) so I can scroll back and forth through the photos and find the one I want to click on to display.
Since I have no experience with Action-script I was hoping someone could get me started with that process and maybe explain how the Slider works.
Thanks!
You can create easily your own slider, and learn something in process :) .
In slider - moving of knob, must correspond to moving of gallery where size of gallery is translated to size of slider. That is basically it. So you will need some mathematical formulas and basic elements:
gallery.width/slider.width - to determine if gallery is wider than
slider (so you would want to proceed with sliding), you can also use this proportion to determine a size of the knob. So if gallery would be smaller than slider - then you may not render slider, or make knob the size of slider, so it would be not movable. Or make knob proportional size to size of overflow of gallery - just experiment with everything I'm writing here.
You would need to use also those elements:
gallery (Display Object),
mask/container for gallery (the visible part of gallery),
slider,
knob.
Rectangle object
Gallery would be just a Display Object that contains all images as children.
Mask/container would be display object that would provide boundaries of area where part of gallery would be visible
Slider - any Sprite
Knob - any Sprite
Rectangle - would be of course Rectangle object, with width of slider.width - knob.width, and height of 0, so it would allow to drag knob along a slider without going outside of it, by using function:
knob.startDrag(false, rect); // Use it at MouseEvent.MOUSE_DOWN of knob
knob.stopDrag() // Use it at MouseEvent.MOUSE_OUT of knob
You can create rectangle with this code:
new Rectangle(0, knob.x, slider.width - knob.width, 0);
And you would need to translate moving of knob to moving of gallery which would be something like this:
// When moving knob you can use this formula:
gallery.x = knob.y / (slider.width - knob.width) * (gallery.width - mask.width); // Use it at MouseEvent.MOUSE_MOVE of knob
I think that should be it, I wrote it from the top of my head based on some library I wrote some time ago, so please tell me if you will encounter any problems, but I think that are all basics you need.
Have a look at the ScrollPane
Add your thumbnails in a container and use that as the Scrollpane's source and scrolling will be taken care of

Setting movieclip origin with AS3

I have a spotlight that moves on a stage.
Now I rotate the spotlight but its not rotating on the correct point/origin.
I am trying to do something like
myOject.setOrigin = {x , y};
//and then rotate it about x,y.
I have manually set the white circle in the correct place and when I rotate the
object with the mouse on the screen it works.
Can somebody help me?
Make sure the registration point is in the middle of your symbol. It's not the white circle that appears when you use the Free Transform Tool:
But the crosshair that appears when you edit your movie clip:
You can easily center the object by selecting everything, then opening the Align panel and aligning its horizontal and vertical axes to the center using the two "center" icons under the Align section. If your MC has multiple items per layer, group each layer before aligning, then ungroup after aligning:
The white circle is not what will be used as the origin, it's the little cross. Adjust your clip to have that in the center (you'll have to move all of it's contents). Another option, if moving is not possible, is to wrap your clip in another clip and move it within that.
Select symbol and click CTRL+E - Then move it to positioning cross.

Swing rotate border

I'm working on a swing program to display several pictures. And one can rotate the picture (implemented each as a JComponent).
Problem is, when a picture gets rotated, the border of the JComponent doesn't change so that the picture gets clipped.
Is there any way to also rotate the border so that the picture can be fully drawn?
(I know one can calculate the new size of the border, but it leaves empty space on the edge. When a rotated picture overlaps with another and one want to move the one underneath, one cannot do that because the event will be passed to the picture above, onto the transparent edge. So it is more ideal if one can just rotate the border).
Execute another pack() on your top-level JFrame after rotating.

HTML 5: how to make stackable images?

Is it possible to load up 10 images (same dimension), stack them on top of one another only showing 1 image at a time and then by holding down the left mouse button and dragging the mouse up you scroll in one direction and moving the mouse down scrolls in the opposite direction?'
if so how can this be done? canvas element would be the begining, no?
This sounds like a job for... Javascript!
This solution isn't perfect, but it's an example of mouse scrolling images: https://github.com/kamranayub/Just-Another-Carousel