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




Swap ?



Hi,

is it possible to write a bit of code which when called upon, swaps one movie clip with another?? without jumping to another frame?

cheers,
g



FlashKit > Flash Help > Flash ActionScript
Posted on: 05-15-2004, 06:51 AM


View Complete Forum Thread with Replies

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

How Do I Swap Flash Movies In Dreamweaver In Place Of Swap Image?
In Dreamweaver you can swap images on a mouseover event using behaviors.

Instead of swapping images, I want to swap flash movies.

Example:

Build a table
place and play a flash movie in a cell
on a mouseover, replace that flash movie with another flash movie.

Can it be done? It apparently can't be done directly - Dreamweaver won't see flash files as swappable. Perhaps there's a workaround.

Swap Images Or Swap Symbols?
I want to load a bunch of images dynamically -- into different movie clips. And then simply have a master clip which lets me swap out these dynamically loaded clips. Is that possible?

Can I do a swap or replace symbol on the Master to have it be replaced by each loaded clip one after the other?

Swap MC's
Hello,

i have a MC1 and during the running of my flash movie i want to remove MC1 and place MC2 in its position. Just like the swap command in the properties window...is this possible with actionscript?

Thanks,
Miguel

Swap Mc
hi, idiot user here.
basically i'd like to drag a symbol over a specific area and for it to swap with another symbol while held over that area.
i figured out the dragging ok.....
my_mc.onPress=function(){
my_mc.startDrag();
}
my_mc.onRelease=function(){
my_mc.stopDrag();
if(my_mc.hitTest(area_mc)==true){


now how dod i swap it??

thanks

Swap MCs'
How do you change an MC into a different one in the middle of a movie?

Swap X/Y
Hi,

So far, my code:


PHP Code:



fscommand("allowscale", "false");
bar.useHandCursor = dragger.useHandCursor=false;
space = 20;
friction = .9;
speed = 4;
y = dragger._y;
top = main._y;
bottom = main._y+mask_mc._height-main._height-space;
dragger.onPress = function() {
    drag = true;
    this.startDrag(false, this._x, this._parent.y, this._x, this._parent.y+this._parent.bar._height-this._height);
    dragger.scrollEase();
};
dragger.onMouseUp = function() {
    this.stopDrag();
    drag = false;
};
bar.onPress = function() {
    drag = true;
    if (this._parent._ymouse>this._y+this._height-this._parent.dragger._height) {
        this._parent.dragger._y = this._parent._ymouse;
        this._parent.dragger._y = this._y+this._height-this._parent.dragger._height;
    } else {
        this._parent.dragger._y = this._parent._ymouse;
    }
    dragger.scrollEase();
};
bar.onMouseUp = function() {
    drag = false;
};
moveDragger = function (d) {
    if ((dragger._y>=y+bar._height-dragger._height && d == 1) || (dragger._y<=y && d == -1)) {
        clearInterval(myInterval);
    } else {
        dragger._y += d;
        dragger.scrollEase();
        updateAfterEvent();
    }
};
up_btn.onPress = function() {
    myInterval = setInterval(moveDragger, 18, -1);
};
down_btn.onPress = function() {
    myInterval = setInterval(moveDragger, 18, 1);
};
up_btn.onMouseUp = down_btn.onMouseUp=function () {
    clearInterval(myInterval);
};
MovieClip.prototype.scrollEase = function() {
    this.onEnterFrame = function() {
        if (Math.abs(dy) == 0 && drag == false) {
            delete this.onEnterFrame;
        }
        r = (this._y-y)/(bar._height-this._height);
        dy = Math.round((((top-(top-bottom)*r)-main._y)/speed)*friction);
        main._y += dy;
    };
};




is used to control a horizontal scroll bar. How would I go about making it horizontal? Where would I change the Y values to X?

Thanks

--iMat

Swap
hi, so i use loadMovie to load some.swf to loaderMC (the target),which can be a movie clip in an swf on level90. then i use this.swapdepths(50); to tell loaderMC to swap to level50 and it will take some.swf with it?

do you think you could rewrite- this.swapdepths(50);
so that it is correct, i guess this becomes loaderMC?

thanks very much
mark

Swap 2 Swf's
I have created 2 swf files and I would like to attach to a button the action script to switch from one to the other. Please can anyone help. my two files are hamopen.swf and hampanto.swf

i have tried

on (release) {
loadMovie("Hampanto.swf");
}

but it doesn't work


thanks

Swap To Top
currently using:

on (press) {
this._parent.BUT1.swapDepths(this._parent.BUT2);
this._parent.BUT1.swapDepths(this._parent.BUT3);
}

can i simple call the pressed button to the top layer with code?

cheers rat

Swap Swf
Hi everyone,

im working on an audio player for my website, but rather than streaming because some people have buffering issues, i want to make a separate swf file foe each song with its own individual preloader. This way viewers dont have to wait for all the songs to load. Anyways just wondering if any one could help me out for the script?

Thanks in advance

Herv

How To Swap One Mc With Another In AS3
I have a timeline animation that contains a movieclip of a yellow bouncing ball. I want to change the instance of the yellow ball to a yellow top hat and have the TopHat bounce up and down instead of the ball. Sort of like the Swap button in the Flash editor, but at runtime.

The ball mc is called yball, and inside that is the mc I want to replace, called yellowBall. I also created an mc called TopHat and exported it for AS. Then I tried a few variations on something like this:

trace(yball.yellowBall); // Says the object is a MovieClip
var newHat:TopHat = new TopHat();
yball.yellowBall = newHat;
trace(yball.yellowBall); // Says the object is a TopHat
yball.addChild(newHat);

Before you ask, no, this isn't the actual project, but I need the same swapping behaviour.

I have attached my FLA file if it helps.

Any suggestions?

Thanks!

How To Swap A MC For Another MC
Is it possible to swap a MC with a MC in my library?

It seems logical that you could, but I'm not sure how.

For example

I have a red ball on the stage that is a movie clip with an instance name of of "redBall" (clever huh?)

In my library I have a movie clip of a greenball.

On the stage I have a green button and a red button, you click the green button and I want the ball to turn green , click the red button and you guessed it, it turns red!

How i've been doing this is in the past is on the stage I would put both movieclips on frame 1name the instances to each red ball = redBall, green ball = greenBall

On the timeline on frame 1 I would put
redBall._visible = true;
greenBall._visible = false;

on the green button I would put
on (press) {
redBall._visible = false;
greenBall._visible = true;
}

on the red button I would put
on (press) {
greenBall._visible = false;
redBall._visible = true;
}

while this works, I can't help but feel there is a better way of doing things. After all what if I had 30 _mc on the stage, that's a lot of true/false statements.

Any help and examples would be appreciated/
Thanks!
D

Swap Depths
hi, can anyone help?
i have 6 movie clips (windows) on the main stage with instance names of... about, news, contact, laboratory, portfolio and arcade.
i want them to swap depths but i can get to grips with it!
please help
thanks in advance
matt

Button Swap
Hi,
I am trying to set up four button with a continuous loop animation taking place beside them.

When the button is rolled over, the animation disappears, and static type takes the space of the animation while the button is rolled over.

Can someone please help me?

Thanks!

Swap Movies
Is there a way of swapping an mc for a different one by clicking a button?

Swap Depths Bug?
After swapping a draggable MC's depth in frame 1 loop between frame 3 and 2. On going to the previous frame the MC is duplicated ( but does not show as an object in Debugger!). Has anyone had this before or is it a bug( or am i just crap!). See code below and try it yourself.

create a MC with Instance name Target. Create a place in a new layer above a object i.e. a box, ( to check swapdepths works).

Frame1:
Target.swapDepths( 100 );
startDrag ("Target", true);

Frame2:
"No code"

Frame3:
gotoAndPlay (2);

Tried it with any loop i.e. frame 15 to 7, and the MC is duplicate when gotoAndPlay is executed.


Please help as i think i am going mad

Thanks

Swap Depths
Can someone help me with swapping depths between different movie levels.

In level 2 I have an mc called "am"
in level 3 i have an mc called "wrk"
in level 4 I have an mc called "rsme"


I load in all of the movies into different levels and each window is dragable, I want to be able to swap the depths of the one you click on to bring it ot the front.

?.swapdepth (?);

Any help would be greatly appreciative and a huge thanks in advance.

Jason

Replace Swap MC
Hey,

I'm looking to replace the content of one MC into another. LoadMovie into the MC, LoadMovie from an external .swf, and attachMovie will all work, however I need to find a way to know what is in the MC that I wish to swap.

K..that's probably not making much sense.

Example:
Click on button inside MC1 swaps the content (or clip) of MC1 with the content of MCmain.

Click on button inside MC2, swaps the content of MC2 with the content of MCmain

Click on button inside MC3, swaps the content to MC3 with the content of MCmain

...and so on.

Any ideas how I'd do this? Should I replace the content of the clip or replace the whole clip? How do I find out what's inside MCmain so that I may swap it with the file that's inside MCx?

Replace/swap MC
Hey,

I'm looking to replace the content of one MC into another. LoadMovie into the MC, LoadMovie from an external .swf, and attachMovie will all work, however I need to find a way to know what is in the MC that I wish to swap.

K..that's probably not making much sense.

Example:
Click on button inside MC1 swaps the content (or clip) of MC1 with the content of MCmain.

Click on button inside MC2, swaps the content of MC2 with the content of MCmain

Click on button inside MC3, swaps the content to MC3 with the content of MCmain

...and so on.

Any ideas how I'd do this? Should I replace the content of the clip or replace the whole clip? How do I find out what's inside MCmain so that I may swap it with the file that's inside MCx?

Swap Depths....swf
Hi there!
Im having a bit of trouble figuring out how to swap depths with seperate swf files. I have a few swf files which are loaded into my main page which is on level 0.

If anyone has the answer I would be very thankful for your help.
If you want to check out my incomplete webpage go to the link below....

Swap Problem =b
Ok heres the scenerio i broke my web page into two parts... the introduction transition, and the main interface...
so my introduction transition is the first page that loads, then when it gets to the last frame i did a simple getUrl(maininterface).... this works fine for the most part, except that every once in a while it will lag showing the background of the html through between the two files... =b

SO what im attempting to do instead is have my intro.swf load then when it gets to the second last frame it loadsMovie('Main.swf',1), the main interface into _level1 from what i understand... so what i figure is in the first frame of the main interface right a script:

_level0.swapDepths(1); //or _level1.swapDepths(0);
unloadMovie(_level1);

this is in the frame script BUT DOES NOT WORK =b

oh yeah you might ask why the hell im swapping the depths... well for some reason the audio in my main interface swf wont play unless the movie is the _root... =b

so if anyone has any ideas of what i could do im all ears

Swap MovieClips
I'm using Flash MX, when attaching a movieclip(B) in another movieclip(A) the last loaded appears over the "caller"(A) movie and this correct, but still are active the buttons on the clip that is backwards (A) resulting an uncontrolled mess.
Somebody knows how to arrange this ?
Thanks

Swap Movieclip Help
I have a movieclip and I need to be able to swap it's instance with another in the library with actionscript.

At the moment I am adding a keyframe and manually swapping via the properties, but that is getting impractical and I need to optimise as much as possible.

Can this be done? I know most of a movieclips properties can be changed via actionscript, but I can't find Instance anywhere!

cheers
Rob

Swap De[ths Problem
Hi,

I have managed to script the swap depth AS into my movie, however, I have come across this problem.

I have three MCs on the stage acting as buttons. On rollover, the expand and slightly cover this other MCs. This is fine as long as that particular MC is on top.

So, here's what I did:

_root.button1.onRollOver = function() {
this.swapDepther(button2,button);
};

this works fine except it only does it once. I need to do it everytime they roll over.

I tried putting a goToAndStop on the _down frame in the actual MC, but it didn't make a difference.

Any ideas? YP

Swap Depths ?
Does anyone know if swap depths - can make one layer appear as if it's above the next and swap 3 or 4 of them at the click of a button ?? Or something that'll do this ?

How To Swap A Existing MC?
How can I do if that is a MC,not a linkage?

e.g.

_root.a.b.c.d.e
swap with
_root.skin.sk1.e

Swap And Tint
how do you tint a symbol a certain color with certain percentage after a condition is proven to be true...
ex:

if ( variable == "red")
{
tint symbolA red 50%
}


AND


can you swap a symbol using actionscript???
like if i have a symbolA on the stage, but i want to swap it to symbolB, how would i do that using actionscript???

please help... either one of the question would be great...

Drag And Swap
Can Someone explain to me how I can drag and swap

and what does depth means please cuz I'm really in big prob

I'm sure some professional as always get it done please don't make me disappointed

thanks

Swap Image
what would be the best way in mx to have a menu button that
would swap out an image on the stage
ty

Swap Clips?
How can I swap a movie clip in flash like you can do in director? - I couldnt find an easy way is there a way round this using duplicatemovie or loadmovie or something - I want it to be like director when you swap a sprite - I want to keep all the properties inc movement and position etc but just swap the clips - the clips are the same size btw.

any help much appreciated.

Swap Contents In A MC
I am working on a template for a window-style website. Right now I am working on having the user move the window around by dragging the titlebar. I don't really like how the whole MC is visible while dragging so I thought of replacing the original MC with an MC of just the frame of the window. When the user presses down the mouse button while over the title bar the frame will appear, then when they release the original window will re-appear and the stopDrag(); function will execute.

Does anyone know an easy way of swapping the contents of an MC with another while still retaining all of the actions within a Movie Clip?
I've thought of making a frame MC in the original one and just have it above everything else and have it invisible, then have it become visible when the user clicks and have a background inside the frame that would block out the original window. But I would like to have the background behind everything visible when dragging, so that was no good.

Any ideas?

Swap MovieClip
Anyone know how to replace MCs within the same move? Is this possible (like swap cast members in director)?

I've been using loadMovie and linkage properties...this replaces the MC on the stage but not with the chosen MC from my library.

Swap Graphics?....
I'm using Flash MX, and I'm making a game-show type of game. Anyway, the first thing I want a user to do is to see a variety of different contestants that they can be. Then the user will click on who they want, and for the remainder of the game, that's who will be shown in the contestant chair on the game.

Basically, the game will be built with a blank area for a contestant - how do I put the correct contestant picture into that spot based on what the user selects? I'm sure there's simple actionscripting to do this with swapping graphics somehow or something, but I'm only moderately experienced in actionScript. I hope this makes sense - thanks!!!....

Image Swap Done By...
I am trying to do an image swap with Flash MX and ActionScript, but no love yet

I have three layers.
1) all my images
2) off image
3) on image

When it loads I want the ON IMAGE shown and the OFF IMAGE hidden. Then if someone clicks a button (location on the mainlayer) then it HIDES a layer and makes another layer VISIBLE.

Is that how you do in image swap based on a press button event?

Swap Symbols...
I don't know if this is a newbie question or not. I'm not a newbie, I've been using Flash for a few years now, but I'm trying to be more efficient and finding that I can't do what I want.

Here's my problem.

I want to animate a character all on one layer (i.e., place all of the bits: head, eyes, arms, body, etc on one layer where all of the elements are in an hierarchy within that layer). What I'm hoping to do (and maybe it's not possible) is use the "Swap Symbols" feature on the mouth to animate talking. What I'm finding, though, is that when I try this, the symbol swaps in design mode, but when I test the movie the symbol doesn't change. I can't figure out why and it's contributing to my insanity. Is the problem that I have too many symbols on one layer? Is the only (or best) way to animate a character by making a separate layer for each element? This works, but it takes a long time.

I hope I've explained my problem clearly. Any help would be appreciated.

Thanks!

Ed

Swap Depth
I have 5 buttons i my menu and have made a MC for each of the buttons. The MC's has their own layer. The problem is if u press
BTN 5 first then press BTN 1. The button 1 MC start playing under the MC related to BTN 5.

I was told that I have to use a swapDepth action. The button actions that I have used is:

on (release) {
_root.instance name.play();
}

what will the the swapDepths action be?

Swap Function
var top = B_mc;
var bot = A_mc;
function swap(){
var t = top;
top.swapDepths(bot);
top = bot;
bot = t;
}

is that a correct swap function?

(btw, my 100th post)

Can't Swap Symbols, Duh
i reckon i'm missing something obvious here, sometimes i can swap symbols, but most times i can't

the badger walks across the stage, and the motion tween ends, then i want to swap the walking badger for one that stays still, but no matter what i do it always springs back to the previous option, i can't even change it from a loop to a play once

any clues? i'm using flash mx btw

How To: Swap The Parent Of A MC?
hi all,
I have got a problem in my program.

I want to change the _parent of the existed MC, from root to other MC, anyone can help me to solve the problem...@@..

description:
There are two movieclips on the stage, one is called temp_mc1, one is call temp_mc2, and I want to change the _parent of temp_mc1 from root to temp_mc2, that mean the final result I want is _root.temp_mc2.temp_mc1 instead of _root.temp_mc1, is it possible to do that without using duplicate a new movieclip??


Thanks,
Jack

Swap Img By Rollover Btn - How?
I am trying to swap images when the mouse is rollover a button.
Details:
I have main menu, and when you rollover it,the sub-menu is open.
I want to swap images when the user rollover the sub-menu.

the menu item is movie-clip and the sub-menu item is a button.
The main-menu movie clip contain layers for the options(sub-menu items).

If you are replying, please , detail as much as you can, what should I do in order to do that.

thanks

Swap Depths Help
I am creating a nav that will swap depths when pressed.
Im not sure what is wrong with this code. Ive attached the fla
any help would be great.
thanx always

Swap Depth Nav
I am creating a swap depth nav
there are movie clips on the main stage each has a button inside

Kind of lost
-thanx for the help
p2studios.com

Swap Layer
I need guide on the actionscript for the swap layer.

Code:
function bringForward(part)
{
if(_root.selected == true)
{
i = part;
if(! _root.j <= i)
{
_root.i.swapDepths(i + 1);
_root.i._name = i + 1;
_root.i + 1.swapDepths(i);
_root.i + 1._name = i;
_root.partNum = _root.partNum++;
}
}
}
function sendBackward(part)
{
if(_root.selected == true)
{
i = part;
if(! i <= 1)
{
_root.i - 1.swapDepths(i);
_root.i - 1._name = i;
_root.i.swapDepths(i - 1);
_root.i._name = i - 1;
_root.partNum = _root.partNum--;
}
}
}


I'm using Flash MX and below is the error i got.

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 11: ';' expected
_root.i + 1._name = i;;

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 23: ';' expected
_root.i - 1.swapDepths(i);

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 24: ';' expected
_root.i - 1._name = i;

Can someone please help? Thanks!

Swap Several Symbol
Hi all

I want to know if its possible to swap several symbol is the same time.
For example, i made a ball animation in plasma and when i import if flash, i have one key for one ball position.. its very heavy ! So if i can convert and swap it, it will be very light after
Anyone knows how to do that ?

Help With Swap Depths
I have a puzzle that I found in the open source movies that I've tweaked. The only issue I've run into is swapping depths. It would be nice if the puzzle pieces selected on press would swap depths to the top. I've been able to get them to swap depths but a duplicate of the clip is left on the stage where the original was?

Any ideas what I need to do utilize swap depths?

The following is the code that is attached to a button symbol which is a puzzle piece. This is code on the main timeline that specifies the target x and y coordinates. It has a pixel radius that will cause a snap to coordinates when released and code that runs to see if all of the pieces have been dropped in the correct coordinates.

Code on the button (I've commented out the swapdepth code that isn't quite working right:

on (press) {
if (Number(_parent.k8) == 1) {
_parent.k8 = 0;
_parent.:numok = _parent.:numok-1;
}
startDrag("_parent.m8");
//this.swapDepths(1);

}
on (release, releaseOutside) {
stopDrag();
//this.swapDepths(0);

if (Number(getProperty("_parent.m8", _x))>Number(_parent.:m8x-_parent.:snap) and Number(getProperty("_parent.m8", _x))<Number(Number(_parent.:m8x)+Number(_parent.:s nap)) and Number(getProperty("_parent.m8", _y))>Number(_parent.:m8y-_parent.:snap) and Number(getProperty("_parent.m8", _y))<Number(Number(_parent.:m8y)+Number(_parent.:s nap))) {
setProperty("_parent.m8", _x, _parent.:m8x);
setProperty("_parent.m8", _y, _parent.:m8y);
if (Number(_parent.k8) == 0) {
_parent.k8 = 1;
_parent.:numok = Number(_parent.:numok)+1;
}
}
}


Thanks in advance.

Swap A Level
IS there a way to swap a level like swapDepths.
I am trying to do a work around to loading a main swf into a shell of a blank swf this way the load bar will show up at the start of the movie and not 70% into the movie.
I am using the MovieClipLoader class. Which loads the main movie into level 1 but the problem is it uses _root as reference throughout the movie or _level0 so I need a way to swap from level 1 when it loads to level 0 or can this be done.


Here is the code

Code:
loadShell = new MovieClipLoader();
loadShell.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number) {
var p = loadedBytes/totalBytes*100;
tracer.text = "target_mc :"+target_mc;
mainLoadBar._xscale = p;
};
loadShell.loadClip("main_shell_9_e.swf", 1);

Swap Depth
hi folks,

can anybody please help me with some actionscript trouble?

in the attached file I sent you my problem. I got a master movie which loads over some buttons external swf's into my master movie. these swf should be able to swap their depth-value when clicking on them (like you already know it from MS Windows).
Until this point everything works fine, but if I load all the movies on my stage they dont behave as they should.
when I click on movie1 to bring it up on top of the others, movie3 is also kicking through. Is tere a way to avoid this effect?

every support is appreciated.

bye

smik

Swap Layers HELP
I have lots of different buttons on their corresponding layers...this is because the button was animating before it became a button....

when the button is in the over state, it expands, but it remains visible underneath other buttons which are on layers above it..is there any way to make it appear above the rest of the buttons, kind of like 'swapDepth' action script but for layers?

Thank you for reading

Nav

could i do it another way so that all the buttons are on one layer by containing their animation in the upstate? althought this would take lots and lots of time as i have 175 buttons

Need To Have A Box Above My Swap Depths Mc's
Aight... I have two mc's that i have swaping depths. The problem is that need to mask them out, or have a element in my movie that is above them. When i added the swap depths to these mc's they basicly movied to the top of my moive, even though there are layers above them in the timeline. How can i do this?

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