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




Variables In Movieclips



HELP!!!!

i've entered this line :

var playMCBox = closed;

and in my movieclip ive entered this line:

trace(_root.playMCBox)

and i really don't know why its coming up as undefined!! have i done something obviously wrong ? or am i missing something ??

Can somebody pleeeeease help!!

Thanks
Si



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 05-17-2006, 11:15 AM


View Complete Forum Thread with Replies

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

Variables And Movieclips
Hi.
I am trying to do the whole variable thing with movieclips. My navigation calls different MCs on to the stage, one at a time. When I press a different button, current clip tweens off, and new clip tweens in.

This is what I have so far.

on the button I put this code:


on (release) {


status = active


//this deactivates everything


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


_root["working" + i].active = -1;


}


active = -1*(status); //this will switch it from active to inactive or vise versa


}

On the MC instance which I have placed on the stage I have this:
onClipEvent (load) {


if (active == 1) {


this.gotoAndPlay ("open");


} else if (active == -1) {


this.gotoAndPlay ("close");



}


}

Please help. Do I put all of my variable movie clips in to one clip, and then put them on the stage?

These are my error messages:
Symbol=blankM, Layer=working, Frame=2: Line 1: Identifier expected
onClipEvent (1) {

Symbol=blankM, Layer=working, Frame=2: Line 7: ']' or ',' expected
[insert code to open it or whatever here]

Symbol=blankM, Layer=working, Frame=2: Line 4: Statement must appear within onClipEvent handler
if (active == 1) {

Symbol=blankM, Layer=working, Frame=2: Line 10: Unexpected '}' encountered
} else if (active == -1) {

Movieclips And Variables
Hi,
I've made this flash movie and it has a varible in it on the main timeline when you click a button. Then in a movieclip it checks for this variable and then does an action but it's not working. I think its because the two timelines have there own varibles and thats it, but is there anyway i can pass this varible from the main timeline to the movieclip?
Thanks,
Chris

Variables And Movieclips
I have a movie clip that set some variables but i want to use some of the variables in another movieclip, how do get them from the other movieclip?

Any help would be grand!

Cheers

Jemes

Variables And Movieclips
I'm trying to pass a variable from a movieclip to another movieclip. Both clips are on the root timeline. I've tried everything from _global to _parent.mcname.variable.

I could truly use someone's help here...

MovieClips And Variables
I have established a variable in the beginning of my movie; it's a quiz. At the beginning the user enters his/her name. Another variable tracks the correct answers. At the end of the quiz, the frame displays: the user's name and the how many they got correct. Everything works fine.
However, when I put the text boxes that are displaying the variables inside of a movie clip (so i can print the results), they no longer display and are blank. Does putting the variables inside the movie clip affect affect variables' value? How can I get the value of the variables to display in the movieclip?

Variables In Different Movieclips
HELP!!!!

i've entered this line :

var playMCBox = closed;

and in my movieclip ive entered this line:

trace(_root.playMCBox)

and i really don't know why its coming up as undefined!! have i done something obviously wrong ? or am i missing something ??

Can somebody pleeeeease help!!

Thanks
Si

Variables And Movieclips
so im tryin to access a mc inside of a mc inside of a movieclip, but using variables

the main mc is called map, filled with mcs called dist1-5, each filled with mcs called info1-5

so instead of using map.dist2.info3.gotoAndPlay(whatever) or map.dist4.info1.gotoAndPlay(blahblah) i want to use variables that have been previously declared

so i would have map.district.info.gotoAndPlay, district being named "dist1" or "dist4" earlier in a script and info being named "info2" or "info5" earlier. this code doesnt seem to work tho, it seems to want specific movie clip names not variables, so can someone help point me in the right direction??

Variables And Movieclips
Hello everyone!

My first question is that is it possible to convert the type of a variable?
For example, converting a variable that's a string to a movieclip?

My problem is basically this. Here's a piece of code:

Code:
var getANumber:Number = 2;
createEmptyMovieClip("image"+getANumber+"_mc", this.getNextHighestDepth());
image"+getANumber+"_mc"._visible:MovieClip = false;
Now, Output will about type mismatch. So, how could I make this work? Any ideas?

What could also work if I could retrieve the path of a movieclip. How do you do that? Some code like,
Code:
retrieve this.MovieClip.location ??
and save as a new MovieClip variable. Perhaps?

Thanks for the help in advanced!

Using Variables As Movieclips
Whats up everyone,

I need to know how I would use a variable as a movieclip, like me expain with an example:

currentMovie = "MovieClipName";

_root.currentMovie.gotoAndPlay(2);

I want to have 'MovieClipName' to be the movieclip that plays.
But obviously AS 2 things I'm asking for 'currentMovie' to play but its just a variable.

How can I implement this? Help Please?

Thanks.
Noir

Variables In Movieclips?
Hi all,

Im having abit of a thick moment at the mo...Im trying to get a button on the _root to define a variable in a movieclip called contentmc, then I want contentmc to play and then check to see what the variable is set to (via if/else statements) dependant on which button on the _root has been clicked, and then once it's got the variable value, it goes and plays one of three frame labels and stops..once another button on the _root is clicked, the variable wants to be changed again the the contentmc playhead to play on and then check again what the value of the variable is and therefore jump to the appropriate frame label if that makes sense.

Now I can get it working all fine if I define the variables at _root level, but for the life of me cant get it to work with variables in movieclips?

This is what I have within the contentmc for checking what the variable "content" is equal to:

ActionScript Code:
if (this:content == "print") {
    this.gotoAndPlay("print");
} else if (content(this:content == "online") {
    this.gotoAndPlay("online");
} else if (this:content == "art") {
    this.gotoAndPlay("art");
} else {
    this.gotoAndStop("contentin");
}


And this is whats on the buttons on the _root


ActionScript Code:
_root.portfoliobtns.printbut_mc.onRelease = function() {
    _root.portfoliobtns.printbut_mc.gotoAndStop(1);
    _root.compscreen.contentmc.content = "print";
    _root.compscreen.contentmc.play();
};


contentmc is within another movieclip compscreen.

Im doin something wrong somewhere...appreciate some lighteners!

cheers!

Transform Variables --> Movieclips
Hi. I've a flash movie it's making me 2 become crazy.
I've a variable called NAME.
This variable gets its value from an url:
http://www.mysite.com/test.php3?NAME=John
If this php has no value, then NAME takes "NONE" value.
The flash movie shows fine, all works good, BUT:

What have i to do to animate that variable?
How can i transform that variable into a movieclip so i can animate it? Does anyone have any idea about this? Where can i find more info about this?

Thanks in advance.
I'm newbie... plz don't explain in a very TECHNICAL way...
=)

Variables In Movieclips Or Graphics?
every time i try to use a variable in a movieclip or a graphic, something seems to go wrong --> it doesn't work
if you know what could be the problem, plz help me!
tnx
Matthijs

Movieclips And Variables And Strings
If I have, for example, a movieclip called "foto01_0001", how can I extract
part of the movieclip's name and put it into a variable? For example, just
to extract the string before the "_". To put "foto01" into a variable, and
"0001" into another variable.

Any help will be *greatly* appreciated.

Thanks....

Getting Movieclips Propertys Using Variables
Can I address movieclips using variables?
I want to get 40 movie clips positions and put them into an array.
The movies are on the stage and they are called square1 through to square40
I am hoping I can do something like below. But am new to flash scripting. Any help would be great

var numCells = 40

for (var i = 1; i<numCells -1; i++) {
var name = "square" + i;
var whichPiece = eval(name);
getProperty(whichPiece._x);
getProperty(whichPiece._y);

posArray = [];
for (i=0; i<numCells-1; i++) {
posArray[i] = i;
}
empty = numCells-1;}




}

Passing Variables To Movieclips...
I have a problem... In a project I have one movieclip that is used four times in another movieclip. That movieclip is then used 10 times in another movieclip. That movieclip is used twice in the main project window...
In the first movieclip I have an if-statement in a script. That if-statement checks a local variable against a variable that should be set in the main project window...

How do I send this variable down to the fisrt movieclip from the main timeline? Anyone?

Anyway To Change Variables To Movieclips
if i have a movie clip that has two instances on the stage, called inst1 and inst2. and they are instances of a movieclip called calendar. The movie clip calendar has a dynamic textfield in there that pulls off of a text file. i want both instances to pull from different locations. Is there anyway to do that? Or is it possible to have calender and then have two swfs from calendar and import them both their own textfiles, and then have them dynamically appear into my original movie!

Variables Talking To Movieclips?
Hello,

I had to write all the rest of this to figure out my question succinctly, so here it is, you can read the rest for more info...

HOW DO I talk to a movieclip, defined by a variable?

I'm working in MX putting together a fairly large piece with multiple scrollable pages. I want to be able to jump from links on any one page, to preset points on another page, which could well be half way down the scrollable page.

I've got jumping from page to page working fine, but I'm having trouble jumping to the points. My idea was to mark each point with a blank movieclip labeled m1, m2, m3 and so on, then check their _y value relative to the pages _height, and position the slider accordingly, which would inturn move the page where it's supposed to be, seems simple enough eh.

My problem is when I click a button on page 2 saying goto page 4, marker m2, that doesn't exist at this point on the timeline. I figured I could make a variable called JumptoMarker, set it to "m2" then jump to page 4 and check JumptoMarker to see which marker to goto, but I can't seem to make this work.

How do I tell Flash to check the _y of this movieclip (m1, m2, m3...) which is defined by a variable (JumptoMarker)?

I would also like to keep track of where the user came from, any help in working out either of these problems would be greatly appreciated.

Thanks,
Ocean Byrne

Attaching Movieclips With Variables.
I am trying to place text boxes on my movie with various values for the text.

the code I have goes like this...



c=10;
this.createEmptyMovieClip("blank_mc",1);
blank_mc.onEnterFrame = function() {
currtime=getTimer();
if (currtime > lasttime + 2000) {
_root.attachMovie("question", "q"+c, c);
with (_root["q"+c]) {
_x=Math.random()*300;
_y=Math.random()*300;
this.text="SOME TEXT VLAUE";

}
this._parent["q"+this._parent.c].onEnterFrame = function () {
this._x+=5;

}

lasttime+=2000
c++;
}
}


What I am guessing is that the "with" statement only works with properties and not variables. How can i change variables in a clip without knowing its name? That is, by using "q"+index as opposed to "q12"?

I used to know how to do this!

Also, how do I make my actionscript code formated when posting here?

Multiple Movieclips And Variables
Ok, im sure i've seen this before... Ive got 10 or so movie clips all named: checkBox1, checkBox2, checkBox3... and so on. I need to access all of their "_currentframe"'s within a for loop.

So far this is what i have...

for(i=1; i<=10; i++){
if (_root.nav.checkBox[i]._currentframe == 2) {
completed++;
}
}

This isnt working so im assuming im doing something wrong Ive tried using the trace function

trace(_root.nav.checkBox[i]._currentframe);

and it returns "undefined" meaning that im using the wrong syntax to call the instance of the check box. Any help would be appreciated.

Exporting Variables To Other Movieclips, V.1
Hi, basically, iv got a little flash where a movie clip moves round the screen, controlled as in the asteroids game. i want to able to add a second movie clip in when i press space for instance, so that it goes off with the same speed and in the same direction as the original ship, but then doesnt respond to controls or change its direction. So obviosuly for this you need to get the speed variables from the ship and import them into the floating "blob", but im at a loss as to how to do this.

any help would be appreciated,

beedle

Adding Variables To Movieclips
slight problem, probably easily fixed.

firstly, ive got about 30 movieclips on the stage.

ive got 6 variables I want to use in all these 30 movieclips.

Ive got a function which has these 6 variables, which is to basically initilize the movieclips.

using:

Code:
function initFunction() {

var one:Number = 100;
var two:Number = 100;
var three:Number = 100;
var four:Number = 100;

}

movieclip29_mc.onLoad () = function {

initFunction(_parent);

}
the reason i wish to do this is I dont want to add onClipEvent(load) etc to EVERY single movieclip, it would take ages!

many thanks for any solution!!!

cheers

How To Manipulate Variables Between Movieclips
hi guys,
anybody knows how to read/write a variable across movieclips ?


Thanks

Sending Variables To PHP From Within Movieclips
http://www.aaronsleeper.com/site.fla

my mail form which can be found in the above fla at _root.window.content.mailform is not sending the variables to PHP like it's supposed to

the PHP works fine and sends the mail to me but the only thing that comes in the mail is the text from the PHP code field names .... like the things i typed in PHP to go before the contents of the variables that were supposed to be sent

so the variables are not getting from the text input fields in the flash movie ... to the PHP script and to my email

someone please help

How To Issue MovieClips With Variables.
Hi, im wondering if its possible, to be able to issue variables to movieClips, thats is, lets say i create an emptyMovieClip, is it possible to declare/create/give its own set of variables to that new empty movieClip?

e.g _createEmptyMovieClip("abc",_root.getNextHighestDe pth());
//give abc variables age:Number, Address:String etc...

would appreciate any feed back.

thanks.

Switching Variables With Movieclips [FMX]
Alright, outta nowhere this just hit me and I'm dying to know.

I'm trying to make a game where you can customize your character. Therefore, the head is changeable, the shoes, etc. But all I need is the head and I can take it from there.

How can I create a code that will show a different head everytime you press a button. And everytime you press the button, a variable will hold the current head name.

(The heads are drawn out as movieclips and in the library. Their ID's are Head1, Head2, etc.)

Playing Movieclips With Variables
Hello ppls

I'v got an external txt file that loads variables into dynamic txt boxes. But what needs to happen now is that I've got a little indicator movie clip with 2 frames - 1st frame with a green triangle 2nd with a red pointing upwards.

Now everytime the variables are refreshed and the value is eg. up, the indicator movieclip must play the first frame, but when the value has fallen, the movieclip must play the 2nd frame of the indicator mc. Does anybody have an idea as to how I go around this?

Thanks in advance

Renay

Variables = Dynamic Movieclips?
Okay going to keep it short, the less I type the more sense it will make. I'm making an xml-scroll and I'm using this tutorial: http://www.purephotoshop.com/article/112

I got my xml working just fine and I understand all the code using the for loop and the incrementing of the newname field for the attachmovie in correspondance with the counter for the loop. My only problem is I don't understand the variables being created and set to the createmovieclip such as:

function makeNews(xmlFile, x)
{
var container=_root.createEmptyMovieClip("cont", 10);
var container2 = container.createEmptyMovieClip("newsMC", 11);
var clip2 = container2.duplicateMovieClip("newsMC2", 12);
... some more code

I'm confused on what data type container, container2, and clip2 are....
Is container basically a variable of data movieclip that contains a movieclip named cont?
Is Container2 a movieclip that assumes the value of container, but also has the movie clip newsMC?
Clip2 is pretty basic, its just an exact copy of Container2 only the entire movieclip is called newsMC2?
So I guess my main concern is understanding what the data representation of Container2 is....

If someone could explain this for me that would be GREAT!!!!
Thanks!

Variables` Exchange Between 2 MovieCLips (one Inside The Other)
Please help me!...
I can use variables only inside the movie clip. If I have sub-movieclip inside the main MC, formulas inside sub-mc don`t work!!! Please if anyone know where can I read about this problem (a tutor) please give me the link (URL). I tryed to find it by myself but I still got nothing Thank You in advance.

Pass Variables To Duplicated Movieclips
hi, i have a problem with a template i am making, the use of it is to load a timer for a cyber cafe, but i want it to load as many buttons as i say in a txt file, everything is ok up to the point where i want to give each button a number, the main button has a text field where i want the number, but i have noticed that if i give any created instance a variable number, the rest get the same, any idea of how can i get around this?
here's the code i used, but i don't know what can i do next.

loadVariablesNum("data.txt", 0);
_root.onEnterFrame=function(){
for(i=2;i<varcabs;i++){
duplicateMovieClip(mc1,"mc"+i,i);
setProperty ("mc"+i, _x, (31*i)-6);
setProperty ("mc"+i, _y, 362);
}}

maybe if someone wants to check the fla...

Trouble With Variables In Root And Movieclips
I'm using a variable flag in action script to prevent a button to be clicked when the movieclip it launches is still running. All the Actionscript runs from one section and all the event handling is done from this location.
I set the flag to 0 at startup
If you click a button and the flag is 0 then the flag is set to 1 and the clip plays
extra clicks on the buttons are now disallowed
when the clip finished the variable is set to 0 again and I know it works as I have it updating a dynamic text box with the variable value

Problem is that the buttons never work again even though the flag is reset.

Is there some reason that variables set in movieclips don't apply to elements at the root level? It's driving me nuts!!!

I've taken over the project from someone else and would prefer all the actions being attached to individual buttons, but company policy is to run it all from one location where possible. Seems very old fashioned and un-object oriented, and wonder if it is part of the problem?

Thanks for your attention!!

Using External Variables To Control Movieclips
ok so im trying to use an external text and get the variables to tell specific movies wich frame to stop on

this is for a server company, so if one of their servers goes down they can put offline in the variable for that server and upload the new text file

im probably doing it all backwards


Code:
loadVariablesNum("servers.txt", 0);
loadVarsText.onLoad = function(success) {
if (this.s1 == offline)
{
status1_mc.gotoAndStop("offline");
}
else
{
status1_mc.gotoAndStop("online");
}
};
}


and there is 2 frames per server one labeled online and one labeled offline

[F8] - Help - Adding Up Dynamic Variables From MovieClips.
Hi Guys!
I'm ripping my hair out over this one, so if anyone could shout some suggestions my wy I'd be forever in your debt!
Basically I've been building a web based order form and my client want the ability to add items (as many as you want) and for them to be totalled up.
I've used Kirupas Scrollpane with Dynamic Mc's tutorial to add my products, but I can't seem to add them up!
Each product adds up it's subtotal in the dynamically attached Mc and outputs the variable 'subtotal'
In my root I have this function to call the subtotals, but I can't seem to get it to add up each of them to output a total...
Any suggestions ?

Here's my add up function


Code:
valued_btn.onRelease = function() {
if (i != 0) {
i++;
var total:Number = scrollPane.spContentHolder["form"+i].tag.subtotal;
trace(total);
}
};
Any help would be amazing

Liam

Setting And Accessing Variables In Movieclips
Okay guys, I really need help with this one.

I have a variable stored in a movieclip, that I want to use store a value from the main timelime.

The problem is, I can't set the movieclip variable from the main timelime, so it will let me access the variable's new value from the movieclip; say to trace it.

Anyone had this problem?

Change Movieclips Parameters-Variables
Hi,
Im working on the following code and i need some help to change part of the code:
The code is a slider to view pictures loaded from external file. I changed the size of the stage(1000x1000), the big pictures are displayed above(1000x400) and i would like to do 3 things:
1.The slider has the size(400x50). I changed its size(500x80), the thumbnails move but at some point the slider remains half empty and then fills up again. This happens when i have small amount of pictures. I would like not to double but treble the No of the thumbnails so the slider wont remains empty.
2.Move the thumbnails on the right-half part of the stage. When i only change the coordinates(x,y) of the slider it doesnt work.They r loaded on the right part, but when placing the cursor above they disappear.
3.Is it possible when placing the cursor over a thumbnails to show text(small description of each pic)????
Heres the URL of the code working: http://www.flash-creations.com/notes/dynamic_slidingviewer.php
Thanks
Theo
Heres the code:
/********* DECLARE AND INITIALIZE VARIABLES **************************/
// names of folder and pictures, in the order to put them into the slider
var picnames:Array = [
"flower_orange",
"flower_yellow",
"flower_pink",
"flower_red",
"flower_purple"
];

// constants
var PICPATH:String = "flowers/";// folder with jpgs
var NPICS:Number = picnames.length;// number of pictures to load
var PICX:Number = 10; // x loc of big picture
var PICY:Number = 10; // y loc
var THUMBHOLDERX:Number = 0; // x location of thumbnail holder movieclip
var THUMBHOLDERY:Number = 240; // y location
var THUMBW:Number = 72; // width of each thumbnail
var THUMBH:Number = 40; // height
var MARGIN:Number = 10; // margin between thumbnails
var TOTALBYTES:Number = 212000; // approx sum of bytes in all jpgs (x 2)
var MAXPIXELS:Number = 12; // max number of pixels to move slider per frame

// mask definition; mask is assumed to cover some part of the thumbnail slider (here the numbers
// were chosen so that there are margins between the mask and the right and left edges of the movie
// (which is 420 x 290), and enough space above and below the thumbs to show them when they 'grow'
// on mouseover
var MASKX:Number = 10;// start x location of mask
var MASKW:Number = 400;// mask width
var MASKY:Number = 230;// start y location of mask
var MASKH:Number = 60;// mask height

var totalloaded:Number = 0; // running tally of bytes loaded from all pics

// index into pictures array, used for loading
var ipic:Number;

// set up loader, an instance of MovieClipLoader
var loader:MovieClipLoader = new MovieClipLoader();

// use the main timeline to listen to and respond to loader's broadcast events
loader.addListener(this);

/********* DEFINE FUNCTIONS, INCLUDING INIT FOR MOVIE SETUP **********/
// thumbnail rollover handler

function grow() {
this.onEnterFrame = function() {
if (this._width < THUMBW * 1.2) {
this._x -= this._width * .025;
this._y -= this._height * .025;
this._width *= 1.05;
this._height *= 1.05;
} else delete this.onEnterFrame;
};
}

// thumbnail rollout handler

function shrink() {
this.onEnterFrame = function() {
if (this._width > THUMBW) {
this._width /= 1.05;
this._height /= 1.05;
this._x += this._width * .025;
this._y += this._height * .025;
} else delete this.onEnterFrame;
};
}

// function to move thumbnail slider ("this" = thumbs_mc)

function sliderControl() {
var w:Number = this._width/2;
var hw:Number = mask_mc._width/2;
var npixels:Number;
// only do when mouse over slider mask
if (_ymouse > mask_mc._y && _ymouse < mask_mc._y + mask_mc._height) {
// mouse over left half of slider:
if (_xmouse > mask_mc._x && _xmouse < mask_mc._x + hw) {
npixels = (hw - _xmouse) / hw * MAXPIXELS;
this._x += npixels;
if (this._x >= 0) this._x = this._x - w;
// mouse over right half of slider:
} else if (_xmouse > mask_mc._x + hw && _xmouse < mask_mc._x + mask_mc._width) {
npixels = (_xmouse - hw) / hw * MAXPIXELS;
this._x -= npixels;
if (this._x <= -w) this._x = this._x + w;
}
}
}

// thumbnail click (onrelease) handler

function openPic() {
pic_mc.loadMovie(PICPATH + picnames[this.i] + ".jpg");
}

// assign event handlers (called when all jpgs are loaded)

function setupHandlers() {
pct_txt.removeTextField();// don't need loading indicator any more
thumbs_mc.onEnterFrame = sliderControl;
for (var i:Number = 0; i < NPICS*2; i++) {
thumbs_mc["mc"+i].onRollOver = grow;
thumbs_mc["mc"+i].onRollOut = shrink;
thumbs_mc["mc"+i].onRelease = openPic;
}
}

// listener function for broadcast 'done' message (for each pic)
// onLoadInit gets executed when the movieclip has been loaded into _mc AND
// its width and height data are available.
// (_mc = the movieclip being loaded into)
// this routine sets the size and position of each thumbnail clip as its jpg
// is loaded and starts the next one loading. When all have been loaded,
// a random picture is loaded into pic_mc and setupHandlers is called to
// assign handlers to each thumbnail movieclip

function onLoadInit(_mc:MovieClip) {
// this gets done when the jpg is completely loaded:
_mc._width = THUMBW;
_mc._height = THUMBH;
_mc._alpha = 99;// for image clarity
// give the movieclip a property to remind it who it is
// (used by openPic to know which big picture to open)
_mc.i = (ipic >= NPICS ? ipic-NPICS : ipic);

// add picture size to totalloaded variable
totalloaded += loader.getProgress(_mc).bytesTotal;

// now load the next one (if there are more) or set up handlers if done
ipic++;
if (ipic == NPICS * 2) {
// start with a random photo displayed when all thumbs loaded
pic_mc.loadMovie(PICPATH + picnames[Math.floor(Math.random()*NPICS)] + ".jpg");
setupHandlers();
} else if (ipic >= NPICS) {
// load jpg into duplicate thumbnail (will already be cached)
loader.loadClip(PICPATH + picnames[ipic-NPICS] + ".jpg", thumbs_mc["mc"+ipic]);
} else {
// load jpg into thumbnail
loader.loadClip(PICPATH + picnames[ipic] + ".jpg", thumbs_mc["mc"+ipic]);
}
}

// listener function to handle broadcast progress messages
// make pct_txt show cumulative loading progress

function onLoadProgress(_mc:MovieClip, loaded:Number) {
var loadedsofar:Number = totalloaded + loaded;
pct_txt.text = Math.floor(loadedsofar / TOTALBYTES * 100) + "%";
}

function init() {
// create holder for pictures
createEmptyMovieClip("pic_mc", 1);
pic_mc._x = PICX;
pic_mc._y = PICY;

// create (and draw) holder for thumbnails
createEmptyMovieClip("thumbs_mc", 2);
thumbs_mc.beginFill(0, 100);// black
thumbs_mc.moveTo(0, 0);
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, 0);
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, THUMBH);
thumbs_mc.lineTo(0, THUMBH);
thumbs_mc.endFill();
// drawing the thumb holder at 0, 0 and then moving it makes its reg point = upper left
thumbs_mc._x = THUMBHOLDERX;
thumbs_mc._y = THUMBHOLDERY;

// create, draw and enable mask over thumbs (could use different variables to define mask
// if desired)
createEmptyMovieClip("mask_mc", 3);
mask_mc.beginFill(0x0000cc, 100);
mask_mc.moveTo(0, 0);
mask_mc.lineTo(MASKW, 0);
mask_mc.lineTo(MASKW, MASKH);
mask_mc.lineTo(0, MASKH);
mask_mc.endFill();
mask_mc._x = MASKX;
mask_mc._y = MASKY;
thumbs_mc.setMask(mask_mc);

// create loading textfield indicator
createTextField("pct_txt", 4, 200, 100, 40, 100);
var tf:TextFormat = new TextFormat();
tf.align = "center";
tf.size = 12;
tf.font = "Verdana";
tf.color = 0xFFFF00;
pct_txt.setNewTextFormat(tf);

// make empty movieclips in thumbs_mc for each pic to go into
// make double the number so the slider can move continuously and show content
for (var i:Number = 0; i < NPICS * 2; i++) {
var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
mc._x = i*(MARGIN + THUMBW);
mc._y = 0;
}

// set the pointer to the first jpg in the array picnames
ipic = 0;
// start loading jpgs (ipic is initialized to 0)
loader.loadClip(PICPATH + picnames[ipic] + ".jpg", thumbs_mc["mc"+ipic]);
}

/********* CALL THE INIT FUNCTION TO START THE MOVIE *****************/
init();

Accessing Variables Inside Other Movieclips.
I'm currently learning OOP through Sen's information here at Kirupa, and I've decided to try out his "creatures" exercise mentioned in his Best of Senocular thread...I still have a bunch to learn, but I wanted to go ahead and ask a question for a problem I am having right now.

The situation is a random number of sprites are created, and they move around the stage, interacting. They all have a certain amount of "health," defined as a variable in a MovieClip prototype applied to the MC. When they hit, I want their health to go down a little bit, so how can I access a particular MC's "health" variable while I'm outside of the MC itself?

Passing Variables Through Multiple Movieclips
Basically I just wondered if there was any way to condense this so I don't have to keep repeating the code over and over for all of the movieclips:


ActionScript Code:
onClipEvent (enterFrame) {var colorChanger:Color = new Color(this._parent.leaf8);var origTransform:Object = colorChanger.getTransform();var newtintTransform:Object = {rb:10, bb:0, gb:-15};var colorChanger2:Color = new Color(this._parent.leaf9);var origTransform2:Object = colorChanger2.getTransform();var newtintTransform2:Object = {rb:10, bb:0, gb:-15};}


And so on...there are going to be about 9 clips I want this color changer to apply to, but I'm not sure how to make this code cleaner, since I'm a total newb! Any help would be appreciated.

Help - Adding Up Dynamic Variables From MovieClips.
Hi Guys!
I'm ripping my hair out over this one, so if anyone could shout some suggestions my wy I'd be forever in your debt!
Basically I've been building a web based order form and my client want the ability to add items (as many as you want) and for them to be totalled up.
I've used Kirupas Scrollpane with Dynamic Mc's tutorial to add my products, but I can't seem to add them up!
Each product adds up it's subtotal in the dynamically attached Mc and outputs the variable 'subtotal'
In my root I have this function to call the subtotals, but I can't seem to get it to add up each of them to output a total...
Any suggestions ?

Here's my add up function


Code:
valued_btn.onRelease = function() {
if (i != 0) {
i++;
var total:Number = scrollPane.spContentHolder["form"+i].tag.subtotal;
trace(total);
}
};
Any help would be amazing

Liam

Accessing Variables Inside Other Movieclips.
I'm currently learning OOP through Sen's information here at Kirupa, and I've decided to try out his "creatures" exercise mentioned in his Best of Senocular thread...I still have a bunch to learn, but I wanted to go ahead and ask a question for a problem I am having right now.

The situation is a random number of sprites are created, and they move around the stage, interacting. They all have a certain amount of "health," defined as a variable in a MovieClip prototype applied to the MC. When they hit, I want their health to go down a little bit, so how can I access a particular MC's "health" variable while I'm outside of the MC itself?

Passing Text-field-variables To Other Movieclips
i have a timeline with a few dynamic text-fields with variables. i also have an extra movieclip placed in this timeline and want the text-field-variables be passed into that movieclip so they can be displayed in it. how can i do this? how can i "load or pass" these text-variables into a certain movieclip and other timelines?

thanx for any support from germany
martin

Controling Variables For Spawnable Instances Of Movieclips
I am trying to make a flash application that has spawnable window like objects that contain dynamic text pulled from \folderinfo.txt

1.) How do I spawn/kill an instance of this movieclip on a click of a button?
2.) How do I change the variables contained in that spawned instance of the moviecliop?
3.) If I have more than one of these instances open, how do I distinguish between them?

Assigning Variables To Dynamically Created Movieclips
I'm building a navigation menu using dynamically duplicated movieclips. When the user clicks on a menu item, a submenu appears, and the menu items move down to accomodate the submenu.

I found a tutorial on line that was designed for Flash MX, with actionscript 1, and I've rewritten almost everything to work in AS2. BUT--

I'm having a problem figuring out how to assign a numerical index to each dynamically created menu item.
The code that I have now is causing a problem when I try to test the movie-- flash says "there is a problem with one of the scripts in this file, causing flash player to run slowly. Do you want to abort this script?"

The section of script that I'm having problems with is as follows:

//------------------<SHOW SUBMENUS>-------------------\

// called by clicking the main menu buttons, this shows the submenu and moves the main menu buttons to give them space

function submenuShow() {
resetMenu();
h = eval("subText" + choice);

if (h >= 1) {
for (n = 1; n <= h; ++n) {
this["subMenuMC" + choice + n]._visible = true;
}
this["menuMC" + (choice + 1)]._y = this["subMenuMC" + choice + (n-1)]._y + this["subMenuMC" + choice + (n-1)]._height;
for (p = choice + 2; p<=_root.total; ++p) {
this["menuMC" + p]._y = this["menuMC" + (p-1)]._y + this["menuMC" + (p-1)]._height;
}
}
}

//------------------</SHOW SUBMENUS>-------------------\

I think the variable "choice" is causing the problem. I'm calling this variable at the very beginning of the script, in this section of code:

for (i=1; i<= _root.total; ++i) {
//duplicate movie clip
menuMC.duplicateMovieClip("menuMC" + i, i);

//then position them one under the other

this["menuMC" + i]._y = this["menuMC" + (i-1)]._y + this["menuMC" + (i-1)]._height;
/*The next step is to assign a variable to each main menu
button, so that when it is clicked, there is a simple method for identifying
the menu item.
*/
this["menuMC" + i].choice = i;

/* Finally, track how many levels have been used to create the main menu, so that
these can be added to as the submenus are duplicated.
*/
levelTrack = i;
}

Basically, I need to be able to reference a number index for each item on the menu, so that I can plug it into the code that operates the submenu.

Am tearing my hair out over this one-- please help.

Dynamically Creating Empy Movieclips And Accessing Variables
The code at bottom of this page makes a row of 65 color swatches on the main stage at runtime. Now i understand all the code ( the loop is a bit tricky, but take my word for it creates 65 swatches that spread across the stage and are 10 pixels each.

The part i do NOT understand is this part i.e


Code:

mcSwatch.onRelease = function():Void {
trace(nColor);
};
(when we click on each swatch it shows us the color of each swatch in the output window)

THE question is when we test the movie and we click a swatch, how does it know what the value of nColor was when the swatch was created? Because i cant see the value of 'nColor' stored in any array or anything that would have allowed us to associate it with that particular swatch.

(what seems more obvious is that when we click any swatch it should just display the LAST value that nColor was given when the loop ended).

The full code is as below:


Code:
// Create a movie clip to hold the color selector.
var mcColorSelector:MovieClip = this.createEmptyMovieClip("mcColorSelector", this.getNextHighestDepth());

// Declare a variable to store the selected color.
var nSelectedColor:Number = 0;

createColorSelector();

// Create the color swatches.
function createColorSelector():Void {
var nColor:Number = 0;
for(var i:Number = 0; i < 5; i++) {
for(var j:Number = 0; j < 13; j++) {
createColorSwatch(nColor, (10 * i) + (50 * j), 375);
nColor += 17;
}
nColor += 1053475;
}
}

function createColorSwatch(nColor:Number, nX:Number, nY:Number):Void {

var nDepth:Number = mcColorSelector.getNextHighestDepth();

// Create a movie clip for the swatch.
var mcSwatch:MovieClip = mcColorSelector.createEmptyMovieClip("mcSwatch" + nDepth, nDepth);

// Draw a rectangle in the swatch. Fill the rectangle with the specified
// color.
mcSwatch.lineStyle(0, 0, 0);
mcSwatch.beginFill(nColor, 100);
drawRectangle(mcSwatch, 10, 18);
mcSwatch.endFill();
mcSwatch._x = nX;
mcSwatch._y = nY;

mcSwatch.onRelease = function():Void {
trace(nColor);
};
}


function drawRectangle(mcClip:MovieClip, nWidth:Number, nHeight:Number):Void {
mcClip.lineTo(nWidth, 0);
mcClip.lineTo(nWidth, nHeight);
mcClip.lineTo(0, nHeight);
mcClip.lineTo(0, 0);
}
Any help would be appreciated..its doing my head in!!! Ive attached the fla ..please help cheers

AS3 Global Variables And How To Access Buttons Inside Movieclips
Hi, I am making a simple game and I have an option to change the player appearance.
Problem is I tried to use a variable to detect and change clothes but it doesn't work.
I have already declared the variable using var playerClothes= "normal"; but it seems because the clothes movieclip is in another movieclip, it can't access the variables.

I've tried package to make global variables, but it says my package is unexpected although the code checker says there are no errors. I put the package in the first frame.

I have also the same problem when trying to access a button inside a movieclip it can't find it....

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









Attach Code

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

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

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

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

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

Here is a chunk of my code:


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

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


Thanks...


EDIT:

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

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

In my code I do the standard:

PHP Code:



mainUI=new UI_total;
addChild(mainUI); 




to instance the UI_Total.

Now, I can do something like

PHP Code:



mainUI.star3.x+=500 




no problem.

And when I do

PHP Code:



trace(mainUI.star3.parent) 




I get [object UI_Total] as expected.

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



mainUI.removeChild(star3) 




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



mainUI.getChildIndex(star3) 

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

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

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

Here is a chunk of my code:


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

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


Thanks...

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

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

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

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

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

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

thanks

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

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


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

Michael

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