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




Attaching Code To Movieclips In Library



Im making a game and i want to load in with actionscript movieclips in the library. However, i want these movieclips to contain code that will load with them onto the stage, and from what ive heard attachMovieclip doesnt do this. I dont want to have a clip existing on the stage in the begining and then use duplicateMovieclip. Anyone know if this can be done or how to do it?



FlashKit > Flash Help > Flash ActionScript
Posted on: 04-28-2005, 12:53 AM


View Complete Forum Thread with Replies

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

Attaching Several Movieclips From Library?
Hey

I have a for-loop where I want to attach several movieclips from library. I have tried:


Code:
var movie:MovieClip;

for (i = 0; i < 20; i++)
{
movie = attachMovie("MCname", "MCname"+i, getNextHighestDepth);
movie._y = 31+31*i;
}
When I test the movie only the last clip shows. Is this because it only works for 1 clip. I've tried some other things like duplicateMovieClip and so on, but can't get it to work..

Attaching MovieClips Not In The Library
I'm just coming back to Flash after not using it for a few years, and I'm struggling with a particular aspect of ActionScript 2 (I'm still using Flash 8). I am creating something along the lines of an image grid or "video wall" of still images. The image grid will randomly show different images, and I want any cell in the grid to have access to the full array of images to choose from.

I want to dynamically load in the individual PNG bitmap files from the server to facilitate swapping them out, rather than baking them into a SWF. At the root level, I've managed to use MovieClipLoader to load my PNG files into a dynamically generated array of MovieClips. My image grid is a bunch of instances of of a MovieClip which contains a mask, decorations, and a placeholder MovieClip for the images.

What I can't figure out how to do is attach the PNGs to the placeholder clips. It seems like my two options are attachMovie and attachBitmap. However, both of them require you to specify a linkage ID to a library asset, which I do not have- I have an array of MovieClips not contained in the library!

I'd really appreciate it if someone could point me in the right direction.

Attaching MovieClips Fromthe Library
Hey could someone help me out here?

I am using this code to attach a library movieClip with the linkage instance name of can 15 times to the stage when running. This works fine but i am having heaps of trouble as i am trying to get the var x to distribute at increments of 20 along the y axis which is currently set to 355.

So when it is running it would look something like this::

[] [] [] [] [] [] [] [] [] [] [] [] [] [] []


the cod i am using on frame 1 of the movie is:

totalCans = 15;
screenWidth = 550;
screenHeight = 400;
for (var i=0; i<totalCans; ++i){
var name = "can"+i;
_root.attachMovie("can", name, i);
var x = random(screenWidth);
var y = 355;
_root[name]._x = x;
_root[name]._y = y;
}

Attaching ActionScript To MovieClips In The Library
Hello everyone! Here is a question for ya.

In my library I have a bunch of movieclips that are dynamically going to be placed on my stage. Is there a simple method of attaching ActionScript to these movieclips so that when they are used on the stage, they have the script applied to them already?

Thanks in advance!

Attaching Movieclips From Library Into A Movieclip
I have a MC shape, its actually a parallelogram and so its slanted and the perspective is tilted a bit (not sure if this matters).

I also have a few different MCs in the library the same shape which I want to place into the MC shape when different buttons are pressed.

For button one, I used this code:

on (release) {
myShape.attachMovie("firstMC");
}

Am I doing something wrong or using the wrong code? In the library, I named the first MC "firstMC" as you can see. I also put the linkage as "export as actionscript".

Any clues?

Attaching ActionScript To MovieClips In The Library
Hello everyone! Here is a question for ya.

In my library I have a bunch of movieclips that are dynamically going to be placed on my stage. Is there a simple method of attaching ActionScript to these movieclips so that when they are used on the stage, they have the script applied to them already?

Thanks in advance!

[AS3] Attaching Buttons / Movieclips From Library That Contain Other Items Already
So im trying out AS3 and kinda havin some issues. I want to be able to attach a button or a movieclip that I have constructed in the Flash IDE - it contains a textfield, some other movieclips, etc.

If i make it a button, I have tried subclassing the simplebutton class, attaching that class to the button, and then creating new instances of that class. That works fine - until I have to access, say, a textfield in the button. It seems that these elements are drawn, but are not accessible (or even connected in any way - i used flash.utils.descibreType(mybutton) and the instance names dont even show up in the XML).

So, I thought about a different route - using a movieclip or sprite, and making it react LIKE a SimpleButton. Not what I had in mind, but whatever. Unfortunately, it seems that when I subclass Sprite or MovieClip, the class has to be made dynamic in order to attach things to it from within the IDE before compilation (as opposed to from actionscript).

What is the best method to create a button in the Flash IDE with textfields, sprites, etc, and have access to those elements from the class that's attached to the symbol??

Attaching An MC From The Library W/ Code Already...
I need to attach my character from the Library w/ code on the actuall MC, not within. I DO NOT want to use a blank mc to store him in then add the code on the inside. He needs to load w/ code on his parent MC from the library.

-Tyler

any ideas?

Writing Code In FlashDevelop And Attaching Instances From Library
Hi guys, I'm trying to migrate to AS 3.0 and I faced some difficulties.

Code is written in FlashDevelop and compiled with help of Flex SDK Everything is working great, but now I'm in need in connecting this code with the fla file more specifically I need to attach some instances from the fla file library.

So how can I make it?

This is a very newbie question but I really need your help,
Thank you in advance

Sound Only Attaching From Preloader Library Not Main Movie Library
Hi guys, i've got my main movie with sounds used in classes attached from the library via attachSound. works fine when run on its own, but when run through a seperate preloader swf it only works when the sound is in the preloaders library.

Any help would be much appreciated.

[Help] Attaching An MC To An MC In The Library
Hey guys, I was wonderinf if its possible to add an MC to an MC thats in the library.

Say I had "closetMC" inside of the library and I wanted to add "shirt1" from the timeline into "closetMC". Is this possible? And if so, how could I achieve this?

Thanks a bunch!

Attaching Mc From Library In AS3
Hello:
I´m searching, not finding some help about attaching MCs from library to stage with AS3. I can´t understand what´s the problem. I´ve tried dozens of solutions but without success. Please anyone has an idea.
Here is my code:

ActionScript Code:
function boton(nombre_mc:String, other_mc:String){
    this[nombre_mc].buttonMode = true;
    var container_mc:MovieClip = new MovieClip();
    addChild(container_mc);
    var theClassName:Class = getDefinitionByName(other_mc);
    var theClass:MovieClip = new theClassName();
    this[nombre_mc].addEventListener(MouseEvent.MOUSE_OVER, efecto);
             function efecto ($event:MouseEvent) {
                     $event.currentTarget.gotoAndPlay(2);
                     var caraBio:* = new tempClass();
                     container_mc.addChild(theClass);
    }
}
boton("First_mc", "FirstAA_mc");
The First_mc and the FirstAA_mc are both linked with the same name to AS.
When I test the movie, it says:
error 1046
error 1118
error 1180
Anybody knows how to meka a function to attach a library MC.
Thanks.

Attaching A Library MC From A Loaded Swf.
//on (release) {
// _root.main.attachMovie("att2", "newname2", 1);
//}

This does not work. Any help?

Trying to attach a movie clip from inside the Library to a blank MC on Main Stage from a loaded swf movie.

Is this possible?...or should my code work with better path.

M

Attaching Scrollbar From Library
Hi

I'm trying to use the Flash MX scrollbar in MX 2004 but I am having problems with it. If you are wondering why I don't use the MX 2004 textarea component, it is because it is pants and has more bugs than your average garden.

I'm creating my textfields using createTextField and then attaching the scrollbar from the library thus:

/////////////////
_root.question_mc.attachMovie("FScrollBarSymbol"," insScroll_mc",100);

_root.question_mc.insScroll_mc.setScrollTarget("_r oot.question_mc.ins_txt");

_root.question_mc.insScroll_mc.setScrollContent("_ root.question_mc.ins_txt");

_root.question_mc.insScroll_mc._y = _root.question_mc.ins_txt._y;

_root.question_mc.insScroll_mc._x = _root.question_mc.ins_txt._x + _root.question_mc.ins_txt._width + 25;

_root.question_mc.insScroll_mc.setSize(_root.quest ion_mc.ins_txt._height + _global.textBoxSpacing);

_root.question_mc.insScroll_mc.setSmallScroll(14);

_root.question_mc.insScroll_mc.setEnabled(true);
/////////////////////

I found TWO methods in the MX help for setting the target textfield for the component, yet neither seems to work. All the other changes I make to the scrollbar including setSmallScroll work, but not target.

Can any bright sparks out there shed some light on this little puzzler?

Ta

Barry

Attaching A MC From A Library And Setting Its X And Y
Hi all!
I have a movie in the library which I want to attach to the stage by code. Here's the code I've been using:

Code:
count = 0;
_quality="High";
onEnterframe = function () {
attachMovie("main", "circle"+count, count++);
};
This code works, but it puts the attached MC (circle) in the middle of the stage. How can I set its X and Y coordinates to place it exectly where I need it? I tried a few things, but the code I tried shifted the entire stage instead of that MC alone... So how can I do it?

Thanks in advance!

[F8] Attaching A Mc From The Library Into A Loaded Swf
hey folks

I'm trying to do this


Code:
targetMC.attachMovie("bullet_bar", "bullet_bar", 20);


the targetMC is the location of another loaded swf file. the bullet_bar movieclip is in the library of my root swf

can this work cos I'm having a few problems

Attaching MC From Library By Function In AS3
Hi everyone:
I´m trying to create a mc (that works as a button). I´d like when the cursos goes over it, the mc run to frame 2 (this is obteined thanks to xxneon in other thread) and also that it put a mc that exist in the library.
If the mc is with the "export for as" checked, and the name is MC_mc, why this doesn´t work:

ActionScript Code:
function boton(nombre_mc:String, cara_bio:String){
    this[nombre_mc].buttonMode = true;
    this[nombre_mc].addEventListener(MouseEvent.MOUSE_OVER, efecto);
    this[nombre_mc].addEventListener(MouseEvent.MOUSE_OUT, inicio);
    function efecto ($event:MouseEvent) {
        $event.currentTarget.gotoAndPlay(2);
        var caraBio:cara_bio = new [cara_bio]();
        addChild(DisplayObject(caraBio));
    }
    function inicio ($evente:MouseEvent) {
        $evente.currentTarget.gotoAndStop(1);
    }
}
boton("other_mc", "MC_mc");
(other_mc is in the stage yet)
Thanks

Attaching Objects From Another Library
I have the following scenario: I have a main.swf, and it loads a lib.swf, in which library are some movie clips that I want to attach in main.swf. Is it possible? (PS: I do not want to attach the symbols inside the loaded lib.swf. What I want is to use lib.swf's library in main.swf).
Thank you.

Attaching A Clickable MC From The Library
Hi there,

When I click my 'hit_mc', 'hitarea_mc' gets placed on the stage from the library. When I click 'hitarea_mc', I want it to disappear.

So Ive done the following, but the newly attached hitarea_mc refuses to be clickable. How would I tell AS to make it thus ....
Thanks..

Code:
var a:Number = Stage.width/2;
var b:Number = Stage.height/2;

function attach (){
_root.attachMovie("hitarea","hitarea_mc",10,{_x:a,_y:b});

}

hit_mc.onRelease = function(){
attach();
}
hitarea_mc.onRelease = function(){
this._alpha = 0;

}

Attaching MovieClip From Library (Please Help)
Hello

I have created a textfield and then attached a movieclip as a background on top of which I wanna place the text field just like a button.

Here is the code

var txt:TextField = new TextField();

var bg:MovieClipClass = new MovieClipClass( );
bg.addChild( txt );

txt.text = "Hello World!!";
addChild(bg);

The movieclip and text field are displayed on the stage but the text field is not on top of the background clip it is always away from the clip I have even tried

assigning the moviclip x and y coordinate to text field but does not work.

Any help will be well appreciated

Thank in advance

Attaching MovieClip From Library (Please Help)
Hello

I have created a textfield and then attached a movieclip as a background on top of which I wanna place the text field just like a button.

Here is the code

var txt:TextField = new TextField();

var bg:MovieClipClass = new MovieClipClass( );
bg.addChild( txt );
txt.text = "Hello World!!";
addChild(bg);

The movieclip and text field are displayed on the stage but the text field is not on top of the background clip it is always away from the clip I have even tried
assigning the moviclip x and y coordinate to text field but does not work.

Any help will be well appreciated
Thank in advance

Attaching Sound From Library Using Variables
I´ve been having a huge problem with flash lately. I´m setting up a site using a whole lot of levels. And on one level I'm using a soundpanel to control the background music on the site. I wanted to give the user the opertunity to choose between three different types of background music. But that requires a great deal of bandwidht for the user. So I thought I´d load each song in on a different level with a preloader.

I started by setting a variable for the swf file being loaded as the sound file and another variable for the linkage identifier being used to attach the soundobject directly through the library. I then use this variable to load the sound into a soundcontainer on the soundpanel level. My problem is that the sound doesn´t even play or anything. Has anyone tried this before... or have any experience using variable with the sound object. I´ve been staring at this same problem now for days and it´s driving me insane. I´ve tried at least 7 different appraches changing the way I use the variables but nothing works.

Attaching Mc From Library Of A Dynamically Loaded Swf?
Hi..
I beleive there is some way to solve this problem. I want to attach a movie clip from the library of the swf file with is loaded dynamically into another swf file. The mc loads if it is available in the root swf file.
Can any one help me out?

Yet Another AS 2.0 Problem: Attaching A Class To A Library Mc
Hey all,

I know everyone must be sick of OOP questions, but I can't find the answer to this one anywhere in the usual tutorials.

Here goes:
When you create/convert a movieclip, you have the option to link the movieclip to an AS custom class, I assume besides MovieClip class. But I don't fully understand the relationship between the movieclip and the class. For instance, how would I reference the movieclip from the class? Is it the class itself (so if I wanted to change the _x of the movieclip onstage in a function, would it just be this._x = 20;?)

So if anyone understands this relationship or has a tutorial link that explains it, I would greatly appreciate it. Thanks a lot!

Dave

Attaching MCs Onto A Motion Path From Library
hello all...

so here is my situation...i would like to create an environment where on my stage i have an animation path (motion guide) that, say, 50 or so MCs travel along in my scene. They all follow the same path almost like a group of train cars strung together following RR tracks

The part i am struggling to set up is to do the bulk of this through Actionscript, in a manner where all these "traincars" are library items that are attached to this motion path and then carry out their animation along that path.

i have dug around on the forums and found what i think is a good starting point but i need some help in figuring out where to go as this is a bit beyond my skill level. if anyone would be so kind as to help me wrap my head around this i would be very grateful

this is what i have so far...i know its not much but as i said this is a bit beyond my scope:


Code:
var i:Number = 0;
//"loader" being the dummyMC i load content into and "ant" being the first library item (out of roughly 50) that gets loaded onto the stage
loader = this.attachMovie("loader", "loader_"+i, this.getNextHighestDepth(), {_x:0, _y:0});
ant = cell.attachMovie("ant", "ant_"+i, cell.getNextHighestDepth(), {_width:133, _height:100, _x:40, _y:10});
again if anyone could help i would really appreciate it...thanks for your time!

[F8] Attaching Movieclip From Library In A Class?
This is really stupid but I've never used external classes (.as) files before and I'm having some trouble attaching movieclips from inside the class.
I have a movieclip in my library and just want to attach it from the Testing class, why isn't it working?


PHP Code:




mytest.fla

var blah:Testing = new Testing();








PHP Code:




Testing.as

class Testing extends MovieClip{
    function Testing(){
        attachMovie("photo_mc", "photo", this.getNextHighestDepth());
    }
        
}

Attaching MCs Onto A Motion Path From Library
hello all...

so here is my situation...i would like to create an environment where on my stage i have an animation path (motion guide) that, say, 50 or so MCs travel along in my scene. They all follow the same path almost like a group of train cars strung together following RR tracks

The part i am struggling to set up is to do the bulk of this through Actionscript, in a manner where all these "traincars" are library items that are attached to this motion path and then carry out their animation along that path.

i have dug around on the forums and found what i think is a good starting point but i need some help in figuring out where to go as this is a bit beyond my skill level. if anyone would be so kind as to help me wrap my head around this i would be very grateful

this is what i have so far...i know its not much but as i said this is a bit beyond my scope:


Code:
var i:Number = 0;
//"loader" being the dummyMC i load content into and "ant" being the first library item (out of roughly 50) that gets loaded onto the stage
loader = this.attachMovie("loader", "loader_"+i, this.getNextHighestDepth(), {_x:0, _y:0});
ant = cell.attachMovie("ant", "ant_"+i, cell.getNextHighestDepth(), {_width:133, _height:100, _x:40, _y:10});
again if anyone could help i would really appreciate it...thanks for your time!

Get Properties Of Library Clip BEFORE Attaching
Hi, not sure if this is possible, seems not, but I couldnt find anything about it.

Is it possible to get the properties of a library clip that is set for export on first frame without first attaching it?

I'd like to get the size of my library clip before I attach an instance of it.

Attaching Movie Clip From Library
I am having trouble loading a movieclip from the library.

This is the script I have

attachMovie(logo, logo1, 5)

What am i doing wrong?

Attaching Images From The Library To Stage?
How can I attach images from the library, without converting it to a movieclip, to the stage or empty movieclip. My reason for this is because I have 100+ images in my library and I want to avoid converting them all to individual movieclips for production sake.

Thanks...

Problem Attaching A Movie From Library
I modified the code for the hover captions that is on kirupa.com
The reason i had to try and modify it is because i am generating thumbnails from an xml document and when i want to use the hover caption it is creating the hover on the depth of -16745 or something and all of the thumbnails are on levels 1-10 or however many there are
I can't seem to figure out how to get the caption to be above the thumbnails.
here is the code i have so far, hope someone can help. but this code so far doesn't show the caption image that I have in my library
argh

Code:
captionFN = function (showCaption, captionText, bName) {
if (showCaption) {
//var caption:MovieClip = _root.createEmptyMovieClip("hoverCaption", getNextHighestDepth());
//trace(this.getDepth());
this.attachMovie("caption", "cap_mc", this.getNextHighestDepth());
//cap_mc.caption_txt.text = captionText;
if ((bName._width+bName._x+cap_mc._width)>Stage.width) {
xo = -2-cap._width;
yo = -17;
} else {
xo = 2;
yo = -17;
}
cap_mc.onEnterFrame = function() {
cap_mc._x = _root._xmouse+xo;
cap_mc._y = _root._ymouse+yo;
cap_mc._visible = true;
};
} else {
delete hoverCaption.onEnterFrame;
cap_mc.removeMovieClip();
}
};

Attaching A Movieclip From The Library To The Stage.
Hey Guys,

Sorry about the noobish question...it's been a while since i've attached something from the library to the stage.

But basically i have my blank document (no movieclips on the stage). I ahve my library item which is a movieclip and i want to attach this directly to the stage NOT into another movieclip.

Any ideas on how to do this??

Thanks in advance guys

Attaching A Movie From Library After An Event?
Hi all,

my base class loads xml data and then creates the navigation etc in the handler method. In the handler tracing 'this' still returns the base class but can I cannot use this.addChild(something) to add a new MovieClip to the stage. but if I paste the same code in to the constructor or init methods then it works?? it also works if I use this.someMoveClip.addChild(something) just not directly on this? This is really confusing me, code below


Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;

public class Application extends MovieClip
{
public var xmlData:XmlData;

private var _navigation:Navigation;
private var _home:HomePage;

public function Application()
{
trace('New Application');
init();
}

private function init()
{
// load the xml data
xmlData = new XmlData();
xmlData.addEventListener("onLoad", initPages);
xmlData.load('work.xml');
}

private function initPages(e:Event)
{
trace('handleXmlLoaded')


var s:Square = new Square();
s.x = 0;
s.y = 0;
this.addChild(s);


// build navigation
_navigation = new Navigation(this.navigation_mc);
}
}
}

Attaching Images From The Library To Stage?
How can I attach images from the library, without converting it to a movieclip, to the stage or empty movieclip. My reason for this is because I have 100+ images in my library and I want to avoid converting them all to individual movieclips for production sake.

Thanks...

Second Try: Attaching Actions To Shared Library Assets (im)possible?
hi flashlovers and -haters,
would be great if anybody could tell me, if i´m just too stupid or if it just doesn´t work in generell.
my problem is, i try to use buttons from a shared library to which i try to attach actions, but nothing works. even simple things like a on rollover-trace action has no result. behaviors/actions work if the button is in the movié´s library, but if i open the shared library and switch the button symbols then, nothing works anymore.
anybody any clue??
or do shared libraries only work with simple animations.
looking forward for inspiration or salvation

thanks in advance
belikin

Attaching Movie Clip From Library Problem
I am trying to attach a movie clip to my main movie using a clip from the library that is using "import for runtime sharing".

When I use the attachMovie function, the clip doesn't appear. It only appears if a drag the clip to an area off the stage.

Is there a way around this? Is it possible to replicate the process of draging in a movie in action script?

Thanks

Help Attaching/adding Movies From Library To Scrollpane
Hi,

I'm a newbie with action script and working in Flash MX,...can anyone please point me in the right direction with adding movies from the library to a scrollpane...

I have a scrollPane (scrollPane1) and a movie (movie1). I just(!) want to be able to dynamically add a number of instances of the movie to the scrollpane.

With the following code, 10 instances of movie1 are added to the stage but they do not appear to be attached, or anything to do with the scrollpane, since it does not scroll to accomodate them.

code:
x = 50;
increaseBy=60;
for (i=1;i<=10;i++){
sq = _root.scrollPane1.attachMovie("movie1","mylabel"+i ,i);
sq._x = x;
sq._y = 30;
x=x+increaseBy;

}


Can anyone see what i'm doing wrong? I have litterally spent many hours over a few days looking through the help file and many examples of similar on this site, but I must be missing something somewhere (yes, a brain, i know what you're thinking lol .

many thanks to anyone who can help.

MRB

[MX04] Attaching Movie Not In Symbol Library
I'm trying to attach a movie that I created as an emptyMovieClip to a new path (so it loads inside a masked movie clip). The code works fine when I use an object from the symbol library, but I can't get it to take a movie clip I create in the code. How could I do this? Or should I use something other than attachMovieClip?

myPhotoMC = _root["main_"+i]["fullPhotos_"+i]["photo_"+i+"_"+j];
moveClip = _root["main_"+i]["screen_"+i].area.attachMovie(myPhotoMC, "container", 3000);
}

Is there a way to just change the target path of a movie clip instead of going through all this?

Thanks!

Attaching Library Elements From Main Movie
Hi all,

I did a search on the site but all the example were other way around that I would like to implement, so will ask it straight away.

I have an external.swf movie that I am loading into the main.swf movie. I want to display a movieclip from the main.swf library in the external.swf. Any ideas how this could be achieved?

I have set the linkage Id for the movieclip in the main.swf but I am not able to load it. Obvisouly if I bring the clip into the external.swf it will load nicely. I am using the attachMovie() method.

Thanks

Attaching A Library Item To The Stage From A Class
First.. I want to make sure I'm following the best practice for what I want to do... I have a flash quiz that uses a class file and then on the last frame I want to attach a custom movieclip with logo graphics, etc on it and the score in it. I heard that best practice is not to have any graphics, etc. in the FLA file and try to keep it all in external class files. I put this movieclip in the library and set up linkage identifiers like so:


Code:
class = logo_mc
base class = flash.display.MovieClip
checked "export for actionscript"
checked "export in first frame"
How do I add this movieclip to the stage?? I see similar posts but people are not adding things to the stage with classes...

I tried a sample document like this:

Code:
package {

import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.*;

public class testing extends MovieClip {
private var logo_mc:MovieClip;

public function testing(){
loadMovieClips();
}
private function loadMovieClips(){
this.addChild(logo_mc);
}

}
}
But then I get this error:

Code:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at testing/::loadMovieClips()
at testing$iinit()
What am I doing wrong? I'm coming from the actionscript 2 way of thinking where I would have several movie clips in the library that I would attach to the stage with attachMovie when needed.

Any help is much appreciated!

Dynamically Attaching Library Items From A Loaded Swf
I've been working at this problem for a while so let me cut right to the chase. I have designed a site with a photgallery of lots of high res images.

Okay, so inspired by the Peter Funch site, I knew I wanted a dynamic masking effect, so I use attachmove and attachmask, and pull the images from my library using their linkage identifiers.

Everything is good, but I can't load all of the images up front. The wait would be too big. So what I am doing now is loading a second swf into an empty clip/slug. In that second swf (movie 2) that is in a slug i now attach more movies using movie 2s library.

I just get the feeling that I am doing this very clumsily and in fact after a while things start working less smoothly, even though I am removing clips as I go.

So my questions are these:
1. Is it smart to use a shared library, instead of loading clips onto the root of my movie and having them sit there. Will this prevent my movie from becoming clumsy?
2. Suppose I go to a library item's identifier and export for actionscript. Let's call this movie movie 1. If I have movie 2 and in movie 2 I load movie 1 (loadMove("movie1"...), are movie 1s library items available to movie 2?
3. Does anyone know of a tutorial on loading a movie in stages, and working with linkage property names across these multiple movies.

The site I am trying to improve is http://www.jennifermorton.com

Any strategies would be appreciated.

Thanks,
Kent Rygiel

Attaching MCs From Library & Placing Them At Pre-determined Positions
I have this piece of code that attaches 3 instances form the mc named 'btn' in the library. I need to place each one of them at specific x/y coordinates and I can't figure out how.


Code:
xbtn0 = 100;
ybtn0 = 100;
xbtn1 = 120;
ybtn1 = 120;
xbtn2 = 130;
ybtn2 = 130;
for (var i = 0; i<3; i++) {
xbtn = ('xbtn'+i);
ybtn = ('ybtn'+i);
trace(xbtn);
trace(ybtn);
_root.attachMovie('btn', 'btn'+i, i, {_x:[xbtn], _y:[ybtn]});
}
Also: There's a dynamic text field inside the 'btn' movie clip; is it possible to have this text field display the mc name? (btn1, btn2, btn3, etc.)

Does anyone know if this is possible at all? Please let me know,

Thanks a lot in advance!
- wryenn

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

[F8] Attaching Movieclips
hi,

I'm making a game with a top down view of a virtual world, where you can do stuff through a menu with actions you can select. Now I got a player in the map, but the way the game is built up now is that the map is on the root of the movie and so is the player. The map has a empty movieclip in it, that indicate the position where the player is standing when entering a room. I use the localToGlobal method to convert the x and y position of the empty movieclip into raw numbers, which in turn are used for the player movieclip to set it to that position. In generally it works fine , but (there's always a but ) the player isn't a child of the map, therefor the player can't hide behind items, like if she or he is sitting on a chair, you would see the entire player over the chair, but you want the chair partly over the player. So as you can see it's a layer issue.

So I thought well, instead of placing the player on the root of the movie on the same timeline as the map (a room), why not make him a part of the room, where I can place the player between layers. And this is where I bumped my head . I wanted to attach the player's movieclip to the empty movieclips. But I can't seem to move around a movieclip from timeline to timeline at runtime. Anybody got any suggestions? Sorry for the long story, but at least you know my motivation, so if there's a completly different way of accomplishing this don't hold back .

Help With Attaching Movieclips
I can't seem to figure out how to instead of load external jpg's, attachMovies that reside in the library with instance names mc1, mc2, etc. I did not write this code, simply trying to modify it, can anyone help?

ActionScript Code:
#include "lmc_tween_as1.as"stop();//======================================================================// OBJECTSvar menuElements = new Array();var pictures = new Array();    pictures[0] = "mc1";    pictures[1] = this["mc2"];    pictures[2] = this["mc"+3];    pictures[3] = "image4_import.jpg";    pictures[4] = "image1_import.jpg";    pictures[5] = "image2_import.jpg";    pictures[6] = "image3_import.jpg";    pictures[7] = "image4_import.jpg";    pictures[8] = "image1_import.jpg";    pictures[9] = "image2_import.jpg";var thumbs = new Array();    thumbs[0] = "thumb1.jpg";    thumbs[1] = "thumb2.jpg";    thumbs[2] = "thumb3.jpg";    thumbs[3] = "thumb4.jpg";    thumbs[4] = "thumb1.jpg";    thumbs[5] = "thumb2.jpg";    thumbs[6] = "thumb3.jpg";    thumbs[7] = "thumb4.jpg";    thumbs[8] = "thumb1.jpg";    thumbs[9] = "thumb2.jpg";//======================================================================// CONSTANTSvar CENTER_X = Stage.width / 2;var CENTER_Y = Stage.height - 50;var MENU_SIZE = pictures.length;//======================================================================// VARIABLES_global.depthCount = 0;var textDepth = depthCount * 2;text.swapDepths(100);var menuSpacing = 2;//======================================================================// PROTOTYPESMovieClip.prototype.drawRoundRect = function(w, h, r, st, sc, fc) {    if(st != 0) this.lineStyle(st, sc);    this.beginFill(fc);    this.moveTo(r, 0);    this.lineTo(w-r, 0);    this.curveTo(w, 0, w, r);    this.lineTo(w, h-r);    this.curveTo(w, h, w-r, h);    this.lineTo(r, h);    this.curveTo(0, h, 0, h-r);    this.lineTo(0, r);    this.curveTo(0, 0, r, 0);    this.endFill();}//======================================================================// FUNCTIONSfunction nextDepth() {    _global.depthCount++;    return _global.depthCount;}function loadImage(imageName) {    with(imageHolder) {        _alpha = 0;        alphaTo(100, 0.5, "easeOutQuad", 0.5);    }    //imageHolder.loadMovie(imageName);    imageHolder.attachMovie(imageName);    imageHolder._parent.onEnterFrame = function() {        var total = Math.round(imageHolder.getBytesTotal() / 1024);        var loaded = Math.round(imageHolder.getBytesLoaded() / 1024);        if(total != 0 && loaded >= total) {            imageHolder.setMask(imageMask);            delete this.onEnterFrame;        }    };}//======================================================================// GENERAL CODEcreateEmptyMovieClip("imageMask", nextDepth());imageMask._x = 25;imageMask._y = 25;createEmptyMovieClip("imageHolder", nextDepth());imageHolder._x = 25;imageHolder._y = 25;imageMask.drawRoundRect(375, 170, 20, 0, 0xFFFFFF, 0x000000);imageMask._alpha = 0;loadImage(pictures[0]);menuHolder = createEmptyMovieClip("menuHolder", nextDepth());menuHolder._y = CENTER_Y;menuHolder.onEnterFrame = function() {    var width = 0;    for(i = 0; i < MENU_SIZE; i++) {        var xxm = menuElements[i]._xmouse;        var yym = menuElements[i]._ymouse;        var xm = Math.sqrt(xxm * xxm + yym * yym);        if(xm < 50) {            menuElements[i]._xscale = menuElements[i]._yscale += ((200 - xm) - menuElements[i]._yscale) / 3;        } else {            menuElements[i]._xscale = menuElements[i]._yscale += (100 - menuElements[i]._yscale) / 3;        }        width += menuElements[i]._width;     }    width += (MENU_SIZE - 1) * menuSpacing;    var xpos = Math.round(CENTER_X - width / 2);    for(i = 0; i < MENU_SIZE; i++) {        xpos += menuElements[i - 1]._width / 2 + menuSpacing + menuElements[i]._width / 2;        menuElements[i]._x = xpos;    }};for(i = 0; i < MENU_SIZE; i++) {    menuItem = menuHolder.attachMovie("menuItem", "menu" + i, i);    menuItem._x = CENTER_X - ((MENU_SIZE - 1) * menuSpacing) + i;    menuItem.holder_mc.loadMovie(thumbs[i]);    menuItem.id = i;    menuItem.onRollOver = function() {        this._parent.selected = this;        this.gotoAndPlay("over");    };    menuItem.onRollOut = function() {        this.gotoAndPlay("out");    };    menuItem.onRelease = function() {        this._parent._parent.imageHolder.alphaTo(0, 0.5, "easeOutQuad", 0, {func: loadImage, args: [pictures[this.id]]});    };    menuElements.push(menuItem);}//======================================================================  

Attaching Movieclips
ok yo, another dumb question - sorry!

i want to replace one movieclip with another

so i have

movieClip1 - named clip1
movieClip2 - named clip2

i want to replace movieClip1 with movieClip2, while keeping movieClip1 named clip1

i thought i could do something like

clip1.attachMovie(clip2)

but maybe not....

how do i do this please flash gods?

Loading External SWFs And Attaching Items From Their Library?
This was often difficult in earlier versions of Flash.. is it any easier now? How is this done?

I would like to have an empty FLA pointing to my main/document class, and have all assets load as linked library items from external SWFs. I would like to load all of the SWFs at runtime first, then once everything is loaded, have instant access to the various linked library symbols through code to place them on the stage when necessary. Is this possible, and how to structure this?

Thanks for any advice,

SB

Randomly Loading Mc From Library, And Attaching Random Movie To It
Hi guys

Basically, I have movie1, movie2, movie3, movie4 in the library, with linkages.

These are just 5 frame clips, with a single dummy_mc moving statically over the 4 frames.

I need these to be picked randomly and placed (each has its own set of co-ordinates where it should appear) on the stage at a random set interval (ie, every 2-3 seconds).

There are also 7 items (item1, item2, etc) in the library.

So once one of the 4 movies has been placed on the stage, I need one of these 7 items to randomly attach itself to the dummy_mc within that movie (and, I guess, generate instance names etc)

Would greatly appreciate any light someone can shed, i've been playing with some code, but to no avail.

Cheers

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