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




How Do You Reference Other Movieclips



How do you reference other Movieclips? I'm coming back from a flash vacation and I don't remember anything.

For example, if I were to have the following code, the result is perfect.

Code:
on (rollOver) {
this._alpha = 50;
}
What I can't find out is how to reference other Movieclips, like

Code:
on (rollOver) {
this._alpha = 50;
someotherMC._alpha = 50;
}
The movie clip that I wish to affect is in another layer, if that helps.



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 01-28-2007, 04:29 AM


View Complete Forum Thread with Replies

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

Dynamic Reference To MovieClips
I have an array containing names (as strings) of already existing MovieClips, array=["a1","a2","a3",...].
Is it possible to refer to a MovieClip using the content of an array?

For example I would like to load the MovieClip "a1" into a blank MovieClip placed on the stage. How can I load the MovieClip using array[0] as a reference?

Obviously MovieClip.attachMovie(array[0]) does not work..

Any ideas?

Dynamic Reference For Movieclips
I have read several examples both on the web and in the Adobe help files regarding dynamic referencing.

I cannot get Actionscript to recognize a dynamically named clip such as in the attached for loop.

Any suggestions as to why thumbCan[thumbMC+i] returns undefined and therfore doesn't allow anything to be loaded?







Attach Code

for (i = 0; i < mainArr.length; i++) {

thumbCan.createEmptyMovieClip("thumbMC"+i, thumbCan.getNextHighestDepth());
trace("trace1= "+thumbCan[thumbMC+i]); // returns undefined
trace("trace2= "+thumbCan); // returns _level0.thumbCan as expected

daLoader.loadClip(mainArr[i][0], thumbCan[thumbMC+i]);
}

Reference Child Movieclips
I have 5 moviecips inside a main movieclip.

_cn (main cclip) and _gl0,_gl1,_gl2,_gl3,_gl4 .. inside the main clip.

i want to refer to the clild clip inside a function .. how to do that.

for example .. as below,


Code:
function _xx(_num){
trace(this['cn']); // works fine
trace(_cn.this['_gl'+_num+'']); // error
}
_xx(3);

Dynamically Reference Multiple MovieClips
I'm looking for a concise way to dynamically change the widths of 12 Movie Clips. Let's say they're named mc1, mc2, mc3, etc. Is there a way I can loop through these instance names, referencing them dynamically?

This is what I'm talking about, obviously it doesn't work:

for(i=1;i<=12;i++){
"mc"+i+"._width"-=2;
}

Trying to avoid:
function changeWidth(){
mc1._width-=2;
mc2._width-=2;
mc3._width-=2;
etc...
}

Null Object Reference With Nested Movieclips
I've been struggling with this issue for a couple of days now, please someone help me out. Basically all I want to do is change the frame of a nested movieclip and flash is getting a null object reference and crashing. This seems like it should be a very simple thing to do in flash, but it is not. I have a movieclip linked to a class which I am attaching via code, that is working no problem. Inside of this clip is another clip with an instance name. As long as the outer movieclip is at frame 1, I can access the inner clip. However if the outer clip is at another frame number the inner clip will not be accessible.

I have created a quick little file which illustrates the problem. In the file there are 2 instances of a movieclip, called test1_mc and test2_mc. Inside this movieclip are 4 different frames, each one with a different box movieclip (a box with the text "1", "2", etc). Each one of these numbered box movieclips are given a different instance name, box1_mc, box2_mc, etc. This inner movieclip also has 4 different frames on it (with different colors). If the outer clip (test1_mc) is at frame 1 then you can access the inner clip (box1_mc) as you would expect (test1_mc.box1_mc). However if the outer clip is on any other frame the inner clip is null. If I check the numChildren, it still traces out 1, but then tracing getChildAt(0) is null. I don't get it.

Below is the code that causes the error:
Click here to download the FLA file


Code:
test1_mc.gotoAndStop(1);
test1_mc.box1_mc.gotoAndStop(3);
trace("test 1 child num: " + test1_mc.numChildren);
var child1 = test1_mc.getChildAt(0);
trace("test 1 child = " + child1);
trace("child 1 name = " + child1.name);
//
test2_mc.gotoAndStop(2);
trace("test 2 child num: " + test2_mc.numChildren);
var child2 = test2_mc.getChildAt(0);
trace("test 2 child = " + child2);
//
trace(" - - - display list - - -");
traceDisplayList(stage);
This file traces out the following:

Code:
test 1 child num: 1
test 1 child = [object MovieClip]
child 1 name = box1_mc
test 2 child num: 1
test 2 child = null
- - - display list - - -
[object MainTimeline] root1
[object TestMovieclip_1] test1_mc
[object MovieClip] box1_mc
[object Shape] instance1
[object StaticText] instance2
[object TestMovieclip_1] test2_mc
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at NestedMovieclips_fla::MainTimeline/traceDisplayList()
at NestedMovieclips_fla::MainTimeline/traceDisplayList()
at NestedMovieclips_fla::MainTimeline/traceDisplayList()
at NestedMovieclips_fla::MainTimeline/NestedMovieclips_fla::frame1()
Notice how the test2_mc numChildren is equal to 1, yet getChildAt(0) is null. I think the is the crux of the problem. Honestly, this is looking like a bug in flash9, because the crash happens even if you just traverse the display list as shown above. How is it possible that something that is displayed on the screen could be null? Or in other words, how could can an object exist on the display list, be physically on the screen, and yet be null. If anyone can give me a work around or explain what is happening here, it will be greatly appreciated.

Referencing MovieClips Inside MovieClips From The Main Time Line?
is it possible to have event listeners that listen for a movie clip inside a movieclip and then execute a function from the main time line?
Or is it impossible to relate something this far removed? Sounds like a geek Jerry Springer episode!
Something sort of like this:









Attach Code

movie1_mc.closeBtn1.addEventListener(movie1_mc.MouseEvent.CLICK, closeMenu1);
movie2_mc.closeBtn2.addEventListener(movie2_mc.MouseEvent.CLICK, closeMenu1);

function closeMenu1(e:Event):void {
if (e.currentTarget.name == "closeBtn1"){
movie1.gotoAndPlay(27);
movie1.visible = true;
} else if (e.currentTarget.name == "closeBtn2") {
movie2.gotoAndPlay(27);
movie2.visible = true;
}
}

Adding Movieclips Inside Of Two Other Movieclips... XML Powered Slideshow
hello..

I have been working on this project that used part of the kirupa.com tutorial for XML slideshows as a base. What it does is takes a set of thumbnails from an XML file and puts them in a movie clip on different layers. (Each thumbnail a new movieclip on a new layer of the original movieclip)

Anyways, what I am trying to do is make a menu movieclip pop up when a button is clicked. Inside this movieclip is where I want to throw the movieclip for thumbnails to load on. The menu movieclip is working fine and whatnot, but I cannot figure out how to get the thumbnails to load inside that second movieclip.

Here is a chunk of my code:


Code:
function createThumbnailScroller(current_mc, currentThumbFile, thumbCenter) {
thumbnail_scroller.createEmptyMovieClip("t"+current_mc, thumbnail_scroller.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+20)*current_mc;
target_mc.pictureValue = thumbNumb[current_mc];
//trace(thumbNumbforJS[current_mc]);
target_mc.onEnterFrame = function() {
thumbWidth = target_mc._width;
};
target_mc.onRelease = function() {
//tell JS to jump to that slide
flash.external.ExternalInterface.call("jumpToSlide", thumbNumbforJS[current_mc] )
//set scroller movieclip back in its original position (go back to main screen)
yVal = 362;
scroller_move();
};
target_mc.onRollOver = function() {
fadeDown(this);
};
target_mc.onRollOut = function() {
fadeUp(this);
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(currentThumbFile, "thumbnail_scroller.t" + current_mc);
}

"thumbnail_scroller" is the movieclip which is inside of "scroller", the menu movieclip.


Thanks...


EDIT:

I got it working.. I just had to add "_root.movieclipname." in front of the movieclips I referred.

[CS3] Simple Display List Problem (MovieClips In MovieClips)
I have an object called UI_Total which contains 3 objects called Star, instanced as star1 star2 and star3.

In my code I do the standard:

PHP Code:



mainUI=new UI_total;
addChild(mainUI); 




to instance the UI_Total.

Now, I can do something like

PHP Code:



mainUI.star3.x+=500 




no problem.

And when I do

PHP Code:



trace(mainUI.star3.parent) 




I get [object UI_Total] as expected.

Would someone be so kind as to explain to me then why
PHP Code:



mainUI.removeChild(star3) 




doesn't work, and also why I can't do anything like
PHP Code:



mainUI.getChildIndex(star3) 

Adding Movieclips Inside Of Two Other Movieclips... XML Powered Slideshow
hello..

I have been working on this project that used part of the kirupa tutorial for XML slideshows as a base. What it does is takes a set of thumbnails from an XML file and puts them in a movie clip on different layers. (Each thumbnail a new movieclip on a new layer of the original movieclip)

Anyways, what I am trying to do is make a menu movieclip pop up when a button is clicked. Inside this movieclip is where I want to throw the movieclip for thumbnails to load on. The menu movieclip is working fine and whatnot, but I cannot figure out how to get the thumbnails to load inside that second movieclip.

Here is a chunk of my code:


Code:
function createThumbnailScroller(current_mc, currentThumbFile, thumbCenter) {
thumbnail_scroller.createEmptyMovieClip("t"+current_mc, thumbnail_scroller.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+20)*current_mc;
target_mc.pictureValue = thumbNumb[current_mc];
//trace(thumbNumbforJS[current_mc]);
target_mc.onEnterFrame = function() {
thumbWidth = target_mc._width;
};
target_mc.onRelease = function() {
//tell JS to jump to that slide
flash.external.ExternalInterface.call("jumpToSlide", thumbNumbforJS[current_mc] )
//set scroller movieclip back in its original position (go back to main screen)
yVal = 362;
scroller_move();
};
target_mc.onRollOver = function() {
fadeDown(this);
};
target_mc.onRollOut = function() {
fadeUp(this);
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(currentThumbFile, "thumbnail_scroller.t" + current_mc);
}

"thumbnail_scroller" is the movieclip which is inside of "scroller", the menu movieclip.


Thanks...

RollOver Scripts On Movieclips In Movieclips With RollOvers
Hi,
This might get a little confusing so I'll try to explain clearly.
Basically, in Scene1 I have a colored rectangle movieclip with a rollover script that activates its animation e.g. on(rollOver){this.gotoAndPlay(2). That works just fine in activating the rectangle animation,which is just an alpha and tint change.

Within the rectangle movieclip symbol is another movie clip consisting of text graphics that has a similar rollover script placed within its instance within the rectangle symbol.

First of all, this rollover script will not activate when moused over, though the rectangle effect change does.

When I set the text movie clip as a button and place it within Scene 1 rather than within the rectangle symbol, the rollover does work, but it performs a rollOut of the rectangle movieclip. Even though the text button is directly on top of it, the rollOut occurs with the rectangle movieclip when the text button is rolled over.

So maybe you can see what I'm saying here. As part of the first movieclip, an embedded rollover script won't work. As a button placed on that movieclip, the button rollover state interferes with the movieclip rollover script.

I'm sure somebody has encountered this. If I haven't thoroughly confused you, hopefully some charitable soul will help me out.

thanks

Movieclips Within Empty Movieclips...problems
Okay, I'm doing a band web site for my brother and I'm running into this problem...

I want each of the links to be a separate flash file. I understand how to do that and have basic ones working. I have empty movieclips and use the loadMovie function, i.e.


Code:
on(release) {
loadMovie("shows.swf", "shows");
}
The thing is though, the shows.swf file has a textbox which is inside a movieclip which loads an external text file (this is so that they can update the site easily themselves). When I just double click the shows.swf file myself, it opens in the flash player correctly, but when I try to open it from the main.swf file, the shows.swf file loads, BUT the text doesn't appear in the textbox(which is in the movieclip). The movieclip which holds the textbox has an instance name of textbox. I can give you guys the two files if you want to see more if it will help you give me a solution to this problem. I thank you for your time and hope someone can help me.

Michael

Removing Movieclips, Alot Of Movieclips
through a duplicateMovieClip action, i created about 200 mc's named "circleMovie1", "circleMovie2", and so on.

now, how can i delete all these mc's without typing out 200 "removeMovieClip" actions?

plz help!

Movieclips Inside Movieclips Problems
hi.

i have a mc called question13 which holds a number of other mc's inside it on the 12th frame, called tick1-tick6. each of these acts as a simple radio button with the following code (for tick1)...

on (release) {
if (_root.tick1select == 1) {
_root.question13.tick1.gotoAndStop(1);
_root.tick1select = 0;
}
else {
_root.tick1select = 1;
_root.question13.tick1.gotoAndStop(2);
}
}

These work fine as they are.

but i need to set the tick1 to look as though it is "ticked" (ie at frame 2) from the main timeline, not within question13, how do i do this?

Movieclips Play Sounds Of Other Movieclips...
I made a very simply movie comprising of 6 movieclips with sound that play when you press the corresponding key. The top 3 clips play fine but the bottom three play the sound or sounds from previous clips.

also the huskey clip will play when you press either enter or space but it should only be played when you press space. (I was thinking that enter is reserved for playing movies or something.
Thanks for all help.

im using Flash 5

My .fla in a zip file -can be downloaded here...http://www3.telus.net/seanc007/MC_Test.zip

(Too big to be attached)

Checking Distance Between Movieclips Within Other Movieclips
I'm not sure if there is a really quick & dirty way to do this, but I have some movieclips, which are nested within another movieclip, and I'd like to write some code that will return which one is closest to a movieclip on the main timeline. Since there _x's are entirely different because they're not in the same movieclip - is there any way I can make this work?

Thanks!

Target Movieclips From Nested Movieclips...
All,

I was wondering if you could give me a hand?

I have a file that contains two movieclips. One movieclip contains a container clip and the other movieclip contains two nested movieclips which end up with a button. Please see diagram...

I would like for the button, when clicked, to load an external .swf file into the container movieclip which is nested inside a _root movieclip. See diagram...

I have used the following code on my button to no avail:

Code:
loadMovie("Flash/homeIMGs/image1.swf", _root.mainImageMC.imageMC);

AND

_root.mainImageMC.imageMC.loadMovie("Flash/homeIMGs/image1.swf");


Please help.

Movieclips As Buttons Embedded In Movieclips
Hi,

I have a couple movie clips embedded inside a main movie on the root of my movie.

i have an action onRollover applied to the main movie clip, which triggers actions on the movie clips inside it.

i want to use the child movie clips as buttons, but i am getting no response to the code below:


ActionScript Code:
this.mcPic.onRollOver = function() {
trace("rollover");
_root.mcPic.btnBuy.xSlideTo(135, .5, "easeOutBounce");
_root.mcPic.btnListen.xSlideTo(105, .5, "easeOutBounce");
}

this.mcPic.onRollOut = function() {
    trace("rollout");
    _root.mcPic.btnBuy.xSlideTo(360, .5, "easeOutBounce");
    _root.mcPic.btnListen.xSlideTo(-91, .5, "easeOutBounce");
    }

// the following code here gives no response.

this.mcPic.btnBuy.onRelease = function() {
    trace("click OK");
}
this.mcPic.btnListen.onRelease = function() {
    trace("click OK");
   
}

any help would be appreciated.

thanks!
eric

Getting My Buttons Active When Movieclips Are Within Movieclips
Ok so I have this site in progress with these neat drop down menus. When you rollover the image, two or more choices appear that link you to other pages. Only when you rollover them, the buttons don't work. The buttons work when you isolate each movie clip. But once I place the movieclip in the main time line, the buttons don't work anymore. The rollovers don't happen. They aren't clickable.

I need to know how to tell flash to make these buttons work. I can do this if a button is in the maintime line but not when it's embedded in a movieclip which is then embedded in the main time line. Get it?

I uploaded the work in progress so you can see what I mean. www.stephanieerdel.com/headermov.swf

rollover "Vibrations" and you'll see the choices pop up. In the movie clip each choice changes color when you rollover it. As mentioned before, when I put the clip in the main timeline, the buttons don't work. but you see them and the movie clip works fine.

If someone can write out what the code is to let flash know to make these buttons work, I would appreciate it soooo much.

Thank you!

-Stephanie

Calling Other MovieClips Inside Other MovieClips
The problem I am having is a little moe signifcant than what the titles suggests.

What I am trying to do is to determine whether a movieClip, which is nested inside another a movieClip hits another moviceClip, which, you guessed it, is inside another movieClip.

Something along the lines of this:

Code:
onClipEvent(enterFrame){
if( _root.character.charNose_mc.hitTest( this )){
_root.character._x -= _root.char_speed;
}
}
Obviously this code is not working. The movieClip the hitTest( this ) is referring to is inside another movieClip. And charNose_mc is nested inside character at the root level. As you can tell, the goal of this code is to move the character movieClip in a negative direction using a predefined variable called char_speed.

Any ideas on what I am doing wrong, or what is the proper way to format this code? Thanks!

Why Do Movieclips Inside Movieclips Have Different _x And _y Than The Timeline?
I'm confused, why does a MC inside another MC have different _x and _y values than the main timeline?

What I am trying to do right now is animate a MC inside another MC then get the main MC holding everything to move where that new MC ended animating at (it's part of a game I'm making.)

I know it's confusing but Flash shows the cursors current X and Y in the info panel, which is the same as the main timeline. Yet inside the movieclip, an x of 76 and a y of 277 on the timeline is -195 and -30.9 (respectively) inside the MC.

How do I fix it so I can get the _x and _y values to match up so I can tell the main MC to reposition itself to the new X and Y (of the inside MC)

MovieClips Inside Other MovieClips - Detecting All
I have a movieclip called mapWindow, inside mapWindow are dynamically created movieclips of various sizes. The movieclips inside the mapWindow don't take up the entire space of the mapWindow and thus I use a startDrag on the mapWindow upon detection of a mouse press. The problem is, I don't want the start drag to start if the mouse is detected over any of the child movieclips inside mapWindow.

I have a few ideas of how to proceed, but I'm not sure how to reference all child movieclips of a particular movieclip - or something along those lines.

It would be easy to use the hittest function if I knew how to reference all the movieclips I need to, but alas...

Thanks in advance.

Calling Other MovieClips Inside Other MovieClips
The problem I am having is a little moe signifcant than what the titles suggests.

What I am trying to do is to determine whether a movieClip, which is nested inside another a movieClip hits another moviceClip, which, you guessed it, is inside another movieClip.

Something along the lines of this:

Code:
onClipEvent(enterFrame){
if( _root.character.charNose_mc.hitTest( this )){
_root.character._x -= _root.char_speed;
}
}
Obviously this code is not working. The movieClip the hitTest( this ) is referring to is inside another movieClip. And charNose_mc is nested inside character at the root level. As you can tell, the goal of this code is to move the character movieClip in a negative direction using a predefined variable called char_speed.

Any ideas on what I am doing wrong, or what is the proper way to format this code? Thanks!

Targeting Movieclips In Attached Movieclips
I have a movieclip that is linked with the name sound1. Inside this movieclip is another movieclip, a loadBar, that when I place on the mainstage, functions fine. I want the loader to be in the attached MovieClip. I'm having issues with targeting though:


ActionScript Code:
rotateMenu.onRelease = function() {
 mySoundLoading = 0;
 myNewMovie = attachMovie(mybounce, "holder", this.getNextHighestDepth(), {_x:182, _y:125});
this.myNewMovie.loadBar._xscale = mySoundLoading;
trace(this.myNewMovie.loadBar._xscale);
trace(mySoundLoading);}

My first trace comes up undefined...the loadBar doesn't function.
I've tried targeting this.holder.loadBar._xscale.
I've tried targeting without this.
I've tried targeting the name of the linked movie:mybounce....
How do I get to the loadBar within my attached movie??
Thanks.

AS3 - Reading Movieclips Inside Movieclips
hey all. i'm such a noob when it comes to AS3 but i'm determined to learn.

i've had to drop out of strict mode to make this work. can someone tell me why? i've a feeling it has to do with casting maybe. this is in an .as file and not on timeline.

trace(getChildByName("box1").playerStats.x);

in strict it throws up "1119: Access of possibly undefined property playerStats through a reference with static type flash.displayisplayObject."

yet trace(getChildByName("box1").x); works just fine.

also i want to refer to it dynamically with "box"+i. do i use this["box+i].playerStats.x?

edit: trace(getChildByName("box"+playerPos).playerCards.x); seems to work ok!

help!

Targeting Movieclips From Movieclips
I just moved up to Flash MX from Flash 4 and the dot notation is killing me.

My goal is to target one movie clip (mc2) and play a certain frame(lable1) from a button on another movie clip. Normally, I would do an "on release, tell target" and everything would be grand, but my dot notation isn't working properly. It works on the first click but intermittently on further clicks. My code on the button is:

on (release) {
_root.mc2.play(lable1)}

The first time it plays the right lable, the next time I click it plays the next lable on the timeline, next click it jumps to another lable-all within mc2 at least. Each label has stops so that isn't the issue (i don't think)

Is there a better way to do this? Why is this so hard!?!

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?

Loading Movieclips Into Other Movieclips
Hello, not sure if this is possible but...

I've got a random number of dynamically generated movieclips.

I want to put all these movieclips inside a scrollpane.

I realise that I can only have 1 movieclip inside a scrollpane, so

how can I load each of these random movieclips into my container clip?

Cheers for your help

Detecting MovieClips On MovieClips
If you have object1, say a movie clip and its dropped onto object2 another movie clip, object2 is now the droptarget of object1. Am I correct?

Is there any way to access object1 from object2. Say, give me the object that is on top of object2.

And is there any way to determine if an object has any objects(doesn't matter what object) on top of it?

Movieclips Inside Movieclips
hi.

I am having problems with my game. I want to make bombs and for this i needed a movieclip 1 inside movieclip 2. When movieclip 1 is touched by the player the movieclip 2 plays. I have had no success so far and i cannot use such things as nameing the bomb as it wil take too long because i would like to c +p loads on the game.
Here are the codes i have tried:

code: onClipEvent(enterFrame) {
if(this.hitTest(_root.box))
_root.play ();
}
that made the main frame change.
code: onClipEvent(enterFrame) {
if(this.hitTest(_root.box))
play ();
}
this did nothing
i also tried this but it did not work.
code: onClipEvent(enterFrame) {
if(this.hitTest(_root.box))
_root.this.play ();
}

Have you got any ideas? i tried to provide code and my errors like i must. thanks

[F8] Movieclips Within Movieclips Probs
another super long one!
on my main timeline sits a moviclip called photobook. Its first frame is empty except for a transparent button, which when clicked, 'opens the book' by going onto frame 2, a page from the book
inside this clip laid out on the 'pages'are six other clips, they appears as 'newscuttings' in the scrapbook which is my photobook clip. I have scripted it so that when the user clicks on one of the six clips, they see a larger version of the newscutting image. I have achieved this by placing a larger version of the image in a layer above the original image, all contained in the 'newscutting' clip. The I created a 2 frame clip called 'papermask' the first frame containing some invisible shape, the second containing the mask shape which covers the larger version of the image. i placed this 'papermask' clip in a layer above the larger version, and turned masking on.
then I applied the following script to the newscutting movieclip:

on (release) {
this.papermask.gotoAndStop(2);
_parent.closeBtn.gotoAndPlay(2);
}
the second line refers to a 2 frame clip which acts as a close button to the enlarged image. the second frame contains the close button, so when the enlarged image appears, so does the close button.
the close clip has the script attached to it:
on (release) {
_parent.newscrap1.papermask.gotoAndStop(1);
this.gotoAndPlay(1)
}
It closes the image by going into the mask clip and returning the playhead to the first emppty frame, hiding the big version from view. it goes to its own first frame, hiding itself from view.

Right, now i get to the point!!
This all works, I can see a larger version of my news cutting image by clicking on movieclip, and can close it by clicking the close clip.
the problem is, when i click a close BUTTON which closes the parent "photobook" clip by returning it to its first, invisible frame, the 'newscutting' clip that i have clicked on stays there, even though it is inside the 'photobook' clip and should not be there, as it does not exist in the first frame if 'photobook' !
I tried attaching this to photobook's close button:
on(release)
{_parent.newscrap1.gotoAndStop(1);
gotoAndPlay(1);
}
but no luck!

i know this is a bit of an essay, but i wanted to give as full context as possible so someone could give me some hints!

Loop Through Movieclips Within Movieclips
Hi guys, I ve checked everywhere but I cant find the simple answer to this. I just need to be able to control different movie clip from a loop. The only difference between this and what all the turorials tell me is that my Catergory buttons are within the scope of another movie clip..ShopCatergories..I would have thought the following code should work but I does nothing.


Code:
var temp_mc;

//I put this one in just toe check if I can manually stop on of the
//animations..this works fine.
ShopCategories.CatButton1.stop();

//But none of these stop playing??
for (var i = 0; i<3; i++)
{
temp_mc=["CatButton"+i];
trace(""+temp_mc);//traces the correct thin eg..CatButton1 etc
ShopCategories.temp_mc.stop();
}

Movieclips Interacting With Other Movieclips
I am creating an AS3 Flash CS3 project that moves shapes to other shapes. I have created movieclip buttons, when one clicks on the button a shape connects to another shape. Each button has its own layer and within that layer lies two additional layer. One layer for the actions and another layer for the button states.

I am now trying to disable one button while another is enabled or in the down state.

I have tried listening for the state of the other button, root paths, and every other option that I could find on the net, but with no avail.

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

Loading Movieclips Into Movieclips
what i want to do is have one movieclip load and play certain movie clips whenever a certain button is pressed. i am doing this in my video game, as when u press left, it will load the left walking animation and play it while it moves, then when u release the left arrow key, it will load the standing still animation.
any help would be appreciated!

Accessing Movieclips Within Other Movieclips?
Greetings,

I appreciate you taking the time to look at this problem i am having.
I am still transfering from AS2 to AS3 and right now i am having a very annoying problem.

THE STRUCTURE:
Maintimeline contains 2 buttons that i want to use to access children in a bunch of movieclips.
rectangle_mc has circle_mc circle_mc contains xx_mc xx_mc contains wtf_mc

placed on frame 1 on maintimeline

Why can't flash see my nested movieclips? I remember in AS2 you could go down the line:
_root.movieclipA.movieclipB.movieClipC.movieclipD. movieclipE.gotoAndPlay(frame#);

Any Help Appreciated Thanks,










Attach Code

stop();

function playTimeline (evt:MouseEvent):void {
this.rectangle_mc.gotoAndPlay(2);
}
start_btn.addEventListener (MouseEvent.MOUSE_DOWN, playTimeline);

/*This code errors out*/
function EndTimeline (evt:MouseEvent):void{
this.rectangle_mc.circle_mc.xx_mc.wtf_mc.gotoAndPlay(2);
}
stop_btn.addEventListener (MouseEvent.MOUSE_DOWN,EndTimeline);

Movieclips Talking To Movieclips?
Hi,

Probably a silly question (had a few late nights!!)...

Can I communicate between movieclips?

I have a movieclip containing some buttons but I would like the buttons to tell another loaded movieclip to do something?

Im not sure what to put before the gotoandplay option ie:

on(press){

......... gotoAndPlay("text");
}

etc

Thanks

Spence

Referencing Movieclips Within Movieclips
ok heres the problem:

I have a movieclip which is a button, and this button is inside another movie clip, and this movie clip is within the main movieclip, soo

mainMenu ----> subMenu ----> buttonMenu

how would i reference the button in buttonMenu so that when it is released it goes to requeid frame.

i tried:

_root.mainMenu.subMenu.buttonMenu.onRelease = function() {
required actions
};

but it doesn't work. I'm sure i'm missing something pretty simple but been looking at it for ages now and its just gone blurry.

I've assigned al lthe movieclips instance names.

Many Thanks

Sean

More Problems With Movieclips In Movieclips
I have the next code:

Im trying to make a preloader for the image that gets loaded in a movieclip called picholder,

Now the problem is that i get undefined back for the image ,
so i cannot preload what is not there hehe

and im not sure what im doing wrong .
In my other fla the image passes fine and the code is the same

trace(tes.picholder);

gives me back undefined
where tes is the movieclip i created for each item
picholder is the movieclip where the picture goes in.
(i have put stop() in there and taken it out to test but with no luck)
The code is


Code:

MovieClip.prototype.makeVisible = function() {
clearInterval(this.interval);
this._visible = true;
this.play()
};



function LoadPicInMovie (thepic ,wherein)
{
//wherein._alpha = 0;
trace (thepic);
trace (wherein);
var totalbytes = wherein.getBytesTotal();
var loadedbytes = wherein.getBytesLoaded();
var percentloaded = Math.ceil((loadedbytes/totalbytes)*100);
trace(percentloaded);

wherein.preloadertxt.text = percentloaded;
if (percentloaded == 100)
{

wherein.loadMovie(thepic);
}
}
function clearAll() {
for (var obj in moviecl) {
if (typeof moviecl[obj] == "movieclip") {
clearInterval(moviecl[obj].interval)
moviecl[obj].removeMovieClip();
}
}
}

function AttachMc(counter)
{
tes = GalleryContainer.attachMovie("Holder","item"+counter, counter);
return tes;
}

function List (howmany,Arr)
{
counter = 0;
item_spacing = 160;
luck = 0;
row = 0;
for (var g=0; g < howmany ; g++)
{
var tes = AttachMc(counter);
trace(tes);// fine
LoadPicInMovie(Arr["Clientimages"][g],tes.picholder);
trace(tes.picholder);// undefined

if (luck == 3)
{
row++;
luck=0;
}


tes._x = luck * item_spacing;
tes._y = 140 * row;
trace (counter);
tes.stop()
tes._visible = false;
tes.interval = setInterval(tes, "makeVisible", 500*g);


counter++;
luck++;
}
}
function PutInArray(my_xml)
{
/*
* This function reads the xml file into an array
*
*/
var item_count = 0;

// start with the first item in the XML
var items = my_xml.firstChild.firstChild.childNodes; // menu -> menuitems -> child nodes array
var total = items.length
// create arrays for the values
var TheClients:Array = new Array();
TheClients["Clientids"] = [];
TheClients["Clientnames"] = [];
TheClients["Clientdescriptions"] = [];
TheClients["Clientimages"] = [];
TheClients["Clientdates"] = [];
TheClients["Totaal"] = total;
for (var i=0; i< total; i++) {
// only continue if the type of this item is a squirrel
// create variables for our elements
var clientid = items[i].firstChild; // same as items[i].childNodes[0]
var clientname = items[i].childNodes[1]; // second child node
var clientdescription = items[i].childNodes[2];
var clientimage = items[i].childNodes[3];
var clientdate = items[i].childNodes[4];

// add to array

TheClients["Clientids"][i] = clientid.firstChild.nodeValue;
TheClients["Clientnames"][i] = clientname.firstChild.nodeValue;
TheClients["Clientdescriptions"][i] = clientdescription.firstChild.nodeValue;
TheClients["Clientimages"][i] = clientimage.firstChild.nodeValue;
TheClients["Clientdates"][i] = clientdate.firstChild.nodeValue;
item_count++;

}

return TheClients;
}

// start procedural code
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success){
if (success){
Client = PutInArray(my_xml);
List (9,Client);
trace(this);
} else{
trace('xml file not loaded');
}
}
my_xml.load("portfolio.xml");
stop();

Thanks in advance

Luck

Events On Movieclips Under Other Movieclips?
I have two movie clips added at runtime. For aesthetics, the one NOT listening for any mouse events has to be on top. I have a second clip that gets added beneath the first one; I'm trying to figure out how I can get the one "underneath" the first to listen for mouse events -- essentially, I want the "top" movieclip to be "invisible" to the mouse.

Both of these clips are on the same parent clip, if that makes any difference. Clear as mud? I'm sure this should be simple, but Flash has been beating me up all day and my brain is fried. Thanks for any help!

Movieclips Talking To Movieclips?
Hi,

Probably a silly question (had a few late nights!!)...

Can I communicate between movieclips?

I have a movieclip containing some buttons but I would like the buttons to tell another loaded movieclip to do something?

Im not sure what to put before the gotoandplay option ie:

on(press){

......... gotoAndPlay("text");
}

etc

Thanks

Spence

Reference
Hi! I wish to know if there are any useful books on actionscripting coz the books tt I have is so preface. Thnks...

How Do I Reference An Mc With An Mc?
onClipEvent (enterFrame) {
if (_root.philo.hitTest(this._x, this._y, true) == true) {
_root.enemy.gotoAndPlay(2);
}
}

right now I have that -

what I want to do is reference an MC that is inside philo which is called fist


I tried _root.philo.fist but that didnt work-

can anyone help ? do you understand what I am saying/

thanks.

[F8] URL Reference
Let's say there's an .as file that says:
my_lv = new LoadVars();
my_lv.load("imagespic.png"); //full name is C:Flashimagespic.png
//The AS file resides at C:Flashscripts

now, the .as file is used by a .swf residing at C:Flash

Will the correct file pic.png be retrieved? Even though the .as file is in the wrong directory, but the .swf using it is in the correct directory. I tried it and it didn't work. But i cant tell for sure whether my load() code is wrong or other sections of my code is wrong, so does anyone know whether the code above will work?

Oh, and is it possible to use AS 2.0 to get a list of all the files present on a sub directory, if the .swf is located in a parent directory on the hard drive? Thanks in advace.

Reference Swf 1 From Swf 3
Hello all,

semi newbe here. This should be an easy one. My flash movie loads up. I have a button that loads a second flash swf in layer 3. I have a button in my swf on layer 3 that unloads itself from layer 3. Now I want my first swf in layer 1 to gotoAndPlay("back"); How can I reference frame "back" in swf 1 from swf 3?

I was not sure what to search other then gotoandplay. I could not find what I needed. I hope I made sense. Thanks for any replies.

izze

AS3 Using The Right Reference
Hi there flashers.

I've recently started coding AS3, and I've yet managed to run into several mistakes, but I'm slowly getting to know the language.

My problem is to reference things. I have a main class called Birdy.as, and som subclasses. Look at this listing:


Code:
+Birdy.as
+Shot_mc.as
+Bird_mc.as
+Head_mc.as
To get an easier overview of the code I have called all the classes that comes with a MovieClip with _mc. That means that Shot_mc handles the movieclip "shot" and so on...

The problem is that I don't know how to call the movieclip "head" inside my Shot_mc.as.

It goes like this:

In Birdy.as I make an instance of Bird_mc.as and add it to the stage:

Code:
var bird=new Bird_mc();
addChild(bird);
Then in Bird_mc.as I have the following code:

Code:
//When you click:
var shot=new Shot_mc;
Birdy(root).addChild(shot);

//When we initialize Bird_mc.as
var head=new Head_mc;
addChild(head);
In Shot_mc.as I need to use some information from the Head_mc - how do I do that? How do I get to the Head_mc.as?

Please help me, and give me a link to a tutorial - or explain to me - how I should reference properly.

If I'm unclear in any kind tell me, and I will reformulate my problem.

Many thanks in advance.
Brinck10

Looking For Reference
Does anyone have an actionscript reference for an automated slideshow similar to the swf found on the bestbuy.ca website? Or anything with an animated fading slideshow...I can add in the buttons later.

Much Appreciated!
-Mark

Reference
Hi

On a button I have this script
on (release) {
_root.setArray(this._name, 1)
}

General I have this functionscript
function setArray(whichButton, whichPosition){
whichPosition -= 1;
if (_global["status_"+ whichButton] == "NOTactive") {
myPresentationArray[whichPosition] = whichButton;
whichButton.gotoAndStop("active");
trace("active");
}else{
myPresentationArray[whichPosition] = "";
whichButton.gotoAndStop("NOTactive");
trace("NOTactive");
}
trace("myPresentationArray: " + myPresentationArray);
}


now the part that says.... "whichButton.gotoAndStop("active");" doens't work.
It's like flash doens't recognize the reference to "whichButton".

Oh, and the buttons are on the root of the movie.


Hope somebody can explain this to me.

tx

Reference XML To Another XML, Possible?
is it possible to make an XML file reference another XML file?
Like I have an XML like so:


PHP Code:



 <press>    <path="pages/">    <pages>        <id="0"/>        <pagename="test"/>        <thumb="thumb.jpg"/>        <content>            //refer to content.xml        </content>    </pages>    <pages>        <id="1"/>        <pagename="test2"/>        <thumb="thumb.jpg"/>        <content>            //refer to another content.xml        </content>    </pages></press> 




content.xml
i'll have multiple instances of this, seperated by folders.

PHP Code:



<content>    <name="TEST">    <title>            This is a test.    </title>    <desc>        Lorem ipsum and stuff.    </desc></content> 




i hope that was clear.. is that possible? if so, how would I do that?
or if that can't be done, any alternative method?

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