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




Snap To X,Y



Hey -
i know its easy and that its out there - just can't seem to find it.
i need my movie clip to snap to the xy coordinates to keep the text sharp.
applied to this code:


Code:
onClipEvent (load) {
_x = 1280;
_y = 0;
speed = 5;
}
onClipEvent (mouseMove) {
endX = _root._xmouse;
endY = _root._ymouse;
}
onClipEvent (enterFrame) {
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
thanks!



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 11-17-2005, 02:52 PM


View Complete Forum Thread with Replies

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

Snap To
Can anyone help me with a snap to. I am trying to get a movie to snap to a postion on the screen when it is dragged to within a certain distance from the position. what I am currently doing is

getting the x and y position of the positon
getting the x and y position of the movie

subtracting the smallest x position from the largest
subtracting the smallest y position from the largest

if the both positions are less than a specified distance then setting the x and y properties of the movie to that of the snap position.

Here is the code that I have written for the x position am I on the right track:

//snaplooper movie contains 2 loopng frames

//frame 1
set (c, getProperty(_root.a, _x));
set (d, getProperty(_root.b, _x));

//a is the movie, b is the position

//frame 2

if (c>d) {
f = (c-d);
} else {
f =(d-c);
}
if (f < 30) {
setProperty ("_root.a", _x, d);
}
gotoAndPlay (1);


Thanks

Snap
Hey, I've sort of just jumped into the deep end on a project. Hoping I'll learn to swim.

It's a self-help quiz with 2 draggable MC's sorta like marbles (one called "more" and one called "less"), and 4 holes to put the marbles in, depending on their answer. At this point, I'm just trying to get the marbles to snap back to original position if the user doesn't put it in a hole.

THE PART THAT WORKS OK:
I was able to make the marble MC's (each containing a smaller MC called "snap") snap to the holes using hittests-- I placed this script on each hole (with different y positions depending on which hole)

onClipEvent (enterFrame) {
if (this.hitTest(_root.less.snap)) {
setProperty ("_root.less", _x, "84");
setProperty ("_root.less", _y, "102");
} else if (this.hitTest(_root.more.snap)) {
setProperty ("_root.more", _x, "84");
setProperty ("_root.more", _y, "102");
play ();
}
}
That seems to work allright. The draggable MC's start acting weird when they snap to position, though. Like hard to pick back up, or you can pick it up, but the mouse is no longer actually touching marble. I tried adding
Start Drag ("drag", lockcenter), but it gave me an error saying it had to be true or false. I'm new to this, I'm a moron, I know. The error is probably obvious to you masters, but I'm clueless why it's not working.

THE PART I CAN'T GET TO WORK AT ALL: the snap back to original position.

I've tried several approaches, some based on other discussions I found by searching this board, but none seemed to work. So I decided to try writing my own, but I think there's some sort of syntax error, or logic flaw somewhere.

I added a very narrow box-like MC over the row of holes, and called it "testerbar". Then on draggable, I tried:

onClipEvent (mouseDown) {
startDrag ("");
}
onClipEvent (mouseUp) {
stopDrag ();
if (this._droptarget != _root.testerbar) {
setProperty ("this", _x, "366.8");
setProperty ("this", _y, "367.9");
}
}

Is this just WAY off track? Am I using the != in the wrong way?

***DEMO: The client wanted a prototype sorta demo to see how it could work (he didn't think flash could do this sorta thing! hahahaha), and I put one together assuming (HOPING) I'd be able to figure it out if I got the job. I got the job, so now I need to figure it out. Bad way to do it, I know, but you can view the demo at: http://www.apexdesign.tv/ali/


THANK YOU FOR ANY ADVICE


========================================Pointless Rambling=
ActionScript is exciting as hell! but I feel like I'm learning Japanese, and all I want to say is "Which way to the bathroom", but probably coming out as "How spoon is my fire dog?"

I've spent oodles of dough on AS books, but they must all be too basic. One doesn't even mention the _droptarget property, and the other just gives a tooltip size description of what it is. ARGH.

I'm sure I'll have more questions later, but right now I'd just like to figure out why I can't get this snap to work. But also, in the meantime, is there any other source for ActionScripting KNOW-HOW besides books and FlashKit tutes? Seems like I keep shelling out dough on books, just to find out it doesn't tell me what I want to know.
[Edited by Al Flashino on 08-11-2001 at 09:25 AM]

Help/Does Anybody Know How To Snap?
Having great difficulty trying to figure this one out. I have a series of cubes and a series of squares. The cubes are dragable and when any cube is dragged onto any of the squares I want it to snap into place on the square. If anyone can help me out with this one I'd appreciate it.

Snap
Okay, I want to snap my all of my duplicate clips of "circle" when dragged over the target. The targets are named target1, target2 and so on, and it goes on till target 15.

When snapped, I would like them to still be draggable. Can someone help me out with this task? I have posted some of the coding that I have, I just need to add the snap to target command. Any help would be greatly appreciated.



Code:
for (i=1; i<=totNum; i++) {
circle.duplicateMovieClip("circle"+i, i);
ref = this["circle"+i];
ref._x = 45;
ref._y = 130;
funName = "fun"+ref;
ref.onPress = function() {
startDrag(this, false, 0, 0, Stage.width, Stage.height);
};
ref.onRelease = function() {
stopDrag();
};
}

[Edited by wiReZ on 06-13-2002 at 05:51 PM]

Snap To Help
Hello,

My flashMX 2004 is giving me a headache. i turned on snap to, turned on the magnet, hell i even put it to tolerant! but it wont snap to lines! it only snaps to straight lines(as in up,down,left or right). This is only when i draw with straight lines. When i normally move a line side with my mouse (when its already drawn) it does snap to the other lines.

A little help here please.

Snap To
how can I make only selected draggable movie clips "snap to" a non-draggable movie clip? Can anyone help me out? thx.

Snap
Any niffy suggestion on creating a snap game?

I want the press button to detect the last button pressed and if the shapes match, make them do something...obviously.

I think I'm going at it the wrong way.

I need to stick a "triange" id into the button/mc then if compares that and then if there is a match works then... right?


Code:
if(zum>1 && zum<=3){

ab[cb] = i
cb=cb+
}
if(zum>3 &&zum<5){
ac[cc] = i
cc=cc+
}
if(zum>5 &&zum<7){
ad[cd] = i
cd=cd+
}
if(zum>7 &&zum<9){
ae[ce] = i
ce=ce+
}
if(zum>9 &&zum<11){
af[cf] = i
cf=cf+
}
if(zum>11 &&zum<13){
ag[cg] = i
cg=cg+
}
if(zum>13 &&zum<15){
ah[ch] = i
ch=ch+
}
if(zum>15 &&zum<17){
ai[ci] = i
ci=ci+
}
if(zum>17 &&zum<19){
aj[cj] = i
cj=cj+
}
if(zum>19 &&zum<21){
ak[ck] = i
ck=ck+
}
if(zum>21 &&zum<23){
al[cl] = i
cl=cl+
}

Drag, Snap
Can someone help me? I need to know how to make this draggable words snap
parallel to the word to which it
is being matched, regardless of whether it is correct or not?.
http://www.eclipselatino.com/pearsonDrag&drop.html

Drag And SNAP
What i'm trying to do here is a drag and SNAP, whereby the obj i'm dragging will automatically "snap" to the droptarget area when i release my dragged obj near it.
There are plenty of plain drag & drop tutorials, but i juz can't find the one that i want. Can someone help?

Snap Modifier - What And Where Is It ?
I recently wen"t through the Flash5 lessons.
However I newer wen"t through lesson (08 - Animation) bicos I just can"t find this "snap modifier" !?!
I found button "the snap to object" but, when I moved bee to the end of the line, no black ring apers at the center of bee.
Please, if somebody has manage to pass this lesson whit actually animating movement of the bee, please share you knowledge whit me I"m so thamm curious :/

Drag - Snap
Does any1 saw AS with draggin' MovieClip to the area.
When it's near - MC must SNAP.

I have somethin like that... but it contains bUgs!

Clear?

Snap? And Symbols I Think.
Hello and thank you in advanced for the help.

What I've been trying to figure out how to do is take 2 lines. Both of them I've converted into Symbols (graphic file). I want one bar to be sitting on its own layer running top to bottom, and the other line to start in the middle of the vertical line and grow out from it.

I've tried making motion tweeds where I set change the horozonal transform % and try to grow it, but what happens is instead of just one end growing both ends grow at an equal rate and it looks more like a cross. I've seen some demos that do what I'm trying to do I just can not figure out how =(

Any advice would be helpful

To Snap To Pixel?
Is it possible to snap a minifont to pixel in flash 5. Of does anyone know how I can work arounf the blur problem ?. Im sick and tired of moving my font one pixel at a time to see if it is in focus and not blurred.. please help!

-ace

Paypal Snap In Help
Hi ppl,

I am encountering some problems when using the WA paypal snap in for my website. The tutorial shows that the final price is determine by the size of the shirt and the colour.

As for my item, the price and size is constant throughout and I only need the buyer to set the colour of the T shirt. Therefore I don't need a setprice.. Only need to set colour...

How do I do that? When the buyer click on the Add cart button, the chosen colour will show on the final order.

Please see the attached script below and help me. Thanks..


// Set the initial color and price for when the movie loads

setPrice();

function setPrice() {

// Get the price (based on size list)

var newPrice = sizeList.getValue();

// Declare color object for manipulating colors in the rubberBG Symbol

myColor = new Color(rubberbg);

// Set the background color of the color object to the value from the color list

myColor.setRGB("0x"+colorList.getValue());

// Set the amount of the Add to cart Snap-in

ATC.setAmount(newPrice);

// Set the item name for the Add to cart Snap-in to include the size and color

ATC.setItemName(sizeList.getSelectedItem().label+" "+colorList.getSelectedItem().label+" Brake Pedal Rubber");

// Sets the item number to a unique number based on item (concatinated index of both lists)

ATC.setItemNumber(String(sizeList.getSelectedIndex ())+String(colorList.getSelectedIndex()));

// Set visible price on page

thePrice = "$"+sizeList.getValue();

}

Snap To Mc On Drop
I need to make the key movie click snap onto the lock movie when it is dropped on to it. Can someone tell me what I'm doing wrong.
I have the following code:

on (press) {
startDrag(this, true);
}
on (release)
{
xlock = getProperty(_root.unlock_sequence.lock, _x);
ylock = getProperty(_root.unlock_sequence.lock, _y);

stopDrag();

if (eval(this._droptarget) == _root.unlock_sequence.lock) {

setProperty(_root.unlock_sequence.key, _x, "xlock");
setProperty(_root.unlock_sequence.key, _y, "ylock");

_root.unlock_sequence.lock.gotoAndStop(2);
}
}

Thank you for your time

Snap To Point?
Help!

I'm working in a clip in MX that has a scrollable series of 5 graphic instances (when you move the mouse left or right, the clip "scrolls" in that direction)..... and I want to code the instance to snap to one of 5 coordinates (identified as points between each graphic instance within the top-level strip of graphics)- whichever point is nearest.

How can I do this?

*looks hopeful for some guidance*

Cheers,

Snap MC To Path
hi,

i use a mc as a custom cursor, now i want to snap this cursor to a path if the cursorMC is close to the path.

The path is a randomly free path, generatetd with the drawing API.

If someone have an idea how to resolve this problem, please tell.

thx rocknroad

Scollbar Snap
Hi, does any body know how I can create a scrollbar that snaps to specific points? Thanks.

Snap One Object To Another
I am trying to snap one object to another via an (onload)anything anyone can tell me to get this working? I don't want just snap to an area I want a graphic to snap to a hotspot that will change possition on a screen.

Pixel Snap
I'm getting really really fed up with pixel snap. I have it turned on, but I still get text on fractions of pixels. I'll correct the text, but if I move the movie it's a part of, I end up with fractions again. I must be missing something. How on earth can I limit everything to whole pixel values?

Thanks
Mark

Snap-on Effect
On my drag and drop game how would i go about making an item "snap" into place when its in the general area of where its supposed to go?

Snap To Not Working.....
I am trying to use snap to objects in Flash mx v6.0
I am using a circle to trace a word and I snap it to the begining and then to the end and then tween but when I try it all it does is go from start to end at an angle staraight across the screen from left to right. What am I doing wrong here? Help please.

Thanks

Snap Angel
Hi All it would be kind if some body can tell me where to change the rotation angle when we rotate an object by pressing shift key (default value is 45 degrees)

[F8]Snap Movieclips Together
If there are more than 2 moviclips on the scene, what script should be used to snap them together edge by edge or snap to grids which are invisible?

Snap Scroller Help
I found this exciting little toy on Flash Kit (http://www.flashkit.com/movies/Scrip...1148/index.php) and am having trouble modifying it.

I've got it part of the way to where I want it right now. I've got my own background, selector, etc. created for it and it's running as it should. However, I want it to do a little bit more.

When the icon is over the dot for "Option One," I'd like my icon to change and become a link. For instance, over the first dot it would morph into a house-icon and become a link to my home page; over the second dot the icon would morph into a question mark and become a link to an "about me" page.

Now, the animation of morphing images is easy and I can simply take care of that when I need to. The hard part is getting the rest to happen.

How do I go about making the image change when it's at a certain point? And how do I make it a link? I need the scroller to still be active, so that even if it is acting as the "Home" icon, you can move it to another spot on the scroller.

I can't seem to figure this out, and I figured I'd post here to see if anyone could enlighten me.

Here is my site with the currently-working Flash: http://www.phenixdesigns.net

And here is the FLA file: http://www.phenixdesigns.net/scrolltop.fla

Snap Scroller Help
I'm using Flash MX.

I found this exciting little toy on Flash Kit (http://www.flashkit.com/movies/Scrip...1148/index.php) and am having trouble modifying it.

I've got it part of the way to where I want it right now. I've got my own background, selector, etc. created for it and it's running as it should. However, I want it to do a little bit more.

When the icon is over the dot for "Option One," I'd like my icon to change and become a link. For instance, over the first dot it would morph into a house-icon and become a link to my home page; over the second dot the icon would morph into a question mark and become a link to an "about me" page.

Now, the animation of morphing images is easy and I can simply take care of that when I need to. The hard part is getting the rest to happen.

How do I go about making the image change when it's at a certain point? And how do I make it a link? I need the scroller to still be active, so that even if it is acting as the "Home" icon, you can move it to another spot on the scroller.

I can't seem to figure this out, and I figured I'd post here to see if anyone could enlighten me.

Here is my site with the currently-working Flash: http://www.phenixdesigns.net

And here is the FLA file: http://www.phenixdesigns.net/scrolltop.fla

[F8] Snap To A Point (Oh Please Help)
I'm so close to finishing a game. I just need to know how to make more than one object snap to a certain point when the user person releases it. droptarget doesn't work sooooo any suggestions??

[F8] Snap To Grid
Hi Everyone

I've got at chessboard-like grid, on wich I drag several duplicated MC's. This works fine, but I would like to place thes MC in the midle of the nearest field in my grid automatically as I stop drag the MC, and not across two fields. A 'snap-to-grid'-like function. Preferably without the use of 'invisible buttons and the likes.

Does anyone have an idea to how i can attack this, since I am quite clueless. Perhaps a sctipt, since I am running out of time ...

Hope you can help. Thanks a lot.

[F8] Snap To Grid...need Some Help
Hi,

I'm trying to build a grid (using tile MC's) which will allow pieces to be placed in it. The pieces will then be centered (when dropped onto some spaces). When the object which you want to place somewhere is dragged over the grid pieces they kinda light up, to show the user which ones would be occupied. I need some help because I'm not sure how to approach this, seeing as I don't now a lot of AS. My approach would be:

1. Create a tile class, which has a boolean data member that stores whether or not a tile is occupied.

2. Initialize two arrays. One stores all the y-coordinates for the tiles which are created, the other one storing all the x-coordinates. Maybe I'll use two two-dimensional arrays (rows and columns).

example: Xarray[0][3] would be 1st row, 4th tile....it's x-coordinate.

3. Have a loop creating all the tile objects from the tile class. 20 x 15 tiles, 300. Every time an object is created, I would pass the tile's x and y coordinate from my arrays to the class' constructor. I would also pass the for loops i variable to the constructor so I can always create a different instance name for every newly placed MC, which would also happen in the constructor.
The coordinate values passed to the constructor would be used to create an MC at that location every time an object from that class is created.

So this is my idea to create all the tiles. Not sure if this will work in AS. Any input is appreciated.

I need a working way of determining which tiles are being "hit/touched" by whatever you are trying to place on them. I don't want to right tons of if statements, any ideas how this could be pulled off?

Thanks for reading,
Chris

How Do I Drag An MC And Have It Snap To Other MCs
Hi, posting again hopefully with more luck this time.

I've set up a grid of buttons that light up as you pass over them and I want to be able to drop a building on them as though they are a grid.
This is the script I'm using:

_root.mwindow.grid1.house2.onPress=function() {
this.startDrag();
}
_root.mwindow.grid1.house2.onRelease=function() {
this.stopDrag();
this._x=eval(this._droptarget)._x;
this._y=eval(this._droptarget)._y;
}

It works but it's inconsistent since the Object I want to drop wont always drop onto one of the buttons. How can I make it fall onto a button within a certain distance?

SNAP/Pairs
Hello All,

Im creating a game of snap/match the pairs for children.
There will be 5 pair, where they are positioned will never change, but....
how do i reveal two at a time?
how do i make the pairs recognise that they are the same? and keep them visible?
how do a make two mis-matches 'un-reveal' themselves

Any ideas?

Function (snap)...?
Hi,
I'm a beginner at actionscripting, and I've got two minor problems...

I'm trying to create a draggable movieclip which will snap into position inside a rectangular area("spprediction") once it is dragged near it.
All I can do though, is this:

Code:
on (release) {
stopDrag ();
if (this._droptarget == "/spprediction") {
setProperty (this, _visible, true);
} else {
setProperty (this, _x, 840);
setProperty (this, _y, 565.7);{
What statement should I give to make it snap into place?

Another problem I have is, instead of having the movieclip snap back to the set position as above, I want to keep it with the pointer. But at the same time I also want it to repel the other rectangular areas which are not "spprediction". How can I do this?

I would appreciate your help.
Thanks,

Snap To Object
i just started using flash mx 2004, and i discovered my first problem... it's about the snapping. i want to draw a nice straight line and add another line to the end of the first line. in flash mx the lines just snapped into the right position, but in flash mx 2004 the wont. i've tried all snapping settings but i just wont work...

can somebody help me?

Drag With Snap
I'm making a slider - the scrub button can be smoothly dragged anywhere along a bar marked with increments, but once the button is released, I want it to snap to the nearest increment.
Would I have an array variable containing the positions of the increments, and then examine that to see which is the nearest position, or is there a better way?

Snap Align
is it possibe to change the colour of the snap align guides that appear?

Snap And Ease
help ... i'm making some draggable mc's that need to put at certain spot and then it not smooth enough and didnt snap with the so-called answer spot.. can soneone help me? i'll show u my swf..thanks in advance

Im About To SNAP Stop After 10
Please could someone help me with the attached. I would like to display the random numbers for each card a set nunber on times before game ends. (i.e. 10 sets). Have been struggling with this all day (phew!! the sun is shinning outsite and it is driving me crazy)

How To Snap Align
hi

i am using flash 8. i have a logo on my flv player. i want to make it align on the bottom right with all sizes of the player, so whether it increases or decreases on a page the logo is itself pushed to the bottom right.

i see a magnet kind of icon on the left side of the flash IDE which is called snap. i click it and it is selected but i do not see any option to mention the alignment for the logo.

can anybody help please how to do it?

thank you

'snap To' Tutorial?
Hi... again...

Anyone have a good tutorial for having an object snap to a position on the screen... I already have the objects dragging... I just want to know how I can take those draggable objects and have them snap to a target when you get close...

thanks again....

Drag And Snap
I was wondering how I could make a line of movie clips, say 5 or 6, and allow them all to be dragged and snapped to the closest coordinate. Say, for instance, like a picture gallery. There are 5 pictures in a horizontal line. If you click on one of them and, while still keeping the mouse button down, move the mouse from side to side, all the pictures will move with the one you clicked. When you release the mouse button, all the pictures will fall into a proper place. Say that each picture is 16x16. There are 10 16x16 tiles where the pictures will fit into perfectly. If you release the mouse button when all the pictures are above a 16x16 tile, they stay where they are. But if you release the mouse button when the pictures are in between two of the tiles, they will snap into the closest tile.

I hope I explained it well enough. Any help will be greatly appreciated. Thanks in advance.

Snap To Object
i just started using flash mx 2004, and i discovered my first problem... it's about the snapping. i want to draw a nice straight line and add another line to the end of the first line. in flash mx the lines just snapped into the right position, but in flash mx 2004 the wont. i've tried all snapping settings but i just wont work...

can somebody help me?

Drag With Snap
I'm making a slider - the scrub button can be smoothly dragged anywhere along a bar marked with increments, but once the button is released, I want it to snap to the nearest increment.
Would I have an array variable containing the positions of the increments, and then examine that to see which is the nearest position, or is there a better way?

Snap In For Flash Mx
Can anyone help. I've downloaded a WA PayPal e commerce snap in for
flash mx (macromedia approved) at http://www.webassist.com/Products/Pr...ils.asp?PID=24

this enables you to add e commerce and shopping cart funcionality to flash movies and applications.

I am using a trial version of flash mx professional 2004 version 7.2

I have followed the tutorial from http://www.webassist.com/Products/Pr...als.asp?PID=24

it looks straightforward, I did notice that the tutorial flash page had convert to symbol in the insert menu, my convert to symbol is in the modify menu.
Any way when I tried to publish preview I got this error:

This movie uses features that are not supported in flash player version 5 view the output panel for details.

**Error** Symbol=Buy Now, layer=definitions, frame=1:Line 10: You must export your movie as Flash 6 to use this action.
#initclip 3

**Error** Symbol=Buy Now, layer=definitions, frame=1:Line 195: You must export your movie as Flash 6 to use this action.
#endinitclip 3

WARNING: This movie uses features that are not supported in the Flash 5 player
Symbol=content coper S, layer=Layer 1, frame=1:Flash MX Button Instance Name
Total ActionScript Errors: 2 Reported Errors: 2

Can you help me.

regards

Nick

Snap No Work?
Howcome snap don't work in flash 80? I've tried to enable it, and adjustin the settings, but nothin' seem to happen??

Snap Movieclip
Hi all....
New to this forum..

I've come across a problem and i hope You can help:

I have a ring (Goethe's color circle) split into 6 coloured segments (mc's). http://www.silverartz.dk/goethe/

The idea is to be able to change the sequence of the segments, and I've already made the mc's dragable.

BUT I NEED A "DROP-FUNCTiON";

These segments has to be able to snap into place in any of the other segments place in the ring, which means, that when they snap, they must turn in order to fit in the given spot in the ring.

Hope someone can help me out here...

Thanks in advance

Projector, I Say SNAP
I have this projector I intend to burn on a CD. I hate fullscreens, so it will open in a regular window. My problem is that I don't want people to be able to maximize it or in any way resize it.

Is there a tool such as reshack to do this, or can this be done in other way? Hmm..... can this be done at all?

Thanks!

How To Snap To Grid?
Does anyone have any idea how to code a screen that when you drag things around they will snap to grid? (like the Windows desktop)

Snap To With Easing
I have a scrollbar that snaps to a certain point when over a specific area. It works great but it is a bit abrupt. Is there a way for me to ease into the snap to?

This is the code that I am using now

ActionScript Code:
scrollbar_mc.onRelease = scrollbar_mc.onReleaseOutside=function () {
    this.onMouseMove = undefined;
    this.stopDrag();
    dragging = false;
    if (this.hitTest(_root.dropTarget_mc)) {
        this._x = _root.dropTarget_mc._x;
        this._y = _root.dropTarget_mc._y;
    }
};

Snap To Point?
Help!

I'm working on a clip in MX that has a scrollable series of 5 graphics (when you move the mouse left or right, the clip "scrolls" in that direction)..... and I want to code the movie clip to snap to one of 5 coordinates (identified as points between each graphic instance within the strip of graphics)- whichever point is nearest.

How can I do this?

*looks hopeful for some guidance*

I posted this message over at FlashKit with an attachment of the work file http://www.flashkit.com/board/showth...eadid=502242-- so far to no avail. Anybody have any ideas?

Cheers,

Blackchurch!

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