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




Creating Multiple Movieclips And Controlling Them



Okay so i have actionscript that creates a ball and places it outside of the stage and moves it across the stage for a game im trying to make and i have it working for 1 ball but i want to be able to create another ball that moves at the same time as the first... please respond if you don't understand. I'll show you waht i have for it working for one ball and what i have for what i tried to do which resulted in it not moving the balls at all.

var i = 0;
var speed = 30;
var x1 = Math.floor(Math.random() * 550);
var x2 = Math.floor(Math.random() * 550);
var y1 = -50;
var y2 = 450;
var xdistance = x2 - x1;
var ydistance = y2 - y1;
var xmove;
var ymove;
setInterval(drawBall, 10000);
function drawBall()
{
i++;
_root.attachMovie("ball", "ball" + i, getNextHighestDepth());
createball("ball"+i);
}
function createball(ball)
{
trace(ball);
var rand = Math.floor(Math.random() * 4);
if (rand == 1)
{
//from top
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y1;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
else if (rand == 2)
{
//from bottom
ydistance = y1 - y2;
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y2;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
else if (rand == 3)
{
//from left
x1 = -50;
x2 = 600;
y1 = Math.floor(Math.random() * 400);
y2 = Math.floor(Math.random() * 400);
xdistance = x2 - x1;
ydistance = y1 - y2;
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y2;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
else
{
//from right
x1 = 600;
x2 = -50;
y1 = Math.floor(Math.random() * 400);
y2 = Math.floor(Math.random() * 400);
xdistance = x2 - x1;
ydistance = y1 - y2;
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y2;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
}


and for the working for one ball i have...


var i = 0;
var speed = 30;
var x1 = Math.floor(Math.random() * 550);
var x2 = Math.floor(Math.random() * 550);
var y1 = -50;
var y2 = 450;
var xdistance = x2 - x1;
var ydistance = y2 - y1;
var xmove;
var ymove;
_root.attachMovie("ball", "ball", getNextHighestDepth());
createball();
function createball()
{
var rand = Math.floor(Math.random() * 4);
if (rand == 1)
{
//from top
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y1;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
else if (rand == 2)
{
//from bottom
ydistance = y1 - y2;
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y2;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
else if (rand == 3)
{
//from left
x1 = -50;
x2 = 600;
y1 = Math.floor(Math.random() * 400);
y2 = Math.floor(Math.random() * 400);
xdistance = x2 - x1;
ydistance = y1 - y2;
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y2;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
else
{
//from right
x1 = 600;
x2 = -50;
y1 = Math.floor(Math.random() * 400);
y2 = Math.floor(Math.random() * 400);
xdistance = x2 - x1;
ydistance = y1 - y2;
xmove = xdistance / speed;
ymove = ydistance / speed;
ball._x = x1;
ball._y = y2;
_root.onEnterFrame = function()
{
ball._x += xmove;
ball._y += ymove;
};
}
}


the fla can be found at http://giraph.ath.cx/testangles/ballmovetest004.fla
and the swf at
http://giraph.ath.cx/testangles/ballmovetest004.swf
please respond if you need any clarifaction



FlashKit > Flash Help > Flash ActionScript
Posted on: 03-03-2005, 04:46 PM


View Complete Forum Thread with Replies

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

Controlling Multiple Movieclips
Hi!

How can I with only one one button on one frame on a scene tell several moviclips on different frames on a scene to go to a certain frame in there own movieclip timeline.

would be very thankfull if someone out there could help me with this

/Sune

Creating Multiple Similar Movieclips?
I want to create multiple movieclips (with the same behaviour and looks) by pressing enter. Or any other action, but for now I put it under an enter for testing.

The code below makes a new clip the first time enter is pressed, but instead of creating a new movieclip after that, it just seems to reset the previous movieclip.


Code:
if (Key.isDown(Key.ENTER)) {
if ( nrOfBalls < 5 )
{
this.attachMovie( "PingPong", "PingPong"+nrOfBalls, 0 );
nrOfBalls += 1;
}
}
What am I doing wrong?

Creating Multiple MovieClips With ActionScript
For some reason both movieClips are instantiated but gets loaded but my second movieClip will not load the png image. What am i doing wrong

Thanx Marijntje


Code:
this.createEmptyMovieClip("navigation_mc", this.getNextHighestDepth());

var navigationListener:Object = new Object();
navigationListener.onLoadInit = function(){
navigation_mc._width = 800;
}
var navigationBackgroundLoader:MovieClipLoader = new MovieClipLoader();
navigationBackgroundLoader.addListener(navigationListener);
navigationBackgroundLoader.loadClip("http://www.h-g.dev/core/img/nav_bg.png", navigation_mc);

this.navigation_mc.createEmptyMovieClip("home_mc", this.navigation_mc.getNextHighestDepth());
var homeButtonListener:Object = new Object();
homeButtonListener.onLoadInit = function(){
//home_mc._width = 800;
}
var homeButtonLoader:MovieClipLoader = new MovieClipLoader();
homeButtonLoader.addListener(homeButtonListener);
homeButtonLoader.loadClip("http://www.h-g.dev/core/img/nav_home_nl_nl.png", home_mc);

Creating Multiple Movieclips With For Loop Help
How can I dynamically create multiple MovieClips and attach to the stage using a for loop?


for (var j:Number = 0; j<total; j++) {

var my_mc1:MovieClip = trackHolder.attachMovie("DefaultBtn", myHolder.getNextHighestDepth())
};

I need to change the name of my_mc1 to my_mc + j.

How can I do this.

Help appreciated

paulie

Help...creating Multiple Empty Movieclips?
Hi all,
I needed some help creating some help with the .createEmptyMovieClip() method.
you see i have a variable rks and accoding to the amount specified in the rks,i want flash to create that number of movieclips
Thanks.
avi

[F8 AS2] Problem Dynamically Creating Multiple Movieclips
Hi all,

I'm in need of some assistance with dynamically creating movieclips. I've some arrays housing information for all manufacturers, all purchase orders, and all sales, dependent on a customer id. There are about a dozen manufacturers against the first customer id, for example. In the middle of the page, there are two dynamic text fields called Purchase Order # and Sales.

Here's where I'm stuck.

What I'd like is for a vertical listing of all manufacturers to appear on the far left based on the customer id. I'd also like it so that whenever you click on a manufacturers name, the Purchase Order # and Sales text fields are populated with the information that matches the manufacturer id.

Though I didn't see anything exactly like what I want online, I did find enough to get me started. I've been trying to create an empty movie clip with text inside, but my code isn't working. And I'm not sure how to fix it.

Here's what I have so far:


Code:
function createNav(){
for (var i = 0; i < allManufacturers.length; i++) {
var mc:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
mc.createTextField('mfr' + i + '_txt',i,35,(300 + (i * 15)),165,30);
var mfr = this['mfr' + i + '_txt'];
mc.mfr.selectable = false;
mc.mfr.textColor = 0x000000;
mc.mfr.text = allManufacturers[i];
mc.onRollOver = function(){
mc.mfr.textColor = 0x000000; };
mc.onRollOut = function(){
mc.mfr.textColor = 0xFF0000; };
mc.onPress = function(){
mc.mfr.textColor = 0x0000FF; };
}
}


It was working fine until I added "mfr' + i + _txt' to line 4. However, I believe I need that to identify each movieclip separately. I think. I think line 5 is also a problem. I've try variations on resolving to no effect. The text simply no longer appears (and even when it did, the mouseover only worked on the last item in the list).

Can someone direct me as to what I'm doing wrong?

Thanks.

Stephen

Creating Multiple Objects (movieclips) And Using Keywords.
I have a class - MyObject - that is called several times through a loop (reading content from an XML file). For each time a new MovieClip is displayed in my SWF-file, but what I want to do is too add a undefined number (5, 10, 23..) of MovieClips, they appear identical, but I want to have control over them with keywords..

So if I have a total of 10 movieclips, 4 are red, 2 green, 3 blue and 1 black, and I want to be able to have buttons that say "reds", "greens", "blues" and "blacks" and I want to be able to click "reds" and making all other colored objects go invisible.

I can't really figure out a smooth way to do this, so do you guys have any tips, you don't need to write down an entire function/class, whatever, just point me in the right direction.

The ways I've come up with are:

check the color attribute in the xml file and create a switch, if its red the movieclip will be added in a parent instance called "redParent" (redParent.addChild(redObject)). Then I control that parents position/opacity with the button "reds".

Add an array for each different color, in which the MovieClips will be put, if I click "reds" it will call for the array "redsArray" and loop throught the array, chaning all the red objects opacity one by one. (In this case I need some help anyway, since I don't really know how to make an array with movieclips in it.



Any help is greatly appriciated.

Creating Individual Loaders For Multiple Movieclips
hello friends,

i have created an interactive movie where multiple movieclips(containing animations) are there on the timeline of Scene 1. Now the movie is extreme heavy as it contains several screenshots of our software we are working on. so i want to put individual loaders for the movieclips whenever they will be clicked by the user. I have put a loader, which will load the whole movie. but it is taking huge time. so i want each movie clip should contain individual loaders.

i will be extremely thankful for ur helps.

thanks and regards

HELP Multiple Buttons Controlling Multiple Movies
I hope someone can either help, or point me in the right direction!

I am trying to do a little program for kids, where there make their own plants. They are to pick from several buttons; the petal, leaf size and stem size. Once they have done that, they have to then click sun and water. Only then does flash fetch the correct movie case that matches with the buttons pressed, and plays it.

My problem is this...i am a total newbie, and have no idea where to start! Any tips would be very appreciated, or if anyone has stumbled across any tutorials that might help, i would be very grateful!

thanks

Controlling Multiple Movies With Multiple Buttons
I am trying to use variables to control mulitple movies with multiple buttons (I think). I can get one button to control all the movies the way i want, but not ALL the buttons to control ALL the movies.

Take a look at the main menu on exopolis.com and you'll see the effect I'm going for

http://www.exopolis.com


I am also using the code from joshua davis' flash to the core (tutorial #8). I'm try to apply this same concept, but with mulitple movies and mulitple buttons.

http://flashtothecore.praystation.com


I have four movies named:

home_mc
work_mc
play_mc
contact_mc

Each movie has a button within them that declares a variable that will be true or false depending on the rollver state. (fade01,fade02,etc.)


In the root, first frame I have the following:


//handle the onEnterFrame event
_root.bt_home_mc.onEnterFrame=function(){
if(_root.fade01){
_root.bt_work_mc.nextFrame();
_root.bt_play_mc.nextFrame();
_root.bt_contact_mc.nextFrame();
}else{
_root.bt_work_mc.prevFrame();
_root.bt_play_mc.prevFrame();
_root.bt_contact_mc.prevFrame();
}
};

//handle the onEnterFrame event
_root.bt_work_mc.onEnterFrame=function(){
if(_root.fade02){
_root.bt_home_mc.nextFrame();
_root.bt_play_mc.nextFrame();
_root.bt_contact_mc.nextFrame();
}else{
_root.bt_home_mc.prevFrame();
_root.bt_play_mc.prevFrame();
_root.bt_contact_mc.prevFrame();
}
};


//handle the onEnterFrame event
_root.bt_play_mc.onEnterFrame=function(){
if(_root.nav_mc.fade03_mc.fade03){
_root.bt_home_mc.nextFrame();
_root.bt_work_mc.nextFrame();
_root.bt_contact_mc.nextFrame();
}else{
_root.bt_home_mc.prevFrame();
_root.bt_work_mc.prevFrame();
_root.bt_contact_mc.prevFrame();
}
};


//handle the onEnterFrame event
_root.bt_contact_mc.onEnterFrame=function(){
if(fade04){
_root.bt_home_mc.nextFrame();
_root.bt_work_mc.nextFrame();
_root.bt_play_mc.nextFrame();
}else{
_root.bt_home_mc.prevFrame();
_root.bt_work_mc.prevFrame();
_root.bt_play_mc.prevFrame();
}
};



On each button I have the following (except the variable is unique....fade01, fade02, etc)


on(rollOver){
_root.fade01=true;
}
on(rollOut, dragOut){
_root.fade01=false;
}




Please help. This is for a personal project. If you need my fla file, i can send it to you. Thanks

[CS3] Issues Creating Multiple MC From Multiple Variable Data Arrays.
I have had some great help with this from some very kind FlashKit members. However I have played with the code extensively and am having an issue getting multiple MC's from the global variable arrays "V_1", "V_2" and "V_3".

Right now I have the code set to build up a scalable graph for array V_1. I have not had it working "properly" to show the other values in graphs side by side for V_2 and V_3. I have had some weird Frankenstein looking results that led me to believe I was on the right track, but only to find that I could not figure it out. I have a g_seperator variable that I was hoping to use to determine the space between each column of data.

Can anyone out there help me please?

Thank you.

here is my code reprinted here, since my flavor of Flash may not export to a version compatible with some of your working versions.



Code:
stop();
//BAR ATTRIBUTES
_global.g_x = 240;// chart starting x position
_global.g_seperator = 130;// distance between bars
_global.g_width = 50;// graph segments width
_global.g_base = 450;// graph starting Y position
_global.g_alpha = 40;
//BOX VALUES
_global.v_1 = new Array(20, 40, 1, 10, 12, 10, 20, 15, 5, 21, 31, 50, 20, 10, 20);
_global.v_2 = new Array(60, 70, 1, 10, 42, 10, 50, 15, 30, 21, 31, 10, 20, 10, 20);
_global.v_3 = new Array(20, 70, 1, 10, 12, 10, 20, 25, 10, 31, 31, 10, 20, 10, 20);
_global.color_set = new Array(0x000099, 0x00FF00, 0xddddd, 0xcccccc, 0x990000d, 0xff9900, 0x99eeee, 0x99cccc, 0xf21000, 0xffdddddd, 0x005900, 0xff00ff, 0x0ff000, 0xff9999, 0xf2f321);
_global.pos_name = new Array("Site3", "Site5", "Site7");

var home = this;

draw1NPositions("mc_pos"+[p],pos_name[p],g_seperator);

function draw1NPositions(mc_pos, positionName, gap) {
this.createEmptyMovieClip(mc_pos,1000);
for (i=0; i<v_1.length; ++i) {
makeBox(i,g_x,g_base,g_width,v_1[i],color_set[i]);
}
}
function drawBox(mc, w, h, color) {
mc.beginFill(color);
mc.lineStyle(0,color,100);
mc.moveTo(0,0);
mc.lineTo(0,-h);
mc.lineTo(w,-h);
mc.lineTo(w,0);
mc.lineTo(0,0);
mc.endFill();
}
function makeBox(num, posX, posY, wide, tall, color) {
var myBox = home.createEmptyMovieClip("box_mc"+num, num);
myBox._x = posX;
myBox._y = posY;
myBox.num = num;
myBox.dragging = false;
drawBox(myBox,wide,tall,color);
myBox.onMouseUp = function() {
this.dragging = false;
};
myBox.onMouseDown = function() {
if (this.hitTest(_xmouse, _ymouse) && !this.dragging) {
this.startY = _ymouse;
this.startX = _xmouse;
this.startH = this._height;
this.dragging = true;
}
};
myBox.onEnterFrame = function() {
for (var i = 1; i<v_1.length; i++) {
boxes[i-1].y = home["box_mc"+(i-1)]._y=home["box_mc"+i]._y-home["box_mc"+i]._height;
}
};
myBox.onMouseMove = function() {
if (this.dragging) {
dist = this.startH-(_ymouse-this.startY);
boxes[this.num].h = this._height=(dist>1) ? dist : 1;
_root.boxValue.text = this._height;
}
};
Mouse.addListener(myBox);
}

Controlling 3 MovieClips
I have a main movie. I want to play 3 movieclips in bottom up load order:

main
intro
preloader:


I have 3 layers for each mc, 3 labels, and 3 stop actions.
I just thought at the end of preloader I could do this:

_parent.gotoAndPlay ("intro");

At the end of intro, I could do this:

_parent.gotoAndPlay ("main");

I also have stop actions inside each movie clip, but it keeps looping and looping. What did I miss?

Controlling Movieclips From Outside?
i need to script a butten with a gotoAndPlay for its own animation and then in the same butten i need to put a gotoAndPlay that will control a different movieclip so that the butten and the movieclip animate at the same time.

cheers

Controlling Movieclips With With()
Hi:

I duplicate a movie 80 times using:

duplicateMovieClip("mask", "mask" + number, number);


So i have these movies:

mask
mask1
mask2
mask3
mask4
...
mask80


I want to control these movies using with().

* * * * * * * * * * * * * * * * * * * * * * * *

If I Write:

with(mask4)
{
gotoAndplay(25);
}

I can control the duplicated movie mask4


* * * * * * * * * * * * * * * * * * * * * * * *


Also if i write:


value = mask4;

with (value) {

gotoAndPlay(25);
}


I can control the duplicated movie mask4

* * * * * * * * * * * * * * * * * * * * * * * *

BUT I DONT WANT TO WRITE 80 WITH CLAUSULES TO CONTROL EACH MOVIE CLIP.

I WANT TO CREATE A LOOP, for example:

for (i=1; i <= 80; i++)
{
movie_number = i;
valor = "mask" + movie_number;

with (valor) {

gotoAndPlay(25);
}
}

BUT THIS CODE DOES NOT WORK.

It suppose to control mask1, then mask2, etc. But it does not.


I HAVE TRIED ALSO

for (i=1; i <= 80; i++)
{
x = 1;
valor = "mask" + x;

with (valor) {

gotoAndPlay(25);
}
x++
}


How can i solve this problem...?

Controlling Movieclips(avi)
Hi, I'm using a php script to load avi file to my Flash as movieclip.

How can I control the avi playback? Say if I have a stop button, how can I stop the avi from playing and while I have a play button and it will resume playing the video from where it stopped?

Controlling Movieclips
I am new to flash and I am trying to learn on how to control movieclips on different levels. I attached a small file where I have a movieclip on the main stage and a movieclip in side that movieclip. Inside the first movieclip I changed the alpha on the second moieclip. Then on the main time line I am trying to set the alpha back to 100%. I know I can do it with in the movieclip where I attached the first alpha but i was trying to figure out on how to do it from the main time line. Could use some help. Thanks

AS3 Controlling Movieclips.
I have a flash project that has several movieclips on the main timeline. One is a movie clip called displayTab that has 5 key frames that highlight graphically what button you have pressed. My buttons are grouped together in another movieclip called CategoryButtons. I'm really stuggling with this simple function in AS3. Previously, in AS2, I think it would have looked something like this:

on(release) {
_root.displayTab.gotoAndStop("video");
}

In AS3, after digging around for a while I came up with:

videoButton.addEventListener(MouseEvent.MOUSE_UP, change_tab);
function change_tab(evt:MouseEvent):void{
root.displayTab.gotoAndStop("video");
}

I know this is wrong but I'm not sure where to go from here.

Thanks, m

Controlling 2 MovieClips HelP
What I wanna do is, if I'm dragging 1 movie clip, how do I make that other one drag at the same time? And I'm also aligning these MC's so that they drag in the same X and Y position.

- Possible?? -

Controlling Movieclips(avi)
Hi, I'm using a php script to load avi file to my Flash as movieclip.

How can I control the avi playback? Say if I have a stop button, how can I stop the avi from playing and while I have a play button and it will resume playing the video from where it stopped?

Controlling Movieclips
Hi, Newb Here.

I have 2 movie clips that are actionscript based (text effects). I want one to run, then the other because I couldn't figure out how to flow the actions in a single script and clip. The scripts are yanked right out of a sitepoint book.

I do not know the best way of doing this - Do I use a function at the end of script 1 in movieclip 1 to load movieclip 2? If so, which function? I see "movieclip" functions and "movie" functions, and I can't determine which I should use?

Or should I use a timeline function like stop() in frame one and then at the end of the script in clip one, advance the timeline to frame 2 to run the second clip? I tried this, but couldn't figure out how to reference the main timeline of the movie from the script embedded in the clip, and not the timeline of the clip itself.

Confused. Just getting started. If anyone could offer some guidance I would appreciate it.

Thanks,

JS

Controlling MovieClips
Wondering if anyone has dealt with code that would allow movieClips (nested or other) to stop playing when the main timeline is told to stop. Normally, when the main timeline is stopped all MovieClips will continue to play. I want everything to stop at once. Also, it would great to stop all MovieClips without referring to them by name, but in a generic way such as... stopAllMovieClips();

Any ideas?

Controlling Movieclips
I'm trying to do something I think is simple to most actionscipters but I'm new and trying to learn. I have a movie with several movieclips on the stage with alpha set to 0. All the movieclips fade to alpha 100%. How can I control (through buttons) individual movieclips playing to 100% alpha. Ideally, I would also like some of the movieclips to fade back to 0 alpha when a button is selected. If you can imagine - different movieclips fading in and out when each button is selected. Any help would be appreciated!

Controlling Movieclips Within Movieclips-help
i need to tell a movieclip to play but it seems like it won't work becos this MC is embedded within another MC.

it goes like this:

MC1 calls MC2, and within MC2 i need to call out *another* MC (let's call it MC3) with buttons that will call out other MCs. On each button on MC3 i've put this code:

on(release) {
this.gotoAndplay("mymovie");
}

when i publish to movie, the link is active but there's no response when i click on it.

what went wrong?

Controlling Movieclips Within Movieclips
I have a button on my root scene which I want to control the timeline of a movieclip that is an object with a movieclip on that root scene. Basically-


Scene 1 -> Movieclip (archMC) in 'Scene 1' -> Movieclip (picnavi) in 'archMC'

I want a button on Scene 1 to change the timeline head to go to frame 1 on the movieclip 'picnavi'. And I only have about 6 hours to figure out how to do it!

Controlling Movieclips Within Movieclips-help
i need to tell a movieclip to play but it seems like it won't work becos this MC is embedded within another MC.

it goes like this:

MC1 calls MC2, and within MC2 i need to call out *another* MC (let's call it MC3) with buttons that will call out other MCs. On each button on MC3 i've put this code:

on(release) {
this.gotoAndplay("mymovie");
}

when i publish to movie, the link is active but there's no response when i click on it. i think it could have targetted it wrongly.

can someone help me pleeeease!

aryastark

Controlling Sound In Movieclips
Hi Friends,

I've created several movieclips with soundtracks in them. I'm having problems telling them to stop and start playing using the 'stopallsounds' command. Is there a basic actionscript technique to control sounds in movieclips? The tutorials I've read aren't clear on this aspect.

Thanks, woktoc

Controlling Duplicate Movieclips
I have a movieclip with a variable name titled "cerdito" that is duplicated six times. I have a bunch of actionscripting going on with the movieclips and I want to have it so when you click a button all the movieclips do a specific action together. How do I write the code to make all the duplicated movieclips move together... for instance if all the clips are moving around and when I click on a button, all the clips move with velocity from there current state to the value of 400 on the y axis. How do I write this to include all the movieclips?

Thank you for your help,

Kyle

Controlling Movieclips With An IF Function
Hi all i got a slight problem

I have created 3 movieclip buttons which have a total of 3 states each
UP, OVER and Pressed.

What i am wanting to do is create a fuction that will change the state of an already pressed button back to its UP state. For example

Button one is press and will stay in its state untill button 2 or 3 are presses then it will revert back to its up state.

My way of tackling the problem was to target a frame in the movie clip that I wanted to change such as this:

on (rollOut) {
gotoAndPlay("ee");
}
on (press) {
gotoAndPlay("dd");
}
on (press) {
_root.jill.gotoAndPlay(52);
}

as you can see nothing to it. but I then released that when I had more than two buttons using this fuction it then became obsolete due to the fact that the button would play a portion of the frame that I did not want to appear on screen.

I am a newbie to flash so complex scripting was not an option for me. Im not sure on how to approch this. I think an if statement is what i am looking for but how would you apply to this.

I want a statement that basically says for e.g

If button 1 is on the pressed state then when button 2 or 3 are pressed revert back to your up state (Im guessing i would have to apply this to all 3 buttons).

Ok thats it, If any one as any idea to how I can solve this pain in the neck or if anyone could point to any online tutorials that relate to my problem that would be great.

Thanks

w9914420

P.s i have also included a example of what i am working on but with 4 buttons instaead of 3

Controlling Duplicated Movieclips
I inserted a movieclip in "FRAME 1"

This movie clip contains a figure moving using a motion tween. When the motion ends, i put a stop();

Its instance name is mask.


I want to duplicate six times. I want to duplicate it each 3 frames.

So I did this:



In "FRAME 1" I initializated the variable:

i = 1;


In "FRAME 5" I duplicate mask once, usign the following code:

duplicateMovieClip("mask", "mask"+i, i);
i++; // I increase i by one, to count how many times mask has been duplicated


In "FRAME 6" i check how many times mask has been duplicated.

if (i >= 6) {
gotoAndPlay(10); // stop to duplicate
} else {
gotoAndPlay(2); // go and duplicate mask again
}

Finally, in "FRAME 10" I have my 6 duplicated movies:

mask
mask1
mask2
mask3
mask4
mask5


I "FRAME 20" i want to change the position of all these movies.

I want to change the position of all the movies one by one and play them again. I want the main timeline go 3 frames and then move and replay a duplicated movie.

The dull solution is put in each 3 frames the following instruction:

maskn._X = 120;
maskn.gotoandplay (1);

where n corresponds to the number of the duplicated movie.

For example:

In "FRAME 23" I should put:

mask._X = 20;
mask.gotoandplay (1);

In "FRAME 26" I should put:

mask1._X = 20;
mask1.gotoandplay (1);

In "FRAME 27" I should put:

mask7._X = 20;
mask2.gotoandplay (1);




But I want to create a loop that moves the movies one by one, similar as the loop which creates them.

HOW CAN I CREATE THIS LOOP?

I have troubles referring the movieclip and get acces to its properties...

I have tried:

"FRAME 23"
i = 1; // i restart the variable, so i start moving the first duplicated movie clip


"FRAME 25"

In this frame i have no idea how to refer to the movie clip

a.
I have tried

"mask" + i._x = 120;
"mask" + i.gotoandplay (1);

or

"mask" + "i"._x = 120;
"mask" + "i".gotoandplay (1);

or

mask + i._x = 120;
mask + i.gotoandplay (1);

IT DOES NOT WORK

b.
with (mask + i) {
_x = 120;
gotoandplay (1);
}

or

with ("mask" + "i") {
_x = 120;
gotoandplay (1);
}



or

with ("mask" + i) {
_x = 120;
gotoandplay (1);
}

c.
pelicula = mask + i;

pelicula._x = 120;
pelicula.gotoandplay (1);

or

pelicula = "mask" + i;

pelicula._x = 120;
pelicula.gotoandplay (1);


NONE OF THESE WORK.....


"FRAME 28"

if (i >= 6) {
gotoAndPlay(30); // stop to duplicate
} else {
gotoAndPlay(25); // go and duplicate mask again
}


"FRAME 30"
stop();

Controlling Movieclips With Buttons
Ok here is the problem. I've created 3 movie clips that fades in an image and fades out.

Home Clip 1. fades in from 1-10 then fades out from 11-20

About Clip 2. fades in from 20-30 then fades out from 30-40

Contact Clip 3. fades in from 40-50 then fades out from 50-60


I have 3 buttons that I want to control the movie clips with.

Home button, About button and Contact button.

How can I make one movie close and have another open after?

For example: If HomeClip is on frame 10 and I click on the Contact button then goto frame 11 and Play and after Home Clip has closed the Contact Clip plays from 40-50.


I want to be able to control a movieclip only if it's in a certain frame number.

Can anyone help with that?

Controlling Movieclips With Buttons
Ok here is the problem. I've created 3 movie clips that fades in an image and fades out.

Home Clip 1. fades in from 1-10 then fades out from 11-20

About Clip 2. fades in from 20-30 then fades out from 30-40

Contact Clip 3. fades in from 40-50 then fades out from 50-60


I have 3 buttons that I want to control the movie clips with.

Home button, About button and Contact button.

How can I make one movie close and have another open after?

For example: If HomeClip is on frame 10 and I click on the Contact button then goto frame 11 and Play and after Home Clip has closed the Contact Clip plays from 40-50.


I want to be able to control a movieclip only if it's in a certain frame number.

Can anyone help with that?

[CS3] Controlling Movieclips On The Stage
Hi,

I have 2 instances on my stage of a 'speedometer' movieclip.

At the moment I just want to control each of the instances by moving the playhead to a specified frame within the each movieclip.

In my first keyframe I have the actionscript:

this.rm_mc.gotoAndStop(7);
this.ca_mc.gotoAndStop(5);

I have given each instance the correct name (rm_mc and ca_mc) in the propery inspector.

..which theory should send the first instance to frame 7 and the second to frame 5.

When I test the movie I get:

TypeError: Error #1010: A term is undefined and has no properties.
at speedometer/::frame1()
TypeError: Error #1010: A term is undefined and has no properties.
at speedometer/::frame1()

Can anyone point me in the right direction cos this is driving me mad! All I have done is follow a textbook!

Controlling MovieClips With Boundries
I have movieClip on the stage called floor, into it I load a movieClip , how do I keep this new movieClip so it doesn't go outside the boundries of the floor movieClip?

Right now the floor width and height are 350 x 300. The location is
yMax --> 375
yMin --> 75
xMax --> 510
xMin --> 160

Thanks for any and all help.


ActionScript Code:
_global.count = 0;
function newPiece() {
    // create a movieclip to hold the functionality of the peice of furniture
    // keep all the furniture inside 1 clip (called 'pieceContainer') for organizational purposes
    //var count:Number = floor.pieceContainer.getNextHighestDepth();
    var item_mc:MovieClip = floor.pieceContainer.createEmptyMovieClip("item_mc"+count, this.getNextHighestDepth());
    trace(count);
    count++;
    // create a container to load the furniture swf into
    var container:MovieClip = item_mc.createEmptyMovieClip("container_mc", 0);
    container._x = 0;
    container._y = 0;
    // setup a MCL to handle the swf's loading, when its loaded, apply the freeTransform methods to it. 
    item_mc.mcl = new MovieClipLoader();
    item_mc.mcl.addListener(mclListener_2);
    item_mc.mcl.loadClip("decals/"+this.piece+".swf", container);
    // 
    // 
}
//
var mclListener_2:Object = new Object();
mclListener_2.onLoadInit = function(mc:MovieClip) {
    // set variables to remember the original dimensions
    var axw = mc._width;
    var axh = mc._height;
    // center piece  
    mc._y = -(axh/2);
    mc._x = -(axw/2);
    //
    //addFreeTransform
    mc._parent.onPress = function() {
        this.addFreeTransform();
    };
};

Controlling 2 Movieclips From Different Btns
Hello there,

I have searched for a possible answer to my question, but have been unsuccessful. I'm hoping someone here can help me.

I would like to be able to control 2 different movieclips from different buttons, I've attached my files to make it easier, there are 3 files.

One is the main file, which automatically loads in the first swf, the second is the nav bar, and the 3rd is the middle content. Ideally, there will be pages where only the middle content changes, and other instances where the whole page changes, all being controlled by buttons. I can't figure out how to control different empty MC using the buttons. It seems like such a simple thing, but very frustrating...

I'm really in a bind on this one, and have attached my files, if someone can please have a look at my files, I'd really appreciate it.

Thanks in advance...

Controlling Imported MovieClips?
How do I find out which frame an external movieClip is passing?
for Instance I have a movieClip imported onto my main flash project. But it keeps looping repeatedly, I want it to play every 5 seconds, so I need it to know that if its on the last frame it will stop, wait 5 sec, GotoAndPlay on first frame of this movieClip?

Could anyone show me an example code for this?

Controlling Duplicate Movieclips
I found the tutorial on duplicating movieclips very helpful, especially the line-by-line translation of the code. I'd appreciate information on how to communicate with those clips—specifically to make them draggable and also to change the _rotation with Key.Right, Key.Left.

Thanks,
Cliff

duplicating movieclips

Controlling Unnamed Movieclips
Hey,
I've got an fla with over two thousand movieclips in one frame. Each movieclip does not have an instance name. Can anyone suggest a way to control each movieclip individually? For example, rotating all movieclips 45 degrees?
Thanks.

Another Controlling Movieclips Question
I have this working pretty well now, but I have hit a snag that I can't seem to get around.

I'm trying to create a button that triggers the movieclips in the rollovers of my other buttons to draw attention to them. I am doing this by creating a movieclip and putting it on the stage in the first scene. I have, by testing, noticed that I am successfully getting the button to trigger the start of this movieclip.

Within this movieclip, called "titlebarFREAKOUT", though, is where the trouble arises. I have put the following code onto one of the frames in titlebarFREAKOUT.


Quote:




_parent.titlebarTCPsideways.titlebartcpRO.gotoAndP lay(1);




I used parent because titlebarFREAKOUT is located within the main scene, which is also the location of titlebarTCPsideways. Within titlebarTCPsideways (a button), on the roll over frame, is titlebartcpRO.

Yes, I named all the instances, yes they're all on the stage. Does anybody have an idea as to why it isn't working?

Help Controlling Nested Movieclips
This is more a request for direction than a specific question. I have a nested movieclip that I need to control. I have searched the net and to this point I have been able to make it gotoAndStop at frame 1 and play(). I can't make it stop. I understand that actionscript can be attached to the movieclip instance or placed on the root timeline. Pointers would be appreciated but what I would like is direction to websites and or tutorials that might teach me how to control a nested movieclip.

Thanks in advance for the help ... Michael

Controlling Nested Movieclips
I'm working on a game. And I decided to put all the bosses nested in a single movieclip. I did this so I could do collision detection and general code involving the bosses on a single movie clip rather than writing code for each one. The way it works logically is

masterboss
|
bosslist (movie clip containing a different boss on each frame
| | |
boss1 boss2 boss3
and nested within those are boss attacks. I'm trying to reference the boss attack level. Which it seems I can do if each of the nested movieclips have an instance name.
However as soon as I add an instance name gives me the error
1046: Type was not found or was not a compile-time constant: bossList.
Anyone have any ideas or thoughts? Any kind of help would be greatly appreciated.

Controlling Duplicate Movieclips
I found the tutorial on duplicating movieclips very helpful, especially the line-by-line translation of the code. I'd appreciate information on how to communicate with those clips—specifically to make them draggable and also to change the _rotation with Key.Right, Key.Left.

Thanks,
Cliff

duplicating movieclips

Controlling Movieclips With An IF Function
Hi all i got a slight problem

I have created 3 movieclip buttons which have a total of 3 states each
UP, OVER and Pressed.

What i am wanting to do is create a fuction that will change the state of an already pressed button back to its UP state. For example

Button one is press and will stay in its state untill button 2 or 3 are presses then it will revert back to its up state.

My way of tackling the problem was to target a frame in the movie clip that I wanted to change such as this:

on (rollOut) {
    gotoAndPlay("ee");
}
on (press) {
    gotoAndPlay("dd");
}
on (press) {
    _root.jill.gotoAndPlay(52);
}

as you can see nothing to it. but I then released that when I had more than two buttons using this fuction it then became obsolete due to the fact that the button would play a portion of the frame that I did not want to appear on screen.

I am a newbie to flash so complex scripting was not an option for me. Im not sure on how to approch this. I think an if statement is what i am looking for but how would you apply to this.

I want a statement that basically says for e.g

If button 1 is on the pressed state then when button 2 or 3 are pressed revert back to your up state (Im guessing i would have to apply this to all 3 buttons).

Ok thats it, If any one as any idea to how I can solve this pain in the neck or if anyone could point to any online tutorials that relate to my problem that would be great.

Thanks

w9914420:D

Trouble Controlling Movieclips
Hey, i got a problem to control a movieclip from another one. Both are loaded onto a main flash movie. The menu controls the other movie clip like this:

ActionScript Code:
on (release) {
    if (this._parent.clientesvar == "1") {
        _root.proyectos.stop();
    } else if (this._parent.clientesvar == "0") {
        _root.proyectos.loadMovie("clientes/abba.swf");
        this._parent.clientesvar = "1";
    } else if (this._parent.clientesvar != "0" || this._parent.clientesvar != "1") {
        _root.proyectos.gotoAndPlay("salida");
        this._parent.clientesvar = "1";
    }
}

The thing is that the movie in proyectos does not go to the scene "salida", just loads the new movie. Sometimes, it doesn't even load the movie!!!!

Hope you can help me.

Controlling Movieclips With An IF Function
Last edited by w9914420 : 2003-12-06 at 13:49.
























Hi all i got a slight problem

I have created 3 movieclip buttons which have a total of 3 states each
UP, OVER and Pressed.

What i am wanting to do is create a fuction that will change the state of an already pressed button back to its UP state. For example

Button one is press and will stay in its state untill button 2 or 3 are presses then it will revert back to its up state.

My way of tackling the problem was to target a frame in the movie clip that I wanted to change such as this:

on (rollOut) {
gotoAndPlay("ee");
}
on (press) {
gotoAndPlay("dd");
}
on (press) {
_root.jill.gotoAndPlay(52);
}

as you can see nothing to it. but I then released that when I had more than two buttons using this fuction it then became obsolete due to the fact that the button would play a portion of the frame that I did not want to appear on screen.

I am a newbie to flash so complex scripting was not an option for me. Im not sure on how to approch this. I think an if statement is what i am looking for but how would you apply to this.

I want a statement that basically says for e.g

If button 1 is on the pressed state then when button 2 or 3 are pressed revert back to your up state (Im guessing i would have to apply this to all 3 buttons).

Ok thats it, If any one as any idea to how I can solve this pain in the neck or if anyone could point to any online tutorials that relate to my problem that would be great.

Thanks

w9914420

Movieclips Controlling Volue
I have a movieclip 'volumePod' that animates in and contains other movieclip "buttons" called 'volumeDown' and 'volumeUp'. The music loads fine, but in a simple test, I cannot get the 'volumeDown' movieclip to control the volume.

Any help would be appreciated. Thnx.


ActionScript Code:
_root.createEmptyMovieClip("GlobalMusic",1);
var music:Sound = new Sound(GlobalMusic);
music.loadSound("instrumental.mp3",true);
 
music.setVolume(100);
 
volumePod.volumeDown.onPress = function() {
    if (music.getVolume() == 100) {
        music.setVolume(0);
    }else{
        music.setVolume(10);
    }
}

Buttons Controlling Movieclips
Hey,

I need some advice. I have two buttons and two movieclips.

btn_1 is for mc_imgs movieclip
btn_2 is for mc_anime movieclip

on rollOver of btn_1, mc_imgs comes tweening and fading in.
on rollOut, it tweens and fades out.
on press, I'd like for mc_imgs to stay put in its fade in/tween in position and if btn_1 is pressed again, mc_imgs fades/tweens out... AND... if you press on btn_2 (mc_anime) when mc_imgs is locked in its tween in/fade in position, mc_imgs should tween and fade out. i hope that made sense....

I do ok with AS if it is linear, but as soon as it requires backward motion, I'm lost.

Here is the AS I started with. It is placed on btn_1. I'm also using laco tweens.



ActionScript Code:
on(rollOver){
    this.btn_center.brightnessTo(60, .75);
    _root.mc_imgs.tween("_x", 175, 6, "easeOutElastic");
    _root.mc_imgs.alphaTo(100, 1, .5);
    _root.mc_imgs.imgsBlur.tween("_x", 14, 8, "easeOutElastic");
    _root.mc_imgs.mc_imagesTxt.brightnessTo(60, .75);
}
on(release){
    _root.mc_imgs.tween = this._x;
    _root.mc_imgs.alphaTo = this._alpha;
    _root.mc_imgs.mc_imagesTxt.brightnessTo = this.brightnessTo;
    _root.imgsBlur.tween = this._x;
}
 
on(rollOut){
    this.btn_center.brightnessTo(0, .75);
    _root.mc_imgs.tween("_x", 125, 5, "easeOutElastic");
    _root.mc_imgs.alphaTo(0, 1, .5);
    _root.mc_imgs.imgsBlur.tween("_x", 0, 8, "easeOutElastic");
    _root.mc_imgs.mc_imagesTxt.brightnessTo(0, .75);
}




Any advice would be of great help. Structuring is really my downfall. Like should I have written functions, or use if statements or just point me in the direction of a tutorial. thanks for the help.

Multiple SWFs In Multiple MovieClips
So I'm trying to load eight swf files at the same time using eight different movie clips (cause i need to move them around) placed in one big movie clip. I'm using a loop that looks like this :


Code:
for (var i = 1; i<=8; i++) {
this.clip_mc.createEmptyMovieClip("spec" + i + "_mc", 10000+1);
this.clip_mc["spec"+i+"_mc"].loadMovie("species/" + i + "_25.swf");
this.clip_mc["spec"+i+"_mc"]._x = 150;
this.clip_mc["spec"+i+"_mc"]._y = 25*i;
}
The problem is that only the last one (number 8 or in fact any number I put as the last one in the loop) shows up on the scene. I'm pretty sure something is wrong with my syntax but I can't figure out what... any tips?

Controlling Movieclips In Loaded Levels?
Hi.
Here is the example, I have interface with buttons..every button has a submenu with 4 buttons. As I click one of the submenu buttons it should load external *.swf to a leveln. Even more, every submenu button must direct to a different frame in that loaded leveln *.swf.
My problem is that if I am trying to make the loaded movie to go to frame 2...I just cant get it work.
Here is the AS I have assigned to a button what has to load an external *.swf to level 4 and open frame 1 in buttonbar movie clip.

on (press) {
loadMovieNum("5.1.swf", 4);
_level4.buttonbar.gotoAndStop(1);
}

With that I am having no problems. Problems occur when I am adding a script for second button.

on (press) {
loadMovieNum("5.1.swf", 4);
_level4.buttonbar.gotoAndStop(2);
}

This should load *.swf called 5.1 to level 4 and stop in a second frame in bottonbar movieclip.
But with this script, it aint working. It goes to 1'th frame in buttonbar and stops there, but I want it to go to 2'd frame and stop there. So I am suspecting that here is something wrong with AS.
Any ideas...any help would be greatly apprecciated. Thank you for ur time

Actionscript Trouble Controlling Movieclips
Hey I was trying my best not to ask for help on this one but I just can't seem to get it right.

I have 7 buttons on the stage and they control animated text set as MC's AND they also control an animation that is set inside the button itself (by the way, the buttons are set as mc's). For example if button1 is pressed the "textclip" and "buttonanimation" that is currently active plays it's closing animation and the button that was clicked plays it's opening textand button animation. It's a every action, theres areaction sorta thing going on.

Ok I have attached a sample. The buttons and their animation work but I can't get the text clips to do the same. To view the script you'll have to edit the "homebuttonclip" etc. Then the script should be in the layer labled "ROLL".

Can anyone help with this??

Thanks!!

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