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




Scripted Movement



Hi,

I'm trying to script movement in a flash presentation I'm doing because tweening is making my file size too big. I don't know much about actionscript but I do understand code. The scenario is I have these drapes opening. The left and the right sides go from the middle of the stage all the way off the stage. I was looking at this scripting tutorial and was using the code below in an attempt to script the blinds but when I tried to put the action/code on more than one blind/movie they all went the same way. How do I script mutiple movie clips to move different ways. Your help is greatly appreciated.



//____________________________________________
//
var totalFrames = 50; // How many frames our tween will take.
var currentFrame = 0; // How many frames have passed so far.
var startX = 250.0; // The starting position of our ball.
var endX = 0; // The ending position of our ball.
var changeInX = endX - startX; // The distance our ball will travel (450 pixels).
left_side3_mc.onEnterFrame = function(){
//
// Note that we have entered another frame
// by adding one to our currentFrame variable.
currentFrame++;
//
// Use our formula to determine how far we need to move the ball.
var currentDistance = startX +(currentFrame/totalFrames) * changeInX;
//
// Move the ball.
this._x = currentDistance;
//
// If 10 frames have passed, stop moving the ball.
if (currentFrame>totalFrames) delete this.onEnterFrame;
}
//____________________________________________

Misslilbit02



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 05-25-2006, 12:07 AM


View Complete Forum Thread with Replies

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

Scripted Movement
Hello
I am super new to actionscript in fact this problem has caused me to want to learn about it so. . .

my problem is:
I have created a flash site
and I wanted a graphic of cloud.png near top of movie to move across
very very slow, then again after a minute or so.

The only problem is I am a tweener! hehe
(not for long i hope) So when I tween it long enough to slow it down
it not only looks bad

IT IS 700 frames long!!!! no way man not gonna!

So I have been looking for hours and cant seem to find a script that fits.

I did find this little box that moves across with no tween WOW:
Action script_______________

onClipEvent (enterFrame) {
speed = .2;
this._x += speed;
}
_________________________________

point 2 it goes the speed i need very very slow
but how do i make it loop with a 30 sec pause in between loops?

thanks
oneshot

Scripted Movement
on my site i use a lot of scripted movement. For some reason ive noticed a lag during playback. Im trying to figure out if its processor lag or if its my hosting service.

Im running an apple g5 so there shouldnt be any problems with processing

will a lot of AS tween slow down the performance of the site?


i also bumped up the fps and its not running near as fast as i would like it too

have a look and let me know what you think

http://www.thewesternmovement.com

Scripted MC Movement..
I have a navigation I am putting together that operates something like this:



--A-----------------B----
MENU : OPTION1 OPTION2



where 'A' symbolizes a pointer that dynamiclly slides along the X axis towards 'B'

I have an invisable movieclip hovering over the text for OPTION2 (location 'B') with the following code:


Code:
on (rollOver){
var spot = 128;
while (_parent.pointer._x < spot) {
_parent.pointer._x = _parent.pointer._x + spot-(spot*.75);
spot = spot-_parent.pointer._x;
}
}
where 'spot' = the .x location of OPTION2(B) and 'pointer' is the instance name of 'A'


I am trying to get a smooth 'ease out' effect, but it just kinda jumps in little increments every time I mouseOver instead of a smooth meovement.

-thanks in advance for any suggestions

MC Scripted Movement
i have a movie clip, and i need to to move from stage right to stage left, and when it hits a certain point i need it to go to a new frame on the main timeline. i didn't want to use a tween any ideas?
thanks in advance

Scripted Movement Help
I'm not sure how to describe my problem clearly but here goes;

I'm messing around with some MC's with scripted movement. I have 3 MC's and 4 buttons three to control the Y pos of the MC's and one to reset the y pos of only the first MC.

The movement script sits in frame one on the timeline and is called by the buttons.

When each of the buttons is pressed the corresponding MC moves to the desired y pos.

This works fine.

The 4th buttons purpose is to move the first MC back. But instead all the MC's move back.

Why ???

I've attached the FLA because I've just read this back to myself and I'm lost already.

Please help.

Biscuit.

Scripted Movement Help
I have run into a problem with my scripted movement for a website that I am developing and I need some help. The problem is that the movement is shaky and I don’t know how to change the code that a friend helped me right to fix the problem. Here is the line of code that scripts the movement.

ActionScript Code:
// move the grid according to which layer is active
    for (j=1; j<=num_grids; j++) {
        _root['copy_'+j].testing = _root['copy_'+j]._name+'('+(Math.round(grid_position[j].z*100)/100)+')';

Here is the rest of the code for the website.

ActionScript Code:
onClipEvent (load) {
    origin_x = 675;
    origin_y = 370;
    // used for perspective - distance from the viewer to the screen
    D = 100;
    num_grids = 9;
    // z pos where current grid should land
    dist = 550;
    grid_position = new Array(num_grids);
    shift_x = new Array(num_grids);
    shift_y = new Array(num_grids);
    // size of movie clip at the origin
    regular_size = _root['main']._width;
    //button position
    _root.dest = 0;
    //duplicate new movie clip
    for (j=1; j<=num_grids; j++) {
        _root.main.duplicateMovieClip('copy_'+j, j);
        _parent['copy_'+j].attachMovie('image'+j,'pix'+j,j);
        grid_position[j] = new Object();
        grid_position[j].x = 0;
        grid_position[j].y = 0;
        grid_position[j].z = j*dist;
        inc = 5;
    }
}
onClipEvent (enterFrame) {
    // move the grid according to which layer is active
    for (j=1; j<=num_grids; j++) {
        _root['copy_'+j].testing = _root['copy_'+j]._name+'('+(Math.round(grid_position[j].z*100)/100)+')';
        // Find where it's supposed to be.
        grid_position[j].destZ = ((j-_root.dest)*dist);
        grid_position[j].z+= (grid_position[j].destZ-grid_position[j].z)*.05;
        if (grid_position[j].z<7) {
            // just right before hitting 0
            _root['copy_'+j]._visible = false;
        } else {
            _root['copy_'+j]._visible = true;
            // calculate the perspective ratio
            perspective_ratio = D/(D+grid_position[j].z);
            // calculate position of grid on computer screen
            perspective_x = grid_position[j].x*perspective_ratio;
            perspective_y = grid_position[j].y*perspective_ratio;
            // update position of movie clip on stage
            _root['copy_'+j]._x = origin_x+perspective_x;
            _root['copy_'+j]._y = origin_y-perspective_y;
            // update size of movie clip
            _root['copy_'+j]._xscale = _root['copy_'+j]._yscale=regular_size*perspective_ratio;
            // set the depth of the clip based on its z-position
            _root['copy_'+j].swapDepths(-grid_position[j].z);
            _root['copy_'+j]._alpha = 650*perspective_ratio;
        }
    }
}

Can anyone please help me?

Scripted Movement Help
iI have 3 varaibles mapx, mapy and mapz sent to an mc "map"
in the map firstframe i have

ActionScript Code:
this.onEnterFrame = function() {
    if ((map._x<>mapx) && (map._y<>mapy) && (map._xscale<>mapz) && (map._yscale<>mapz)) {
//what do i put here to animate map to x y z
    }
    if ((map._x == mapx) && (map._y == mapy) && (map._xscale == mapz) && (map._yscale == mapz)) {
        delete this.onEnterFrame;
    }
};


Cheers
Love u all :P
merry xmass

Scripted Movement In MX
Hi,

in flash 5 i used to use a movieclips timeline and an IF statement to move an object around the screen.

With MX, I'm getting into Functions, and wanted to know how I can animated an object across the screen?

The IF loop doesn't run via a function that I can see, as this doesn't cross a timeline - I've tried a WHILE - but this processes the rule immediately so the object jumps to a location rather than the _root.object._x+1 glide I require.

Any suggestions?

Also, using the lineTo functions - I need to draw a box on the stage (which I can achieve) - I then need to move this box - which I can do. However, i've madea rule to create 4 boxes and using +i to label them.

Problem lies in the WITH (name) element - I can't seem to get a dynamic name to work. EG

name = "NewBox" +1
createEmptyMovieClip (name,i)
with (name) <<<<< this doesn't work!

This has to work in some method, otherwise why offer it if a dynamic name can't be used???

Again any help appretiated

Thanks

Trouble With Scripted Movement Please Help
Hi
I’ve generated a quite simple scripted movement. It moves different movieclips that hold either textfields or images and assigns them randomly different scale, speed, ypos and alpha. They move continously from the right to the left and generate interesting overlaying effects. It works fine, the problem is the undesired overlapping.
Is there a way so that I can prevent two MCs which have the same height from getting the same ypos?
Here’s my code.
In every MC:
onClipEvent (enterFrame) {
var width = this._width;
var finalpos = 0-width;
if (this._x>finalpos) {
this._x = this._x-speed;
}
if (this._x<finalpos) {
this._x = 1000;
_parent.text = "t3";
_parent.newtext();
}
}
the parent.text variable defines the target for the function to assign values. There’s 7 (“t1”, “t2”, “t3”...)at the moment.

The function:
function newtext () {
variation = int(random(5));
alpha = 80 - variation*17;
scale = 100*(variation+1)*1.3;
this[text].speed = variation*1.5 + 1;
this[text]._alpha = alpha;
this[text]._xscale = scale;
this[text]._yscale = scale;
ypos = int(random(201)+250);
ylastpos = ypos;
yheight = this[text]._height;
if ((ypos + yheight) > (450 - yheight/2)) {
this[text]._y = 450 - yheight*1.5;
} else {
this[text]._y = ypos;
}
}
All these MCs are placed in a stripe, therefore the random values (from 250 to 450) and the if statement at the end of the function (it checks that MCs don’t get further than 450)

Really hope someone can help me.

PS Sooorry for the long post

Help With On Rollover Scripted Movement
I have a script that makes an MC (call it MC1) follow the mouse and that's it. How do i call the motion from a button that's inside another MC (call it MC2), such that when you move the mouse over the button, or on rollover, MC1 moves over to the button that's inside MC2 horizontally. This is very much like the menu system in www.eccentris.com under "Detour", except i'm trying to do it horizontally. The script I currently have for the simple mouse following is as follow:




Code:
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._xmouse-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.xChange = Math.round(_root._xmouse-this._x);
_root.xMove = Math.round(_root.xChange/5);
this._x += _root.xMove;
}

Thanks!

Scripted Movement Problem.
I have a couple of buttons following the _xmouse position.
Once one of the buttons have been clicked:
- The clicked button needs to stop following the _xmouse position
- The clicked button needs to move 160 pixels to the left from its current position.

How can i accomplish this?

This is what i've tried:

I can get the MC to stop, no problem.
After this I'm trying to get it to move -160 pixels after stopping this way:


Code:
mx = _x-160;
xspeed = _x-mx/15;
_x = _x-xspeed;


The problem is the 'mx' variable keeps changing, so the button keeps moving to the left, instead of stopping at the desired position.
This is because the code is on a onClipEvent (enterframe) handle, this is needed because it needs to check if certain variables are true before performing the code.

How would you deal with this problem?

Campus Map Help, Scripted Movement And More
hi everyone.

I could really use some help. I am working on designing a flash map for our university campus. Using MX2004. I have a lot working so far, but I am running into some stumbling blocks. I've used flash for a while, but only for simple animations, I'm pretty new to actionscripting but so far have been able to piece together tutorials, examples and so forth to get the functionality I need so far.

However, I need some tips on a few things and I hope this thread can help with the development of this.

The map loads from an external flash file so it can be updated more easily by other people down the road.
I have the controls to move it around and zoom it in by using a slider and some nav buttons, both of which has been hacked together from different examples.

Now, I am trying to create a list of buildings that when clicked on colors the building and moves the view to where that building is located.

I am doing this in the following way:
each building in the imported map is a movie clip comprised of 2 frames, each with a stop(); command. the first frame is the normal color, the 2nd frame the building is colored orange.

in my list, which will be just a list of text buttons, a user clicks once on a building name and it advances the building movie clip frame foward to the next frame, which changes the color, and the next click on the same button moves to the previous frame setting the color back to green.


Problem is, if the user is not zoomed all the way out, they won't see which building is being highlighted. So what I would like, is despite what zoom or x/y position the map is currently at, when they click on a building it moves to a preset x/y coordinate and zoom level that is preset to center that selected building within the viewable area of the map window.

I have the movement and zoom kind of working, but it jumps to it. What i would like is some actionscripted smooth movement toward the preset x and y coordinates from whereever the viewer currently is.

here is the code i'm using right now for when a user clicks on a building name button:


Code:
on (release) {
if (Number(button) == 2) {
_root.mainMap.mainMap.alumnicenter.nextFrame();
_root.mainMap._y = 404; //vertical position
_root.mainMap._x = 457; //horizontal position
_root.mainMap._xscale = 300;
_root.mainMap._yscale = 300;
_root.slider._y = 27; //height of slider on range bar
_root.slider._x = 144.3; //dont change
button = 1;
} else {
_root.mainMap.mainMap.alumnicenter.prevFrame();
_root.mainMap._y = 204; //vertical position
_root.mainMap._x = 457; //horizontal position
_root.mainMap._xscale = 150;
_root.mainMap._yscale = 150;
_root.slider._y = 95; //height of slider on range bar
_root.slider._x = 144.3; //dont change
button = 2;
}
}
the flash file is too big to attach and like i said it pulls from external files, if needed I can package up the folder in a zip file, but here is the latest swf file to give you an idea. http://acketon.com/campus_map1.html

here's what's being replaced: http://www.selu.edu/map this is all part of a major redesign effort of the entire website. Most of which is done or underway, but I have taken this on as a project.

Placement And Movement Of Scripted MC's
ok, so i'm creating MC's on levels to load images into. the x and y positions are where they should be, but i want the mc to come from off stage and move to a position and be able to control the speed at which it moves.

this is what i have so far


Code:
createEmptyMovieClip("mc_1", 1);
mc_1._x = 22
mc_1._y = 5
mc_1.loadMovie("Jewelry/hughes.jpg")
this places the MC at a location, but how do i tell it to move to another location at a particular speed?

many thanks
p13

Scripted Movement (like A Ribbon)
Hi all! Hope you can give me a nudge in the right direction here. I'm looking into making a neat little action for a website. They have 5 coloured ribbons in their logo, which are horizontal across the screen .What I would like to acheive initially is to see the ribbons moving (floating) slowly in the logo.

I am familiar with scripting functions to move / scale movie clips, but I don't really know where to start with this thing. I have looked through some tutorials with scripted motion but they're all a bit naff and not really geared to what i want to do, if you have any pointers / tutorials you can link to then i'd be immensely grateful.

Cheers,

James

Scripted Movement, How To Stop ?
so i have a MC called "pala" and a button called "nappi" .. i have the following script in the first frame of the movie and everything works how it should, but how do i get the "pala" stop moving when it reaches the property -307 ?

var speed:Number = 8;

pala.startMove = function()
{
this.onEnterFrame = function()
{
this._x -= speed;
}
}

pala.stopMove = function()
{
delete this.onEnterFrame
}


nappi.onRollOver = function()
{
pala.startMove();
}

nappi.onRollOut = function()
{
pala.stopMove();
}

Scripted Movement (like A Ribbon)
Hi all! Hope you can give me a nudge in the right direction here. I'm looking into making a neat little action for a website. They have 5 coloured ribbons in their logo, which are horizontal across the screen .What I would like to acheive initially is to see the ribbons moving (floating) slowly in the logo.

I am familiar with scripting functions to move / scale movie clips, but I don't really know where to start with this thing. I have looked through some tutorials with scripted motion but they're all a bit naff and not really geared to what i want to do, if you have any pointers / tutorials you can link to then i'd be immensely grateful.

Cheers,

James

Scripted Movement Along Guide
I was curious if there was a way to animate a movieclip along a motion guide, direction dependent on mouse movement direction.

Thanks

Moving Mask Over Another Scripted Movement Mc
i know this has been talked about, but how is it done?
i have one mc with instance "pic1" and code as follows:

//pic1 code for x and y movement
current_x = getProperty("../pic1", _x);
dif_x = current_x-/ic1x;
setProperty ("../pic4", _x, current_x-(dif_x/2));
current_y = getProperty("../pic1", _y);
dif_y = current_y-/ic1y;
setProperty ("../pic1", _y, current_y-(dif_y/2));


then a mask mc with instance name "mask" and same code:
//mask code for x and y movement
current_x = getProperty("../mask", _x);
dif_x = current_x-/:maskx;
setProperty ("../mask", _x, current_x-(dif_x/2));
current_y = getProperty("../mask", _y);
dif_y = current_y-/:masky;
setProperty ("../mask", _y, current_y-(dif_y/2));

but it will not mask the "pic1" mc. why?

thanks,

nathan

Action Scripted Movement For Rollover.
wanted to know how this was done.
I only know of
_x +=1

That is what i use to move clips i need a more complicated better working way to do this.

Scripted Random Fish Movement
I would really appreciate it if someone could write out a simple script, that would make a movie clip randomly move around the screen like a fish in the water. It will need to rotate and always go head first, and the movement has to be fluid. If someone could write out a simple script or piont in the direction of one that I could look at, I would greatly appreciate it.

Thank you.

MikeMadMan

I am a intermediate scriptor so please explain things somewhat if you write me some code.

Scripted Back & Forth Movement - Simple
Help,

I need to script a movie clip that moves back and forth in my flash file. Currently i'm using the following code but experiencing problems. After it loops back and forth a couple times, it "hicups" and basically isnt doing what i want it to. IS there a simpler way to do this? Thanks in advance, this board is invaluable to my job! - Bo

FRAME ONE (looped with frame 2)

_parent.mousefollow._x +=1;
if (_parent.mousefollow._x > 60)
{gotoAndPlay(3);}
play();

FRAME THREE (looped with frame 4)

_parent.mousefollow._x -= 1;
if (_parent.mousefollow._x < 39)
{gotoAndPlay(1);}
play();

Scripted Movement From Multidimensional Array
hi

I was wondering if you guys could shine some light on a little problem im having:

Ive got a movieclip which when you rollover it will move along a specified line. The movement works, but it only goes to the last coordinates from the array, where it gets the _x and _y values from.

I have tried SetInterval() and this only delayed the time it went from it initial position to the last position.

Do you guys have any idea as how i can get movement?

The array holding coordinates:

ActionScript Code:
//a point - of pointX and pointY variables
var point:Array = new Array(pointX, pointY);

//x and y coordinates for ball to follow line
var pointX:Array = [469, 439, 428, 423, 418, 412, 405, 399, 392, 361, 355, 352];
var pointY:Array = [114, 122, 124, 124, 123, 120, 114, 112, 114, 133, 135, 135];


The onrollover function:

ActionScript Code:
ball_mc1.onRollOver = function()
{
    Move();
}


The function that moves the movieclip along these coordinates:

ActionScript Code:
function Move()
{
    var pointIter:Number;   //iterator for point array
    var iterX:Number;      //iterator for pointX array inside point

    //loops through all elements of the point array
    for(pointIter =0; pointIter < 1; pointIter++)
    {
        //loops through the elements of the pointX array and pointY
        for(iterX = 0; iterX < point[pointIter].length; iterX++)
        {
            ball_mc1._x = point[pointIter][iterX];
            ball_mc1._y = point[pointIter+1][iterX];           
        }
       
    }
   
}

any help with this would be fantatstic

Cheers!

Simple Scripted MC Movement/Easing...
Okay, I quit. I've tried incrementing _x, startDrag's with easing...nothing. Anyone that can help explain how to code the little red bar for the navigation on this site ( http://www.brandnewrock.com/index.php ) will become my hero.

I'm kind of new, kind of not new...which is why I feel like an *** posting this question, because I SHOULD KNOW THIS.

Controlling Placement And Movement Of Scripted MC's
ok this is the whole thing i'm trying to do

i need to have movie clips created at certain intervals. i do not understand how to set, call or clear intervals yet.

a MC is created via scripting. it is positioned in the middle of the movie using exact x and y positions. after 2 seconds, that first mc(mc_1) moves to another position and a second empty mc(mc_2) is created under it, loading a different image, and then moves to it's position of exact x and y position.
after 2 seconds a third mc(mc_3) is created and moves from under mc_2 to it's exactly x and y position.
after 2 seconds a fourth mc(mc_4) is created and moves from under mc_3's position to it's own exact x and y positions

it sits like this for 8 seconds. after 8 seconds, mc_1 and mc_2 both move off stage to the right. then load in different images and move back to their original x and y positions from the left of the stage.

2 seconds passes and mc_3 and mc_4 both move off stage to the right. then load in different images and move back to their original x and y positions from the left of the stage.

8 seconds after this occurs, mc_1 and mc_2 do their thing all over again loading in yet another image set...etc ad naseum.

does that make sense? i know it's a lot of help to ask for but i'm totally stuck.

this is the scripting that i have so far

Code:
createEmptyMovieClip("mc_1", 10);
mc_1._x = 22
mc_1._y = 5
mc_1.loadMovie("Jewelry/hughes.jpg")

createEmptyMovieClip("mc_2", 9);
mc_2._x = 202
mc_2._y = 5
mc_2.loadMovie("Jewelry/Large-Coral-Ring-w-leaf-pat.jpg")

createEmptyMovieClip("mc_3", 8);
mc_3._x = 22
mc_3._y = 185
mc_3.loadMovie("Jewelry/Kitty-Catapillar.jpg")

createEmptyMovieClip("mc_4", 7);
mc_4._x = 202
mc_4._y = 185
mc_4.loadMovie("Jewelry/Opal-&-Diamond-Pendant.jpg")
many thanks
p13

Simple Scripted MC Movement/Easing...
Okay, I quit. I've tried incrementing _x, startDrag's with easing...nothing. Anyone that can help explain how to code the little red bar for the navigation on this site ( http://www.brandnewrock.com/index.php ) will become my hero.

I'm kind of new, kind of not new...which is why I feel like an *** posting this question, because I SHOULD KNOW THIS.

Strange Problem With Scripted Movement
The script below returns _yscale as being 195,395,115 etc. It need to be 190,390,115 etc. Very strange since no part of the script or the array holds anthing finishing in 5.
~Script:

ActionScript Code:
this.onEnterFrame = function() {
    if (map._x != mapx || map._y != mapy || map._xscale != mapz || map._yscale != mapz) {
        animateMap(mapx, mapy, mapz);
    } else {
        delete this.onEnterFrame;
    }
};
function animateMap(x, y, z) {
    if (Math.ceil(map._xscale)<z) {
        map._xscale += 20;
    } else if (Math.ceil(map._xscale)>z) {
        map._xscale -= 20;
    }
    if (Math.ceil(map._yscale)<z) {
        map._yscale += 20;
    } else if (Math.ceil(map._yscale)>z) {
        map._yscale -= 20;
    }
    if (Math.ceil(map._y)<y) {
        map._y += 10;
    } else if (Math.ceil(map._y)>y) {
        map._y -= 10;
    }
    if (map._x<x) {
        //&& (map._xscale == mapz*100) && (map._yscale == mapz*100)) {
        map._x += 10;
    } else if (map._x>x) {
        //&& (map._xscale == mapz*100) && (map._yscale == mapz*100)) {
        map._x -= 10;
    }
    trace("mapx= "+map._x);
    trace("mapy= "+map._y);
    trace("mapxscale= "+map._xscale);
    trace("mapyscale= "+map._yscale);
}
stop();

~Array:

ActionScript Code:
// -------------Country-----_x--_y-_z
country[0] = ["United State", -190, -300, 500];
country[1] = ["Afghanistan", -530, -320, 600];
country[2] = ["Albania", -420, -320, 600];
country[3] = ["Algeria", -350, -350, 600];
country[4] = ["Andorra", -320, -360, 600];
country[5] = ["Angola", -420, -490, 600];
country[6] = ["Alaska", 20, -150, 500];
country[7] = ["Argentina", -130, -460, 500];
country[8] = ["Armenia", -380, -230, 500];
country[9] = ["Australia", -640, -420, 500];
country[10] = ["Austria", -360, -220, 600];
country[11] = ["Azerbaidjan", -420, -250, 600];
country[12] = ["Bahamas", -110, -300, 600];
country[13] = ["Bangladesh", -530, -300, 600];
country[14] = ["Belarus", -380, -170, 600];
country[15] = ["Belgium", -350, -200, 600];
country[16] = ["Belize", -100, -300, 600];

very strange. I have spent the past couple of hours tinkering about to no avil .

Cheers
Paul

Scripted Motion - Simulating Upstream Movement
... been a while since I visited Kirupa! Hello all

How would you go about coding something like the waves in the header on this page?
http://www.trts.com/radio/radio.html

I'm hoping to write something that will look a bit like eels swimming upstream but wasn't quite sure where to start ... any pointers would be much appreciated. Thanks!

Tom

Scripted Movement Over Time Period/frame Length
i'm using this as to move an mc across the screen on the x coordinate:

code:
onClipEvent (load) {
//set initial x pos of clip
this._x = 0;
}

onClipEvent(enterFrame){
//this moves our clip 1 pixel to the right every frame
//up to a certain point
if (this._x<300)
{
this._x+=1;
}
}


I need to adjust this so that the movement takes place over an alotted time period or a defined frame length. Any ideas?

MX2004: Campus Map, Smooth Scripted Movement And Other Problems
hi everyone.

I could really use some help. I am working on designing a flash map for our university campus. Using MX2004. I have a lot working so far, but I am running into some stumbling blocks. I've used flash for a while, but only for simple animations, I'm pretty new to actionscripting but so far have been able to piece together tutorials, examples and so forth to get the functionality I need so far.

However, I need some tips on a few things and I hope this thread can help with the development of this.

The map loads from an external flash file so it can be updated more easily by other people down the road.
I have the controls to move it around and zoom it in by using a slider and some nav buttons, both of which has been hacked together from different examples.

Now, I am trying to create a list of buildings that when clicked on colors the building and moves the view to where that building is located.

I am doing this in the following way:
each building in the imported map is a movie clip comprised of 2 frames, each with a stop(); command. the first frame is the normal color, the 2nd frame the building is colored orange.

in my list, which will be just a list of text buttons, a user clicks once on a building name and it advances the building movie clip frame foward to the next frame, which changes the color, and the next click on the same button moves to the previous frame setting the color back to green.


Problem is, if the user is not zoomed all the way out, they won't see which building is being highlighted. So what I would like, is despite what zoom or x/y position the map is currently at, when they click on a building it moves to a preset x/y coordinate and zoom level that is preset to center that selected building within the viewable area of the map window.

I have the movement and zoom kind of working, but it jumps to it. What i would like is some actionscripted smooth movement toward the preset x and y coordinates from whereever the viewer currently is.

here is the code i'm using right now for when a user clicks on a building name button:

Code:
on (release) {
if (Number(button) == 2) {
_root.mainMap.mainMap.alumnicenter.nextFrame();
_root.mainMap._y = 404; //vertical position
_root.mainMap._x = 457; //horizontal position
_root.mainMap._xscale = 300;
_root.mainMap._yscale = 300;
_root.slider._y = 27; //height of slider on range bar
_root.slider._x = 144.3; //dont change
button = 1;
} else {
_root.mainMap.mainMap.alumnicenter.prevFrame();
_root.mainMap._y = 204; //vertical position
_root.mainMap._x = 457; //horizontal position
_root.mainMap._xscale = 150;
_root.mainMap._yscale = 150;
_root.slider._y = 95; //height of slider on range bar
_root.slider._x = 144.3; //dont change
button = 2;
}
}
the flash file is too big to attach and like i said it pulls from external files, if needed I can package up the folder in a zip file, but here is the latest swf file to give you an idea. http://acketon.com/campus_map1.html

here's what's being replaced: http://www.selu.edu/map this is all part of a major redesign effort of the entire website. Most of which is done or underway, but I have taken this on as a project.

Mouse-movement Triggers Background Movement - Help Me Find Tutorial
I want to learn how to make an image react on my mouse-movement, so you get the effect as if you're looking around. You move the mouse to the right, and the image on the screen moves to the right, etc. I've seen an example of that on http://www.center-of-the-world.com/ - but I don't know how to find a tutorial for that on the Flashkit-site. Can anyone help?

Capturing Mouse Movement/locking Out A Direction Of Movement
does anyone have a good solution in AS 2 for simulating horizontal and vertical finger gestures like on an iPhone?

I have a Mouse listener that calculates movement in both directions and whichever one is larger in value (primary movement of mouse) then it locks out the other using a boolean value. And then once the mouseUp event is triggered, it sets the values to true again to listen for another horizontal or vertical gesture movement.

the problem I'm running into is that every once in awhile while I'm "gesturing" or moving the mouse in a particular direction, I'll get some funky results which clues me into that the other direction might not being totally locked out.

Make any sense?

Flowing Mc Movement Opposite Of Mouse Movement
I have a mc (fStrip) which looks like a piece of filmstrip with thumbnail images in it. I want this mc to move when the users mouse is positioned over it, but I only want it to move only along it's x-axis and in a direction opposite that of the mouse. And I want it to move or flow smoothly.

I've been trying to figure this out (see my lame attempt below) but without much luck. Can anyone help me out? Thanks.


onClipEvent (mouseMove) {
buffer=20 //movement buffer
mousePos=_root.fStrip._xmouse //store mouse position
if (mymouse!=_root.fStrip._xmouse){ //if the mouse has moved
diff=mymouse-_root.fStrip._xmouse; //find amount of movement
_root.fStrip._x-=diff/buffer; //buffer & set strips movement
updateAfterEvent(); //adding this makes the movement cleaner
}
}

Image Movement Based On Mouse Movement
I have my Flash canvas. In the Canvas I have an image that's centered and larger than the canvas. Obviously the entire image isn't shown. How can I use actionscript to move the image according to where the mouse is? So if I move my mouse to the top right corner I want the image to move accordingly to display the top-right corner (obviously in a smooth fashion . I tried looking for examples but wanted to know if anybody out there new.

Any ideas?

Little help and thanks in advance!
Brian

Ants Movement (based On Snow Movement)
Hey! I have a question for those who think they can help and might have the time to do so. I wish to get the effect of ants scuttering across the screen or up a tree, I have not decided which direction yet. I started with the tutorial code for the snow effect from kirupa, and changed it around to fit the little vector ant I created. The way I have it now looks pretty good, but the movement is a little too fluid. They obviously move in sinusoidal paths bc the code tells them to. I have about 20 copies of the main obj, and they're all a little different in size and specs (speed, transparency, etc) but what I was wondering was if there is any way I can change the code to make it a little more hectic, or erratic, not so fluid. If there is no way of doing so, it looks pretty good right now. If there is, however, I think it could look awesome. here's the code I'm using for the object.

onClipEvent (load) {
//stage
movieWidth = 850;
movieHeight = 50;

//mods for ants
i = 1+Math.random()*5;
k = 1.2*(-Math.PI)+Math.random()*Math.PI;

//each ant diff
this._xscale = this._yscale=38+Math.random()*30;
this._alpha = 75+Math.random()*100;
this._y = -10+Math.random()*movieHeight;
this._x = -10+Math.random()*movieWidth;
}
onClipEvent (enterFrame) {
rad += (k/70)*Math.PI;
this._y -= Math.cos(rad);
this._x += i;
if (this._x>=movieWidth) {
this._x = -3;
}
if ((this._y>=movieHeight) || (this._y<=0)) {
this._y = -2+Math.random()*movieHeight;
this._x = -3;
}
}

(I apologize for posting the code without one of those code boxes ppl use, I do not know how to do that yet....)

Any help is greatly appreciated! I wanted to congratulate everyone here at kirupa for having a great community, and great help to those that need it. I am so glad to be a part of it.

Luke

Object Movement Based On Mouse Movement
Not sure how to word this but. I have a object on the stage lets say that is 300 pixels wide. The actual stage is only 100px wide. I want to be able to "pan" the object left and right based on mouse position/movement. I saw a tutorial for it a while back but cant seem to find it. Anyone have a link to a tut or can throw out a little source code? It would be greatly appreciated.

Ants Movement (based On Snow Movement)
Hey! I have a question for those who think they can help and might have the time to do so. I wish to get the effect of ants scuttering across the screen or up a tree, I have not decided which direction yet. I started with the tutorial code for the snow effect from kirupa, and changed it around to fit the little vector ant I created. The way I have it now looks pretty good, but the movement is a little too fluid. They obviously move in sinusoidal paths bc the code tells them to. I have about 20 copies of the main obj, and they're all a little different in size and specs (speed, transparency, etc) but what I was wondering was if there is any way I can change the code to make it a little more hectic, or erratic, not so fluid. If there is no way of doing so, it looks pretty good right now. If there is, however, I think it could look awesome. here's the code I'm using for the object.

onClipEvent (load) {
//stage
movieWidth = 850;
movieHeight = 50;

//mods for ants
i = 1+Math.random()*5;
k = 1.2*(-Math.PI)+Math.random()*Math.PI;

//each ant diff
this._xscale = this._yscale=38+Math.random()*30;
this._alpha = 75+Math.random()*100;
this._y = -10+Math.random()*movieHeight;
this._x = -10+Math.random()*movieWidth;
}
onClipEvent (enterFrame) {
rad += (k/70)*Math.PI;
this._y -= Math.cos(rad);
this._x += i;
if (this._x>=movieWidth) {
this._x = -3;
}
if ((this._y>=movieHeight) || (this._y<=0)) {
this._y = -2+Math.random()*movieHeight;
this._x = -3;
}
}

(I apologize for posting the code without one of those code boxes ppl use, I do not know how to do that yet....)

Any help is greatly appreciated! I wanted to congratulate everyone here at kirupa for having a great community, and great help to those that need it. I am so glad to be a part of it.

Luke

Sluggish Movement With ActionScripted Movement...
I really enjoy using the following bit of code for quick little flash animations:

=======================================

onClipEvent (load) {
_root.targXscale = 50;
_root.targYscale = 200;
}
onClipEvent (enterFrame) {
cXscale = this._xscale;
cYscale = this._yscale;
difXscale = cXscale-_root.targXscale;
difYscale = cYscale-_root.targYscale;
setProperty(this, _xscale, cXscale-(difXscale/5));
setProperty(this, _yscale, cYscale-(difYscale/5));
}


=======================================

It comes straight from the tutorials ("Basic Animation via ActionScript"). Anyways, whenever I view the .swf (via IE) on my computer (2.4 Ghz / 512 MB RAM), it looks great... better than great... it looks AWESOME! But, if I check it out at work (550 Mhz, 256 MB RAM) it looks terrible. It's choppy, mouse movement is sluggish, and the entire animation looks like it's running at 1 or 2 FPS.

I know it can't be completely dependent on the computer speed, b/c I've seen other flash sites that look great on the slower PC. Even some of the non-scripted movements are sluggish on my work PC... what the?! Is there a snippet of code that would / could help?

Scripted Rotation
I have a good understanding on x and y, alpha, height and width, and elasticity, but I want my clip to rotate into a specified position on button click.

Here is what I'm using on the clip now:
onClipEvent (enterFrame) {
_x += (x-_x)/20;
_y += (y-_y)/7;
xvel = xvel*.99+(x-_x)*.99;
_x += xvel;
yvel = yvel*.25+(y-_y)*.35;
_y += yvel;
}

and for a button click I would use:
on (press) {
_root.back.x = 0;
_root.back.y = 100;
_root.back.height = 100;
_root.back.width = 550;
}

Now how do I add rotation to this baby?
as always, thanks in advance. -John

Scripted Blur
Scripted blur!!

Do you know if there is a way of scripting blurred motion for animations. I've seen the effect on the web and don't think it's a series of animated bitmaps?

Anybody know if such a script exsist's?

Thanks in advance

Nick

Scripted Alpha
I have a mc, that fades up from 0 alpha to 100 and then there is a counter and when the counter reaches 300 the alpha is meant to fade down again and stay down . but I cant get it to fade back down and stay at 0. Can anyone help please

onClipEvent (load) {
looped =300 ;
count=0;
this._alpha=0;
this._visible=false;
}
onClipEvent (enterFrame) {
this._visible=true;
this._alpha+=1;
if (this._alpha>=100) {
this._alpha=100;
count+=1;
if ( count==looped ) {
this._alpha-=1;
if ( this._alpha<=0 ) {
this._alpha=0
}


}
}

}

Scripted Delay ?
I was wondering if it is possible to script a time delay in frames.

In other words, I have a text field that I want to appear 10 frames after a button is clicked. is this possible??

Scripted Listbox
I'm trying to create a listbox that will add and remove items by script and not by user interface).

Has anyone seen, developed, or know of a working sample?

The basic premis is to constantly list the active users on the site, and create a messaging system. I'm a wiz at the server back-end, but a back-end at the flash front-end (if you know what i mean, wink, wink).

Any help appreciated.

Scripted Tweening
Hi everyone,

I'd like to script the tween of a MC between two coordinates without affecting the stage's timeline.

Is this possible with actionscripting ?

I'd like it to go from point A to point B (let's say _x = 30 to _x = 60), in a nice and smooth tweening fashion, all of that with scripting.

Thanks for your time, Simon.

Scripted Navigation
I;m trying to do some thing like http://www.sym-music.com minimize panel navigation effec.Oh and http://www.ego7.com sorta has something similar.Im starting to think that my script isnt the best approach.
here it is http://www.noinetattoo.com/MinimizeExperiment.zip


any help would be great!!!

Scripted Animation?
Hi pleasee help!!

I need to make a 'snow falling effect animation' and have been having problems when I motion tween my graphic lots of times, basically its slowing down the processsor and making the animation run very slow.

Can anyone help me write some code that randomly postitions the snowflakes at random times and then animates them down the page (top to bottom) rotating at they move?

????

Scripted Motion...
hi, i got 2 cases here....

1. once the frame is loaded... i want to tell the instance to move , but the movement is a scripted motion... it's not tweens on the timeline...

and
2. once the frame is loaded,... i want to change a fade in/out of the instance from tweens on the timeline... into a scripted motion...
since it means much on the file size...

the problem in these 2 cases is, i m not sure how to activate the movement once the frame is loaded... i did try onLoad event method... but it's not working...

basically , all i wanna do is some intro similar to www.ysl.com

Scripted Masks
Funny Story,

I scripted an MC to perform typical movement and then thought it would work perfect as a MASK over my scene below.

Nada.

Why won't *Scripted* MCs perform on MASK layers ?

Yeah, I just don't get it guys'N'gals....

THX.

Scripted Motion?
Can someone please give me a tutorial or a link for "scripted motion". I just want to learn a little about it because I just learned that I can get smoother animation by using that other than using tweens? Help.

How Do You Do This (scripted Animation)?
anyone know where to find the code or a tutorial to produce an effect like this?:
http://utilityinc.com/ (click on "words to play")

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