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








Stop At A Point


ok i am making a game and i want a MC to rotate but when it rotates half way i want it to stop rotating like a line

Example:
1
o
o
o
2

ooo

and when it turns half way i want it to stop i want it to do it both left and right way...

sry for missspell




KirupaForum > Flash > Flash 8 (and earlier) > Flash MX
Posted on: 04-23-2005, 06:57 PM


View Complete Forum Thread with Replies

Sponsored Links:

How Do I Stop My Mc At A Certain Point?
onClipEvent (enterFrame) {
trgt_y = _root._ymouse - _y;
_y = _y + (trgt_y/10);
}

I have this code on a movieclip which is just an arrow which scrolls up and down next to some buttons.

How can I get it to stop at a maximum height of Y:82, and depth of Y:408?

Thanks

View Replies !    View Related
Stop Point
not sure how i make my object to stop moving at a certain quadrant.
i'm using this code right now.
StageWidth = 1280;
StageHeight = 1440;

function moveStuff() {
if (Key.isDown(Key.LEFT)) {
this._x += this.speed;
}
if (Key.isDown(Key.RIGHT)) {
this._x -= this.speed;
}
if (Key.isDown(Key.UP)) {
this._y += this.speed;
}
if (Key.isDown(Key.DOWN)) {
this._y -= this.speed;
}
}

Map_mc.speed=10;
map_mc.onEnterFrame=movestuff;

View Replies !    View Related
Stop At A Point
ok i am making a game and i want a MC to rotate but when it rotates half way i want it to stop rotating like a line

Example:
1
o
o
o
2

ooo

and when it turns half way i want it to stop i want it to do it both left and right way...

sry for missspell

View Replies !    View Related
Play Mc Up To A Certain Point And Then Stop.
Hi.

This is really doing my head in.

I'm new to flash and i'm trying to control a movie clip so that when a certain button is pressed, the movie clip plays until its reached a certain frame and then stop.

At the minute I'm just getting it to stop, which looks rubbish.

I have a globe, that spins - when a button called Australia is clicked, I need it to keep spinning until it reaches Australia and then stop, rather than just stop at Australia.

Any ideas pretty please?

View Replies !    View Related
Stop Mc Motion At A Certain Point?
The following block of script works as stated on kirupa.com as far as moving to the right via the this._x += speed.

However, I am trying to modify it to stop scrolling if the the x pos. is less than 136. I am a bit of a noob-hack when it comes to actionscript syntax...as you can see below. please help!

Thanks in advance



onClipEvent (enterFrame) {
speed = 1;
this._x += speed;
if (this._x<=136) {
speed = 0;
}
}


- the movement works, but it dosnt stop...

View Replies !    View Related
Stop Sound At Certain Point
Hello

I have a sound loop which is set to loop three times in my Flash movie. On the third time round, I would like the sound to stop at a specific point, and for a function to be called at this point. I am pretty good with Flash, but I have only just started working with sound.

Any help much appreciated,

Shai

View Replies !    View Related
Stop Sound At Certain Point
Hello

I have a sound loop which is set to loop three times in my Flash movie. On the third time round, I would like the sound to stop at a specific point, and for a function to be called at this point. I am pretty good with Flash, but I have only just started working with sound. I have tried to use an actionscript (with things like mysound.position) but the sound will only loop once. I have used
mysound.start(0, 3);
surely this should make my sound loop three times? it only plays once

Any help much appreciated,

Shai

View Replies !    View Related
How Do I Get My Movie Clip To Stop At A Certain Point
I have this code on my mc

onClipEvent (enterFrame) {
var speed = 14;
var viscosity = 1.3;
xpos = _root.xpos+200;
// X Pos
difference = xpos-this._x;
xvelocity = (xvelocity+(difference)/speed)/viscosity;
this._x += xvelocity;
}

and this code on my buttons-


on (release) {
_root.main._x = 600

stop();

}


the mc will ease to the spot but then return to its starting position.

Help!

View Replies !    View Related
[F8] Flv Cue Point To Stop Sound Loop?
I have a few flv files to stream from the server. Problem is, the sound from the videos when played conflicts with the background sound loop. Would adding a cue point at the start of the video be a decent way of stopping the sound loop? If so, what would the parameters be? I'm not sure how to just target the sound loop and not all the sounds.

View Replies !    View Related
Counter With Set Start/stop Point
I am trying to make a counter that starts at
310.100 and counts down to
305.100 counting by .1
Any suggestions on the best way to go about this?

View Replies !    View Related
Make An Object Stop At Specified Point
Hello guys!

Im currently working on a little game of mine, and I need a little help solving one of my greatest mysteries

If you look at my example, youŽll probably figure out my problem allready. As seen on the sheet, I want to move an object from one point to another, using actionscript.

IŽve figured out that iŽll need the help of good oldschool maths. Trigonometry to be exact. IŽve jumped the current conclusions:


Code:
moveSpeed = 5;

movingAngle = Math.atan(endY/endX)
speedX = moveSpeed * Math.cos(movingAngle);
speedY = moveSpeed * Math.sin(movingAngle);

if(this._x < endX) { this._x += speedX; }
else if(this._x > endX) { this._x -= speedX; }

if(this._y < endY) { this._y += speedY; }
else if(this._y > endY) { this._y -= speedY; }
IŽve tested this code, and it seems to work allright. The problem is that the movement is continius - the object doesnt stop at my selected point. My question is therefore; How do i stop the movement when the object reaches its destination?

IŽve tried to make if-conditions, but the speedoperarator (speed * angle) is not precise enough to make my object stop where i want it to. Any good ideas people?

Please help

View Replies !    View Related
Movement Using ActionScript - Stop On An X Point?
Hi everyone,

I was using this tutorial

http://www.kirupa.com/developer/mx/ASmovement.htm

Which is awesome, but i would like to stop the movement on a certain x point. I'm a real noob and am not sure how to do it.

Could someone please post the script I would need? Thanks!

View Replies !    View Related
Scroll Movieclip - Stop At Certain Point
Hi. I figured out the code below to make a movie clip scroll up and down. However, the problem is that it will keep scrolling forever. Does anyone know how I can get it to stop at a minimum and maximum vertical height?


Code:
var scrollUp = function() {
test_mc.onEnterFrame = function() {
this._y -= 5;
}
};
var scrollDown = function() {
test_mc.onEnterFrame = function() {
this._y += 5;
}
};
scrollup_mc.onRollOver = function() {
scrollUp();
};
scrollup_mc.onRollOut = function() {
delete test_mc.onEnterFrame;
};
scrolldown_mc.onRollOver = function() {
scrollDown();
};
scrolldown_mc.onRollOut = function() {
delete test_mc.onEnterFrame;
};

View Replies !    View Related
Movie Is 100% X 100%, But Can I Stop It From Expanding At A Certain Point?
Im trying to make a movie stop expanding when it hits a certain height or width. Basicaly, i want it to be 100% for smaller resolutions, and then when the resolution is large enough to view the whole thing, i want it to be actual size. Anyone?

View Replies !    View Related
Load A .swf, Then Stop Movie At A Certain Point
I'm trying to load up a .swf file into a new .swf file. I am successful doing this. What I need help with is getting the loaded .swf file to stop at a certain point (I don't want it to play all the way through). Anyone know if this is possible?

Thanks!

View Replies !    View Related
NextFrame PrevFrame Stop At Specific Point
I have a 5 button menu that when the user releases a button a movie clip drops down a submenu. The sub menu is a 3second animation with specific keyframes where a holder loads in the submenu buttons.

What I need is a onRelease function i can put in the _root actions that depending on the button pressed will get the current frame of the submenu mc and either nextFrame or prevFrame until the appropriate frame in the submenu timeline.

Does this make sence?
here is my current attempt


Code:
_root.menu_mc.multiBut.onRollOver= function() {

this.onEnterFrame = function(){

this.nextFrame();

if( this._currentframe == 50 ) this.onEnterFrame = function(){

this.prevFrame();

if( this._currentframe == 1 ) this.onEnterFrame = null;

}

}

}

View Replies !    View Related
Countdown With Specific Start/stop Point
I am trying to make a counter that starts at
310.100 and counts down to
305.100 counting by .1
Any suggestions on the best way to go about this?

View Replies !    View Related
Stop A Tween At A Point Depending On Dynamic Text.
I have a dynamic text box which pulls "Newsflashes" from a database, the content scrolls up the flash movie (like movie credits) and the dynamic textbox has a Auto Size property to fit all the current "newsflahes" inside it. Right now the scroll will only go as far as I have it set in the tween, which wont allow all the newsflashes to go through if there are several, or a few long ones. I want to avoid the scroll from leaving blank space for a long period of time when there are shorter or few "newsflashes".

I belive what i need help with is some Action Scripting, is there a way I can script the texbox to motion tween from its starting point to an endpoint based on the size of the dynamic textbox after it has been filled from the database and Auto Sized to fit the content? Maybe I could somehow use the X,Y coordinates of the box or something?

View Replies !    View Related
Creating A Point-line With Increasing & Decreasing Point Size
hi,
i want to creating a point-line with increasing & decreasing point size, that the final result looks like a wave form.
i guess i have to do that with sine and cosine values...?
i would be very happy for any help or hint.

View Replies !    View Related
Draw A Line From Any Point A To Any Point B Dynamically Through Actionscript
I am trying to make a file where there are several locations made on a map. If a person clicks on one location A and then another location B, there is a plane that flies from A to B and there are 2 text fields that get populated with the names of A and B destinations. This animation is scripted. I wanted to animate a dotted line from point A (from destination of the plane) to point B(to destination of the plane) through action script too so that there is a dotted line following the plane animation.

Thanks

Aneesha

View Replies !    View Related
[CS3] Find Highest Point And Farthest Point Of A Parabola
Hi Guys, I've been using for forum extensively over the past few weeks and have found almost everything I needed until now...

I'm moving a ball using something similar to the following code:


Code:
var spx:Number = 3;
var spy:Number = 7;
var g:Number = 0.1;
var bmove:Boolean = true;

onEnterFrame = function() {
if (bmove) {
move_ball();
}
stop_ball();
}

function stop_ball() {
if (ball._y > 350) {
bmove = false;
}
}

function move_ball() {
spy = spy-g;
ball._x += spx;
ball._y -= spy-g;
}
Is there a way to find the maximum height and farthest point of the parabola it describes? I want to display a path guide using curveTo which shows the route of the ball.

Thanks.

View Replies !    View Related
Moving Object From Point A To Point B - Mathematical Problem
Hi,
I have mathematical problem.

I want to move object from point A to point B but not just X or Y aixis. For example point A(0,0) and point B(500,500).

Please if somebody can send me generic equation to put in ON_ENTER_FRAME event so on each frame object is a little bit closer to point B.
Thanks,

View Replies !    View Related
Find Highest Point And Farthest Point Of A Parabola
Hi Guys, I've been using for forum extensively over the past few weeks and have found almost everything I needed until now...

I'm moving a ball using something similar to the following code:


Code:
var spx:Number = 3;
var spy:Number = 7;
var g:Number = 0.1;
var bmove:Boolean = true;

onEnterFrame = function() {
if (bmove) {
move_ball();
}
stop_ball();
}

function stop_ball() {
if (ball._y > 350) {
bmove = false;
}
}

function move_ball() {
spy = spy-g;
ball._x += spx;
ball._y -= spy-g;
}
Is there a way to find the maximum height and farthest point of the parabola it describes? I want to display a path guide using curveTo which shows the route of the ball.

Thanks.

View Replies !    View Related
Drawing Line Dynamically From Point To Point
Here is what I am looking to do, I will try and be specific:

I would like to create an MC:
when loaded, draws a line dynamically from the first x/y point released on the stage to the next x/y point released, then from there to the next x/y point released, and so on. Creating a path from point to point, wherever you release. Tracing the path of the user (based on onRelease points).

This could be a closed set, where, for example, I would have 10 MC's on the stage that are all potential points for the line. The catch is that I want the user to define the order, selecting the MC's in any order and having a line drawn that traces the users selections.

Or it could allow the user to release anywhere within the parent MC.

I am moderately familiar with drawing a line dynamically, but don't know how to write what I am looking for.

Any help??


Thanks so much.

View Replies !    View Related
How To I Move From Point To Point And Leave A Trail
What i'm doing is have a word appear and then a line come from it and move to a point, while the line is moving what i want it to leave a trail behind it as if someone was drawing the line from 1 point to another, I hope i have explained it ok,

If anyone knows how to do this can you let me know.

thank's

View Replies !    View Related
Using Flash Actionscript To Do Point To Point Linkage
hiya..
do anyone has any idea how to using flash actionscript to do a point to point linkage?

View Replies !    View Related
Move An Object From One Point To Another Point On Graph
Basically what I like to ask is how to move a object from one point to another point based on the point tat you have clicked on a graph. For example, If I click on this coordinate (2,3) on graph, the object (movie clip) will move to that point.

View Replies !    View Related
Registration Point Vs. Transformation Point
I'm extremely frustrated with the behavior of Flash MX 2004's registration/transformation points. I just learned that the distinction between the two just happened with the release of Flash MX 2004. I'd like to know how in the world I'm supposed to transform a symbol relative to its corner or side, seeing how the transformation point insists on being in the center of the symbol every time.

Let's say I have a 200x200 square shape. If I want the transformation point to be in the lower left corner, it looks like I have to:

1. Put the registration point in the center when I create the symbol
2. Double click on the symbol
3. Move the shape 100 px to the right
4. Move the shape -100 px up
5. Exit out of symbol editing mode

which is five times more complicated a process than if they had kept the behavior like it was. Or at the very least, change the Symbol Creation dialog box to this:



Or am I missing something?

View Replies !    View Related
Move An Object From One Point To Another Point
Basically what I like to ask is how to move a object from one point to another point based on the point tat you have clicked on a graph. For example, If I click on this coordinate (2,3) on graph, the object (movie clip) will move to that point.

View Replies !    View Related
Laser From Point X Go To To Point Z. Sort Of
ok i need help! here is what i have so far, this code that i show u is on the laser movie clip (it has been duplicated allready and this is just the code that is on it:

Code:
onClipEvent (load) {
this._x = _root.mech._x;
this._y = _root.mech._y;
laserMoveSpeed = 10;
this.targetAngle = Math.atan2(aim._y-mech._y, aim._x-mech._x);
this._rotation = this.targetAngle/(Math.PI/180);
}
onClipEvent (enterFrame) {
//here is code that will move laser in direction of where
//the mc instance named: aim was when clicked
this._x += Math.cos(this.targetAngle)*this.laserMoveSpeed;
this._y += Math.sin(this.targetAngle)*this.laserMoveSpeed;
}

mech is the instance name for the point the laser shot will start at, aim is the mouse mc whhere you click and then it duplicates the mc, and then this code should get run , the only thing that works is when u click, one of the laser mc shows up, so u can keep clicking and u will get tons of lasers on the screen, but they dont move and just stay at the point where the mech was when shot. how come this code isnt making the laser move in the right direction, so why dont it move?
EDIT: on the onload part i just added a trace(targetAngle); it displays the output of NaN. what does that mean>?

View Replies !    View Related
Add Point And Deduce Point In Flash
Hello everyone,

I am a beginner in Flash and currently I am doing my final year project on a website development. I plan to create a happening website by providing members to actually collect points while they perform some activities like membership sign up will earn them 500 points, submit photo will earn them 100 points and so on.

They can collect point under they membership account and use the point to redeem some stuff. As they redeem their point in their account will automatically deduced accordingly. So the problem here is I am unable to figure out what actionscript is this called- able to add points and deduce point according to the activities the member do in the website. I would be really grateful if you guys can help. Really really need help. I have no idea where to start off. Thank you in advance.

cheers

View Replies !    View Related
From Point To Point With Smooth Rotation
I want to max the stage size to 2880x2880 then make a huge symbol with buttons that say move to point x... y... and have this much rotation...

My problem is if I move from point to point how would i get a smooth move not just a jump? With the rotation gradually happening?

View Replies !    View Related
Point-Point Character Rotation
Alright, so I am working on a point-point character slope rotation system, and for all the different point locations I try, the rotation seems to be off just by abit everytime...

Quick note: "chara" is a box on the stage, also you can probably just copy/paste after putting an mc called chara on the stage


ActionScript Code:
var p1:Point = new Point(10, 10);
var p2:Point = new Point(150, 130);

//var char:Point = new Point(18, 11); //pretty much un-needed

var p1p2rot = Math.atan2(p2.y-p1.y, p2.x-p1.x);
var p1p2rot2 = Math.round((p1p2rot*180/Math.PI))+90;

trace(p1p2rot2);
trace(p1p2rot2-90);

var charrot = 180-(p1p2rot2-90);

trace(charrot);

chara.rotation -= charrot;


what the heck?

View Replies !    View Related
Rotating A Point Around Another Point Using X,y,z Axes
I have a point (a camera) that i want the player to be able to rotate around another point(a 3D mesh) which is centered on 0,0,0. And i want the camera to always point at the object.

implementing rotation around the Y axis is easy. I do it like this..


ActionScript Code:
var camRotation=0;
var camDistance=50;
function enterFrameHandler(e) {
    if (leftIsDown) {
        camRotation-=.1;
    }
    if (rightIsDown) {
        camRotation+=.1;
    }
    camera.x=Math.sin(camRotation)*camDistance;
    camera.y=Math.cos(camRotation)*camDistance;
    camera.rotationY=camRotation*180/Math.PI;
}
and it works the way i want it to.
Now I want to be able to also press up and down to be able to change the camera from side-view to top-view, but thats where im stuck.. i dont know how to add a third dimension to the rotation..

Would anyone help me with this?

View Replies !    View Related
Point A, To Point B... In A Straight Line?
Hello everyone, l'm working on a script that is similar to the old "missile command" game from the 80's, and l just got started.

In any event, the user Clicks on the screen which executes the
"fireMissile(_root._xmouse,_root._ymouse);" function. As you can see, this function duplicates my missile MC, and starts it off with the X/Y coordinates of: 273,312. From that point, l want the MC to move in a *straight line*, from it's starting point, to the point where the mouse *was* when the fireMissle() function was called.

I've ripped some code from one of my actionscript books, but l can't seem to fine tune the scripting correctly, and l'm getting all types of haywire effects that l'm not looking for. IE missiles going every which direction, but where I clicked the mouse.

here's the portion of the code where l'm running into problems... what's wrong here?

Code:
xdiff = x-startX;
ydiff = y-statY;
angle = Math.atan2(ydiff, xdiff);
angle = angle*180/Math.PI;
_root["missile"+missleCount]._x = startX;
_root["missile"+missleCount]._y = startY;
_root["missile"+missleCount].finalX = missleSpeed*Math.cos(angle);
_root["missile"+missleCount].finalY = missleSpeed*Math.sin(angle);
And the entire script (less some of the extra garbage that's been thrown in):


Code:

mouse.hide();
missleCount = 0;
startX = 273;
startY = 312;
missleSpeed = 5;
shotsOnScreen = 0;
maxShotsOnScreen = 100;

function fireMissle(x, y) {

duplicateMovieClip("missile", "missile"+missleCount, missleCount);
xdiff = x-startX;
ydiff = y-statY;
angle = Math.atan2(ydiff, xdiff);
angle = angle*180/Math.PI;
_root["missile"+missleCount]._x = startX;
_root["missile"+missleCount]._y = startY;
_root["missile"+missleCount].finalX = missleSpeed*Math.cos(angle);
_root["missile"+missleCount].finalY = missleSpeed*Math.sin(angle);
missleCount++;
shoutsOnScreen++;

}
and the code on the actual missleMC

Code:
onClipEvent (enterFrame) {
if ((finalX) && (finalY)) {
this._x += this.finalX;
this._y += this.finalY;
}
}

View Replies !    View Related
How Do I Tween To Point B Without Knowing Where Point A Will Be
I have a slide show that resizes depending on what photo is showing, and the users can pick any tab that they want to. How do i shape tween the slide show without knowing what the urrent size is?

Do I need scripting? (AS3)

View Replies !    View Related
Point-to-Point Line-of-Site
Point-to-Point Line-of-Sight* Oops
Man that sounds so cool.

edit:
Since this original post I have learnt of the world of Raycasting. You can see my attempts of it in this post:
http://www.kirupa.com/forum/showthre...88#post1746388

Here's the script. I have used Flash 8's BitmapData and Rectangle classes, but the theory could easily be applied to another tile-based world without any of these, these classes were simply used to display everything.

Use the Arrow keys to move the character, and the character aims to the mouse position.

http://icio.co.uk/random/files/flash/sight.swf


ActionScript Code:
import flash.display.BitmapData;import flash.geom.Rectangle;Stage.scaleMode = "noScale";Mouse.hide();//*********************************************************// Variablesvar tileSize:Number = 10;var map:Array = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]; // This is an awesomely-long line, y0. (762 characters before comment)var baseBitmap:BitmapData = new BitmapData(map[0].length*tileSize, map.length*tileSize, false, 0xEEEEEE);   _root.attachBitmap(baseBitmap, _root.getNextHighestDepth());   // var objBitmap:BitmapData = new BitmapData(baseBitmap.width, baseBitmap.height, true, 0x00000000);         _root.attachBitmap(objBitmap, _root.getNextHighestDepth());        //  |- The bitmaps used in the gamevar hitBitmap:BitmapData = new BitmapData(baseBitmap.width, baseBitmap.height, true, 0x0000FF00);         _root.attachBitmap(hitBitmap, _root.getNextHighestDepth());        // /var tileRectangle:Rectangle = new Rectangle(0, 0, tileSize, tileSize); // A Rectangle object for drawing tiles onto the base bitmap.var objects:Array = [];                      // An array of all the objectsvar player:Object = {y:10*tileSize, x:1*tileSize, color:0xFFFF3399, xspd:0, yspd:0}; objects.push(player);  // The player objectfor (y=0; y<map.length; y++) { for (x=0; x<map[0].length; x++) { if (map[y][x] == 1) {  // Cycle through the numbers in the map and process, then    tileRectangle.x = x*tileSize; tileRectangle.y = y*tileSize;       // Reposition the tile rectangle    baseBitmap.fillRect(tileRectangle, 0x999999);                              // Draw it onto the base bitmap} } }// Draw the objects onto the object bitmapfunction drawObjects() { objBitmap.fillRect(objBitmap.rectangle, 0x00000000); for (i in objects) { objBitmap.fillRect(new Rectangle(objects[i].x, objects[i].y, tileSize, tileSize), objects[i].color); } objBitmap.fillRect(new Rectangle(_xmouse-1, _ymouse-1, 3, 3), 0xFFFF0000); }    //****************************************************************************************// THE IMPORTANT FUNCTION - THIS IS WHAT IT'S ALL ABOUT !! *******************************//****************************************************************************************function lineOfSite(x1:Number, y1:Number, x2:Number, y2:Number) {    var dist:Number = Math.sqrt(Math.pow(x2-x1, 2)+Math.pow(y2-y1, 2));  // The distance from the start point to end point    var angle:Number = Math.atan((y2-y1)/(x2-x1));              // The angle from start point to end point (in radians)        angle += x2-x1<0 ? Math.PI : 0;           // angle correction        angle += x2-x1>=0 && y2-y1<0 ? 2*Math.PI : 0;                     // angle correction        hitBitmap.fillRect(hitBitmap.rectangle, 0x0000FF00);                // (Eye-Candy)    var pos:Number = 0;              // Where we're going to start from on the line    while (pos < dist) {                                                    // Loop until we've tested further than, or to the same distance as, the total distance        pos = pos+1<=dist ? pos+1 : dist;                           // Move onto the test position. (Increasing/Decreasing '1' increases/decreases accuracy)        var x:Number = Math.floor(pos*Math.cos(angle)+x1);            // Calculate the new x-coordinate for testing        var y:Number = Math.floor(pos*Math.sin(angle)+y1);            // Calculate the new y-coordinate for testing        if (map[Math.floor(y/tileSize)][Math.floor(x/tileSize)] == 1) {  // Check to see if the current point's relative tile is '1' or '0'            break;                              // Exit the loop if the tile is a '1'. Upon exitting, `x` and `y` maintain the coordinates        }            hitBitmap.setPixel32(x, y, 0xFF666666);       // (Eye-Candy)    }        hitBitmap.fillRect(new Rectangle((pos==dist?x2: x)-1, (pos==dist?y2:y)-1, 3, 3), pos==dist?0xFF0000FF:0xFF000000);    // (Eye-Candy)    return pos==dist;                                          // Will return true if the target was reachable and false otherwise.}//****************************************************************************************//*********************************************************// Player Movement - Can't be assed commenting all of this.function movePlayer() {    player.xspd += Key.isDown(Key.RIGHT)?1: (Key.isDown(Key.LEFT)?-1:0); player.xspd = Math.abs(player.xspd)>tileSize?tileSize*player.xspd/Math.abs(player.xspd):player.xspd;    player.yspd += Key.isDown(Key.DOWN)?1: (Key.isDown(Key.UP)?-1:0); player.yspd = Math.abs(player.yspd)>tileSize?tileSize*player.yspd/Math.abs(player.yspd):player.yspd;    if (!Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) { player.xspd *= Math.abs(player.xspd)<0.1?0:0.8; }    if (!Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) { player.yspd *= Math.abs(player.yspd)<0.1?0:0.8; }    var xL:Number = Math.floor(player.x / tileSize); var xR:Number = Math.floor((player.x+tileSize-1) / tileSize);    var yT:Number = Math.floor(player.y / tileSize); var yB:Number = Math.floor((player.y+tileSize-1) / tileSize);    var maxL:Number = xL*tileSize; var maxR:Number = xR*tileSize;    var maxU:Number = yT*tileSize; var maxD:Number = yB*tileSize;    var cL:Boolean = !(map[yT][xL-1]==1 || map[yB][xL-1]==1);    var cR:Boolean = !(map[yT][xR+1]==1 || map[yB][xR+1]==1);    var cU:Boolean = !(map[yT-1][xL]==1 || map[yT-1][xR]==1);    var cD:Boolean = !(map[yB+1][xL]==1 || map[yB+1][xR]==1);    var xmove:Number = player.xspd; var ymove:Number = player.yspd;    if (!cL && player.x+player.xspd < maxL) { xmove = maxL - player.x; player.xspd = 0; }    if (!cR && player.x+player.xspd > maxR) { xmove = maxR - player.x; player.xspd = 0; }    if (!cU && player.y+player.yspd < maxU) { ymove = maxU - player.y; player.yspd = 0; }    if (!cD && player.y+player.yspd > maxD) { ymove = maxD - player.y; player.yspd = 0; }    player.x += xmove; player.y += ymove;}// Call Everything_root.onEnterFrame = function() { movePlayer(); drawObjects(); lineOfSite(player.x+tileSize/2, player.y+tileSize/2, _xmouse, _ymouse); }


Dam, smilies make it difficult to post code

Update:
Problems upload .swf at the moment, so here's the .fla:

View Replies !    View Related
MC From Point A To Point C Curving Via Point B
Hi,

I need to move a clip from point A to Point C, but I want it to curve out gradually then two thirds of the way up I want it to come back in more sharply, but slowing down all the way.

I can get the user to define the C point, which would work out the speed of the clip, and i want the user to define the extent of the curve. any ideas?

I know there are a few bezier curves going around, how can they be translated into a math loop on a clip to move.

cheers
tim

View Replies !    View Related
Mouse Point At Target/follow Point "challenge"
hiya.

I ve got a self made cursor to use on my flash site. Ihave mad it follow the mouse and Ive used code to hide the mouse. so at the momment it looks like a custom cursor. great!

What I want to happed is to have this new cursor (arrow) always point at a certain point on the screen (say for now the center) so say the cursor was on the left of the screen it would point right (to the center.)

Im guess this would be fairly simple but I just cant get my hea round it.

Any helpers???


I would have thought it would be simillar to the script which has and object fix in a postion but always point to the mouse location.

View Replies !    View Related
Uploading: From Point A To Point B?
This isn't so much a question geared towards Flash as it is pertains to Dreamweaver, but they're both made by the same company so I figure this is the best forum for my question. So here's my question:
I got a site made in Flash. I have server space purchased somewhere out there. I'm going to use Dreamweaver as my compiler. In the dreamweaver help section it says your page must be labeled "index.html" to be uploaded correctly. Does this mean that my published flash file (.swf) should be renamed "xyz/index", or should I just change the published html's filename to "xyz/index.html"?? Where does this "index.html" come into play?
Help! I'm not sure how to get from Point A to Point B!

View Replies !    View Related
Point A To Point B Lines
I'm looking for some help to be able to draw lines on a flash movie by clicking two points (Point A to Point B). I've seen many posts with help with drawing but nothing exactly like what I need.

Any push in the right direction will be appreciated.

View Replies !    View Related
Ease To Point B Via Point C
Hi guys ... does anyone know a formula that allows you to ease to a given position via another set position? .. for example i might have an mc with its xscale set at 47 ... i want to be able to ease its xscale to 100 via 234.

I have tried using an ease in and ease out tween together, but can't get the smooth motion that i want, i would like to be able to do this with just one tween.

thanks in advance

Bongo

View Replies !    View Related
Stop Actionscript Function At A Specific Frame (stop Looping)
I want to stop an effect at a specific frame but I dunno how.
Do I have to put something in the code?
I'm confused.
Or just tell me how to stop it from looping.
Edit:
Is it possible to attach this to a movie clip? Then i can stop it or use onEnterFrame and then escape();
I actually have no idea what I am talking about. /Edit

Here is one of the code I borrowed:

MovieClip.prototype.placeInSpace = function(id) {
var ratio = this.focaldistance / Math.sqrt(this[id].z * this[id].z);
this[id]._x = this[id].x * ratio;
this[id]._y = this[id].y * ratio;
this[id]._xscale = this[id]._yscale = 1000 / this[id].z;
}
MovieClip.prototype.randomPlace = function(id) {
var radius = this.rmin + (this.rmax - this.rmin) * Math.random();
var polar = 2 * Math.PI * Math.random();
this[id].x = radius * Math.cos(polar);
this[id].y = radius * Math.sin(polar);
this[id].z = this.zmin + (this.zmax - this.zmin) * Math.random();
}

Here's the other code cause I can use two in my movie:
function mover() {
// Move the particle over time
this._y += this.speed;
this._yscale += 10;
this.speed++;
if (this._y>500) {
this._y = 0;
this.speed = Math.random()*10;
this._yscale = 100;
}
}
function starField(x, y, n) {
// Generate a starfield of specified dimensions with n stars
for (var i = 0; i<n; i++) {
var star = this.createEmptyMovieClip("star"+i, i);
var dot = star.createEmptyMovieClip("dot", 0);
star._rotation = Math.random()*360;
star._x = x;
star._y = y;
dot.lineStyle(0, 0xFFFFFF, 100);
dot.moveTo(0, 10);
dot.lineTo(0, 15);
dot.onEnterFrame = mover;
dot.speed = Math.random()*10;
}
}
starField(275, 200, 100);

View Replies !    View Related
[F8] Movie Plays > Stop > Reverse > Stop > Play
I am fairly new to involved action scripting. I have successfully scoured flashkit threads for years to get my answers but this one has been driving me crazy for the past couple days. I have tried numerous solutions but none of them do exactly what I am trying to do.

I am creating an online portfolio that I want to control with two buttons that will play forward on release and stop at every piece unless the user is pressing and holding down - I also would like the scrolling animation to play in reverse on press and stop at every piece unless press and hold which happens to be skateboards in this section. I am posting the .fla for this section. This is what I have been able to accomplish so far. I moved everything into the main timeline from a movie clip because I could not get that to work at all. Should I move it back to movie clip? I also want it to stop at the first board.

here is the code I was able to peice together that just plays continously without stops.

Empty movie clip on second frame.

PHP Code:




onClipEvent (enterFrame)
{
    if (_root.goBack)
    {
        _root.prevFrame();
    }
    else
    {
        _root.nextFrame();
    }
    _root.frameNo = "Frame : " + _root._currentFrame;
}







Forward button.

PHP Code:




on (press)
{
    _root.goBack = false;
}







Reverse Button.

PHP Code:




on (press)
{
    _root.goBack = true;
}







I have only done basic stops; goToAndPLay, getURL and such I am a little out of my league here but I started the ball rolling and would like to make this work as I intended. Any help making this do anything close to what I am describing would be much appreciated

View Replies !    View Related
How To Make The Wings Of A Fly Stop When The Flash Movie Stop?
Hello,

I made a simple "Fly Flying" flash animation. The wings of the fly are moving up and down while the fly is flying from one location to the other. My problem is:

The wings of the fly are still moving up and down when the fly is landed on the ground. I tried to add a stop(); action script at the last frame. However the wings are still moving even the movie is stopped.

How can I make the wings stop moving when the flash movie is stop? Please download and take a look at my flash file (fly_flying.fla):

http://space.uwants.com/batch.download.php?aid=313219

Thanks and best regards

Alex

View Replies !    View Related
Play "in Point" To "out Point" Of Mp3 (audio Editor)
I am trying to create an audio editor/player. I want to be able to load a mp3 sound (which i can do) but then play it from lets say a set "in point" to the set "out point" and only that part.

The way i have these set is i have a 15 second slider that you can slide across the waveform. I am able to get the in point and out point via actionscript but what i need to do is lets say i'm at "in point" number 56 which would be 56 seconds into the song and the out point is set to "71" i want it so that when i scrub to that position in the waveform to play just that selection when i hit play.

So basically i am trying to get it to play a selection of the audio piece rather then the whole thing.

What i'm trying to pretty much kind of do is exactly what the itunes ringtone creator does in the new version of itunes. Any code or actual fla example would be greatly appreciated.

View Replies !    View Related
How Can I Stop Flash From Looping And Stop On The Last Frame
I am having a problem with looping. I created a flash file and published it. I only want it to play through once and stop on the last frame. I can't get it to stop, it keeps looping through and playing the movie.

I have tried to add a layer that has some script in it with a start and a last tag on frame 1 and frame 310 there is 315 frames total.

the action script was
<code>
// this was in the first frame
ifFrameLoaded ("last") {
gotoAndPlay("start");
}

//this was in the second frame
gotoAndPlay(1);

//this was in the last frame 315
stop ();
</code>

your help is greatly appreciated.

skj

View Replies !    View Related
Cannot Stop Movie Clip - This.stop() Confusion
Hello,

In my pong game when someone scores a goal I want the ball to pause in the middle of the screen, wait xx seconds and then randomly move.


Code:
// Return to kick off position
this.stop();
this._y = 325;
this._x = 275;
a = 0;
var myInterval = setInterval(this, "wait", 30*1000);
This calls function wait that simply uses this.play(); to allow the ball to move again.(See below)


Code:
onClipEvent (load) {
this.wait = function() {
this.play();
clearInterval(myInterval);
};
}
However I cant EVER get the ball symbol to stop no matter what I do.

Ive included all the code attached to the clipevent for the ball below.
Im thinking it must be due to the nested loops or somethings, very very confused


Code:
onClipEvent (load) {
this.wait = function() {
this.play();
clearInterval(myInterval);
};
}
onClipEvent (enterFrame) {
//Kick Off, play whistle and select random direction from 4 diagonals
if (a == 0) {
_root.kickoffwhistle.start();
//Use variable to ensure random numbers are generated only once per game
var randNumber1:Number = Math.pow(-1, Math.floor(Math.random()*2));
//-1 ^1 or ^2 = 1 or -1
var randNumber2:Number = Math.pow(-1, Math.floor(Math.random()*2));
//move it on the y axis at -1 or 1 & //move it on the x axis at -1 or 1
this._y += this.randNumber1;
this._x += this.randNumber2;
++a;
//set a trigger to increment so only actioned once.
}
if (randNumber1>0) {
this._y += this.yspeed;
//move it on the y axis at the set speed
} else {
this._y -= this.yspeed;
//move it on the y axis at the set speed
}
if (randNumber2>0) {
this._x += this.xspeed;
//move it on the x axis at the set speed
} else {
this._x -= this.xspeed;
//move it on the x axis at the set speed
}
// Ball(this) collides with PL1 and ball travelling upwards then deflect off randomly {
if (this.hitTest(_root.P1footballman) && this.yspeed<0) {
// Define boundaries for collision detection
var pl1bounds:Object = _root.P1footballman.getpl1bounds(_root);
this._x = Math.round(Math.random()*(pl1bounds.xMax-pl1bounds.xMin))+pl1bounds.xMin;
//Revert direction of ball by using formula below
this.yspeed = this.yspeed*-1;
//Randomly play miss sound effect if ball in goal area
if (this._x>133 && this._x<450) {
var result = Math.round(Math.random()*2);
if (result == 0) {
_root.MissedGoal.start();
}
}
//play football kick & header sound
_root.footballkickorheader.start();
}
if (this.hitTest(_root.cpu) && this.yspeed>0) {
var cpubounds:Object = _root.P1footballman.getcpubounds(_root);
this._x = Math.round(Math.random()*(cpubounds.xMax-pl1bounds.xMin))+cpubounds.xMin;
this.yspeed = this.yspeed*-1;
if (this._x>133 && this._x<450) {
var result = Math.round(Math.random()*2);
if (result == 0) {
_root.MissedGoal.start();
}
}
//play football kick & header sound
_root.footballkickorheader.start();
}
//Roatation properties of the ball
i = getProperty(this, _rotation);
setProperty(this, _rotation, i+5);
//Rotate ball i degees per frame
_this.rotation = i;
//Player Scores routine
//If ball object is beyond defined CPU goal area
if (this._y<75 && this._x>133 && this._x<450) {
_root.goalcry.start();
_root.P1footballman.score++;
//add1 to the cpu score
_root.playertxt = 'PLY: '+_root.P1footballman.score;
//Play start whistle for KICKOFF
_root.kickoffwhistle.start();
//Return to kick off position
this._y = 315;
this._x = 275;
a = 0;
//Stop ball in correct position
this.stop();
//5 seconds then calls function "wait" to use this.play() to move ball
var myInterval = setInterval(this, "wait", 5*1000);
}
//CPU Scores routine
//If ball object is beyond defined Player goal area
if (this._y>470 && this._x>133 && this._x<450) {
_root.goalcry.start();
_root.cpu.score++;
//add1 to the cpu score
_root.cputxt = 'CPU: '+_root.cpu.score;
//Play start whistle for KICKOFF
_root.kickoffwhistle.start();
// Return to kick off position
this.stop();
this._y = 325;
this._x = 275;
a = 0;
var myInterval = setInterval(this, "wait", 30*1000);
}
if (this._x>620 || this._x<5) {
this.xspeed = this.xspeed*-1;
//if it hits an edge inverse the xspeed
_root.bounce.start();
//Play bounce side effect
}
if (this._y>470 || this._y<75) {
this.yspeed = this.yspeed*-1;
//if it hits the top or bottom of pitch inverse the yspeed
_root.bounce.start();
//Play bounce side effect
}
}

View Replies !    View Related
Reset Transformation Point/Set Transformation Point
When I right-click a symbol the options "set transformation point" and "reset transformation point" come up. They don't seem to do anything for me. I thought it would center them or something. This is not the case. I have the white transformation point in one corner in one keyframe and a different corner in another keyframe I click "reset transformation point" on both frames and they don't move.

How do these options work?

View Replies !    View Related
How To Zoom From One Scale/point To Another Scale/point
I'm trying to get this effect where an image is zoomed at a specific scale and point, then it zooms out to another scale and point on a button click.

Check out this site and click on the menu buttons and you'll see what I mean: http://www.so-reckless.com

I figure you can use a motion tween but I'm looking for the script for better effect.

Thanks.

View Replies !    View Related
How To Zoom From One Scale/point To Another Scale/point
I'm trying to get this effect where an image is zoomed at a specific scale and point, then it zooms out to another scale and point on a button click.

Check out this site and click on the menu buttons and you'll see what I mean: http://www.so-reckless.com

I figure you can use a motion tween but I'm looking for the script for better effect.

Thanks.

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved