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




Movie Clip Variable Life Span



Ok guys. I'm new to ActionScript and am currently doing my research using the "ActionScript for Flash MX" User's Definitive Guide book.

Im understanding pretty much everything I see, but there's one thing that keeps getting me. Here's the lesson:
_______________________
Suppose we create a new movie with keyframes at frames 1, 2, and 3. On frame 1, we place a clip instance, ball. On the ball timeline, we create a variable, radius. Assume frame 3 of our main timeline is a blank keyframe (the ball instance is not present there).

From frame 2 of the main movie timeline, we can find out the value of radius using this code:

trace(ball.radius);
_______________________

When I trace the "radius" variable located on the first frame "ball" instance, I get "undefined". This only seems to happen when I have the trace action on the first frame of my main timeline. If i move it to the second frame, it works ok. It seems like every time this book references this action, it never works for me. It seems that if I had the Ball_MC on frame 1 of the main timeline, and had the trace on Frame 1 of the main timeline, that it should be able to trace the variable inside of "ball". Any help is much appreciated. Please let me know if I need to provide more information. I'll attach the FLA file too.

Narayan



ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 05-25-2004, 02:10 PM


View Complete Forum Thread with Replies

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

MODERATOR - Why Short Life-span For Posts?
Posts are being removed after less than 2 months, so popular threads are
losing important early postings. What is the point of this? Is Adobe's new
strategy to cover up the big issues then?

Movie Clip Has Life Of It's Own [MX04]
Hi there!

ok so basically i'm making a menu that has 5 points around the screen, centre, top, bottom, left and right. When i click on a button a movie clip scales and moves with easing to the given point. So all that works!
BUT, when i first load my movie the movie clip (icircle) it starts in the centre (which i want it to do), then moves to the top left of my movie screen (0,0) and also scales down from 100 to 0, so it looks like it disapears off basically. how can i stop it from from doing anything untill i click or roll over given things?

OH and my document size is 600 x 600
i've learnt this from a couple different tutorials on line, so have i missed something? i'm using MX 2004...

here's the code that i've put into the icircle movie clip:

onClipEvent (load) {
_root.icircle._x = 300;
_root.icircle._y = 300;
}

onClipEvent (enterFrame) {
div = 7
_x += (endX-_x)/div;
_y += (endY-_y)/div;
_xscale += (endSX-_xscale)/div;
_yscale += (endSY-_yscale)/div;


// the rest of the code is where each of the the buttons are and then where to move the icircle movie clip and how much it should scale

_root.ibuttonsmain.bhome.onRollOver = function() {
endX = 300;
endY = 300;
endSX = 95;
endSY = 95;
};

_root.graphic2.bwork.onRelease = function() {
endX = 300;
endY = 393;
endSX = 189;
endSY = 189;
};

_root.graphic4.babout.onRelease = function() {
endX = 300;
endY = 207;
endSX = 189;
endSY = 189;
};

_root.graphic1.bmeth.onRelease = function() {
endX = 207;
endY = 300;
endSX = 189;
endSY = 189;
};

_root.graphic3.bcont.onRelease = function() {
endX = 393;
endY = 300;
endSX = 189;
endSY = 189;
};

}

thanks for your help!
it'll be MUCH apreciated!

Cant Get This Intro Movie Clip To Run Normally For The Life Of Me
Hey guys.
I just got done designing this intro that is supposed to go on to a CD for this client. The flash piece is meant to be a interactive CD. The Intro has a lot going on lots of bitmaps going this way and that and as such is im sure kind of heavy on a processor. It runs perfectly on my computer(But again it always does) but on other computers its much slower so it throws off the music completeley. I see my only options as being to tone down the amount of stuff moving which seems kind of ridiculous cause its not that much or making the intro a quicktime movie that segways into the flash. Any help would be greatly appreciated.
thanks guys,
Chris

Game Life Bar That Has A Variable To Decrement
i am trying to make a life bar that depending on what type of hit it is, it will pass a value to a variable to tell it wether it decrements so much or increments. any ideas. thanks for any feedback

J


Code:
//this is suppose to be the variable for increment/decrement
//HitValue = 5;

SmallButton_BTN.onPress = function()
{
_root.Life_Bar_MC._xscale --;

if (_root.Life_Bar_MC._xscale <= 0)
{
trace("your dead");
}
}

Variable In Movie Clip With A Variable Name
Hello,
I need to find out the content of a variable in a Movie Clip with a variable name. I created several movie clips with "duplicateMovieclip" in a for... loop. Looks like this:
for (i=1; i<=5; i++) {
duplicateMovieClip (_root.oldname, "newname"+i, i);}
Now I want to know and set the content of a variable stored in this clip, but again in a for.... loop.
I tried it with:
"_root.newname"+i+".variable"=content;
This does not work. Anyone any ideas?
Thanks for any answer that might help me.
Greetings from cologne
Ole

Calling A _root. Variable Of A Movie Clip That Is Loaded Into Another Movie...
My problem is I have two movie clips that i'm working with. The child-clip has a variable and a movie at _level10 (the base of it) that I would like to call when the child-clip is loaded into the parent-clip. I tried _level10.variable but that did not work. And commonly _root brought me to the _root of parent.

How can I get around this?

P.S.
I know there was a way in Flash 4 that you could call instances backwards (//instance) or something like that. But I haven't used Flash 4 in a LONG while.

Plz Help

Send Variable From The Main Movie To A Movie Clip.
How do I send variable form my main movie to a movie clip.

Have some dynamic text in my movie clip whose variables are determined in the main movie

Sending A Variable From Movie Clip To Main Movie
In flash MX is there something like private variables and global ones?
I am asking this because I want to be able to open up a menu when you click on a button, and then according to which ever button you picked in the new menu you'd have a variable returned into the original movie. The new menu is in a movie clip.

How would I go about this? Is there some sort of code word for variable that is global not private?

2 Logical Questions About Movie Event Life Cycle
Hi all

the 1 Question : can someone describe the Movie Event Life Cycle

first is Load Movie Then what

for example in ASP.NET The Live Cycle is

Page_Init

Page_Load

Control Events

Page_Unload

Page is disposed


the 2 Question : does the Load Movie executes more than one

at a run time ?

thanks a lot

Set Variable In Movie Clip?
Hello all,

I've tried to set a variable by a button in a movie clip with:
on (release) {
keuze = 2;

On a frame in the root scene I put this:

if (keuze == 2) {
gotoAndPlay ("Scene 3", 1);
}

But this doesn't work!

It DOES work when I set the variable in the scene itself, but not when I set it in a movie clip... Why not??

Thanx for any help!

How To Use A Variable Containing A Movie Clip
hi!

ok i have a movie clip on the main scene of the movie, i want to duplicate it on the highest depth (so it will cover everything else) and then i want to play it

there is the script i have done so far

on (release) {
/:helpboxcount = /:helpboxcount+1;

/:depth = /:depth+1;

myname = "helpbox" add /:helpboxcount;

duplicateMovieClip ("/helpbox", myname, /:depth);

path = "/" add myname;

path.play();
}

helpbox is the movie clip, so i duplicate it, and the new movie is called helpbox1 and is on the depth 1
that works
i just don't know how to play the new movie
if i do helpbox1.play() then only the first copy of helpbox will be played
it doesn't work either if i use myname.play()

thank you for helping me!!!
i hope this is clear enought...:P

Movie Clip Variable
Dear Flash Experts,

I would like to be able to access the value of a global variable that resides in a movie clip action handler-- on an action script frame on the main time line.

For example, if you look at the code that I'm using below...I need to be able to know what state the variable 'soundplaying' is in on the movie clip's associated frame action script in the main timeline. I need this so that I can tell the play head to go to another Frame label when the movie clip is finished playing. I've been fighting with this for a while and have recognized that the onClipEvent(enterFrame) is executed AFTER the frame script...so it never goes back to the framescript. I'm not sure. I can read the value of 'soundplaying' in the main timeline frame from the onClipEvent(load) handler, but I cannot get the value of 'soundplaying' to make it from the onClipEvent(enterFrame) handler to the maintimeline frame.

I hope this makes sense.

I'm using the following code
(which, with the exception of the global variable declaration, I thankfully copied from hp3's Sound Forum Fact number 25
http://www.flashkit.com/board/showth...hreadid=299918 )

onClipEvent (load) {
mysoundobj = new Sound(this);
mysoundobj.attachSound("_root.musreflx");
mysoundobj.sndlength = 63100;
// 1000 milliseconds
mysoundobj.start();
startTime = getTimer();
_global.songplaying = true;
_global.Sit = "fuk";
}
onClipEvent (enterFrame) {
if (_global.songplaying) {
now = getTimer()-startTime;
if (now>=mysoundobj.sndlength) {
_global.songplaying = false;
// stop loop
trace(songplaying);
}
}
}


My frame code reads as follows:

trace(songplaying);
trace(Sit);
if (songplaying) {
stop();
} else {
trace(songplaying);
gotoAndPlay("symetrical");
}

Thank you for your help!

Using A Variable As A Movie Clip Name
I have a whole bunch of movie clips that I'm creating with "duplicate movie" and as I create each one, I want each movie clip to go to a random frame.

What command do I use... niether of these seem to work:

(i is a counting variable)

z = eval("mc"+i+".gotoAndPlay("+frame+")");

and

setProperty ("mc"+i, _currentframe, frame);

-Greg

Set The Variable In A Movie Clip
If I have 2 movieclip(main char and enemy), I want to set enemy die.
I use some script for my char

if(_root.char.Thumb.hitTest(_root.enemy)){
//trace(this._y);
_root.enemy.gotoAndStop(2);
// play a sound
punchSound.start(0,1);
punchSound.setVolume(Math.abs(speed)*6);
//add 2 to score
_root.score += 2;


}

For the "enemy" I use some script like that

if (!dead) {
he continue to walk
}

How can I right some script for the enemy so the script can detect enemy will die in the main character script?

Can I write something like that

if(_root.enemy.dead = true){
_root.enemy._alpha = 0
}
_root.enemy.enemyspeed = 0;
// its speed is set to 0
_root.enemy.enemystepsright = 0;
// how far it has moved right is set to 0
_root.enemy.enemystepsleft = 0;
// how far it has moved left set to 0

Movie Clip Variable
can I get help with the correct code to test whether or not a movieclip is open or if it is on a particular frame? I know I need a variable in the clip, but not certain how to set it up...

Thanks.

Movie Clip ID Into A Variable
I have several Movie Clips that act as buttons. Is there a way to harvest the Movie Clip's ID name and put it into a variable on a rollover?

Variable Movie Clip Name
I'm sorry if this is a double posting, but I don't know if my original went through.

What worked in AS 2:

this["clipName" + n + "_mc"]._alpha = 100;

where n is a Number variable.

I did change this for AS 3 to be:

this["clipName" + n + "_mc"].alpha = 100;

since AS 3 doesn't use _alpha. It doesn't work. Any suggestions?

How Do I Use A Variable To Name A Movie Clip?
I am trying to duplicate a move clip and then set some of it's properties with actionscript. What's the notation to do this?

Here is my guess:


ActionScript Code:
duplicateMovieClip(_root.event, ("event"+i), i);[event+i]._y = ([event-i]._y)+([event+i].height);[_root.event+i].eDate = ("4/2"+i);trace([_root.event+i].eDate);


Thanks in advance,
RMB

How Do I Use A Variable To Name A Movie Clip?
I am trying to duplicate a move clip and then set some of it's properties with actionscript. What's the notation to do this?

Here is my guess:


ActionScript Code:
duplicateMovieClip(_root.event, ("event"+i), i);[event+i]._y = ([event-i]._y)+([event+i].height);[_root.event+i].eDate = ("4/2"+i);trace([_root.event+i].eDate);


Thanks in advance,
RMB

How To Set The Name Of A Movie-clip To A Variable?
How do I set the instance name of a movie-clip to a variable?

I tried this within the movie-clip but it doesn't work:
on (rollOver) {
    var gridLabel = _root.GridHotSpot;    
}

Want I want is to mouse over the movie clip "GridHotSpot" which has a instance name of "E4", I want E4 to appear in the dynamic text field named "gridLabel" which is inside the movie clip.

Thanks.



Movie Clip Variable
can I get help with the correct code to test whether or not a movieclip is open or if it is on a particular frame? I know I need a variable in the clip, but not certain how to set it up...

Thanks.

Using A Variable To Reference A Movie Clip
This has got to be simple....
How do you use a variable to reference a movie clip which is linked from the library?
eg, I have a movie clip linked as movie1. And a variable called varmovieclip.
and I want to say - varmovieclip.play()???????

Variable In Movie Clip Notation
I need to use a variable in a moive clip reference
eg. movie1.submovie[somevariable].play()

I have lloked in the actionscript reference and have tried
using
with (movie1.submovie[somevariable])
{play()}
I have also tried using targetpath
targetpath (movie1.submovie[somevariable])
{play()}
this also doesnt work.
I would have used something like
tellTarget ("/sf" add _root.curfloor) {prevframe()
}
in flash 4 just wondering what to do in 5

Calling A Variable From Within A Movie Clip
the answer to this question must be simple and i have made a hard honest attempt to find the answer myself. i cant find it in the book i have so i was wondering if u ppl could help me out.

i have several scenes and the first one loads and the user can click one of 5 links done, and then it takes them to another scene with another navbar. what i want to do is assign a variable to the scene thats says what scene(or page) it is, i need this so i can use it in a if else statement in the nav bar mc code to figure out which scene is loaded, that way a user clicking the same button as the page he or she is on will not have any effect. i need the actionscript for it.

oh yeah btw, i stopped writing this message twice cause of ideas i had that might work, and guess what, they didn't i really need your help

thankx in advance.

dave

Passing A Variable To A Movie Clip
I give, I give!!!1
I have a movie clip that contains a textbox. The textbox is a dynamic textbox with the variable named texbox.

I then use duplicateMovieClip to duplicate the move and my question is how can I change the variable "textbox" to anything like "M1"

This is on a line graph and I want the numbers to showup on the chart.

I would send the code but I just dumped it.

Thank you for any help

Marc

Help..... Variable Movie Clip Instances?
Can my MC instance name be replaced by a variable?

for example:

current = main;
tellTarget (_root.current_enter) {
gotoAndPlay (2);
}

i tried this but flash won't play my movie
my MC instances are named "main_enter", "main_exit" etc etc

help?

Setting A Movie Clip To A Variable?
I got this [error]:

Scene=Scene 1, Layer=other, Frame=1: Line 1: ';' expected
o1 = MovieClip"o1";

When i typed in:
o1 = MovieClip"o1";


What did i do wrong?

A Variable Can Load A Movie-clip?
Hi everyone...

i need to load a movie-clip into a target clip...
but i don't want to specify an URL...
the path to the .SWF movie is stored in a DB!

So i set a variable (imgurl) and then load the variable
from my DB (by an ASP page that give me an URL encoding).

So, now i've got (imgurl = http...)!
Since here all work fine, and if i try to print the variable it return me the correct url http://localhost...

But!!! =(
I've tryed many times to load a movie with that variable set instead of the URL path (set as expression, method POST) but my movie won't load!!! Why?

Please anyone can help me?
Where i'm wrong?

Thanx =)

Animating A Variable Movie Clip
HI y'all..i am making a game where i have to generate a random card and when the user clicks on it, it is to be animated to a certain position, it used to be like taking candy from a baby when using tweening, but now the card is variable, and tweening is not possible. I thought of a way, possible or not i don't know..here it goes...

in the actions of the movie clip button (the card that is clicked) i put that when the card is clicked a loop happens, in the loop where i is increasing by 1, every turn, i move the card a position by using the
setProperty("card",_x,20*i) all i need now is something to pause for like .5 secs and then repaet the loop where the i will be incremented and a new position drawn...this (in my mind) should give an animated effect.
the problem...NO delay command in flash...i tried to make a delay of my own but it seems that it's not working. please please help me oh mighty Flash Masters!!!!

Thanx

Problems With Variable In Movie Clip
I have a problem with my variables

in movie clip I have
_root.Bro_AN = 2066

in my main timeline, I have a dynamic text box

Bro_AN

this work

I select the 2066 and pouf it goes to this box

but I can't add it to my total

why???

this is what I wrote for the scene

TOTAL = Bro_AN + Bro_FR

Passing A Variable Into A Movie Clip?
I have a movie that contains a movie clip. A variable has been passed to the movie and I need the movie clip to acknowledge that variable so it can run some logic. I have two other movies that don't use movie clips and they work fine.

Is there anything special I need to do?

Passing A Variable From A Movie Clip
Hey whats up? I cant seem to get a movie clip to pass a variable to a INPUT textfield on a different timeline.

Is this possible ?

Thanks

Loading A Movie Clip From A Variable
hi

Using Flash MX

I'm trying to load a movie clip from a variable. The variable is defined by what the user types into a username text field. If the user types 'bob' for a username, flash will load 'bob.swf'.

Heres my code so far, hope someone can help me!

************

_global.name;
login_lv = new LoadVars();
login_lv.onLoad = function() {

if (this.userInfo == "true") {
name = _root.login_txt;
trace{"Weclome")
????************LOAD 'variable'.SWF************????
} else {

trace("Invalid data");
login_txt.text = "";
password_txt.text = "";
}
};

onLogin = function () {
name = _root.login_txt;
if (login_txt.text.length<1) {
trace("please provide a login name");
} else if (password_txt.text.length<5) {
trace("invalid password");
password_txt.text = "";
} else {
login_lv.username = login_txt.text;
login_lv.password = password_txt.text;
login_lv.sendAndLoad("http://www.lightmill.co.uk/login.asp", login_lv, "POST");
}
};

Sending Variable To Movie Clip...
Hi all - need to know... is it possible to send a variable from a movie clip say on level 1 to another movie clip on level 3? Be great if you could, doesnt seem to work using "SEND" or "GET" tho - pls help! thax in advance - yoonks

Variable/Movie-Clip Confusion
I sort of have a problem here. I want to run hittest on a movie clip whose name is stored inside a variable. The problem is that you don't need to put quotes around movie clips nor variables. How can flash tell if I am trying to use a movie clilp or a variable?

Using A Variable To Set Property Of Movie Clip
I am using the following to "switch on" a movie clip on the stage (it was previously hidden):

_root.movieclip1._visible=true;


Which works fine, but I want to target which movie clip gets switched on by passing a variable from a button, e.g. the button sets:

cliptoactivate=movieclip1

so I need to incorporate this.

I have tried:

_root.("cliptoactivate")._visible=true;

but i get errors, not sure what other way to try it. Im sure its very simple.


for a bonus point, how can I then get this movie clip to start playing?

Thanks alot

Variable Movie Clip Size
Hi, i really need help!.
i have a background which i want to stay a set size, even if it bleeds off the browser...

Stage.align = "TL";
Stage.scaleMode = "noscale";

which is cool, but i have a long graphic which i need to appear on the stage infront no matter how big/small the browser (i.e my stage is 1000px, the graphic is 800px at full size, but if my browser window was only 600px wide, my graphic needs to be resized to 400px, 100px on each side). i only want to change the width of it, not the height. the object can be called menu_mc for instance.

any ideas?


cheers.
krustafarian

Loading A Movie Clip With Variable
I have 1 question, if I can ask

I have made one variable holder , and i named it „var.txt“. And I have made a movie clip and I want that movie clip asks variable witch movie clip he should load.


I have writed in var.txt.

&movie = movieclip.swf

And in movie clip


loadVariablesNum("var.txt",_root );

loadMovieNum (movie,1);


And I dont know what is wrong?

How can I load different movie clip to one movie with variable?
Is that possible?

[F8] An _x _y Variable Wont Set For A Movie Clip
For some reason I cant get this script to work. It just wont go to the position.
Whats wrong with it x.x?

Code:
onClipEvent(load){
_x=_root.testwall.point1;
_y=240+(_root.camera.cameraz-_root.testwall.wall_top)*_root.testwall.scale1;
}

Using Variable Name To Target Movie Clip
I want to target different movie clips depending on the name of a variable (puzNum below). Basically, by incrementing i, I want to target movie clips "movie.scene0" through "movie.scene31".

var puz = new Array();
for (i = 0; i < 32; i++){
puz[i] = "movie.scene" + i;
}

var puzNum = puz[i];
puzNum._alpha -=10;

Any help is appreciated.

Creating Movie Clip Variable
Quick Question for a flash beginner - lets say I have two keyframes, in keyframe 1 I have a movie clip with 20 frames. Once the movie clip runs, I have placed an action at the end of the movie clip that directs it to the the main flash file again ( the actionscript is : _parent.play() )

So, let's say I have the exact same set up in a different scene. Is it possible to make the movie clip run through only 10 of the 20 frames and then jump back to the main flash file where it would go to keyframe 2? I know that if move the actionscripting of _parent.play(to frame 10 of the movie clip that it would just alter the entire movie clip altogether. I want to differentiate the way the movie clip acts in scene 1 and in scene 2. I hope that makes sense and someone has a relatively simple answer for me as I am now very good at any of this. Thanks!

AS 3.0 Simple Variable In Movie Clip
Hi,

I am trying to convert old interaction templates that I created using AS 2.0 to AS 3.0. I have run into a problem with how I used to use variables inside a movie clip to talk to the main timeline.

Ok so on frame 1 of the main timeline I am setting the variable
var a = 0;

When the user clicks an object it tells the movie clip they clicked on to play (this is a select all that apply interaction) which makes the object highlighted so the user knows it is selected. Inside that object which in this case is Object1 when the movieclip gets to frame 2 it sets the variable equal to 1.

a = 1;

In AS 2.0 I would have it be _root.a = 1; which would work but I already tried root.a = 1; and that doesnt work either.

Then the Done button on the main timeline will check to see what a is equal to.

How do I do this in AS 3.0? I am getting so frustrated that I cant get these simple things in AS 2.0 figured out in 3.0.

Thanks so much!

Check Value Of A Variable From A Movie Clip
I feel stupid asking this question, but am having trouble checking and changing the value of a variable I created in Frame 1 (the whole application is 1 frame) that has global scope (I didnt declare it as global, but from my experience if I declare the variable outside of any function it is global...) and I wanted to check the value of that Variable from a movie clip that is later added (addChile(someClip) to the application and vice versa (It is added to the stage). From Frame 1 I thought i could simply do someClip.variablename = whatever; but get errors saying that it is undefined... which it is as its declared in the movie clip and not the stage... my brain is really messed up this morning, so I am sorry if I am not making sense or if my question seems trivial.

Cheers.

Movie Clip Instance Name In Variable
Hello

I attach MCs within actionscript but I don't know how to use them. For example:

PHP Code:



for (i=1; i<5; i++){
    attachMovie("mc1","mca" add i,i);
    setProperty("mca" add i, _x, i*100);
    // how can I control clip "mca1"..., for example how can I change txt box inside "mca1...
    // it works with setProperty, but that's it.





I need something like:

PHP Code:



mca1.txt.text="abc" 




but mca1 is a variable. Or

PHP Code:



for (i=1; i<5; i++){
             temp = "mca" add i
    attachMovie("mc1",temp,i);
    setProperty(temp, _x, i*100);
         ->***    temp.txt.text="abc"   ***<-





So, how can I use MC within a temp variable. Thanks.

Using A Variable To Indicate An Active Movie Clip
I'm trying to use a variable to indicate a movie clip is active. there are multiple clips, about fifteen of them, so I'm trying to get around having to talk to them all at once. I figured I could have the clip say it's target name as a variable, and then use that variable to target it, but I'm not sure how to use the variable in an action. here's what I was thinking:

the active clip sends it's target name to the timeline as a variable "active-clip-target-name"

the button in another clip, to communicate with it, says:
"_root."+"active-clip-target-name"+".play()";

but this is not working at all. does anyone know the correct syntax for this kind of thing?

How Do I Use A Variable To Set Movie Clip Properties?
I'm building a simple contact page that allows users to select a city from a comboBox. I'd like to pass the selected comboBox data through a variable that controls a movie clip with the same name. (already on the stage)

locationListener.change = function (loc_obj:Object) {
var loc_mc = loc_obj.target.selectedItem.data;
loc_mc._visible = true;

So far this hasn't worked. I've tested hardcoding the movie clip instance name (Atlanta._visible = true) and it works, but I can't figure out why using the variable loc_mc won't trigger interaction with the movie clip.

Something simple, I assume. Thanks in advance for any help.





























Edited: 08/22/2007 at 11:34:40 AM by LDJ3

Reading Variable In A Movie Clip
just wondering how can I send a variable generated in the main time line to a movie clip time line.
Thanks

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