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








Targeting Dynamically Created Movie Clip?


So I got this little array going on, right? And I'd like to set it up so that you'd loop through the pics by clicking on the dynamically created movie clip "container_mc". This ain't working so I've resorted to putting an invisible mc over the pics to do this job. I know it has to be possible to target the "container_mc" because that's its instance name. I've tried "this.onPress" and "_level1.container_mc.onPress" and just plain ol' "_root.container_mc.onPress", but nothing works.

Can anyone shed some light on this for me?
Here's my puny code.


ActionScript Code:
stop();pics = new Array("01.jpg", "02.jpg", "03.jpg");_root.count = 0;createEmptyMovieClip("container_mc", 1);loadMovie(pics[_root.count], "container_mc");container_mc._x=200, container_mc._y=60;////////////////button_mc.onPress = function() {    _root.count++;    if (_root.count>2) {        _root.count = 0;    }    loadMovie(pics[_root.count], "container_mc");    trace(count);};




KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 05-25-2005, 06:28 PM


View Complete Forum Thread with Replies

Sponsored Links:

Targeting A Movie Clip That Was Created Dynamically
Hi All,

I'm could really use some help with this. I'm using duplicate movie clips to load variables from an .asp file on the server. The problem I'm having is getting the return variables into the movieclip that made the call.

The following script creates the duplicate movieclip and passes it some variables. It is in a movieclip named Governor.


Set Variable: "RandomNum" = Random(50)
Set Variable: "NewClip" = "CR" & RandomNum
Duplicate Movie Clip ("_level0/ContactRemote", NewClip, RandomNum)
Set Variable: "_level0/" & NewClip & "/:CalledFunction" = ../:CalledFunction
Set Variable: "_level0/" & NewClip & "/:ReturnFunction" = ../:ReturnFunction
Set Variable: "_level0/" & NewClip & "/:Parms" = ../:Parms
Set Variable: "_level0/" & NewClip & "/:TargetServerURL" = ../:TargetServerURL
Set Variable: "_level0/" & NewClip & "/:ClipDepth" = RandomNum
Set Variable: "_level0/" & NewClip & "/:ClipName" = NewClip
Call ("_level0/" & NewClip & ":CallServer")
Go to and Stop (1)

Next, in the newly created movie clip I do this:
Load Variables (TargetServerURL, "_level0/" & ClipName, vars=POST)
Get URL ("javascript:" & ReturnFunction & "('" & retval & "')")
Remove Movie Clip ("_level0/" & ClipName)
Stop

The problem seems to be the target in the Load Variables action, but I've tried several different ways of specifying it but the only one that works is using level 0 and fetching the variable from there.

Any help is greatly appreciated!

View Replies !    View Related
Targeting Dynamically-created Movie Clips
Okay, here's the deal, maybe some of you can offer some advice. First, a bit of background:

I'm creating a small application that dynamically creates movie clips, and those movie clips dynamically create their own. Sounds more confusing than it is, but my whole point here is that hard-coding the path in the code isn't going to "cut the mustard", if you will.

SO, inside this movieclip I want to target a subitem and edit properties (rotation, x and y, size, etc) via a series of buttons. Right now I have a variable located in the parent called cur_item. when I click on a subitem, I tell it the following:

_parent.cur_item = this;

Which then gives the parent variable a nice long name, something like _level0.instance_2.item_0, where item_0 is the correct name, so that part checks out.

Where I have the real trouble is in my buttons. The button exists on the parent layer (same as the cur_item variable). I have this script on the button:

on (release) {
this[cur_item]._rotation += 15;
}

When I test the movie and hit that button, the ENTIRE movie rotates 15 degrees!!! I have no idea why that happens. Do any of you?

View Replies !    View Related
[F8] Targeting Dynamically Created Movie Clips
hi everybody,

I am pulling data from an xml and dynamically attaching mcs, that are being populated with data. To create a cool section indicator I am changing the alpha of the selected mc. But to make sure that when a different section is selected I have to change every mc back to alpha 100.

This is what I'm doing right now:

_root.clips_masked.loadClipsInfos["clip_info"+i].btn_vid.onRelease = function() {
_root.clips_masked.loadClipsInfos.clip_info0.box_m c._alpha = 100;
_root.clips_masked.loadClipsInfos.clip_info1.box_m c._alpha = 100;
_root.clips_masked.loadClipsInfos.clip_info2.box_m c._alpha = 100;
_root.clips_masked.loadClipsInfos.clip_info3.box_m c._alpha = 100;
_root.clips_masked.loadClipsInfos.clip_info4.box_m c._alpha = 100;
_root.clips_masked.loadClipsInfos.clip_info5.box_m c._alpha = 100;

etc...

can I target all clip_info mcs at the same time?

Help would be appreciated!

View Replies !    View Related
How Do I Put A Dynamically Created Movie Clip Into Another Dynamically Created Mc?
I want to be able to have movie clip A to be inside movie clip B, but both movie clips should be dynamically created.
How should I do that?
is there a function for putting one movie clip inside another?

View Replies !    View Related
Problem Targeting A Movie Clip Created With XML Information
(I tried posting this in the MX2004 forum, but didn't get a response, so I figured I'd try here.)

I am having trouble targeting a movie clip that was dynamically generated from information in an XML document. Basically, what I want to do is be able to manipulate the movie clip after it was generated by the initial function. Unfortunately, I can't figure out how to properly target the clip even though I am pretty sure I have the proper title and location (tried both _root. and _level0.).

I've put the files I am working with online for reference:http://www.forma3.com/stuff/flash/

If you load the swf ( http://www.forma3.com/stuff/flash/portfolio2.swf) the string at the bottom - "_level0.mc_image2" - is the name of the last movie clip (with an image inside) to the right.

Also, if you look at the code, you'll see this is a modification of the portfolio from: http://www.kirupa.com/web/xml/examples/portfolio.htm

Thanks in advance for any help you can give!

View Replies !    View Related
Problem Targeting A Movie Clip Created With XML Information
(I tried posting this in the MX2004 forum, but didn't get a response, so I figured I'd try here.)

I am having trouble targeting a movie clip that was dynamically generated from information in an XML document. Basically, what I want to do is be able to manipulate the movie clip after it was generated by the initial function. Unfortunately, I can't figure out how to properly target the clip even though I am pretty sure I have the proper title and location (tried both _root. and _level0.).

I've put the files I am working with online for reference:http://www.forma3.com/stuff/flash/

If you load the swf ( http://www.forma3.com/stuff/flash/portfolio2.swf) the string at the bottom - "_level0.mc_image2" - is the name of the last movie clip (with an image inside) to the right.

Also, if you look at the code, you'll see this is a modification of the portfolio from: http://www.kirupa.com/web/xml/examples/portfolio.htm

Thanks in advance for any help you can give!

View Replies !    View Related
OnClipEvent For Dynamically Created Movie Clip?
I've just dynamically created a movie clip containing a simple square by inserting the following code into the first frame of a new project:

this.createEmptyMovieClip('square',0);
with(_root.square)
{
moveTo(0,0);
beginFill(0x000088)
lineTo(100,0);
lineTo(100,100);
lineTo(0,100);
endFill();
}

Now I want to be able to animate this square. I want to use the OnClipEvent(EnterFrame) and change the _x value of this square. But Flash keeps telling me that the OnClipEvent can only be applied to a movie clip object. So how can I do this purely from code? I don't want to have to create the square at design time.

Also, how can I animate the square without having to use the OnClipEvent(EnterFrame)? I tried using a For..Next loop but it just animated so fast that I only see the last position of the square. How can I do this so that I can actually see it animating? Again, I want to do this purely in code.

Thanks,

May

View Replies !    View Related
Duplicating A Dynamically Created Movie Clip
Hi,

I dynamically create some movie clips from images that I load into the first scene of my movie using the createEmptyMovieClip() command - loadMovie is used to assign an image to these clips. This part works fine.

In the next scene, I am trying to duplicate these clips to use them in other movie clips but it doesn't work. I don't think it is a targetting problem, as I can trace the properties of the clips generated in the first scene, and the clips themselves are still visible in this scene. When I use the duplicateMovieClip command nothing happens, and the "new" clip's properties are undefined.

Am i doing something stupid here? Is it possible to duplicate a movie that hasn't been manually created in the library. I haven't got a clue!

Would appreciate any help!

View Replies !    View Related
How Do You Resize A Dynamically Created Movie Clip
So I have a movieclip that I am dynamically adding to the stage when a user clicks a particular button. There are multiple button that each result in the movieclip getting attached to the staged and scaled to a different particular size. Instead of attaching a new instance of the movieclip every time a button is clicked, I only want to attach a new movieclip the first time one of the buttons are clicked and then scale the dynamically added movie to the size specified in the functions for all of the subsequent button clicks. To be clear, I want to attach the movieclip on the first click and then scale it for all of the subsequent clicks.


Here is the code I am using for the buttons:

ActionScript Code:
stop();

videosBTN.onRelease= function() {
_root.cover.spaceships.attachMovie("boxBg", "Bg", 01, {_x:5, _y:127, _xscale:92,_yscale:100} );
}


photosBTN.onRelease= function() {
_root.cover.spaceships.attachMovie("boxBg", "Bg", 01, {_x:5, _y:140, _xscale:93,_yscale:123} );
}

Here is what I am using for the moviclip I want to scale:

ActionScript Code:
onClipEvent (enterFrame) {
        //this scales our clip along the x axis 10% every frame until it reaches a certain width
        if (this._xscale< 100) {
                this._xscale += 10;
        }

}

onClipEvent (enterFrame) {
        //this scales our clip along the x axis 10% every frame until it reaches a certain width
        if (this._yscale< 100) {
                this._yscale += 10;
        }
       
}

Is there a way to do this?

View Replies !    View Related
Publish Dynamically Created Movie Clip
If I create dynamically movie clip, creat sound object, and then attach sound from library can I then publish this movie clip as swf?

View Replies !    View Related
[CS3]How Do You Resize A Dynamically Created Movie Clip?
So I have a movieclip that I am dynamically adding to the stage when a user clicks a particular button. There are multiple button that each result in the movieclip getting attached to the staged and scaled to a different particular size. Instead of attaching a new instance of the movieclip every time a button is clicked, I only want to attach a new movieclip the first time one of the buttons are clicked and then scale the dynamically added movie to the size specified in the functions for all of the subsequent button clicks. To be clear, I want to attach the movieclip on the first click and then scale it for all of the subsequent clicks.


Here is the code I am using for the buttons:

Code:
stop();

videosBTN.onRelease= function() {
_root.cover.spaceships.attachMovie("boxBg", "Bg", 01, {_x:5, _y:127, _xscale:92,_yscale:100} );
}


photosBTN.onRelease= function() {
_root.cover.spaceships.attachMovie("boxBg", "Bg", 01, {_x:5, _y:140, _xscale:93,_yscale:123} );
}
Here is what I am using for the moviclip I want to scale:

Code:

onClipEvent (enterFrame) {
//this scales our clip along the x axis 10% every frame until it reaches a certain width
if (this._xscale< 100) {
this._xscale += 10;
}

}

onClipEvent (enterFrame) {
//this scales our clip along the x axis 10% every frame until it reaches a certain width
if (this._yscale< 100) {
this._yscale += 10;
}

}
Is there a way to do this?

View Replies !    View Related
Publish Dynamically Created Movie Clip
If I create dynamically movie clip, creat sound object, and then attach sound from library can I then publish this movie clip as swf?

View Replies !    View Related
How Do I Assign Actions To A Dynamically Created Movie Clip?
I have a box that is being drawn dynamically with the draw functions. It's created using createEmptyMovieClip. How do i dynamicaly assign action to it?

View Replies !    View Related
Turn A Dynamically Created Rectangle Into A Movie Clip
Hello there,
What's the best way of turning this dynamically created rectangular border into a movie clip?


//Put a border on the stage
function stageBorder() {
var lineThickness = 2;
this.clear();
this.lineStyle(lineThickness, 0x000000, 100);
this.moveTo(0, 0);
this.lineTo(Stage.width-lineThickness, 0);
this.lineTo(Stage.width-lineThickness, Stage.height-lineThickness);
this.lineTo(0, Stage.height-lineThickness);
this.lineTo(0, 0);
}
stageBorder();


stop();

View Replies !    View Related
Prob Controlling Dynamically Created Movie Clip
this is bery basic i guess but for some reason i can't get this working .... my problem is i am attaching a movie clip from library using attachMovie function. The movie is showing up fine but for some reason i can't seams to adjust some values of it. My code is like this :

function addSlider(sliderid,tminval,tmaxval,tsrartval,tslid erWidth,tstitle) {
attachMovie("sliderlib",sliderid,getNextHighestDep th());
sliderid:minval = tminval;
sliderid:maxval = tmaxval;
sliderid:startval = tsrartval;
sliderid:sliderWidth = tsliderWidth;
sliderid:title.text =tstitle;
trace(sliderid);
}

i am calling the the function like this

addSlider("slider1",0,12,1,130,"Something");

but on the attached movie clip, the values are not assigned at all.
My suspect is, in systex like : sliderid:minval = tminval; , flash is treating "sliderid" as a variable not a movie clip.

Any please tell me where i'm doing it wrong or whats the right get this done ?

Thanks

View Replies !    View Related
How To Run Some Actionscript Inside A Dynamically Created Movie Clip?
Hey Flashkit,

First off forgive me if someone has posted a message on this subject already because I haven't found it, yet.

I would like to create some dynamically created movie clips in a main movie that absorb, receive, or have embedded in them (I do not know the word to use) some actionscript that can be called over and over while the newly created movie clips play through their own timelines.

Is this possible? How can I put some actionscript inside a dynamically created movie clip? I’m interested in using the code on the first frame, perhaps on enter frame or actually anywhere in the move clip.

Thanks,
- Jimmy

View Replies !    View Related
[F8] Can't Understand How To Use GetRGB() On A Dynamically Created Movie Clip
The following code automatically creates a grid of "cells" of a movie clip that's a simple black square. It assigns an onMouseDown and onMouseMove behavior to each cell as it's created, so when I click and drag, the cells I drag over turn white. If the cell I click on is white, I want the next click to turn it to black again. Everything works fine EXCEPT that I can't get the cells to turn black again (the line with the comment "//can't get here!!!!")

I can't find a way to access the color object that was created for each cell in order to do a getRGB() function on it. So, I can't get that line to evaluate to True, and can't get the cells black again. It occurred to me that I could give each color object a unique name, the same way I give each cell a unique name, but that seems awfully complicated. I'm further confused by the fact that the setRGB() function seems to work fine, even though I'm just using dot notation as if the color were a property of the movie clip.

Can anyone help me understand this? I'm sure that color objects must confuse people all of the time. I think I get the general idea, but I don't know how to access each cell's color object in this case, since they aren't uniquely named.

As an aside, can a color object be assigned to more than one movie clip, so that they will all change color when the color object is altered?

Thanks a ton in advance for your time and help...


--------------------------------------------------------
var startx:Number;
var starty:Number;
var xInc:Number;
var yInc:Number;
var numCols:Number;
var numRows:Number;
var myLevel:Number;
var cellWidth:Number;
var cellHeight:Number;
var cellName:String = "(cell name)";
var mouseButtonDown:Boolean; // only draw when this is true

var myMouseListener:Object = new Object();
Mouse.addListener(myMouseListener);

// -------------------

onLoad = function() {
initialize();
}

// -------------------

myMouseListener.onMouseDown = function() {
mouseButtonDown = true;
}

myMouseListener.onMouseUp = function() {
mouseButtonDown = false;
}

// --------------------

function initialize() {

startx = 20; // cell margin; usually 0
starty = 20; // cell margin; usually 0
numCols = 30;// how many cells across do you want?
numRows = 30; // how many cells deep do you want?
myLevel = 0; // always 0
mouseButtonDown = false;

//---- this makes the cells the right height & width

cellWidth = (myBG_mc._width - startx*2)/numCols;
cellHeight = (myBG_mc._height - starty*2)/numRows;

//---- call the function that creates grid ------
makeGrid()
}

//------- set up the grid and add actionscript to cells

function makeGrid() {

for (r = 0; r <= numRows - 1; r++) {
for (c = 0; c <= numCols - 1; c++) {

thisx = myBG_mc._x + (startx + (c * cellWidth));
thisy = myBG_mc._y + (starty + (r * cellHeight));
myLevel++; //add 1 to myLevel

thisItem = attachMovie("cell", "cell"+"_"+(c+1)+"_"+(r+1), myLevel);
thisItem._x = thisx; //set the hor position to the correct place
thisItem._y = thisy; //set the vert position to the correct place
thisItem._width = cellWidth;
thisItem._height = cellHeight;

// ----- add ActionScript for each cell -----

// ---- draw color on mousedown ----
thisItem.onMouseDown = function() {

if (this.hitTest(_xmouse, _ymouse)) {

cellName = this._name;
var cellColor:Color = new Color(this);

if (this.getRGB() == (0xffffff)) { //can't get here!!!!

cellColor.setRGB(0x000000);
} else {
cellColor.setRGB(0xffffff);
}
}
}

// ---- draw color only when mouse button is down
thisItem.onMouseMove = function(){

if (this.hitTest(_xmouse, _ymouse)) {

cellName = this._name;
var cellColor:Color = new Color(this);

if (mouseButtonDown == true) {

if (this.getRGB() == (0xffffff)) {
cellColor.setRGB(0xff0000);
} else {
cellColor.setRGB(0xffffff);
}
}
}
}
}

// --------- end of inner for loop

}
}


[/font]

View Replies !    View Related
How To Set The Registration Point Of A Dynamically Created Movie Clip?
I have this dynamically created movie clip:


ActionScript Code:
this.createEmptyMovieClip("A", this.getNextHighestDepth());

and now I wan to dynamically change its registration point, for example, to its center.
is it achievable?
How can I do that?

View Replies !    View Related
Dynamically Created Movie Clip Depth Issue
I am creating empty movie clips with a for loop, which then have a jpeg loaded into them. In relation to _root, these clips are being created in "_root.frame.scroller". Scroller is a movie clip on the stage, but with nothing in it, except the script.

The result on the stage is a movie clip in a movie clip in a movie clip (i.e. _root.frame.scroller.DYNAMICALLY GENERATED MC.)

The issue is that the event handling (onRollOver) isn't working. No action, no hand cursor, no nothing -- like it's not even there. So I think it's a depth issue, but I'm stuck.

Here's the code, which exists at frame1 of the MC "scroller'.

ActionScript Code:
totalimages = 5;
for (i=0; i<=totalimages; i++) {
    img = "img"+i;
    this.createEmptyMovieClip(img, i);
    this[img].loadMovie("pic_"+i+".jpg");
    this[img]._xscale = 18;
    this[img]._yscale = 18;
    this[img]._x = -82;
    this[img]._y = (i*120)-290;
    this[img]._alpha = 75;
   
    this[img].onRollOver = function () {
        this._alpha = 20;
    }
}

I recognize it may be easier if you could see the FLA, but I cannot provide it. Sorry about that.

Thanks in advance.

View Replies !    View Related
Working With Dynamically Created Instances Of Movie Clip
i've been searching everywhere for this but couldn't find any help. Someone PLEASE HELP ME!

PHP Code:



for(var i=0; i<row; i++)  {         var u=i+1;     attachMovie("friend", "friendName" + u, this.getNextHighestDepth(), {_x:0, _y:ypos});     ypos = ypos + 19;     } 




this code that i have creates this movie clip dynamically and the variable row gets its value from a php script. well inside this i have a text field, with instance name namefield, which i want to change. usually, we do this:
_root.friendName1.namefield.text = "BOB";
_root.friendName2.namefield.text = "Steve";
...
well, how do i do i as refer to dynamically created instance names?

View Replies !    View Related
How To Place Dynamically Created Movie Clip Behind Existing Contents
Hi,
I'm using action script to create several movie clips and place them on the stage. But there are some already hand made content (such as textfields, images etc).

What I want is to place my movie clip behind that content, so for example textfield would appear above created movie clip.

The problem is that hand made textfields, images and graphic objects don't have swapDepth function...

Is there a way to do this? Or the only (and pretty ugly) way is to create all textfields and images from library objects using actionscipt?

View Replies !    View Related
Help - Need To Define OnLoad/onRelease For Dynamically Created Movie Clip
I dynamically creating movie clips and I need to define events for them. What I am currently doing is not working - the events are not automatically called.

i.e.

_root.createEmptyMovieClip("side",1);
side.onLoad = function() {
trace("hello");
}
loadMovie("image.jpg",_root["side"]);



////
the clip is created, I can create functions, but events like onLoad, onRelease are never called automatically unless I manually call them

View Replies !    View Related
Targeting Movie Created By Array
Ok,

I'm importing a variable from a txt file. I convert this variable to an array and use a loop to duplicate the movie called "button" as many times as the length of the array so I end up with "button0", "button1", "button2" etc. Inside "button" there is a var called "name".

What I'm having trouble doing is setting "name" for each button to correspond to the array ex:
button0/:name = menu[0] and button1/:name = menu[1]

here's what I've done so far:

// split the TOC var into array
menu = new Array();
menu = TOC.split(",");

// duplicate button
for (i=0; i<menu.length; i++) {
duplicateMovieClip ("button", "button" + i, i);
setProperty ( "button" + i, _y, i*30 );
//this is the problem
set ( "button"+i+"/:name", menu[i] );

}
stop ();

Would really appreciate any help.

)

View Replies !    View Related
Defining A Function For A Dynamically Created Clip?
i wanna write a function for the onPress handler for a movieclip that will be created dynamically.. how do i do it? this is what i'm doing:

only the ending part of this loop is relevant, where i am writing the thisMC.onpress function. The trace text never appears..


Code:

for (var i = 0; i<galleryLength; i++)
{
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i);
loadMovie(gallery_array[i].src, thisMC);

thisMC._x = 50*xPos+adjust;
xPos++;
thisMC._y = 50*yPos;
thisMC._xscale = 10;
thisMC._yscale = 10;
trace(thisMC+" "+thisMC._x+" "+thisMC._y);
if ((i+1)%5 == 0)
{
yPos++;
xPos = 0;
}
//Here lies the problem:
thisMC.onPress = function()
{
trace("Pressed "+this);
}
}
this whole loop is inside the onClipEvent(load) of another clip. So when that clip is loaded, this code is executed..

View Replies !    View Related
Help - Placing A Dynamically Created Clip Inside Another...
Hey all,

I have a situation and can't figure out how it's solved. The short of it is that I have a dynamically created mc that needs to ultimately be placed INSIDE another dynamically created mc. So I will need to somehow 'attach/place' firstClip_mc into secondClip_mc.

I'm doing this for undo tracking purposes. For example, the user can paint into the dynamically created clip called firstClip_mc and then that 'painting' will then be placed inside secondClip_mc which is also created on the fly. That way I can 'undo' the entire painted clip...attachMovie only works from the library. It's like I need that type of functionality for these two clips...

Any ideas? And thank you in advance!

Brian

View Replies !    View Related
Targeting Programatically Created Movie From Within Externally Loaded Swf
Hi guys, I am trying to use the dynamic image preloader tutorial that I found here, but I am having the following problem.

I have created a movie programatically that is created when the movie plays.

var empty = this.createEmptyMovieClip("container", "100");
empty._x = 300;
empty._y = 300;
my_mc = new MovieClipLoader();
preload = new Object();
my_mc.addListener(preload);
preload.onLoadStart = function(targetMC) {
trace("started loading "+targetMC);
container._alpha = 0;
bar._visible = true;
border._visible = true;
pText._visible = true;
};
preload.onLoadProgress = function(targetMC, lBytes, tBytes) {
bar._width = (lBytes/tBytes)*100;
pText.text = "% "+Math.round((lBytes/tBytes)*100);
};
preload.onLoadComplete = function(targetMC) {
container.fadeIn();
border._visible = false;
bar._visible = false;
dText._visible = false;
trace(targetMC+" finished");
};

The movie above is created on my main timeline, which also has another movie called 'holder'. I am loading an external swf into the movie called 'holder', which works fine.

The problem comes in when I try to call the dynamically created movie (my_mc) with the following line:

_root.my_mc.loadClip("Designs/Patriot.jpg", "_root.container");

What should happen is the dynamically created movie (my_mc) should load the image as soon as the listener is called, but for some reason it doesn't want to!

The line _root.my_mc.loadClip("Designs/Patriot.jpg", "_root.container"); works fine when it isn't inside of an externally loaded swf, but as soon as it is in the external swf, I get problems. Is there some way to target dynamically created movie's that I am not aware of?

Please help, I am ready to pull my hair out!

View Replies !    View Related
Getting Dynamically Created Clips To Move If They Fall On Existing Clip
I wanted to write a script that would check the position of a load of clips created via the “duplicateMovieClip” method (I have also colored them as part of the exercise, but this is not relevant to the problem.)

The idea is if a clip over laps another clip I set it’s _x & _y to 20 greater than the clip it has landed on.

This is where I have got to with it, which is not having the desired effect.

code: var balloonColor;
clam_array = new Array();
for (vari=0; i<20; i++) {
balloon.duplicateMovieClip("balloon"+i, i);
clam_array.push(this["balloon"+i]);
this["balloon"+i]._x = Math.floor(Math.random()*550);
this["balloon"+i]._y = Math.floor(Math.random()*400);
balloonColor = new Color(this["balloon"+i]);
balloonColor.setRGB(Math.floor(Math.random()*0xFFF FFF));
}
delete balloonColor;

for (i in clam_array) {
if (this["balloon"+i].hitTest(clam_array[i])) {
this["balloon"+i]._x = clam_array[i]._x+20;
this["balloon"+i]._y = clam_array[i]._y+20;
trace(this["balloon"+i]._name);
}
}

View Replies !    View Related
Get Name Of Dynamically Created Movie
In a game that I am scripting I am using the duplicateMovieClip() funtion to create a series of animations that go across the screen. Inside each of these clips is another movie clip that does a hitTest(). When the weapon hits this area I need to gotoAndPlay() on the main timeline for the duplicated movie. Since they range from newChar1-100 I need to get then name of that movie dynamically. So I can use a gotoAndPlay() function.


For example....

lets say I dynamically dulpicated a clip and called it 'newChar1'

inside this movie i have another movie called 'hitTest'

when the weapen hits 'hitTest' I want to gotoAndPlay("hit") on the 'newChar1' timeline

The problem is (once again) that I don't acutually know the name of the main movie clip.

I tired putting movieName = this; on the main timeline and this is what I got:

moiveName = [movieclip:_level0.newChar1]


I don't know how to use this or if it is even possible. Thanks for your help.

View Replies !    View Related
Get Name Of Dynamically Created Movie
In a game that I am scripting I am using the duplicateMovieClip() funtion to create a series of animations that go across the screen. Inside each of these clips is another movie clip that does a hitTest(). When the weapon hits this area I need to gotoAndPlay() on the main timeline for the duplicated movie. Since they range from newChar1-100 I need to get then name of that movie dynamically. So I can use a gotoAndPlay() function.


For example....

lets say I dynamically dulpicated a clip and called it 'newChar1'

inside this movie i have another movie called 'hitTest'

when the weapen hits 'hitTest' I want to gotoAndPlay("hit") on the 'newChar1' timeline

The problem is (once again) that I don't acutually know the name of the main movie clip.

I tired putting movieName = this; on the main timeline and this is what I got:

moiveName = [movieclip:_level0.newChar1]
I then used: movieName.gotoAndPlay("hit"); to go to the frame. it didn't work

If you have any suggestions on how to get this to work or another way please let me know. Thanks for your help.

View Replies !    View Related
Targeting A Frame Label In A Movie Clip From A Button In A Separate Movie Clip.
I have two separate movie clips placed on a timeline-MovieclipA and MovieclipB. I have a button in MovieclipB clip that wants to target a frame label located in the MovieclipA timeline. Can someone help me?

View Replies !    View Related
Dynamically Created Movie Clips
Hello. I am a bit stumped on how to attach actionScript to dynamically created buttons (actually movie clips that work lilke buttons). basically my file loads in XML data and creates one button for each xml node. but i don't know how then to make each of the buttons go to a different page (page1, page2 etc). any ideas?

thanks

View Replies !    View Related
Dragging Dynamically Created Movie Clips
I have a bunch of movie clips that are attached dynamically at random positions. i want to be able to drag all of them around, one at a time. it seems really simple. but i don't know how to go about doing this. do you add code to all the clips dynamically somehow?

View Replies !    View Related
Naming Dynamically Created Movie Clips
Hello,
I must load photos from a database at runtime. I thought to create empty movie clips then load them with the photos. I create the empty movie clips in a loop with:
******
var maxSize:Number = 50;
var indexPhotoArray:Array;
for (var i:Number = 0; i<maxSize; i++) {
var photoMC = this.createEmptyMovieClip("plane_index_photo_"+i+" _mc", i);
indexPhotoArray.push(photoMC);

********
When I look in the debugger, all 50 empty movie clips show up fine.
When I try to populate them in a second loop, it does not seem to work
The second loop goes:
************

_root.business_mc.business_ds.first();
for (var i:Number = 0; i < indexPhotoArray.length; i++) {
var z:String =_root.business_mc.business_ds.currentItem.Picture ;
indexPhotoArray.loadMovie("http://www.tonybarre.com/directory/images/" + z);
_root.business_mc.business_ds.next();
}
**************

If I replace this second loop with:
***************
_root.business_mc.business_ds.first();
var z:String =_root.business_mc.business_ds.currentItem.Picture ;
plane_index_photo_1_mc.loadMovie("http://www.tonybarre.com/directory/images/" + z);
*************
I get the one photo. But, of course, I need the whole array.

I have tried to replace what I believe is the problem line with the following, but none work:
***this[indexPhotoArray.pop()].loadMovie("http://www.tonybarre.com/directory/images/" + z);
***indexPhotoArray[i].loadMovie("http://www.tonybarre.com/directory/images/" + z);
***this["plane_index_photo_"+i+"_mc"].loadMovie("http://www.tonybarre.com/directory/images/" + z);

Thanks for any help you can provide.

Tony Barre

View Replies !    View Related
Naming Dynamically Created Movie Clips
Hello,
I must load photos from a database at runtime. I thought to create empty movie clips then load them with the photos. I create the empty movie clips in a loop with:
******
var maxSize:Number = 50;
var indexPhotoArray:Array;
for (var i:Number = 0; i<maxSize; i++) {
var photoMC = this.createEmptyMovieClip("plane_index_photo_"+i+" _mc", i);
indexPhotoArray.push(photoMC);

********
When I look in the debugger, all 50 empty movie clips show up fine.
When I try to populate them in a second loop, it does not seem to work
The second loop goes:
************

_root.business_mc.business_ds.first();
for (var i:Number = 0; i < indexPhotoArray.length; i++) {
var z:String =_root.business_mc.business_ds.currentItem.Picture ;
indexPhotoArray.loadMovie("http://www.tonybarre.com/directory/images/" + z);
_root.business_mc.business_ds.next();
}
**************

If I replace this second loop with:
***************
_root.business_mc.business_ds.first();
var z:String =_root.business_mc.business_ds.currentItem.Picture ;
plane_index_photo_1_mc.loadMovie("http://www.tonybarre.com/directory/images/" + z);
*************
I get the one photo. But, of course, I need the whole array.

I have tried to replace what I believe is the problem line with the following, but none work:
***this[indexPhotoArray.pop()].loadMovie("http://www.tonybarre.com/directory/images/" + z);
***indexPhotoArray[i].loadMovie("http://www.tonybarre.com/directory/images/" + z);
***this["plane_index_photo_"+i+"_mc"].loadMovie("http://www.tonybarre.com/directory/images/" + z);

Thanks for any help you can provide.

Tony Barre

View Replies !    View Related
Adding Variables To A Dynamically Created Movie ?
i have created a empty movieclip and now want to add a array to it as in


ActionScript Code:
createEmptyMovieClip("draw_txt",this.getNextHighestDepth());
draw_txt.myArray = new Array();

but it does not work..how can i do this ?

View Replies !    View Related
Refencing Movie Clips Created Dynamically
I am adding a series of clips using attachMovie and adding a unique numeric identifier to the name of those clips by incrementing through the number of photos in an xml file using "i" as the variable and adding it to the name ("ptextHldr" + i + "_mc" = ptextHldr1_mc, ptextHldr2_mc etc.) each clip has within it a text box that I want to get to dynamically by incrementing again through the names using a variable for the unique identifier, but I can't seem to find the way to reference each clip in this manner. ptextHldr1_mc.textBox1_tb.text works fine, but how does one accomplish the same if I am incrementing through all created using a variable.
Thanks

View Replies !    View Related
Dynamically Created Text Boxes, Movie Clips
I dynamically create text boxes to use XML for different pages, and I place them in movie clips so I can scroll the movie clip (and all the different text boxes on them). The problem is, sometimes the LAST dynamic box doesn't load completely..... When this happens, clicking in the Text Box makes the rest appear... It's kinda weird... Heres a sample script breaking down what I did and making it easier. It's long but simple...

createTextField ("Text1", 1, 0, 0, 300, 2);
with (Text1) {
autosize = true;
background = true;
border = true;
multiline = true;
html = true;
wordWrap = true;
}
Text1.htmlText = "<p>Blah</p><p>By Me</p><p>The Date</p><p>This is my text box. This is my text box. This is my text box. This is my text box. This is my text box. This is my text box.</p>";

k = Text1._y + Text1._height + 6;

createTextField ("Text2", 2, 0, k, 300, 2);
with (Text2) {
autosize = true;
background = true;
border = true;
multiline = true;
html = true;
wordWrap = true;
}
Text2.htmlText = "<p>Blah</p><p>By Me</p><p>The Date</p><p>This is my text box. This is my text box. This is my text box. This is my text box. This is my text box. This is my text box.</p>";

l = Text2._y + Text2._height + 6;

createTextField ("Text3", 3, 0, l, 300, 2);
with (Text3) {
autosize = true;
background = true;
border = true;
multiline = true;
html = true;
wordWrap = true;
}
Text3.htmlText = "<p>Blah</p><p>By Me</p><p>The Date</p><p>This is my text box. This is my text box. This is my text box. This is my text box. This is my text box. This is my text box.</p>";

This, off coarse, goes on the Movie Clip... Any ideas whats wrong? (To test, just copy and paste this onto frame 1 of a blank movie clip, and put an instance of the movie clip on the stage, and test). Also remember it only happens about half the time... so if at first you don't have this problem, keep closing the .swf and retesting, you'll get the problem soon... Any ideas who to get this to work? Thanks in advance...
[Edited by Tormano Cage on 07-04-2002 at 01:07 PM]

View Replies !    View Related
OnClick Events With Dynamically Created Movie Clips
hey, i have a quick question.
I have some script which dynamically creates movieclips, and loads a picture into them. If someone was to click on them, is it possible to recieve on(Click) events from these movie clips and then respond to them?
Thanks

View Replies !    View Related
Problem With Dynamically Created Movie Clips And Levels
ok I have created a site that when loaded decides if it is day or night. Depending on that it links to 1 of 2 movies (one for day, one for nite)

here is the script on the first movie:

myDate = new Date();
myHour = myDate.getHours();

if (myHour > 18) {
_root.holder_mc.loadMovie("tain.swf");
}
if (myHour < 7) {
_root.holder_mc.loadMovie("tain.swf");
} else {
_root.holder_mc.loadMovie("edan.swf");
};


Whether it is day or nite both movies create 16 movieclips dynamically that will link to other projects (photographs, video, etc.)

this is how they create them:

moveMe = function () {
this._y -= this.speed;
if (this._y<0) {
this._y = 400;
}
if (this._y>400) {
this._y = 0;
}
};
for (i=0; i<16; i++) {
nm = "pos" add i;
_root.attachMovie("posID", nm, i);
d = Math.random()*2;
if (d<1) {
_root[nm].speed = -1;
} else {
_root[nm].speed = -2;
}
_root[nm].onEnterFrame = moveMe;
_root[nm]._x = Math.random()*600;
_root[nm]._y = Math.random()*400;

};

Now when I load the first swf into a empty holder movie clip (with loadMovie) and it loads in either the day or nite, the dynamic movieclips are not visible but the movie is loaded because the background is there. Am I loading the movie in the same level as the clips??? What should I do?

(yes I read the sticky about levels but still can't get it. I've been looking in my flash books all day too. )

I am using flash mx.

View Replies !    View Related
[F8] Assign GetURL Link To Dynamically Created Movie
Hi All,

Here's my situation:

1) a php script feeds my .swf file with paths to images
2) in the .swf, I have actionscript that adds movie clips of type "poloroid" to a containing movie clip called "photosmc"
3) I then "initialize" the new movie clips to have various properties - For example:
photomc["mc"+i].dragbutton.onPress = drag; //works
photomc["mc"+i].linkbutton.onRelease = gotoAlbum(); // doesn't work

The result: I can drag my clips around, and I get custom images loading in.
Problem: I can't figure out a way to get the movieclips to link to a web page upon clicking them.

When I try to attach functions to a special "link" button clip that is above the "dragbutton", I either get all of the URLs opening at once (right on load) or not at all. I've tried using the onEnterFrame() function as I do for the drag and stopdrag functions I have -- but that doesn't seem to work for the getURL.


It /seems/ like I can't get *at* the link button to "press" it -- yet when I attach my drag functions to it, it works as expected.

So - what would be a good way to make it so when I click on the image part of my poloriods, I open a link?

Here's an example of the running flash file:
http://photos.animationsite.net

Thank you in advance for your time.

View Replies !    View Related
Adding Actions To Dynamically Created Movie Clips?
I have a Flash app that works as a search engine. The user puts in a keyword and presses search. The page then connects to a PHP page that searches through a database and returns the IDs of images that match the criteria being searched for. Those ID's are then stored in a global array in my Flash file. That all works fine. On my second frame I have this code:

Code:
addbuttons();
function addbuttons() {
// create thumbnails and display them on the screen
var yCount:Number = 1;
var yValue:Number = 0;
var xValue:Number = 0;
for(i=0;i<_global.howmany;i++){
this.createEmptyMovieClip("but"+i,this.getNextHighestDepth())
if (yCount < 6) {
this["but"+i]._x = xValue*100;
} else {
xValue = 0;
yCount = 0;
this["but"+i]._x = xValue*100;
yValue = 150;
}
loadMovie("http://artsmart.leap-prod.com/images/"+_global.thumbArray[i][1]+".jpg", "but"+i);
this["but"+i]._y = yValue;
this["but"+i]._xscale = 25;
this["but"+i]._yscale = 25;
yCount++;
xValue++;
}
}
}
_root["but"+i].onRelease = function(){
trace("clicked");
_root.gotoAndStop(3);
}
This code dynamically creates empty movie clips and displays thumbnails of all the images returned during the search. That works fine too. What doesn't work is this little piece of code:

Code:
_root["but"+i].onRelease = function(){
trace("clicked");
_root.gotoAndStop(3);
}
It doesn't trace anything or perform any of the actions. I have also tried doing this

Code:
this["but"+i].onRelease = function(){
trace("clicked");
_root.gotoAndStop(3);
}
and I've even tried just putting in a static variable this way

Code:
_root.but0.onRelease = function(){
trace(_root["but"+i]);
_root.gotoAndStop(3);
}
I just don't think I am targetting it correctly. Any ideas? Thanks in advance!

View Replies !    View Related
Trouble With AttachMovie And Dynamically Created Movie Clips
hi all,

thank you for reading.

i recently had problems with creating multiple instances of movie clips on the stage. now that i'm past that hurdle, i'm having difficulties with attaching a button to these newly created movie clips.

here is the code in the button i am using to create these clips:


ActionScript Code:
on (release) { 
   
// designs_stage is the movie clip in which all new
// instances are suppose to be placed into 
_root.increment++;
myNewValue = _root.increment;

_root.designs_stage.createEmptyMovieClip("myClipArt" + myNewValue, _root.designs_stage.getNextHighestDepth());

var my_mcl:MovieClipLoader = new MovieClipLoader();

// assetURL is the path of the image in the list
my_mcl.loadClip(assetURL, "_root.designs_stage.myClipArt" + myNewValue);



x = eval("_root.designs_stage.myClipArt" + myNewValue);
trace(x); // returns target of new clipArt instance

z = eval(x.createEmptyMovieClip("dragButtonContainer", 0));
trace(z); // returns target of new dragbuttonContainer inside the clipArt instance

z.attachMovie("_btn_DRAG", "dragButton", 0);  // this won't work!
   
}

everything seems to be working up to the point of creating a second new movie clip inside the first new movie clip. and i can even grab the target path of the second new movie clip [ trace(z); ]...

but when i try to attach a button to the second movie's path (z), it won't work! i'm stumped!


to test to see if my attachMovie code is working, i created a test button on the _root timeline that will attach the same "_btn_DRAG" instance onto the main stage:


ActionScript Code:
on (release) {

_root.attachMovie("_btn_DRAG", "dragButton", 0);

}


my test button works -- it places my "_btn_DRAG" button onto the stage..

but the code in my REAL button doesn't work..

would anyone have any clue as to why i'm experiencing this problem??

hopefully this makes sense! thanks in advance!!

View Replies !    View Related
Adding Parameters To Dynamically Created Movie Clips?
Hey guys, I found this page that explains how to pass variables to dynamically created clips, but I need to know how to do i with AS3.0 using this:


ActionScript Code:
var entry1:tourDate = new tourDate();
addChild(entry1);

I need to pass the following variables to that entry1:

tourDate_str = "November 5, 2007"
tourTime_str = "8PM";
tourVenue_str = "Whatever";

Anyone?

Thank you!

View Replies !    View Related
Click Events For Dynamically Created Movie Clips
hey,
i was wondering if anyone knew how to make dynamically created movie clips clickable. basically what i have is a user clicks a button and it puts boxes on the screen, i want the user to be able to select the boxes by clicking on them. i've tried putting onClipEvent handlers and onMouseUp handlers on the class file linked with the box movie clips, but flash says that's a no-no, so i'm kind of stuck. thanks.

View Replies !    View Related
Move And Fade In Of Dynamically Created Movie Clips
Hi all,

I'm fairly new to the AS world and am struggling to get something to work. What I'm trying to achieve is this: there's a slideshow that automatically changes pictures every 10 secs (I've used a kirupa tutorial to achieve this). The pictures are loaded from an xml file, which also contains captions for the pictures. What I would like to do is to have the caption fade in and slightly move to the left with each picture change. E.g. picture 1 is displayed, caption 1 fades in, moves to the left and stays there; picture 2 is displayed, caption 2 fades in, moves to the left and stays there, and so on.

Below you'll find the actionscript I have for now. It changes the pictures and displays all captions at once. If there's anyone there who can help me create a fade in and a movement for the captions, I would really appreciate the help.

Regards,
Joris


Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
delay = 10000;
var descItems_mc:MovieClip = this.createEmptyMovieClip("di", this.getNextHighestDepth()); // holds small news items
descItems_mc._x = 50;
descItems_mc._y = 30;
//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
var ni_d:MovieClip = descItems_mc.attachMovie("desc_mc", "ni_d" + i, descItems_mc.getNextHighestDepth(), {_y:i * 50});
ni_d.desc_txt.text = description[i];
ni_d.id = i;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = false;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
slideshow();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
slideshow();
}
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}

View Replies !    View Related
Assingning Properties To Dynamically Created Movie Clips
Hello, I am trying to use the duplicateMovieClip event to create a row of custom movie clips dynamically and I would like to be able to set the _alpha properties on each object depending on an event i am firing in a different movie.

Here is my code that actually creates the controls and locates them on the screen.
================================================== ==============
for(var i = 1;i < argCount;i++){

duplicateMovieClip(CounterBackMain_mc0,"CounterBac kMain_mc"+argCount-i,argCount-i);
this["CounterBackMain_mc"+argCount-i].textNumber_mc.textNumber.text = argCount - i;
this["CounterBackMain_mc"+argCount-i]._x = iLocation - CounterBackMain_mc0._width + 4;
this["CounterBackMain_mc"+argCount-i]._y = CounterBackMain_mc0._y;
iLocation = eval("CounterBackMain_mc"+argCount-i)._x;

//set("Counter"+(argCount-i),"CounterBackMain_mc"+(argCount-i));

eval("CounterBackMain_mc"+argCount-i).onRollOver = function(){
setAlpha(this.CounterBack_mc,true);
}
eval("CounterBackMain_mc"+argCount-i).onRollOut = function(){
setAlpha(this.CounterBack_mc,false);
}
eval("CounterBackMain_mc"+argCount-i).onPress = function(){
//_level0.loadImages(imageArray,argCount-i)
_level3.MainImage_mc._alpha = 100;
_level3.setImage(Number(this.textNumber_mc.textNum ber.text)-1);
//trace(Number(this.textNumber_mc.textNumber.text));
}
setAlpha(eval("CounterBackMain_mc"+argCount-i).CounterBack_mc,false);
}

================================================== ==============
Here are the functions called from the event to set the property:
function setPictureNum(argCounter){
//Set alpha to 0 on previous control
setAlpha(eval("CounterBackMain_mc"+current_pos).Co unterBack_mc),false);
setAlpha(eval("CounterBackMain_mc"+argCounter).Cou nterBack_mc"),true);
current_pos = argCounter;
}

function setAlpha(argMC,argVisible){
switch(argVisible){
case true:
argMC._alpha = 100;
break;
case false:
argMC._alpha = 0;
break;
}
}
================================================== ==============

It does not seem to recognize the dynamic clip I am sending to the setAlpha function. Any of the initial events I set in the loop work fine. I just cannot access the properties once the loop is completed. Any suggestions would be very appreciated!!

All the Best!
Jim Davis

View Replies !    View Related
Applying ActionScript To Dynamically Created Movie Clips
Should be simple enough, but I can't quite figure out how to add onClipEvent(enterFrame) {} to dynamically created movie clips.

View Replies !    View Related
Targeting Dynamically Named Movie Instances?
Using attachMovie and a while() loop I duplicated an mc 10 times, and now I want to retrieve dynamically-loaded variables from those mc's using OOP. But the instance names for the mc's don't seem to be valid. I would very much appreciate any input anyone has.

For example, there's one instance of the original mc on the stage, with instance name pinkCircle1. The loop created 10 more mc's with the attachMovie function, each named pinkCircle2, pinkCircle3, etc. up until pinkCircle11.

But now, if I try to retrieve a variable from one of those instances, it returns 'undefined.' For example,

_root.myVariable=_root.pinkCircle4.mcVariable

returns undefined, where myVariable is a variable on the main stage I'm trying to populate with the value from a variable in the dynamically created instance of the pinkCircle mc called mcVariable. Am I making sense?

Anyway, thanks for your help-
Brig.

View Replies !    View Related
Targeting Dynamically Attached Movie Clips
How do I target a movie clip that is added dynamically to another movieclip? I created the movieclip called masker and I have added 50 circles to the masker movie clip. How to I target the each of the movie clips that are nested inside of masker?

ActionScript Code:
var home:MovieClip = _root;

function randRange(min:Number, max:Number):Number {
    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
    return randomNum;
}
this.createEmptyMovieClip("masker", 10);

var space = 0;

for(var i:Number = 0; i < 50; i++) {
    var yspace:Number = randRange(0, 245);
    var xspace:Number = randRange(0, 505);
    var scale:Number = randRange(0, 20);
    var timeWait:Number = (randRange(0, 1))*.5;
    masker.attachMovie("mc_circle2", "mc" + i, i+1000, {_y:yspace, _x:xspace, _xscale:scale, _yscale:scale});
//this is where I am trying to target the movie clips and I get an actionscript error.
    masker.["mc"+i].scaleTo(200,4,"easeInBack", timeWait);
    trace("x: " + xspace + " y: " + yspace + " scale: " + scale);
}

View Replies !    View Related
Setting Variables In Dynamically Created (duplicated) Movie Clips
How do I set a variable in a dynamically created movie clip? Here's the code I used to duplicate the movie clip:

code:
missileCounter++;
_root.missile.duplicateMovieClip("missile"+missile Counter, missileCounter);


I used the setProperty() method to set properties like X and Y positions, but I don't think you can use that for variables, can you?


Thankyou for any help!
Rick

View Replies !    View Related
Making Dynamically Created Movie Clips Instances Re-draggable
This is a Flash 8 / Actionscript 2 problem

The application allows the user to create multiple instances of a dot
by clicking on the original dot - and then drag the instances to position
them on the stage (it's part of a game)

I need to allow dots to be re-dragged - but to do that need to detect the
instance name of the dot under the mouse pointer (otherwise I can't turn
the dragging on)

this is what I've got so far...

numberOfDotDuplicates = 0;

dot.onPress = function()
{
numberOfDotDuplicates++ duplicateMovieClip(_root.dot,"dot"+numberOfDotDupl icates,getNextHighestDepth())
_root["dot" + numberOfDotDuplicates].startDrag(true);
}

/*
This bit below is not realy part of the problem
- but it feels like an inelegant workround
I've had to use a listener to stop the dragging
because the onRelease event is only detectable
if it happens over the original 'dot' (where the
corresponding onPress event was detected)
*/
var myListener:Object=new Object()
Mouse.addListener(myListener);
myListener.onMouseUp = function()
{
stopDrag();
}

Thanks for taking the time to read this

Simon

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved