An Embeded Mc's Coords
Hi, i have a movieclip embeded in another movieclip, and need to find the coordinates of the embedded clip in relation to the main stage in order to use them for a hitTest, does that make sense?
FlashKit > Flash Help > Flash ActionScript
Posted on: 03-24-2004, 05:50 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
X & Y Coords
Can you drag an object/clip only by the X or Y coords of the mouse, not by the center? I want to create an effect like http://www.yigal-azrouel.com/.
I posted this with the wrong subject before:/
-Lissa
Coords
Hi there
could someone help me with this thing i want to make for a web site. so what i want is just a simple cross made out of two lines but working so that when i move the mouse on the screen those lines will follow the pointer. and as it is the coordinates of the mouse will appear next to the pointer. there must be a script to do that or a tutorial which i could follow to make that script. i have some experience from scripting, but i would love to get some help on this one. cheers.
Tero
or tero.helenius@suomi24.fi
X 'n' Y Coords
Hi,
I have set up a MC that detects and displays the mouse coordinates. However, I want it to have X_ and Y_ before that actual coords. How do I do that?
Thanks as always.
YP
Get MC At Coords Y=30
hi all,
Is it possible to get the instance name of an mc at certain coordinates?
i.e. if i wanted to find the name of an mc at x=120 and y=50
tnx
Help With X,Y Coords
How can I change this so I can specifically set the X and Y coordinates but allow the X value to always remain centered on the stage?
Code:
X = (X == undefined || X == "center") ? Stage.width/2-W/2 : X;
Y = (Y == undefined || Y == "center") ? Stage.height/2-H/2 : Y;
Box Coords
Hey basically what i need to know is pretty simple but ive not thought of a a way to do it. When you have a movieclip of a box at 0 degrees to find the top right corner you take half the height added to _y and half the width added to _x. This doesnt work at any other angle since it works on x and y cords and the width changes as the box rotates... is there an equation to work this out? or any meathods. So you can find the _x and _y of any corner of the box aswell as the center.
Thanks for any help,
hope i explained it ok
Mouse Coords.
How do i get the values of the coords. of the mouse
ANYWHERE ON SCREEN. even it the mouse is OUT SIDE of the flash window.
i am trying to make the "Eyeball looking at mouse" type of thing.
but i can only get it to recognize WITHIN the movie
Thanks,
TriAdX@aol.com
Absolute X And Y Coords?
Is there anyway to get absolute x and y position from a symbol?
My issue is that I have _root, then off of root, 2 different symbol branches. Branch1 and branch2. Each with other things inside of them. I need to test if a symbol inside of branch1 is to the left of a symbol in branch2.
I cant just test ._x because the branches are moving, and ._x just references the x pos relative to the parent.
So is there anyway to get a absolute x position?
LoadMovieNum, X Y Coords
Anyone know how to tell a loadMovie script to load on a set of x/y coordinates?
Im using the following to load in the centre.swf to my main scene.
loadMovieNum("centre.swf", 7);
i need to use loadMovieNum because my button uses level7.
on (release) {
_level7.gotoAndPlay("frame label name");
}
cheers.
DuplicateMovieClip With New Y Coords?
I'm trying to duplicate a movie clip and have it appear just below the previous one. I have a button that calls the "c" function which executes the following:
Code:
function c() {
duplicateMovieClip("a"+pillar, "a"+counter, counter);
setProperty("a" + counter, _y, "a" + pillar._y + 15);
setProperty("a" + counter, _alpha, "a" + pillar._alpha + 10);
counter++;
pillar++;
}
I have it also changing the alpha of the new clip to see if was actually generating a new one (when the movie clip got darker I knew there was another one sitting on top of it). There must be something wrong with the first setProperty line, any notable mistakes.
Distance Between 2 X And Y Coords
Hi everyone, I need help with this math bit. I have a map which displays an indicator of current position. I have 2 input text boxes for entering new coords(x and y) Then I have a dynamic textbox that will display an estimated time of arrival. I need to find out how to find the distance between the current position and the new position, then click a button to display the ETA (estimate time arrival)
All I need to figure out is how to find the distance between the old and new points... Help is appreciated. THanks!
Help With X And Y Coords Of Attachmovie
I have a movie clip on the stage called birdplace0 and I attach the movieclip in my library with linkage called bird.
_root.birdplace0.attachMovie("bird", "bird0", 0)
Then, I have some code in birdplace0 that says:
onClipEvent(load){
this._x = 0
this._y = 0}
onClipEvent(enterFrame){
this._x += 1
this._y += 1}
However, when it loads the movie clip gets set like 4 inches to the left of where x and y = 0 on the stage.
I kinda know what is wrong, but have no clue how to fix it.
I belive the x and y are getting messed up when the one movie is getting attached to the other.
Thanks
MC Gets Deleted Before It Can Hit The Last Coords..
I'm trying to save some CPU resorces here but donno how.. my MC script is deleted before it can reach the current point.. what should I do?..
MovieClip.prototype.moveIt = function() {
this.onEnterFrame = function() {
menu._x = Math.round(border._x - ((border._width/2) + 68))+5;
menu._y = Math.round(border._y - border._height/2)+5;
if (Math.abs(menu._x - (Math.round(border._x - ((border._width/2) + 68))+5))<1 && (Math.abs(menu._y - (Math.round(border._y-border._height/2)+5))<1)) {
delete this.onEnterFrame;
}
}
};
MC Gets Deleted Before It Can Hit The Last Coords..
I'm trying to save some CPU resorces here but donno how.. my MC script is deleted before it can reach the current point.. what should I do?..
MovieClip.prototype.moveIt = function() {
this.onEnterFrame = function() {
menu._x = Math.round(border._x - ((border._width/2) + 68))+5;
menu._y = Math.round(border._y - border._height/2)+5;
if (Math.abs(menu._x - (Math.round(border._x - ((border._width/2) + 68))+5))<1 && (Math.abs(menu._y - (Math.round(border._y-border._height/2)+5))<1)) {
delete this.onEnterFrame;
}
}
};
Do NOT Follow The Mouse Coords
I have found this FLA a while back, and I was wondering if it is possible to make the brackets not follow the mouse, instead, to be in the corner when starting, then going back when rolled off a link. If you download the FLA, you will see what I am talking about.
Thanks.
Need To Change The X - Y Coords To Center
I am using the track mouse code (shows X-Y coords).
Is there a way to change the default position of the X-Y coords (default upper left) to be in the center?
I need a way to display the coords of a Map that I built where all the locations on the Map are based off the Center of the image to be X-0 Y-0.
example:
center of my image is X-0 Y-0
Top Left = -8000 8000
bottom left = -8000 -8000
Top right = 8000 8000
bottom right = 8000 -8000
thanks for your help!
ijasont
Rotation Based On X, Y Coords ?
I am using Flash 5:
I have a movie clip that is a drawing of an arrow. I would like the rotation of the arrow (_root.arrow._rotation) to change based on the _root._xmouse and _root._ymouse coords to make the arrow point in the direction of the mouse as it moves arround the screen.
A hint or script to help accomplish this would be much appreciated.
aa
Xmouse, Ymouse Coords
Hi
I posted an earlier problem but still couldn't get it solved, although a couple of guys helped out, i feel i was going in the wrong direction.
I have this script:
_root.test.onRollOut = function() {
if (hitTest(this)) {
scale(this, 100, 100, 1);
}
}
_root.test.onRollOver = function() {
if (hitTest(this)) {
scale(this, 200, 200, 1);
}
}
// scale bounce function //////////////////////////////////////////////////////////////////
function scale(target, xscale, yscale, speed) {
target.yscale = yscale;
target.xscale = xscale;
target.speed = speed;
target.viscocity = 1.5;
target.vy = 0;
target.vx = 0;
target.onEnterFrame = function() {
var dx = this.xscale-this._xscale;
var dy = this.yscale-this._yscale;
this.vy = (this.vy+dy/this.speed)/this.viscocity;
this.vx = (this.vx+dx/this.speed)/this.viscocity;
this._yscale += this.vy;
this._xscale += this.vx;
if (Math.round(dx) == 0 && Math.round(vx) == 0 && Math.round(dy) == 0 && Math.round(vy) == 0) {
delete this.onEnterFrame;
}
};
}
It works but not the way i need it.
Could anyone help me work out a way to use xmouse, ymouse coords on the mc area, rather than rollover/rollout
check out the fla
GPS Coords To X, Y... Help A Math Dummy.
I want the user to be able to input coords in the form of degrees, hours, mins. Then convert that to X, Y (to place a marker on the map).
Has any one had experience with this or know how to do this? Probably just some easy math...right?
[F8] Need Mc To Zoom To Mouse X&y Coords.
Hey all,
I have an mc that when I press a key it will either zoom in or out. Right now it zooms in/out, but it does with with the up-left corner as the point to zoom from.
Can anyone direct me on how to zoom in/out where ever the mouse is relative to the mc? If the mouse is in the middle, then it zooms from the middle and so on.
Thanks!
Need Mc To Zoom To Mouse X&y Coords.
Hey all,
I have an mc that when I press a key it will either zoom in or out. Right now it zooms in/out, but it does with with the up-left corner as the point to zoom from.
Can anyone direct me on how to zoom in/out where ever the mouse is relative to the mc? If the mouse is in the middle, then it zooms from the middle and so on.
Thanks!
X,y Coords Shifting In Pop Up Window>
My swf file which is width700 height 420 and is embedded in an html doc is popping up in the correct window size but the x, y coords seem to be shifting from 0,0. So i am ending up with a slightly shifted swf file within the pop up window??
Why would this be, I have used the code from this tutorial site in the beginner section!!
any answers!!?
ta
Rusty
Sending X And Y Coords Like Animation
Hello,
I am looking to find a way of sending out info of x and y though a shared object. I have done everything except working out a way to make the sending of the x and y smooth, if i just put the lines of code sending the x and y below each other it sends so quick that it seems to jump to the end command. How can i slow this down?
(i am looking for a server version of this post http://www.actionscripts.org/forums/...d.php3?t=46788)
thanx inadvance
solex
_width Is Changing The X Coords...?
I am making a progress bar and most of it works, except when I make the changes the _width property of the mc. for some reason when the incrementation is done on it the x coords is what changes and it races across the screen. I have tweaked it to make the incrementation on the height and it works fine. so I am really lost. Is there a bug that I don't know about?
Here is the code for the first frame
onEnterFrame = function()
{
var percentC;
percentC = _root.getBytesLoaded() / _root.getBytesTotal();
_root.progressBar_mc.bar._width = 130 * percentC; //here is where if I change it to _height it works fine
test._width = 130 * percentC; //test mc on main timeline it works fine, but is a simple object, the other progress bar looks much better
}
Here is the site to see what I mean
http://www.quantics.ca/flash/01_ProgressBar.html
it is the blue scrollbar that is acting funny, the red one is the simple one
Thanks for the help
MC Can't Get Back To The Coords It Was Before.. {hardcore AS}
I'm really lost now..
If you check my site I'm trying to make ( www.napoly.wz.cz ) and click one of my buttons the menu/logo/music/.. will move to the coords..
Here's the script I used:
1st frame:
speed = 5;
frame in which the action will take place:
MovieClip.prototype.move = function() {
endX = 192;
endY = 205;
this._x += Math.floor((endX-this._x)/speed);
this._y += Math.round((endY-this._y)/speed);
delete this.onEnterFrame;
};
MC which you want to move:
onClipEvent(enterFrame){
move()
}
But if you try to click for example on the "contact" button and after "about" button you can see that my music button (right side) is closer to the main border... so why the mc's coords are little off if you had clicked different button before (or if the mc's coords are different than before)? [note that I need to use Math.floor and Math.round to make it look sharp and that the speed value is for all MC's number 5]. Also my MC location is set up to hole pixels..
I tested it without Math function but it was same.. any advice?
Hope I was clear... (sorry for my English)
X, Y To GPS Coords... Help A Math Dummy.
If im not mistaken, if I have a map of say, Wisconsin, and I know what the Latitude coords (degrees, hours, minutes) of the top and bottom of the map, and I know how many pixels tall the map is, then I should be able to convert, with math, degrees:hours:mins to pixels. (same thing with longitude, but lets just focus on one way first)
I would first find out how may hours (minutes would be over kill for my app) there are to a pixel. Thats pretty easy. But this gives me a decimal number. How do i convert a decimal value (like 10.25) back to degrees and hours (in other words, how do i make .25 a "60" based value)?
Ultimately, i want the user to be able to input coords in the form of degrees, hours, mins. Then convert that to X, Y (to place a marker on the map).
Has any one had experience with this or know how to do this? Probably just some easy math...right?
What Influences X And Y Coords Display?
I have a function which attaches a bunch of MCs onto another MC and then calls a function which also attaches a bunch of MCs onto another MC. The problem is as soon as i call both functions the second function puts the MCs into lower right corner. I checked the coords and theyre OK.
When i disable the first function the second works fine. I tried putting the second in front of the first but the result is the same. Also if i disable the second one the first one works fine.
I have no idea what could be wrong and i would be really glad if someone could help me out!
Here are the functions:
Code:
var i:Number;
var j:Number;
for (i = 0; i<stKaset; i++) {
for (j = 0; j<stKasetVer; j++) {
kx=i*43+(i+1)*presledekHor;
ky=j*29+(j+1)*presledekVer;
k = ref.attachMovie("kaseta", "kaseta"+i+""+j, ref.getNextHighestDepth());
k._x = kx;
k._y = ky;
}
}
ref._x = zac_X;
ref._y = zac_Y;
izrisiLinije(lamelaGladka); //this is the second function
Code:
function izrisiLinije(presledek:Number){
var stLinij = zaokrozi(visinaPr/presledek);
var ref = this.vzorec_vrat;
var i=0;
var koo_y = zac_Y;
for(i=0;i<stLinij;i++){
koo_y +=presledek;
var l = ref.attachMovie("locilo", "linija"+i, ref.getNextHighestDepth());
l._x = zac_X+2;
l._y = koo_y;
l._width = sirinaPr-2;
}//for zanka
};
Finding Coords 100px Away
Ok, my head isn't working so it would be faster if someone justs helps me/double checks my trig.
I have a point at 300,300 or whatever, and I'm trying to find the points 100px away at any given angle... Say at angle 0
X is source, x is target 100 px away
ActionScript Code:
|||||||||||||||||||||||
|||||||||||||||||||||||
|||||||||X|||||||||||x|
||||(300,300)||||||||||
|||||||||||||||||||||||
|||||||||||||||||||||||
0 degree angle so ------ (400,300) is 100 px away
However
Say that the point is 100 px away at a 23 degree angle
ActionScript Code:
|||||||||||||||||||||||
||||||||||||||||||||x||
|||||||||||X|||||||||||
|||||||(300,300)|||||||
|||||||||||||||||||||||
|||||||||||||||||||||||
My brain isn't working, it's night time and I need to implement it before tomorrow... So what actionscript function could I use to find the target pixels 100 pixels away at any given degree. I don't mind writing a function like target(300,300,23,100) but I rather use a function or what not. It's basically a point at an angle, with a given radius. The only thing it needs to be is fast/optimized, so I'm cautious about writing > 10 lines of code.
Sorry if my message is incoherent, I'm half awake at this point...
Sorry about wrong forum... See I'm half asleep. :S
Need Mc To Zoom To Mouse X&y Coords.
Hey all,
I have an mc that when I press a key it will either zoom in or out. Right now it zooms in/out, but it does with with the up-left corner as the point to zoom from.
Can anyone direct me on how to zoom in/out where ever the mouse is relative to the mc? If the mouse is in the middle, then it zooms from the middle and so on.
Thanks!
Mouse Coords Outside Swf File
_root._xmouse and _root._ymouse will detect the coordinates of the mouse while it's over the flash movie and those coordinates will be relative to the dimensions of the flash movie
is it possible to detect the position of the mouse on the screen? say for instance i have an html page with a small flash file in it and i wanted to detect the mouse coordinates anywhere on the screen for use as a variable in that flash file
possible?
_width Is Changing The X Coords...?
I am making a progress bar and most of it works, except when I make the changes the _width property of the mc. for some reason when the incrementation is done on it the x coords is what changes and it races across the screen. I have tweaked it to make the incrementation on the height and it works fine. so I am really lost. Is there a bug that I don't know about?
Here is the code for the first frame
onEnterFrame = function()
{
var percentC;
percentC = _root.getBytesLoaded() / _root.getBytesTotal();
_root.progressBar_mc.bar._width = 130 * percentC; //here is where if I change it to _height it works fine
test._width = 130 * percentC; //test mc on main timeline it works fine, but is a simple object, the other progress bar looks much better
}
Here is the site to see what I mean
http://www.quantics.ca/flash/01_ProgressBar.html
it is the blue scrollbar that is acting funny, the red one is the simple one
Thanks for the help
MC Can't Get Back To The Coords It Was Before.. {hardcore AS}
I'm really lost now..
If you check my site I'm trying to make ( www.napoly.wz.cz ) and click one of my buttons the menu/logo/music/.. will move to the coords..
Here's the script I used:
1st frame:
speed = 5;
frame in which the action will take place:
MovieClip.prototype.move = function() {
endX = 192;
endY = 205;
this._x += Math.floor((endX-this._x)/speed);
this._y += Math.round((endY-this._y)/speed);
delete this.onEnterFrame;
};
MC which you want to move:
onClipEvent(enterFrame){
move()
}
But if you try to click for example on the "contact" button and after "about" button you can see that my music button (right side) is closer to the main border... so why the mc's coords are little off if you had clicked different button before (or if the mc's coords are different than before)? [note that I need to use Math.floor and Math.round to make it look sharp and that the speed value is for all MC's number 5]. Also my MC location is set up to hole pixels..
I tested it without Math function but it was same.. any advice?
Hope I was clear... (sorry for my English)
How Do I Change The Center Of A MC So That _x And _y Give New Coords.
So the commands MC._x and MC._y will give the center of a movieclip. So can I change the center of the movieclip so that those commands will give different values? I tried editing the MC and just dragged everything around so the little cross was where I wanted it to be but it didn't work. Any ideas?
Mouse Coords Return Problem
I am returning the position of the mouse position to two text boxes named "x_pos" and "y_pos". My code, in the main timeline, is as follows:
onClipEvent (mouseMove) {
x_pos = _root._xmouse;
y_pos = _root._ymouse;
}
When I test the movie, the response I in the output window is:
"Scene=Scene 1, Layer=Layer 1, Frame=1: Line 3: Clip events are permitted only for movie clip instances
onClipEvent (mouseMove) {"
The mouse is not a movie clip, nor is it ever unless I hide it and subsitute it for one, yet, this is the method taught in the F1 lessons. Any clue, anyone, as to what's being done wrong?
Drag With Soft Approach To Coords
Hi flashers, I´m writing cause I have a problem and I don´t know how to do it myself. I´m trying to drag a mc and I´d like it to come back to its first location on release . I have a mc with:
onClipEvent (enterFrame) {
function sitio() {
this._x += (uno-_root.a._x)/4.9;
this._y += (dos-_root.a._y)/4.9;
}
}
Inside this mc, a frame with:
uno=getProperty(this,_x)
dos=getProperty(this,_y)
and a button with:
on (press) {
startDrag(getProperty(_x, _y));
}
on (release) {
stopDrag();
_root.a.sitio();
}
It seems as if it moved only during a frame.What´s what I am doing bad? Please, any help will be welcome. Thank you all.
Scaling Dynamically.. Changing Coords
Hey, I'm currently trying to scale an MC using AS but when it zooms in, it doesn't stay focused on what the previous center was, rather, it skirts over about 25px to the left. I don't understand why.
My nesting scheme is as follows.
_root:
attachmovie (picturemc)
picturemc.mountain._scale =150 <-----this one scales
I have it traced and the _x of either picturemc or mountain doesn't seem to change, however I can visually see the change. Bear in mind that I'm scaling both the x and the y. I'm using the new MX2004 functions to do the scaling, my picturemc and my mountainmc are both aligned center of their respective hosts.
Thanks,
DaVuLf
edit: on a sidenote, does anyone know why this preloader works in one .fla (only 2 frame, preloader on frame 1, image on 2) and doesn't work on another (only 2 frames, preloader on frame 1, Dynamic AS on frame 2).
This is code for preloader:
PHP Code:
onClipEvent(enterFrame) {
loaded = _root.getBytesLoaded();
total = _root.getBytesTotal();
percent = ((loaded/total)*100);
trace("Loaded: "+loaded+" Total: "+total+" Percent: "+percent);
_root.percentage = ((int(percent)+1)+"%");
this.bar._width = percent*2;
if (percent == 100) {
_root.gotoAndPlay(2);
}
}
Nested And Rotated Coords Problem..
i have 2 buttons in a mc_table which is nested in mc_table_par.
these objects initialise with a random rotation of (local_rot).
when i press them, they first read their relative x and y coords, and then shift the parents + and - that amount, to enable a rotation to happen around them. BUT my mind boggles as to how to solve the next stage - which is to read their x/ypos once they have been rotated around the previously clicked rotation point!
this is neccessary to rotate the parents and shift etc in the right amount/direction and to get the real rotation point in the first place...
//initalise
xpos = this._x;
ypos = this._y;
rot = 360*(Math.random());
begRot = _parent._rotation;
endRot = rot;
midRot = (endRot-begRot)/2;
***function then progressively rotates towards endRot
then, on the nested buttons
on (press) {
begRot = _parent._rotation;
endRot = rot;
if (endRot>180) {
endRot = endRot-180;
}
midRot = (endRot-begRot)/2;
//this moves the parents to enable rotate point to be correct..
xposthis = this._x;
_parent._x = _parent._x-xposthis;
_parent._parent._x = _parent._parent._x+xposthis;
yposthis = this._y;
_parent._y = _parent._y+yposthis;
_parent._parent._y = _parent._parent._y-yposthis;
}
i can imagine that somehting like a local to global, with some trig such as angleBetween would get me there - but i am totally stuck for days.
help would be appreciated!
[F8] Movieclip Moves To Mouse Coords
i can get a movieclip jumping from its position to match the mouses coordinates when the mouse is clicked.
but how would i go about making the movie clip move towards the mousedown coordinates at a speed which i can state in the actionscript?
thank you.
Changing An Object's Coords In An Array?
Code:
empty.attachMovie("item1", arr.push("item1"+i), getNextHighestDepth());
arr[i]._y -= 5
i++
Why cant i do that?
even if i dont use arrays and just do
Code:
empty.attachMovie("item1", "item1"+i, getNextHighestDepth());
"item1"+i._y -= 5
i++
it doesnt work. Am i missing something obvious???
Changing Global Coords To Local
Hi,
I have some sprites on the stage that when I roll over them, a menu should appear.
I know the Global coords of where the menu should appear, but when I use
GlobalToLocal (The location is calculated according to the angle), it never puts the menu at these coords.
this code appears in the object class:
localcoords = globalToLocal(GlobalCoords);
menu.x = localcoords.x;
menu.y = localcoords.y;
The menu doesn't appear on the stage at the correct coordinates.
What am I doing wrong?
What i am trying to do is to make an object that exists in a special class that extends sprite, appear in a certain location on the main stage.
Thanks in advance,
Guy
Moving Items En Masse Using X And Y Coords
I had a row of text items in the timeline that I wanted to move, without having to click on each one individually and put in the new X and Y coordinates in either the properties inspector or the info box.
I selected them all at once, then put in the new coordinates, hit enter, and then when I clicked on each one individually, found they were still in their old position. I had to move them one by one. What a time waster! Ain't there no faster way to do this?
Thanks,
jcarruth
Moving Items En Masse Using X And Y Coords
I had a row of text items in the timeline that I wanted to move, without having to click on each one individually and put in the new X and Y coordinates in either the properties inspector or the info box.
I selected them all at once, then put in the new coordinates, hit enter, and then when I clicked on each one individually, found they were still in their old position. I had to move them one by one. What a time waster! Ain't there no faster way to do this?
Thanks,
jcarruth
Rotating A Circle Using Mouse Coords.
I'm trying to rotate a circle. I want the circle to rotate in relation to the mouse movement across the y axis. Here is my code so far:
onClipEvent (enterFrame) {
_root.xVal = Math.round(_root._xmouse-this._x);
_root.xMove = Math.round(_root.xVal/10);
this._x += _root.xMove;
_root.circle._rotation += _root.xMove*.4;
}
And here is the swf so far: HERE
As you can see, this is the idea i am getting at. I would like the globe to rotate CW when the mouse is moved to the right of the globe and CCW when the mouse is moved to the left of the globe. I would also like the globe to slow as it comes closer to the mouse, but faster as the mouse is further away.. similar to the box that moves above the globe.
When the mouse is put on the globe i woul like it to come to a stop slowly so that the user can select something. If anyone has any ideas please help.
Much appreciated,
Thanks.
MC AScripted Movement To Specific Coords?
I have several MC shapes (shape1, shape2, etc.) on the stage at specific coords. When you click on shape1 I want it to (through AS, no timeline tweening) ease over to another specific set of coords. Same with shape2, but to start/stop at different coords.
After clicking and AFTER the ease over to the second set of coords I want a pop-up browser window to come up.
So the chain of events are: 1) click shape 2)shape moves to new coords 3) window pops up... that easy? So far no problems except 2 things;
first here's the script I put in the MC of the shape:
onClipEvent(load){
//here are the starting coords of the shape
_x=625;
_y=32;
speed=10;
}
on(press){
//here's where I want the shape to go
targetx=400;
targety=300;
//and here's where I want it to wait until it gets
//there to open up the pop up window
//I'm assuming I need an "if" statement but I don't
//know what to say
if(?something about when the MC reaches specific
coords (400,300)?){
address = http://www.google.com;
target_winName = “google”;
width = 600;
height = 600;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 1;
resizable = 0;
openWinCentre(address, target_winName, width, height, toolbar, location,
directories, status, menubar, scrollbars, resizable);
}
}
onClipEvent(enterFrame){
//here's the code for the easing of the shape
_x+=(targetx-_x)/speed;
_y+=(targety-_y)/speed;
}
Now then, the two problems I'm having is when the movie loads, the shapes do begin at their designated beginning coords (625,32 in this example); but they IMMEDIATELY ease on over to 0,0 the split second the movie loads before you can click anything. Then, when you click the shape, it moves beautifully down to the target coords no problem.
How do I prevent the shape from heading over to 0, 0 when the movie loads? I want to keep them still, exactly where I set them until I click them.
The second problem is getting the pop up window to NOT occur UNTIL the shape has reached it's target coords. I would assume I needed an "if" thrown in, but I'm having a helluva time figuring out how to word it correctly. I want to say "on(press) if this shape arrives at exactly 400, 300 then and only then do I want this pop up window to come up...." Follow me?
As I said, this code is nested in the instance of the shape itself. And before you ask, I do have the appropriate code in frame one of the main timeline (the getURL script stuff). The window opens no problem in the example above, it just occurs the moment I click the shape when I want it to wait until the shape reaches it's destination.
Sorry so long winded... Anybody with any flashes of brilliance?
Thanks in advance!
Mouse Coords Detection Without OnClipEvent
MX04
I have an application where I need to detect if the mouse is less than 200 px from the left sie of the screen, then play an animation... Once the mouse is moved back out of the 200 px area I want the animation to reverse.
I'm using the Tween Class for animation and have been messing around with onclipevents with no luck like:
onClipEvent (enterFrame) {
if(_xmouse <= 200)
{
_root.theSwitch = "on";
}else{
_root.theSwitch = "off";
}
if(_root.theSwitch=="on")
{
trace("on")
}
}
(This has been dumbed down)
This will obviously produce a million "on" traces when the mouse is over there - what is the best method for detecting the change once, setting a variable, then playing the animation?
Thanks in advance!
|