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




Attaching Movieclips Inside Movie Clips



okay, this is probably a really stupid question but how do I attatch movieclips inside a pre-existing movieclip... for arguments sake lets say i have an MC called "coin" in my library and MC in my timeline called "level" how would I attach "coin" INSIDE "level"?



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 07-08-2007, 03:59 AM


View Complete Forum Thread with Replies

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

Scroll Pane And Attaching Movie Clips Inside It
Hi Guys. Does anyone know how to do this as its doing my head in

I have a scroll pane which is called 'mypane' on the main timeline. I then have a movie clip called mymc which I want to duplicate 5 times into the scroll pane and have it scroll vertically.

I can duplicate the mc's fine normally but cant seem to get them to duplicate inside the scroll pane and then allow it to scroll through them.

Can anyone offer some help?

Thanks.

Movie Clips Inside Movieclips...
g'day,
I have a main content MC which i load up another MC inside. This MC i load inside has some AS to load up some news from PHP / MYSQL.

When i run the news MC by itself it works ok.

When i run this news MC inside another MC it doesnt come at all???
JD

Using Functions On Movie Clips Inside Of Movieclips?
How do you call a fundtion on the root timeline with a movieclip inside of another? I can't get it to work. Thanks for you help.

Problem Attaching Classed Movieclips Inside A Class
I have a class which extends MovieClip (called PictureContainer), and I want to attach a bunch of other classes which extend MovieClip to it (Picture).

main swf file:

Code:
import PictureContainer.as;
this.createEmptyMovieClip("container",0);
this.container = new PictureContainer(directory,extension,numPics);
PictureContainer.as:

Code:
import Picture.as;

class PictureContainer extends MovieClip
{
private var numPics:Number;
private var directory:String;
private var pictures:Array;

function PictureContainer(directory:String,extension:String,numPics:Number)
{
for(var i=0;i<numPics;i++)
{
this.createEmptyMovieClip("p" + i,i);

var fileName:String;
if(i<10)
fileName = "0" + i + "." + extension;
else
fileName = i + "." + extension;

this["p" + i] = new Picture(directory + fileName,i);
trace("TRACE1: " + this["p" + i]);
}

}
}
Picture.as:

Code:
class Picture extends MovieClip
{
private var img:MovieClip;

function Picture(imagePath:String,imageId:Number)
{
//assign the passed id if it exists and is positive, or else assign it -1 for N/A
if(imageId != undefined && imageId>0)
this.id = imageId;
else
this.id = -1;

this.createEmptyMovieClip("img",0);
trace("TRACE2 " + this["img"]);
}
}
The instance of PictureContainer seems to initialize the Picture movieclips okay - TRACE1 results in [Object object], but TRACE2 results in undefined.

Attaching Two Movie Clips?
Effect trying to attempt: a spillage of different types of objects falling and bouncing around

Issue: I can only get one movie clip (object) to show up in the scene. For example in the coding shown below, only 'a' will appear...

_root.total=50;

for (i=1;i<_root.total;i++){
_root.attachMovie("a","a"+i,i+1); // 'a' is the linkage name for object 1
_root.attachMovie("b","b"+i,i+1); // 'b' is the linkage name object 2
}

Please let me know if you need more information....thanks.

Attaching Movie Clips
Heres my code that creates a movie clip then attaches a movieclip to this.

Code:
this.createEmptyMovieClip("bg", 1)
block1 = bg.attachMovie("block", "block1", _root.getNextHighestDepth());
block1._x = Stage.width/2

this works fine.
But when I try to attach another one to this movieClip it destroys the last one:

Code:
block2 = bg.attachMovie("block", "block2", _root.getNextHighestDepth());
block2._x = Stage.width/3

How do I create a movieclip and put both of these movieclips in them?

HELP Attaching Movie Clips
Hi,

I'm trying to use the attachMovie command, I've been playing with the tutorial here on it but I'm stumped at this point.

1: If you look at this tutorial and download the FLA you will see every time you click one of the buttons an instance of a MC will appear on stage.
Then if you click it again the old one disappears and the new instance appears. I want the old instance to stay on screen and add another instance on top.
http://www.actionscript.org/tutorial...ie/index.shtml

2: Is it possible to attach actionscript to these instances when t hey appear on stage. I would, for example like them to be draggable and attach this code.

ActionScript Code:
onClipEvent (mouseDown) {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
        this.startDrag();
}}

onClipEvent (mouseUp) {
    if (this.hitTest(_root._xmouse, _root._ymouse)) {
        this.stopDrag();
}}
any help???
Thanks Thanks Thanks.

Attaching Movie Clips
Hi,

I have this code I want to modify so that I can attach different movie clips in my library to appear randomly on the stage (right now this attaches words created in the actionscript... I tried a few things and they didn't work):

// register root as environment
Object.environment = this;

// create camera object
this.cam = {x:0, y:0, z:900, dx:0, dy:0, dz:90};

// set environmental constants
this.fl = 800;

// create 'space' to which all words will be attached
this.createEmptyMovieClip("space", 1);
// center 'space' on the stage
space._x=500;
space._y=300;

// a string of words related to the wind
this.somewords = "wind breeze storm stormy blah blah test";
// convert the string of words into an array of words
this.wordList = new Array();
this.wordList = this.somewords.split(" ");

// create one instance for each word in the list
for (n=0;n<this.wordList.length;n++) {
// pick a word from the list
var word = Object.environment.wordList[n];
var x = random(1000)-100;
var y = random(400)-169;
var z = random(Object.environment.fl*2)-Object.environment.fl;

// create an instance of the SpaceWord object
nombre = "word"+String(depth++);
initialization = {txtword: word, x: x, y: y, z: z};
space.attachMovie("movie1", nombre, depth, initialization);
}

this.onEnterFrame = function() {
this.cam.dz+=.5;
// move the camera to its destination
this.cam.x+=(this.cam.dx-this.cam.x)/5;
this.cam.y+=(this.cam.dy-this.cam.y)/5;
this.cam.z+=(this.cam.dz-this.cam.z)/10;
}

stop();

Attaching Movie Clips
Hey dose anybody know how to do it so that you have one movie clips which stays with another one but has its own action, (eg. when you shoot a gun and the bullet comes out the bullet dose not move with the guy) i want to do the on a frame eg.

if (_root.rand=1) {
if (Key.isDown(Key.SPACE)) {
gotoAndStop("bulletframe")
}
}

i have tried the aligning way with the _x and _y axes, but the wont work because the bullet needs to come out were the car is facing.

Thanks for the help

Tom

Un Attaching Movie Clips
Hey everyone. I am making something that when a button is clicked, a movie clip that takes up the whole screen is attached using the attachMovie command. At the end of the movieclip I have a button that I want to clear the movieclip when clicked. What is the command to do this. I've tried clear, destroyObject, removeMovieClip, but maybe I'm just doing it wrong. By the way, the movie clip is in the library. Also, how would I refer to this movie clip when using the command? It's in the library but I want it to destroy the instance on screen. Is it _parent.name or _root.name or what? Thanks.

Attaching Movie Clips
Hi guys, i am trying to attach some movie clips and i manage to attach them in random positions but i dont know how to place them all inside my maze, any help? i got the fla file for it.

Attaching Movie Clips
ok i cant get it to work,
i want 2 attach a ovie clip to another,
so when one moves i wan the other to move too.
this is what i have to attach it

_root.two._x = _root.one._x;
it works, but once one of the thing moves, it dotn go with it. anyoen have suggestions?

Attaching Movie Clips
So heres the new problem

I have a movie clip that plays and movies a button to a position on the stage.

After that i want that button to stay there and have a new movie played

When i try this it gets rid on the previous movie, ie the button!!

Ideas??

Un Attaching Movie Clips
Hey everyone. I am making something that when a button is clicked, a movie clip that takes up the whole screen is attached using the attachMovie command. At the end of the movieclip I have a button that I want to clear the movieclip when clicked. What is the command to do this. I've tried clear, destroyObject, removeMovieClip, but maybe I'm just doing it wrong. By the way, the movie clip is in the library. Also, how would I refer to this movie clip when using the command? It's in the library but I want it to destroy the instance on screen. Is it _parent.name or _root.name or what? Thanks.

Attaching Movie Clips
Hi guys, i am trying to attach some movie clips and i manage to attach them in random positions but i dont know how to place them all inside my maze, any help? i got the fla file for it.

Randomly Attaching Movie Clips
Hi,

I want to randomly import movie clips from a 'library.swf';
(all the mc's within this .swf are linked to be exported as
"01", "02", etc.)

The code at the moment looks like this;

1st frame;
placeHolder.loadMovie("library.swf");

2nd frame;
stop ();
// mc 01
placeHolder.attachMovie("01", "my1", 2);
placeHolder.my1._x = 8;
placeHolder.my1._y = 18;
placeHolder.my1._xscale = 100;
placeHolder.my1._yscale = 100;

What I want to do is to, instead of using "01", "02", etc.
placeHolder.attachMovie("01", "my1", 2);
and use an action to randomly import movies from "01" to "50".

Any help or comments will be greatly appreciated,

Thanks,

Lenny.

Duplicating And Attaching Movie Clips
What I'm trying to do is create an application that allows me to have a base movie clip that will be duplicated multiple times, but I want all the duplicates to retain the actions that I've placed on the original movie clip. (the original movie clip is drag and droppable and is rotated with a keypress and click).

I'm using Flash 8.


The way the code works is that the movie clips that are being rotated and dragged have code inside of them (on another movie clip), and pathing allow them to be affected when they're on the main timeline.

For the clips:

Code:
onClipEvent (load) {
var whichOne = _parent._parent;
_visible = false;
}
onClipEvent (mouseDown) {
with (whichOne) {
if (hitTest(_root._xmouse, _root._ymouse, false)) {
trace("hit");
_root.RotateDrag(_name);
}
}
}
onClipEvent (mouseUp) {
stopDrag();
}

And, on the main timeline:

Code:
function RotateDrag(whichPiece) {
if (Key.isDown(18)) {
_root[whichPiece]._rotation += 90;
} else {
startDrag(_root[whichPiece], false, 20, 20, 780, 580);
}
}


So, anyway. That code works, but when I try to duplicate or attach one of the movie clips with a button, it doesn't work.

The first thing I tried was this, but it just duplicates once, and then when I click it again the first one disappears and another one replaces it.

Code:
on (press) {
i = i + 1;
duplicateMovieClip (_root.movRed1, "movRed1" + i, i);
}


At this point I thought, maybe it's a depth problem. So I changed the code, but even though this gave me more duplicates than before, I was only able to do the mouse actions on the original and the newly duplicated movie clip.

Code:
on (release) {
var nextDepth = _root.getNextHighestDepth();
i = i + 1
duplicateMovieClip (_root.movRed1, "red" + i, nextDepth);
trace(_root.movRed1.getDepth());
}


Finally, I tried to attach the movie clip when the button was clicked, but ran into two problems. The first was that when I clicked on the button, I got an attached clip that I could move around, but when it clicked it again that one went away and I got a new one. Again, I thought, maybe this is a depth problem, so I changed the code. Unfortunately, with this code below I get one attached clip that I can do actions on, then I get another one that I can't do anything to.


Code:
on (release) {
i = i + 1
var nextDepth = _root.getNextHighestDepth();
_root.attachMovie("movRedOrn", "movRed" + i, nextDepth, {_x:200, _y:200});
trace(movRedOrn.getDepth());

[F8] Attaching/Removing Movie Clips
I'm having trouble adding and removing a movieclip to my game, when one movie clip is moused over (ie shot..), I'm tyring to get a blood splat movie attached to it, at the location it was shot. However, of the code I've tried, I've only managed to get it to attach the "splat" movieclip to the top left corner of the movie and repeat itself.

I'm thinking of either having use actionscript to change its alpha from 100 to 0, then when it reaches 0, to use code to remove the clip, as currently I am animating the fade of the blood splat.

Current code is as follows:

Bee movie clips name is "bee"
Splat movie clips name is "splat" (splat is a 12 second animation tween of blood enlarging and fading out)


Code:
splat = function () {
attachMovie( "splat", "splat");
if (splat._alpha <0) {
splat.removeMovieClip();

};

}

bee.onRollOver = function() {
moveBee();
//score += 1;
splat();
//soundInstance.start(0,0);
//playing = true;

}
I also tried the following code to attach the splat to the bee's "death" location:


Code:
attachMovie( "splat", "splat", 2);
this._x = bee._x;
this._y = bee._y;
if (splat._alpha <0) {
splat.removeMovieClip();
};
}
But found it was attaching to the bee's new location, and moving everything around and messing up the whole movie..

Feedback is much appreciated on this one, cheers!

Attaching Random Clips To A Movie
Help needed! - I'm starting to learn Flash and actionscript and would apreciate any help. I need to build an animation with images that cross-fade randomly at the same time as text. There are 2 areas; the image area and the text area so there will always be both an image and text but displayed at random. I know how to set up the clips with animation tweens to fade them in and out, but am not sure how make them random or how best to attach them to the movie. Also is a preloader required for this kind of animation? What is the best way to go about this, I want to do it right from the start.

Thanks

Attaching Movie Clips With A Loop.
Hi,

I'm trying to make a portfolio page where each of my thumbnails loads with the 'fading grid' effect. I've made all the thumbnails movie clips with the appropriate script, and they all work fine. I've also set them to be exported for actionscript, each with a number as their name, i.e. "1" "2" and so on.

I was then planning on using the following bit of code to load these movies into my portfolio clip, to save me having to do it at author-time.


PHP Code:



movieX=35 //set first pics position
movieY=25

for (i=1; i<4; i++) {

    attachMovie(i,("image"+i),5); //attach movie loop number, give it the name image<loop number>
    ("image"+i)._x=movieX //move the clip to the current X pos.
    ("image"+i)._y=movieY
    movieX=movieX+10; //add 10 to X pos for next movie





But for some reason, instead of loading two movies, each one 10 to the right of the previous movie, it just loads them on top of each other. Is it something to do with the stage not updating? Help plz!

Attaching Movie Clips With A Loop.
Hi,

I'm trying to make a portfolio page where each of my thumbnails loads with the 'fading grid' effect. I've made all the thumbnails movie clips with the appropriate script, and they all work fine. I've also set them to be exported for actionscript, each with a number as their name, i.e. "1" "2" and so on.

I was then planning on using the following bit of code to load these movies into my portfolio clip, to save me having to do it at author-time.


PHP Code:



movieX=35 //set first pics position
movieY=25

for (i=1; i<4; i++) {

    attachMovie(i,("image"+i),5); //attach movie loop number, give it the name image<loop number>
    ("image"+i)._x=movieX //move the clip to the current X pos.
    ("image"+i)._y=movieY
    movieX=movieX+10; //add 10 to X pos for next movie





But for some reason, instead of loading two movies, each one 10 to the right of the previous movie, it just loads them on top of each other. Is it something to do with the stage not updating? Help plz!

Attaching Dynamic Movie Clips On A Stage Movie Clip
Hi guys ,

I am calling more images in dynamic movieclip on the stage from XML file and show them on the stage after that evry movieclip is draggable and there is lots of labels (movieclips) on which i have to drag the images called from xml files and placed on that label , label is also draggable once when i placed object on the label moviecli then when i drag the label all images placed in side the label should also move with the label .

And there might be more labels and more images , i can place any images in a label or more images on different label but will work siimilarly described above .

So please suggest me and help me out ASAP.

Attaching Button Actions To Png's Inside Of A Movie Clip
I've figured out how to make the scrollpane work (thanx for the tutorial FlashKit!) but now I need to attach button actions

on (release) {
gotoAndPlay("cd1");
} -------- etc, etc

to the individual png's hat make up the movie clip.
I've tried making the cd's button ---didn't work
I've tried making an invisible button to attach to the movie clip---didn't work either.

Any suggestions???

Thanx
CobyCo

Attaching 2 Movie Clips In The Same Action Script
Hi,
I have this script:
_root.attachMovie( id1, newName1, 10);
_root.attachMovie( id2, newName2, 11);

I want the second movie clip not to start until the first one is finished.
How can I do this? I already tried with _frameloaded, but it didn't work. It's doing both movie clips at the same time.

Thanks in advance,

Franco

Attaching Movie Clips To Keyboard Actions
I am trying to figure out a way to make a different movie clip appear (and remain visible) when certain keys are pressed. I am using the attachMovie() method and setting the depth parameter +1 each time a new key is pressed. My problem is that each time a succesive key is pressed the movie that previously appeared disappears and the new one is shown. (They are not in the same place, so one is not obscuring the other. )

I would greatly appreciate any help on this.
Thank you very much.
Jw

Attaching Movie Clips To A Grid Question
in my movie i have button menu pages with a maximum of 16 buttons (4 across 4 down). This amounts to 8 total xy coords. I have a 2d array full of button properties (like names, text, etc), but i don't want to add over a hunderd extra elements (during authortime) which will contain redundant values anyway.

So basically i want to loop through perhaps a 4x2 2d "coordinates array" containing these coords while using attachmovie. My button names are already defined in my definitions array, so all i need to do is cycle through these 4 elements that contain the xy coords over and over again for the length of my button def array.

dig?

hope you can me

Attaching Movie Clips To Drop Down Menu
I have a drop down menu made from a movieclip which drop down in response to a rollover event. I want the menu options to come from an xml file. The xml file could specify anywhere from 2 to 8 menu options so I'll need to create the menu dynamically at run time. I'm confused though because I'll be using attachmovie to add the menu buttons at runtime but the menu should only show when there's a mouse rollover, so how do I do that with attachmovie? Right now the code attached to the menu is as follows:

onClipEvent(load)
{
onRollOver = function()
{
gotoAndStop(5);
}
onRollOut = function()
{
gotoAndStop(1);
}
}

As you can see, what reveals the menu is simply moving from one frame to another. If I could specify to attach the movie clip to only frame 5 of the Menu movie clip then I could see how this would work.

Any suggestions?

[F8] Attaching Actions To A Bunch Of Movie Clips
OK, I got like 35 movie clips that need to have actions attached to them, because they will be used as buttons. They will have actions for mouseOver Out and Click. The clips have instance names like button001 button 002 ... button035. How do I make a loop from 1 to 35, passing each movieclip the same actions? Also in one of the actions on each button it must trigger another button with the same number ending in its instance name, like Bigbutton002.

Does anyone know how I can set this loop up? Thanks a bunch..

Attaching Movie Clips To Random Locations?
Hi, when attaching a movie clip to the stage, how do I attach it to a random location? By default, all the attached movie clips are ending up at x=0, y=0....

Attaching Movie Clips In Loop Problem
I am trying to attach a number of movie clips to the stage in a loop and its only placing one instance on the stage. Are they all hidden benieth eachother? How do i fix this?


Code:
RecCount = 3
var xposition:Number = 400;
var yposition:Number = -50;
function loadclips() {
for (i=0; i<RecCount; i++) {
p1.two.attachMovie("casebutton", "casebuttond"+i+"_mc", this.getNextHighestDepth(), {_x:xposition, _y:yposition});
yposition = yposition+20;
}

Attaching Multiple Random Movie Clips
Why is the attachMovie overwriting previous carnations of my MovieClip. I thought that the "+ i" in "MC_Big" + i would solve that problem. Anyone have a suggestion?

var i = 1;

obj2 = new Object();
obj2.interval = function(s) {
attachMovie("MC_Big", "MC_Big" + i, this.getNextHighestDepth(), {_x:330, _y:220});
trace("AddMagic function added");
}
setInterval( obj2, "interval", 2000, "interval function called" );

Thanks!

Attaching Mouse Events To Movie Clips
my movie works the first time around but fails to after i try to rollOver it again...please help

i attached the clip

thanks.
jonathan

Attaching Movie Clips From Library With ActionScript
Hello,

I'm trying to target a button within a movie clip that is loaded using ActionScript and I'm having some trouble. Here is my issue: I have two movie clips which reside in the library of my main file called "screenOne_mc" and "screenTwo_mc". Both movie clips contain identical buttons with an instance name of "nextBtn." Both movie clips have linkage identifiers which exactly match their library names. On frame 1 of my main timeline I have the following script:

// attach clip
attachMovie("screenOne_mc", "s1", 0);
swapDepths(0);

// remove ScreenOne_mc and attach ScreenTwo_mc
s1.nextBtn.onRelease = function() {
removeMovieClip("s1");
attachMovie("screenTwo_mc", "S2", 1);
}

// Trace the s2 button clip
this.s2.nextBtn.onRelease = function() {
trace("s2 has been clicked");
}

Attaching screenOne_mc works as does attaching screenTwo_mc, the issue that I'm having that the click of s2.nextBtn doesn't work. I suspect that I'm just incorrectly targeting the the movie clip but I'm just not sure where it is?

Has anyone else run into this issue? Any suggestions?

Thanks!
Jaivin

Attaching Movie Clips At Runtime From Library
Dear All,

I have 6 different clips in Library with the Linkage class given to following names: Class: mc0, mc1, mc2, mc3, mc4, mc5, mc6,


And I want to attach these clips dynamically at run time using the for loop in AS3.0:


For( var i=0; i<6; i++)
{

What should be the code for this at runtime attachment?

//

}


Regards,
Sridhar B

Attaching Movie Clips With Apparent Delay
I've been trying to figger this one out. How do you create a delay effect when dynamically attaching mc's to another mc, the stage, whatever.

say you're building an xml driven menu which is essentially a stack of mc's attached to another. how do you make them appear to fade in one by one, starting at the top and working toward the bottom? (i can create the effect, just not sure how to script it).

it's gotta be fairly straightforward since i see it lots of places. I tried creating it with frames but that doesn't work since the mc's get attached so quickly.

any help is great! we should have a tutorial on this!

thanks!

Attaching Same Rollover State To Array Of Movie Clips
hi guys i've been struggling with this for a few hours now and i'm just not getting it so if any one could give me some guidance that would be much appreciated.

i am trying to attach the same rollover state to an array of movie clips which changes the tint,

this is the code i have written and it was also inside of a 'for loop' giving i values for the array which is photolist.


Code:
photolist[i-1].onRollOver = function():Void {
var mcColour:Color = new Color(photolist[i-1]);
var oTransform:Object = mcColour.getTransform();
oTransform.ra = 50;
oTransform.rb = 100;
mcColour.setTransform(oTransform);
trace(oTransform);
};
thanks
BrownWarrior

Problem With Attaching Multiple Movies In Movie Clips
Hi there,

I am trying to get this code to work for my MA project... I am trying to get multiple sounds playing when a movie clip called "WalkerMC" gets near them. the sound fades in/out depending how far the Walker is from the sound object. You need to use up and down arrows to move the walker and left and right to turn him around.

I have created emtpy movie clips for each sound...

I am using the following code to play the 2 sounds (code below) - and I have also attached the fla (flash8). where am I going wrong?

Any help very much appreciated!

Thanks

gayeta


ActionScript Code:
//
//
MovieClip.prototype.CalculateSounds = function() {
    this.createEmptyMovieClip("bandStandMC", this.getNextHighestDepth());
    this.bandSound = new Sound(bandStandMC);
    this.bandSound.attachSound("euphoria");
    this.bandSound.setVolume(0);
    this.bandSound.start(0, 999);
    this.onEnterFrame = function() {
        //Work out the volume and panning of each sound
        //Band sound
        //Band is positioned at co-ordinates 357, 288
        var xDistanceToBand = this._x - 357;
        var yDistanceToBand = this._y - 288;
        var distanceToBand = Math.sqrt((xDistanceToBand * xDistanceToBand) + (yDistanceToBand * yDistanceToBand));
        var angleToBandRadians = Math.acos(xDistanceToBand / distanceToBand);
        var angleToBandDegrees = -1 * ((angleToBandRadians * 180) / Math.PI);
        if (this._y > 288) {
            angleToBandDegrees = -1 * angleToBandDegrees;
        }
        var panValue = Math.sin((((this._rotation - angleToBandDegrees) * Math.PI) / 180));
        if (distanceToBand > 100) {
            this.bandSound.setVolume(0);
        } else {
            this.bandSound.setVolume((100 - distanceToBand) / 2);
            this.bandSound.setPan(100 * panValue);
            bandStand_show.gotoAndPlay(2);
        }
    };
};
WalkerMC.CalculateSounds();
//sport pitch sound 1
MovieClip.prototype.CalculateSounds2 = function() {
    this.createEmptyMovieClip("sportPitch1", this.getNextHighestDepth());
    this.sportSound = new Sound(sportPitch1);
    this.sportSound.attachSound("cricket");
    this.sportSound.setVolume(0);
    this.sportSound._width = 140;
    this.sportSound._height = 100;
    this.sportSound.start(0, 999);
    this.onEnterFrame = function() {
        //Work out the volume and panning of each sound
        //Band sound
        //Band is positioned at co-ordinates 203, 288
        var xDistanceToSport = this._x - 274;
        var yDistanceToSport = this._y - 350;
        var distanceToSport = Math.sqrt((xDistanceToSport * xDistanceToSport) + (yDistanceToSport * yDistanceToSport));
        var angleToSportRadians = Math.acos(xDistanceToSport / distanceToSport);
        var angleToSportDegrees = -1 * ((angleToSportRadians * 180) / Math.PI);
        if (this._y > 320) {
            angleToBandDegrees = -1 * angleToBandDegrees;
        }
        var panValue = Math.sin((((this._rotation - angleToSportDegrees) * Math.PI) / 180));
        if (distanceToSport > 100) {
            this.sportSound.setVolume(0);
            sportPitch1_show.gotoAndPlay(1);
            //trace(angleToBandDegrees);
            //trace(panValue);
        } else {
            this.sportSound.setVolume((100 - distanceToSport) / 2);
            this.sportSound.setPan(100 * panValue);
            sportPitch1_show.gotoAndPlay(10);
        }
    };
};
WalkerMC.CalculateSounds2();
//
//

Attaching Dynamic Movie Clips In A Static Moviclip
I have a problem regarding attahing these movieclips(images) to a label (movieclip) on the stage and when i will move label the all images shoild move with label which attched to that label , i have tried lot through hit test but not working because i have lots of dynamic movieclips(images) and how to attach these movieclips on the label movieclip which is static movieclip in my case do u have any sample or any question regarding this ??? pl help me out .
Thnx

Problem Attaching External .jpgs To Movie Clips
Hi There,

I am not able to attach a file (.jpg) outside of flash to a movieClip without it changing the scale of the image. Stepping through with the debugger, its clear the image loads correctly til it is applied to the movie clip, I assume with the attachBitmap function. It scales it up a little more than 50% and I can't figure out where that scale is coming from. It appears to scale up from the upper left corner. We have checked to make sure all the movieclips within our flash file are the exact same size as the image files (150 X 150). Please see code example. Everything is fine except for this. We tried using the matrix transformation to down size the images but the quality was not acceptable even with using smoothing and pixel snapping.

So, the basic question being, how do we use attachBitmap and have it preserve the original size? Any ideas for how to get this to work is greatly appreciated...

thanks,

Laura










Attach Code

_global.smoothImageLoad = function(imgURL, targetMovie) {
var i=0
do { i++ } while (eval("_root.smoothImageLoadTemp"+i) != undefined)
tmc = _root.createEmptyMovieClip("smoothImageLoadTemp"+i, _root.getNextHighestDepth())
tmc.createEmptyMovieClip("ti", tmc.getNextHighestDepth())
tmc.tm = targetMovie
with(tmc) {
tmcl = new MovieClipLoader()
tmcl.onLoadComplete = function() {
ti.onEnterFrame = function() {
pixelData = new flash.display.BitmapData(ti._width, ti._height);
pixelData.draw(ti);
tm.attachBitmap(pixelData, 1, true, true);
tm.smoothImageLoadComplete()
removeMovieClip(ti._parent)
}
}
tmcl.loadClip(imgURL, tmc.ti)
}
}

Attaching Buttons And Actions To Duplicated Movie Clips
Are there any tutorials or tips related to this?

I'm reading in an XML file with URLs, information, etc. for a number of different items into an array. I'd like to dynamically duplicate buttons for the number of items in the array and then attach the XML information in the array to getURLs within a button, dynamic text on the button, etc.

I know this isn't too hard, but I haven't been sucessful so far in getting it to work right.

I'd post code, but I got so frustrated last time I trashed the whole thing.

Attaching Buttons And Actions To Duplicated Movie Clips
Are there any tutorials or tips related to this?

I'm reading in an XML file with URLs, information, etc. for a number of different items into an array. I'd like to dynamically duplicate buttons for the number of items in the array and then attach the XML information in the array to getURLs within a button, dynamic text on the button, etc.

I know this isn't too hard, but I haven't been sucessful so far in getting it to work right.

I'd post code, but I got so frustrated last time I trashed the whole thing.

Attaching Several Movie Clips Into A Movie Clip...
Hi;

I'm trying to attach several movie clips into another movie clip. I can add the movie clips successfully . However, the movie clips start from the middle of the main movie clip that I used as the background layer for the other movie clips. Is there any way to make it located to the top left? Here is the code I used:


Code:
Layer_Movie.attachMovie("NumberTop","num",depth,{ _x: scol + (col * 32), _y: scol - 32 });
scol and srow are the attributes that represents the starting locations from the left and top. (I used 10 for the variables scol and srow the movie should be located 10 pixels away from the top and left) 32 is the height and also width of the movie clip to be added.

Is it hopeless? (I know sometimes actionscript is not so powerful to implement such kind of processes. Since I have not time to wait for the another version of actionscript, I must find a solution for that problem)

Please help...

Attaching Several Movie Clips Into A Movie Clip...
Hi;

I'm trying to attach several movie clips into another movie clip. I can add the movie clips successfully . However, the movie clips start from the middle of the main movie clip that I used as the background layer for the other movie clips. Is there any way to make it located to the top left? Here is the code I used:


Code:
Layer_Movie.attachMovie("NumberTop","num",depth,{ _x: scol + (col * 32), _y: scol - 32 });
scol and srow are the attributes that represents the starting locations from the left and top. (I used 10 for the variables scol and srow the movie should be located 10 pixels away from the top and left) 32 is the height and also width of the movie clip to be added.

Is it hopeless? (I know sometimes actionscript is not so powerful to implement such kind of processes. Since I have not time to wait for the another version of actionscript, I must find a solution for that problem)

Please help...

Attaching Movie Clips To Another Movie Clip
I'm attaching (and then removing) relevant movie clips to an empty movie clip that is shown in a scrollpane. It all works fine when triggered from buttons, but when the flash file is first loaded no clip is attached and thus nothing is displayed in the scrollpane. What am I doing wrong?

This is the function I trigger through the buttons and when the file is first loaded:
function loadScroll(the_page)
{
//create delay for component to initialize
i = 1;
this.onEnterFrame = function()
{
i++;

if (i>5)
{
switch (the_page)
{
case "xmlGallery.html":
empty_mc.testreal_mc.removeMovieClip();
empty_mc.attachMovie("gallery", "galleryreal_mc", empty_mc.getNextHighestDepth());
scrollpane.invalidate();
break;
default:
empty_mc.galleryreal_mc.removeMovieClip();
empty_mc.attachMovie("test_mc", "testreal_mc", empty_mc.getNextHighestDepth());
empty_mc.testreal_mc.myTable.createTable(the_page) ;
scrollpane.invalidate();
}
delete this.onEnterFrame;
}
};
test_mc.myTable.onTableRendered = function()
{
scrollpane.hScrollPolicy = "false";
};

loadPicture();
}

Attaching Randomly Movie Clips From The Library And Controling Them By One Function
hi,

i have a very important project to do, and i'm so confused...

there are 2 main questions i can't deal with:

1. i want to add randomly movieclips from the library to my stage , but I didn't succeed (the FLA i made is attached-i really don't understand what i did wrong)

2. let's say i succeed to add the above mentioned movieclips.
how can i controll multiple movieclips by onley one function???
(especially if they were added to the stage by attachMovie method)

(what I want to do is to:
* make the movieclips move from the upperborder to the bottom, and to make them dissappear when they reach there (ofcourse this should occure till the game is over)
* change the movie clip color if it being touched by the hero of the game.

i know how to do it in generaly, but i am totaly clueless when i ned to do it for all the movieclips, especially if they are being attached to the stage onley by their linkage name.

i will be very very gratefull to any help in any kind (especially if you will direct me to tutorials in this subject or FLA files that may help).

thanks in advance.

Attaching Randomly Movie Clips From The Library And Controling Them By One Function
hi,

i have a very important project to do, and i'm so confused...

there are 2 main questions i can't deal with:

1. i want to add randomly movieclips from the library to my stage , but I didn't succeed (the FLA i made is attached-i really don't understand what i did wrong)

2. let's say i succeed to add the above mentioned movieclips.
how can i controll multiple movieclips by onley one function???
(especially if they were added to the stage by attachMovie method)

(what I want to do is to:
* make the movieclips move from the upperborder to the bottom, and to make them dissappear when they reach there (ofcourse this should occure till the game is over)
* change the movie clip color if it being touched by the hero of the game.

i know how to do it in generaly, but i am totaly clueless when i ned to do it for all the movieclips, especially if they are being attached to the stage onley by their linkage name.

i will be very very gratefull to any help in any kind (especially if you will direct me to tutorials in this subject or FLA files that may help).

thanks in advance.

Accessing To The X And Y Coordinates Of Movie Clips Inside Of Other Movie Clips
lets say I have a movie clip with an instance name of "char" and another movie clip inside it with an inctance name of "ball" and when I try this I get zero:

_root.char.ball

why?

thanks in advance because you flashkit users know everything about flash in and out.

Movie Clips Inside Move Clips. How To Control?
I have an object in this case a foot with toes on it. the toes animate as well as the whole foot moving with the nails on it. I have instance names assigned for all the mc's problem is that the toes are buried about 3 layers down inside the foot_mc so they will move with the foot as well. When I assign a function to them the error compiler does not know where the nails are . What is the best way to fix or re-do this layout?

I am a total newbie to Flash and AS3, so any help would be great


I FIGURED IT OUT.

[F8] Problem With Attaching Movie Clips With Dynamically-generated Instance Names
Will something like this create and attach separate movie clips onto the stage with different Instance names?

Because I'm having a problem where each one of the attached movieClips will display the exact same information, which would be the information sent to the last movieClip created. I'm assuming that my problem is that I'm creating their Instance names incorrectly, since when I try to trace the names out (eg panelIndex0), it comes out as undefined.

code: for (currentPanel=0; currentPanel<totalPanels; currentPanel++) {
// identifies and creates appropriate Instance name for the current panel
thisPanel = eval("panelIndex"+currentPanel);

// creates the new panel with its own Instance name (eg panelIndex0, panelIndex1, ...)
attachPanel = attachMovie("GameDescriptionPanel", thisPanel, this.getNextHighestDepth());
}

Is there any way to find out if my panels are indeed coming out with different Instance names?

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