Movieclip display different movie clip
I have 2 movieclips in different places in my movie called
movieclipA and movieclipB. Is there a way to tell movieclipB to
display what's in movieclipA
MovieclipA contains dynamic text fields, MovieclipB contains
Input text fields. When the user enters text into the textfields in
movieclipB the text appears in movieclipA. I need to show another
instance of movieclipA at another place in my movie. The problem is
the tex that is input into the textfields in movieclipB only shows
up in one instance of movieclipA. I need it to show in both
instances.
Similar Messages
-
Hello,
I am creating a program that is going to help students learn to read. In my project are pages of text with each word having a button that when pressed will display a movieclip presentation about that word (its pronounciation and spelling etc..). In the project I am working on now I have over 450 unique presentations of words to deal with. I don't want to have all of these hundreds of movie clips on the stage and tell them one at a time to stop and rewind and then have one play each time a word button is pressed. That seems to be very inefficient to me. So I want to do this with some code in Actionscript 3.
I know I can dynamically add movieclips to the stage using addChild(movieclipname) and remove them using removeChild(movieclipname) but there is a problem. I have hundreds of unique movieclips and I don't want to have to manage hundreds of variables containing the indivudual movieclip instancess. It is a real pain having to figure out what instance is still on the stage before i delete it.
In Adobe Director all I have to do is this:
on mousedown me
sprite(me.spritenum).member = member("somenewmember:)
end
and that was it
But if I do this in actionscript 3:
removeChild(some_mc)
some_mc still exists in memory. And I have to know exactly what variable it is to remove or else the movie will fail with an error. If I try to be brutish about it and try to implicitly remove all 450 movieclip instance variables from the stage I will get at least 449 errors.
What I want to do is this:
removeChild(some_mc)
some_mc = void //or //delete some_mc
var some_mc:MovieClip = new someother_mc();
addChild(some_mc)
but this doesn't work
How am I going to remove one of 450 movie clips and add a new totally different movie clip without the code knowing exactly what the last movie clip was? I suppose if could remove a child from the stage based on a string name then I could hold that name in a variable for later disposal.Can I do this?
Thanks for any help you can give me. I am new to actionscript.Hey I think I may have a solution:
//begin code
var myMC:MovieClip = new ball();
var starMC:MovieClip = new star();
var youpresseeditMC:MovieClip = new youpresseedit();
starMC.name = "star";
myMC.name = "ball";
youpresseeditMC.name = "youpresseedit"
addChild(myMC);
box.addEventListener(MouseEvent.MOUSE_DOWN, replaceball);
press_BTN.addEventListener(MouseEvent.MOUSE_DOWN, replaceballwithtext);
function replaceball(event:MouseEvent):void {
trace(myMC.name)
removeChild(myMC);
myMC = starMC;
addChild(myMC);
trace(myMC.name)
function replaceballwithtext(event:MouseEvent):void {
trace(myMC.name)
removeChild(myMC);
myMC = youpresseeditMC;
addChild(myMC);
trace(myMC.name)
///end code
This works. I see the ball object replaced by the star and I am able to do this by manipulating just myMC. Is there anything I should be concerned with in this approach?
Thanks for your help -
Playing different Movie Clips onRollover?
I have several buttons that I would like to play different
movie clips
onrollover on the stage. So if button 1 is rolled over it
plays a clip
in the lower right corner and when rolled off it stops and if
button 2
is rolled over it does the same.
How is this done?
Thanks!This is the code I am currently using to play and stop a
movieclip:
myPlay_btn.addEventListener(MouseEvent.CLICK, playMc);
myStop_btn.addEventListener(MouseEvent.CLICK, stopMc);
function playMc(e:MouseEvent):void{
my_mc.play();
function stopMc(e:MouseEvent):void{
my_mc.stop();
1. How do I drag my movie clips onto the stage, but not have
them
display until the button is rolled over?
2. Would this code just be applied for each button and
modified from
CLICK to OnRollover?
Thanks!!!!
kglad wrote:
> assign a rollover listener to button 1 and in its
listener function apply the play() method to your right corner
movieclip. likewise for button 2. -
Dynamic text in different movie clip
Inside scene one i have a movie clip that contains a movie
clip that contains a dynamic text field. Also inside Scene one I
have a different movie clip that contains a movie clip that
contains a movie clip that contains a input text field. And I need
for the user to type in to the input text field and see what they
are typing show up in the dynamic text field. What would that
script look like and where would I put it? Can anyone help
please?hi!
Lets say you have your dynamic clip on the same level as the
movieclip containing your input field.
_root.dynamic_texfield_name.text =
_root.name_of_movieclip.input_texfield_name.text;
If you need the dynamic textfield to be updated as soon as
the user types something in the input field you can use a onChange
handler.
_root.name_of_movieclip.input_texfield_name.onChange =
function(){
_root.dynamic_texfield_name.text =
_root.name_of_movieclip.input_texfield_name.text;
} -
Buttons actioning in different movie clips?
So ive set up some buttons into a movie clip, but i want to get them performing actions in a movie clip that is within another clip.
For example, the code below is what I have attached to one of my buttons. The Movieclip 2photosMC2 is inside a DIFFERENT movie clip to the ones where the buttons are stored. How can I script so that the button actions activate the correct clip?
on(release){
photosMC.gotoAndPlay("img 02");
With the code above, photosMC is the movie clip i want to play and img 02 is within this. The button with this code in is in a different movie clip to the one in which photosMC is held
Any ideas?
Many Thanks
DaveIf you get away from attaching code to buttons you might find it easier to manage that targeting you will need to do. If you assign instance names to your buttons and movieclips, then you can have your code in the main timeline and assign the interaction to the objects from there. As an example, le's say you have a button named "gtn" inside a movieclip named "btnHolder" that sits on the main timeline. And you want to have that button tell a movieclip named "mc" that sits inside another movieclip named "mcHolder" that is also on the main timeline. Then in the main timeline you could use...
btnHolder.btn.onRelease = function(){
mcHolder.mc.gotoAndPlay("img02");
To do it the way you want would require using _root or _parent targets, which is usually better to avoid...
on(release){
_root.mcHolder.mc.gotoAndPlay("img 02");
or maybe...
on(release){
_parent.mcHolder.mc.gotoAndPlay("img 02"); -
Same button on single frame to display/hide movie clip?
Hi, can a button on a single frame be coded to both display a movie clip on its first click and, after a second click, hide the movie clip? Thanks
Yes, assuming you make the movieclip invisible to start with, in the event handler function just use...
mc_name.visible = !mc_name.visible; -
How can I display a Movie clip from library on stage in AS3?
Hi,
I have a movie clip in my library and I would like to display it on the stage using AS3.
do I have to define it as a variable?Do I need to use this code: addchild(movieclip);
can I use the 'x' and 'y' to position it?
What would the code look like?
Ben.Great! it works well ! thanks
But I have another question, if I wanted to used the same movie clip but postion it at different x and y positions when a different btn is selected how could I do that?
Would I have to make a copy of the movie clip and give it a different name?
or is there an better way around it?
Ben. -
Different Video Clips for Chapters and Full Feature Movie
How can you assign a different movie clip for the animated chapter frames and for the full feature video when you click on the frame in the menu???
Even if you do not want that part to be seen in the real movie?
We have cut a feature film (dance show) in five parts, just for the sake of video previews (supposed to be seen in slow motion).
If you put these five so called "preview videos" to the end of the time line with the appropriate poster frames linked to the appropriate chapter markers will they be hidden in the main movie, right?
Thanks a lot for your feedback. -
Playing a Movie Clip within a Movie Clip on load
Hi,
I'm trying to play a Movie Clip animation that is within a Movie Clip after a button has been pressed in a different Movie Clip.
The issue is that all Movie Clip animations are playing as soon as the SWF is loaded.
I have a separate Main.as file that contains all of the coding except for the animation stops:
package
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
var title1:Title1;
var scene1:Scene1;
var scene2:Scene2;
var scene3:Scene3;
var scene4:Scene4;
var scene5:Scene5;
var scene6:Scene6;
var scene7:Scene7;
var scene8:Scene8;
var scene9:Scene9;
var scene10:Scene10;
public function Main()
title1 = new Title1();
scene1 = new Scene1();
scene2 = new Scene2();
scene3 = new Scene3();
scene4 = new Scene4();
scene5 = new Scene5();
scene6 = new Scene6();
scene7 = new Scene7();
scene8 = new Scene8();
scene9 = new Scene9();
scene10 = new Scene10();
addChild(title1);
title1.buttonStart.addEventListener(MouseEvent.CLICK,onButtonStartClick);
scene1.buttonWalkOutside.addEventListener(MouseEvent.CLICK,onButtonWalkOutsideC lick);
//title
function onButtonStartClick(event:MouseEvent):void
addChild(scene1);
removeChild(title1);
Scene1(parent).gotoAndPlay("frame1")
//scene1
function onButtonWalkOutsideClick(event:MouseEvent):void
addChild(scene2);
removeChild(scene1);
So right now, I'm getting this error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@46534041 to Scene1.
at Main/onButtonStartClick()
Any help is greatly appreciated... I've been grinding at this all night.I had been trying a bunch of different methods after searching for clues on Google, so it probably doesn't make sense with the parent.
I replaced the code with what you wrote, and I am given this error now:
Main.as, Line 44
1120: Access of undefined property scene1Text1.
Is there somewhere I have to declare scene1Text1 in Main.as? -
How to load dynamic text inside a movie clip?
hello all - i have a main stage where on the first frame my
"home" movie clip displays. i did this by dragging/dropping, and
then i put a stop action. all works fine.
inside this home movie clip on the main stage, there are
links to other movie clips. for example, to get to my faq's page -
you click that button, then it takes you to frame 4 on my main
stage, where my faq's movie clip (followed by stop action) has been
dragged/dropped and displays properly.
within the faq's movie clip this process is repeated, with
buttons taking to you various pages (different frames where
different movie clips play - all works fine).
so now i want to add a dynamic text field within my faq's
movie clip. i have read numerous tutorials where i have created the
text file but i have not been able to display it with success
within my faqs movie clip.
here is some code that my dvd tutorial instructs me to place
on main stage as i practice getting this to work:
var myMCL:MovieClipLoader = new MovieClipLoader ();
var myListener:Object = new Object();
myMCL.addListener(myListener);
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function (success:Boolean) {
if (success) {
_level5.loadedInfo.htmlText = myLV.info;
} else {
_level5.loadedInfo.text = "There has been an error loading
the requested information. Please contact the webmaster.";
and here is some code that i place on the faqs button within
my main movie clip that takes me back to main stage and plays faq
movie clip all successfully:
on (release) {
//Movieclip GotoAndPlay Behavior
_root.gotoAndPlay("4");
//End Behavior
and finally, here is some code that i place within my faqs
movie clip in an attempt to display my dynamic text within the faqs
movie clip - so far unsuccessful:
_level0.myLV.load("vars/faqs.txt");
NOTE:
i have published this to view - not working.
i have my faqs text file starting as info=
i have eliminated white space within my text file
i am using flash 8 pro
can anyone offer some sugestions? thanks!hmmmmm lemme double check as i seem to be a bit lost now.
// this is my actions layer code on frame 4 of main timeline:
stop();
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function (success:Boolean) {
if (success) {
_level5.loadedInfo.htmlText = myLV.info;
} else {
_level5.loadedInfo.text = "There has been an error loading
the requested information. Please contact the webmaster.";
myLV.load("vars/faqs.txt");
1. fyi - at frame 4 on main timeline, one layer beneath the
actions layer where i dragged/dropped my faqs movie clip i gave my
faqs movie clip an instance name of "mainfaqs" - although nowhere
do i refer to this specific mc within my code.
2. where would i replace/insert the following code?
_level0.faq_mc.loadedInfo.text = myLV.info;
3. i didn't know about embedding font but i saw the option
and embedded it - still no results.
4. i'm not sure how to do the following:
_level5.loadedInfo.text ='test'; //although I would still
change the path as above
To see if your getting a return from the load call adn text
file, use a trace statment before the success condition and see
what it returns:
trace(myLV);
sorry to be such a pain - i really have looked around for
answers through previous postings and i googled it and i've been
taking instruction through lynda.com and dvds but i seem to be
stuck here.... as always - thanks for your time -
Using colorTrans:ColorTransform on more than one movie clip
Hi I am very new to Flash and action script so please bare with me...
I would like to be able to change the color of more than one movie clip in the same layer in the same frame. Basically I have place two different movie clips with defined instances,i.e. body and shoulder onto the canvas in one frame on the timeline.
I have created three different buttons (red_btn, blue_btn, and yellow_btn) to use to change the color of say the body or shoulder. I would use red and blue to change the body and say yellow and green to change the shoulders. These are also on the same layer and same frame on the timeline as the movie clips.
The problem I am having is how would I declare the two movies or variables to change independantly? Would I need to place one movie clip on one layer and then place the other on a different layer so that when I press the button I want i.e. the red button, it only changes the body and not the shoulders.
Here is my actionscript that I am using to change the color of the clip(s)
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
var trans:Transform = new Transform(body);
trans.colorTransform = colorTrans;
blue_btn.onRelease = function() {
colorTrans.rgb = 0x0000FF; // blue
trans.colorTransform = colorTrans;
red_btn.onRelease = function() {
colorTrans.rgb = 0xFF0000; // blue
trans.colorTransform = colorTrans;
yellow_btn.onRelease = function () {
colorTrans.rgb = 0xFFFF00; //yellow
trans.colorTransform = colorTrans;
body here is my declared variable wich is the body of a shirt that is one movie clip. When you place both clips on the timeline ontop of each other, you basically get a shirt with different color shoulders and body.
I need some help to know if this is possible first of all, and then what would be the best way to delcare the variables in one actionsript.
Thanks and I am sorry, I just never learned much when it came to flash. Thanks for any patience and help anyone is willing to give me.every movieclip has a transform.colorTransform property that you can use to assign a color transform (with any rgb property). so, for example:
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform = new ColorTransform();
bluebody_btn.onRelease = function() {
colorTrans.rgb = 0x0000FF; // blue
yourbodymovieclip.tranform.colorTransform=colorTrans;
blueshoulders_btn.onRelease = function() {
colorTrans.rgb = 0xFF0000; // blue
yourshouldersmovieclip.transform.colorTransform = colorTrans;
yellowbody_btn.onRelease = function () {
colorTrans.rgb = 0xFFFF00; //yellow
yourbodymovieclip= colorTrans;
etc -
Flash Newbie needs help with Movie Clips/Action Scripting
Hi -
I'm having a problem with my movie clips playing
simultaneously and cannot, for the life of me, figure out what I
have done wrong. I'm new to flash, so I may have set something up
incorrectly, but here's what I have so far:
11 layers, total: 1 layer with 10 control buttons, each
button with the following actionscript:
on (release) {
gotoAndPlay(85);
Where the number changes in relation to which keyframe the
next movie is on.
I have 10 movies, total, but they are only movie clips,
essentially photo slide shows with audio, made all in the library.
The problem happens when I click on the second or third
button. Not only does the movie that I have selected begin to play,
but all of the previous clips do as well, so it all sounds quite
garbled. I don't know what I am missing in the action script, as my
Action Layer has a stop command on it at each keyframe where there
is a new clip to play.
I have tried to add a stopAllSounds command, but I'm afraid
that doesn't do anything because it is not a "sound file" per se,
playing in the timeline.
I'm at the end of my rope and really need some help in
figuring this one out. My project is hanging in the balance on
this, as I have scripted everything else correctly and it runs
beautifully.
Please help!
Thanks,
CarolineEach layer has a blank keyframe before and after each
movieclip. Each movie clip is at a different frame. Even with the
blank keyframes added, the second video starts to play and then the
first video begins to play. Same happens if I click on the third
button. Third plays, and starts 1st and 2nd shortly thereafter. Is
there an action script I can put in that will tell the timeline
that, when a button is clicked, no matter where the movieclip is,
it will stop and start the newly selected movieclip? -
Hi. I've basically been copying code from a series of tutorials, and now I've hit a wall because the series doesn't cover this part, and I'm certainly no expert at ActionScript.
Basically, I'm trying to handle all the navigation with movieclips instead of moving around on the timeline. What Im trying to achieve is to have a main 'page' with a couple navigation buttons. One of them (cartoonButton) would open a movieclip called cartoonBG, which is a 15 frame alpha fade-up that would end with a frame with buttons for opening cartoons (right now, there's only one cartoon, but eventually there will be more).
The problem is, as soon as the file opens, it goes into a loop, playing the cartoonBG movie clip over and over. So, I guess I need to know how to make it so that the frame is still when the clip opens, and then I can do an onRelease for cartoonButton and have that open and play cartoonBG. That's sample 1.
Sample 2 is what I have for frame 15 of cartoonBG. That would be where the alpha fade-up stops, and I want it to be set so you click episode1Button and that loads BnR1.flv into the NetStream (and, later on, when I have a second cartoon, episode2Button would load BnR2.flv and so on). That's sample 2.
Thanks so much in advance if someone could help me out!
SAMPLE 1:
stop;
cartoonButton.onRelease = cartoonBG.play;
SAMPLE 2:
stop;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.play("BnR1.flv");
playButton.onRelease = function() {
ns.pause();
var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;
ns["onMetadata"] = function(obj) {
duration = obj.duration;
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 475;
loader.scrub._x = ns.time / duration * 475;
var scrubInterval;
loader.scrub.onPress = function () {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,461,this._y);
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
clearInteral(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/461)*duration));That works, but I actually want it to be set up so I (or the user) could go back to cartoonBG again, as opposed to getting rid of it completely.
The way I'm setting this up is that homeButton, cartoonButton, and a couple others (extrasButton, downloadsButton) are all navigation on a footer that will always be there, but they'll bring up these different movie clips (cartoonBG, extrasBG, etc.) instead of going to other frames on the main timeline. The tutorial I was working off of seemed to think that was the way to go, and for whatever reason, I took him at his word.
Anyway, is there a different way I could code homeButton that wouldn't get rid of cartoonBG?
I should also take this opportunity to say thanks for all this help! I really do appreciate it! -
Several Clickable Movie Clips?
I have a program where I have several different movie clips,
some on top of one another. And when I click I want the one I
clicked and two or three others to switch places so the others
underneath show. I can do this, but only for one movie clip. I
can't make any other movie clip clickable without having an error
saying I am redefining function clickListener.
What can I do?How are the movieclips arranged. Does the one on top block
all the others or are they spread out such that portions of the
underlying ones are visible?
Also, can you show the code you are using? -
Thanks for reading my post. I have a script that
randomly displays a movie clip of a logo. As shown below:
function showLogo(){
var rndNum:Number = Math.round(Math.random()*11);
this.attachMovie("logo" + rndNum, "logo1_mc",
this.getNextHighestDepth(), {_x:0, _y:0});
setInterval(showLogo(),1000);
It seems to be working. But, I still have two problems.
1. The moviclips stay on the stage after a new clip called.
2. I'd like to have the movieclips fade in then out.
My questions:
1. setInterval() doesn't seem to be called. The online change
in the interval between logos comes from the length of the main
timeline. How do I get it to work?
2. How do I remove a movieclip from the stage? Do I apply it
to the moveclp being shown? Or the moviclip calling the function?
3.How does the _alpha function work?
I'm new to doing this. So, I thank you for your patience in
advance.If you want alpha fades, you need to tween the alpha values.
One way to do this is with the Tween Class:
http://www.adobe.com/devnet/flash/articles/tweening_05.html
And your code is a little off. Here's the corrected code:
Maybe you are looking for
-
I recently borrowed a 1st generation nano from a friend when my 30GB video iPod spazzed out. He's on a PC and I'm on a Mac but he told me to feel free to restore it and update it, whatever, because he doesn't use it much anymore. When I first plugged
-
Which port number should be entered to create an icloud email account?
Which port number should be entered to create an icloud email account?
-
Publishing a BEx Query reports from BI Portal to Main portal
Hi, We have 2 portals in out landscape. BI system has its own portal and the main portal for the commercial users. I have a requirement to bring BEx query Reports to Main portal. I am wondering, how this can be done. Thanks Sam
-
For a few months Mozilla was crashing at least once a day, and a few days ago it started going completely out of hand, crashing, closing unexpectedly every now and then. Since yesterday night it hasn't worked at all, i wasn't able to open any singlel
-
I recently upgraded my Mobo and set CrossfireX, so all my PCIs got obscured, had to let go of my?faithful X-Fi XtremeMusic. So I got a X-Fi Surround 5. USB. Good device but poor software,?I am missing lots of my XtremeMusic features like SVM I used q