Using Variable To Reference Movie Clip?
In AS2 I used to be able to reference a movie clip using a variable like this:
Code:
var target = nameofmovieclip;
I've been looking for an answer on how to do the same thing AS3 but with no luck. I'm trying to create a dynamic homing missle, but unfortunately everything I've tried just generates errors.
Does anyone know how to accomplish something like this is AS3?
KirupaForum > Flash > ActionScript 3.0
Posted on: 07-24-2008, 02:57 PM
View Complete Forum Thread with Replies
Sponsored Links:
Using A Variable To Reference An Already Existing Movie Clip?
Hello,
I have been struggling with what I suppose is a very simple issue: I am importing content into my application via a text file, this all works fine. I have about 10 different movie clips on the parent timeline that I have hidden (dc_mc.visible = false.
So what I need to do is take one of the variable names that I've got from my text file and use its value to "turn on" one of these hidden movie clips.
So I'm trying stuff like:
var directory = e.target.data.directory; // Grabs the data, sets var
var raceNameButton:String = directory+"_mc"; // Set data into new var
raceNamesButton.visible = true; // display movie clip with var name
and it's giving me all sorts of problems. I know I can do this with ActionScript, but just can't seem to get it to work.
Any thoughts out there?
View Replies !
View Related
Using A String Variable To Reference A Movie Clip
I have an appended variable that i want to use to reerence a movie clip instance, but it dosnt work....
var blah_num:Number = 1;
blah = "blah" + blah_num;
_root.blah.gotoAndPlay(5);
I hope this explains what im trying to do. I have 15 instances of the same movie clip that are named "blah1","blah2",...etc. the blah_num variable changes and is appended to blah, and then I want to use the string var blah as a movie clip instance. I ma trying to use it in this form: blah.gotoAndPlay(10); etc...
Thanks in advance
View Replies !
View Related
From A Loaded Swf Clip, Access/reference Variable In The MainTimeline
Hello all, want to ask you a question:
In the mainTimeLine, I have a string variable like this:
var myString:String="Hello!";
Now I load an external swf to the mainTimeline:
var ContentLoader:Loader=new Loader();
ContentLoader.load(new URLRequest("externalClip.swf"));
Now, I can pass the value of variable "myString" to the "ContentLoader.content", no problem.
My question is, if I am not passing the value to the loaded clip, can I use some script (within the loaded swf) to reference the "myString" in the main movie?
it seems to me now it's only one way street in AS3 - I have to pass that variable to the loaded swf, not the other way around... which means, I can't use the AScript in the loaded clip to control anything on the main timeline?
any thoughts?
Sam
View Replies !
View Related
Can't Reference Movie Clip
Help! I can't reference this movie clip. Any sugeestions?
-----------------------------------------------
_root.wishlistbox = _root.attachMovie("newwishlist", "wishlist", d+37, {_x:60,_y:100});
trace("wishlistbox = "+wishlistbox); //outputs: _level0.wishlist
ref1 = _root['wishlist'];
trace("ref1.box = "+ref1.box); //outputs:undefined
ref2 = eval("wishlist.box");
trace("ref2 = "+ref2); //undefined
trace("wishlistbox.box = "+wishlistbox.box); //outputs:undefined
/*
// This is the code in the 'newwishlist' Movie Clip
this.createEmptyMovieClip("box", this.getNextHighestDepth());
//draw filled box
this.box.beginFill(0xffffff, 100);
this.box.lineStyle(1, 0x000000, 20);
this.box.moveTo(0, 0);
this.box.lineTo(750, 0);
this.box.lineTo(750, 80);
this.box.lineTo(0, 80);
this.box.endFill();
timelabel = "wlitem";
createTextField(timelabel, this.getNextHighestDepth(),30,10,200,20);
this[timelabel].multiline = false;
this[timelabel].wordWrap = false;
this[timelabel].border = false
this[timelabel].text = "wishlist";
this[timelabel].selectable = false;
this.timelabelformat = new TextFormat();
this.timelabelformat.bold = true;
this.timelabelformat.align = "left";
this.timelabelformat.font = "Arial";
this.timelabelformat.size = 15;
this.timelabelformat.color = 0xcccccc;
this[timelabel].setTextFormat(timelabelformat);
this.box.onRelease = function(){
trace(this);
}
*/
-----------------------------------------------
Thanks, Pete.
View Replies !
View Related
Help With Movie Clip Reference
Hi Everyone,
Please help me with this script:
rootMovie.Fla code:
courseObj.onPress = function(){
txtIntro._visible = 0;
loadMovie("courseObj.swf", mcPlaceHolder);
}
As you can see I used a button to trigger a swf to load into a MC called "mcPlaceHolder". This works.
courseObj.Fla code:
function txtBasicFunc(mcName,mcAlpha){
_root[mcName]._x = _root._xmouse;
}
This works by itself, but when load into mcPlaceholder in rootMovie.Fla it doesn't work. I know that the _root[mcName] array must be the problem and this is where I need help.
thankyou
View Replies !
View Related
How To Reference To A Movie Clip
Hello
I have a movie clips with 2 buttons (a red and a blue). When I do a mouse over on the red button my blue button will come visible.
When I drag my movie clip to the stage I can see the red button and the blue button will be available when I do a mouse over on the red button
Now I want to apply an action script on the scene for my blue button that makes the time line go to frame 20. But I am not sure on how to reference the button from the movie clip. I get an error with a null reference.
I have attached my scenario. I am new to AS3 so this is maybe a simple question
Thanks
Tanja
View Replies !
View Related
Movie Clip Reference
If i have movieclipD iside movieclipC iside MovieclipB inside MovieclipA whose parent is the _root and i would like to reference MovieClipD in terms of the _root and not its parent. I know i could do it mathamatically calculating the X Y of every parent but i was wondering if there was a simpler way to do it?? for instace something like "movieClip._xworld".
Please and Thank you.
Please ask me to clarify if i have explained it poorly.
View Replies !
View Related
How To Reference Arrays In A Movie Clip
I have dynamic and input text fields in a movie clip
and trying to referance them in a for loop
for (i=0; i<2; i++) {
yoselfMC["varLineTot"+i] = yoselfMC["varLotQty"+i]*aryPrc[i];
Total += yoselfMC["varLineTot"+i];
}
where
yoselfMC is the movie clip instance name
varLineTot1, varLineTot2,.. are dynamic text variable names
and
varLotQty1, varLineQty2,.. are input text varible names
code must calculate total order price but does not
any suggestions about referancing varibles in a movie clip in this manner..
by the way.. should i do something to insert(or attach?) varibles to movie clips..
View Replies !
View Related
Movie Clip Reference Within A Class
Having problems dynamically creating a movieclip reference to pass to another class.
Basically I have a Game class and a Boiler class. The Game class contains a property called "mcReference" which is being created correctly as "_level0.game_mc" when I create the Game instance
var myGame = new Game(this);
Within the Game class I have a method to create 9 Boiler instances.
i.e
Code:
public function create_Boilers():Void {
arrBoilers = new Array();
for (var i:Number = 0; i < numBoilers; i++) {
var vBoilerRef:MovieClip = mcReference["boiler" + (i + 1) +
"_mc"];
var vBoiler_Obj:Boiler = new Boiler(vBoilerRef);
}
}
If I do a trace on vBoilerRef, I get undefined.
Any ideas what I am doing wrong?
The code for the 2 classes is as follows:
Code:
import Boiler;
class Game extends MovieClip{
// -----------
// Constructor
// -----------
public function Game(passed_mcReference:MovieClip) {
mcReference = passed_mcReference;
trace ("Game mcReference = " + mcReference);
}
public var mcReference:MovieClip;
public var arrBoilers:Array;
public var numBoilers:Number
public function init():Void {
numBoilers = 9;
}
public function create_Boilers():Void {
arrBoilers = new Array();
for (var i:Number = 0; i < numBoilers; i++) {
var vBoilerRef:MovieClip = mcReference["boiler" + (i
+ 1) + "_mc"];
var vBoiler_Obj:Boiler = new Boiler(vBoilerRef);
}
}
}
##############################
Code:
class Boiler extends MovieClip{
// -----------
// Constructor
// -----------
public function Boiler(passed_mcReference:MovieClip,
passed_ID:Number) {
mcReference = passed_mcReference;
trace ("Boiler mcReference = " + mcReference);
numID = passed_ID;
trace ("numID = " + numID);
}
public var mcReference:MovieClip;
public var numID:Number;
private var numInitialRotation:Number = -83.5;
public function reset_Needle():Void {
mcReference.guage_panel_mc.needle_mc._rotation = numInitialRotation;
}
public function set_Needle_Rotation(passedRotation:Number):Void {
mcReference.guage_panel_mc.needle_mc._rotation = numInitialRotation;
}
}
View Replies !
View Related
Array Movie Clip Reference
Hi
I got some movie clips' references in an array as follows:
Code:
var buttons:Array = new Array(architektura_mc, urbanistyka_mc);
These movie clips are nested in a movie called 'menu_mc', so I can reference to them like so:
Code:
menu_mc.architektura_mc.property = value;
However, I'd like to facilitate my array in the following way:
Code:
menu_mc.buttons[0].property = value;
It won't work since when I trace menu_mc.buttons[0], it's apparently undefined. How come?
View Replies !
View Related
How To Reference Movie Clip In Button
Hello,
I have a button, lets say its linkage name is btn. From script in the main timeline I am adding the button (from the library) to a movie clip with attachMovie, giving it an instance name btn1. This has been working fine for me (however, please correct me if I should not be using attachMovie on buttons).
This button, in the Up frame, has a movie clip with an instance name interior. Is it possible, after I call attachMovie and create btn1, to reference this interior movie clip, like: _root.outer.btn1.interior ? I can successfully reference btn1 with _root.outer.btn1, but _root.outer.btn1.interior is undefined.
If I list objects while debugging, I can see a target: _root.outer.btn1.instance63. I realize that Flash has generated that instance name, but why hasn't it used the "interior" name I assigned inside the button?
Please excuse my lack of knowledge here, and know that I've spent a number of hours researching this before posting. Any help would be appreciated.
Thanks,
M
View Replies !
View Related
Ways To Reference A Movie Clip?
Can anyone explain why within a function this would work: colorSwatch_0._alpha-=10;
But this would not? this["_root.colorSwatch_"+0]._alpha-=10;
I am certain that the reference is solid, and I can access other variables in the same manner (dynamic text fields).
Any clues?
Thanks muchly
b
View Replies !
View Related
Movie Clip Reference Problem
Hi there, 1st of all, thank you for all those who have helped me out for that last week. I have gained so much information this week more than I do in a month. The progress of my project is going because of this forum.
2nd, I run into another question.
I have 1 index movie (_root). Inside this movie, I have a container_mc, and I load external swf file into this container.
For examble, I load a news.swf into the container_mc
But when I reference into a mc inside the _root timeline of news.swf, It doesnt recognize it.
For example: I have a myMovie_mc inside the _root timeline of news.swf
How do I make an absolute reference to this myMovie_mc?? ( I have a button inside myMovie_mc, and onRelease, I want it to play the 2nd frame on myMovie_mc
This doesnt work:
_root.container_mc.myMovie_mc.gotoAndPlay(2);
A quick solution is appreciated. Thanks guys.
View Replies !
View Related
FMX: Get Reference To Clicked On Movie Clip
New to flash!
I normally write javascript code, so I wonder how to do this.
In JS "Microsoft IS" you'll write code like this:
document.onclick = func;
function func()
{
var obj = event.srcElement; //And there I have reference to the object;
}
The graphic designer creates flash drawings and then converts whatever objects to movieclips. Then passes them over to me. All these "mc" need the same action applied to them. So I don't need to know how many they are or their names....Can this be done in Flash???
Thanx
View Replies !
View Related
Removing A Movie Clip Reference
Last edited by chance : 2003-01-27 at 06:31.
For some reason, I can't seem to remove the reference to an unloaded movieclip that is contained in a movieclip that is contained in another movieclip that has been loaded using attachMovie(). I know the clip is being removed because listing the objects in the movie just shows the reference to the removed clip, not the objects within the removed
clip.
------------- Code ---------------
item = itemPath.attachMovie(itemClip, "item" + i, i);
var mp3 = item.mediaType_mc.mediaMp3_mc;
trace(mp3); // path to mp3
unloadMovie(mp3);
trace(delete mp3); // false
----------------------------------
I've tried:
mp3.unloadMovie()
unloadMovie(mp3)
mp3.removeMovieClip()
removeMovieClip(mp3)
Is there something I'm missing here? I don't have any code anywhere that references these clips so I can't for the life of me figure out why I can't delete their reference.
Any help is appreciated, or if you know a way in the debugger or somewhere else to show all references to a given object, that may help too. I may have set a variable somewhere that references these clips and forgotten about it.
Thanks.
Mark Chance
mchance@ideo.com
IDEO
http://www.ideo.com
View Replies !
View Related
Movie Clip Reference Issue
I'm having this problem quite often now, I know it's kinda vague to tell, but it's basically this; reference to movieclips just stop working for no apprent reason.
For instance, I have this project where I have a movie clip at the stage and I use code from the same fla to make a reference to it and it just doesn't work.
Say myMC.buttonMode = true; to make it change the mouse arrow when the cursor is over the MC.
But if I make it simple, by deleting everything else but the part of the code where it makes the reference the MC and the MC itself, it works!
That's not the first time that it happened to me, so I wonder if it's a kind of well know bug that I should be aware of, or something...
View Replies !
View Related
Loosing Reference To Movie Clip
I'm somehow loosing my reference to my movie clip i created dynamically.... can someone tell me what's wrong with this code.
var y=0;
var x=0;
var imageHolderWidth = 276;
var imageHolderHeight = 362;
var gap=50;
// loop through XML and place in array
for (var i=0;i<2;i++) {
var image = "last10_image_"+i.toString();
_root.createEmptyMovieClip(image,50+i);
var imageHolder = eval(image);
imageHolder._x=x;
imageHolder._y=y;
imageHolder.createEmptyMovieClip("_tn"+i,100+i);
mv_sub_image = imageHolder["_tn"+i]
trace(_root[image]["_tn0"]);
with(mv_sub_image){
_x=1.5;
_y=1.3;
_alpha=60;
with(imageHolder){
lineStyle(2,0xA0A0A0);
moveTo(0,0);
lineTo(imageHolderWidth,0);
lineTo(imageHolderWidth,imageHolderHeight);
lineTo(0,imageHolderHeight);
lineTo(0,0);
}
loadMovie("glamour.jpg");
}
_root[image].onRollOut=function(){
_root[image]["_tn0"]._alpha=60;
}
_root[image].onRollOver=function(){
_root[image]["_tn0"]._alpha=100;
}
currentNode = currentNode.nextSibling;
x = x + gap + imageHolderWidth;
//set the max image that can be displayed.
if(i>=1){break};
}
if you look at the trace output .. the first movie clip is undefined after the second loop.
View Replies !
View Related
How To Reference A Movie Clip In Main Swf From A Class?
I'm a little ahead of myself in doing AS 3 for a client - before I have complete understanding myself.
Here's where I am stuck -
In the main swf(fla) I have "presentation_mc" which is a movie clip with many keyframes. Later designers will add/remove keyframes as needed. So I also have to generate numbered buttons dynamically.
Here is the code that generates the custom buttons in the main.swf:
function placeButtons():void{
var i:int
for(i=0; i<varNumOfSections; i++){
var varTemp:Number = i + 1;
varButtonLabel = String(varTemp);
varButtonX = varButtonFirstX + (35 * i);
varButtonOver = sectionArray[i];
var b1:Button_mc = new Button_mc(varButtonLabel, varButtonX, varButtonY, varButtonOver);
mySprite.addChild(b1);
}
}
----- end code in main.swf
Here is the custom class for Button_mc:
package{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
public class Button_mc extends MovieClip{
public var varLabel:String;
public var varX:Number;
public var varY:Number;
public var varOver:String;
public function Button_mc(varLabel, varX, varY, varOver){
this.label_txt.mouseEnabled = false;
this.label_txt.text = varLabel;
this.x = varX;
this.y = varY;
this.toolTip_mc.over_txt.text = varOver;
this.toolTip_mc.tipBacker_mc.width = this.toolTip_mc.over_txt.textWidth + 20;
this.toolTip_mc.visible = false;
this.buttonOver_mc.visible = false;
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, clickHandler);
}
private function clickHandler(event:MouseEvent):void {
var tempVar:String = this.label_txt.text;
//trace("You clicked " + tempVar);
buttonClick(tempVar);
}
function buttonClick(tempVar:String):void{
trace("I want to go to presentation_mc frame # " + tempVar);
//presentation_mc.gotoAndStop(tempVar);
}
}
}
---- end Button_mc.as
Note the red and bold traces fine on clicks - but I can't actually reference the movie clip "presentation_mc" from here.
I'm really sorry if this is simple - referencing is always the second thing I check on errors - after spelling. But I am getting a specific 1120: Access of undefined property presentation_mc error.
I am working my way through Moock's book on AS 3 at a feverish pace, but if I can't get this sussed I am in serious trouble for today.
I greatly appreciate anyone's help - whether simple or conceptual.
View Replies !
View Related
How Do I Reference The External Movie Clip's Button?
I'm loading a movie into a container (a navigation system). Now I want to put in some code in the first swf, not the external swf, to change the alpha of a movie clip. Can someone help?
Code:
var navLoader:Loader = new Loader();
gavholder.addChild(navLoader);
var navURL:URLRequest = new URLRequest("dock.swf");
navLoader.load(navURL);
navLoader.x=0;
navLoader.y=0;
navLoader.scaleX=1;
navLoader.scaleY=1;
I thought I could just say this
Code:
gavholder.c1.addEventListener(MouseEvent.CLICK, camp);
function camp(event:MouseEvent) {
gcrmcholder.alpha =50;
}
Regards,
Glen Charles Rowell
View Replies !
View Related
Can't Reference A Movie Clip Array Via For Loop
Hello everybody, I have this problem since many weeks ago, I can't figure out how to resolve it. My partial code is:
function checkCollision(rect) {
for(j=0; j < drop.length; j++) {
temp2 = eval(drop[j]);
if(eval(rect._droptarget) == temp2){
rect._x = temp2._x;
rect._y = temp2._y;
}
else {
rect._x = rect.origX;
rect._y = rect.origY;
}
}
}
I send to the function a movie clip that I use for drag and drop, so when I drop this function is called. The problem is that of the three rectangles that I use for contain the others, only the last senses the drop target. I read the Canadian post of frequently asked questions, and one of the questions is very similar, but I can't figure out how to apply it here. Any help please. Thanks
View Replies !
View Related
Pass Reference Of Movie Clip To Function?
Hey guys,
I'm trying to do something like this, but for some reason it isn't working...
ActionScript Code:
function mouseClickHandler(t:MovieClip):Void { if(!t){ trace("no target"); var t:MovieClip = this; } else{ trace(t._name); }}// using a call to this function I want to simulate a click on navItem_2mouseClickHandler(container.navItem_2);
Any idea why this shouldn't work?
Should I do it as a string or what?
Update:
Hmm, I replicated this situation in a blank movie and it works as it should. Really confused now.
View Replies !
View Related
Dynamic Movie Clip Reference Problems
Last edited by Codemonkey : 2006-08-18 at 10:30.
i'm trying to convert the following statement:
ActionScript Code:
line_mc_1.moveTo(end_mc_1._x , 353);
I'd like to replace "mc_1" with the variable "currentSWF". by doing this:
ActionScript Code:
whichLine = "line_" + currentSWF;
whichEndX = "end_" + currentSWF + "._x";
eval(whichLine).lineTo(eval(whichEndX), 353);
...only the first eval is working. Is there a better way of doing this? I'm basically trying to dynamically generate the reference to the MC property. I've tried other approaches with no success.
Thanks in advance!
Raphael
View Replies !
View Related
Loosing Reference To My Movie Clip When Create Dynamically
I'm somehow loosing my reference to my movie clip i created dynamically.... can someone tell me what's wrong with this code.
var y=0;
var x=0;
var imageHolderWidth = 276;
var imageHolderHeight = 362;
var gap=50;
// loop through XML and place in array
for (var i=0;i<2;i++) {
var image = "last10_image_"+i.toString();
_root.createEmptyMovieClip(image,50+i);
var imageHolder = eval(image);
imageHolder._x=x;
imageHolder._y=y;
imageHolder.createEmptyMovieClip("_tn"+i,100+i);
mv_sub_image = imageHolder["_tn"+i]
trace(_root[image]["_tn0"]);
with(mv_sub_image){
_x=1.5;
_y=1.3;
_alpha=60;
with(imageHolder){
lineStyle(2,0xA0A0A0);
moveTo(0,0);
lineTo(imageHolderWidth,0);
lineTo(imageHolderWidth,imageHolderHeight);
lineTo(0,imageHolderHeight);
lineTo(0,0);
}
loadMovie("glamour.jpg");
}
_root[image].onRollOut=function(){
_root[image]["_tn0"]._alpha=60;
}
_root[image].onRollOver=function(){
_root[image]["_tn0"]._alpha=100;
}
currentNode = currentNode.nextSibling;
x = x + gap + imageHolderWidth;
//set the max image that can be displayed.
if(i>=1){break};
}
if you look at the trace output .. the first movie clip is undefined after the second loop.
View Replies !
View Related
Dynamic Movie Clip Reference, Invoke Function In Mc
Happy new year all!!
I'd like to invoke a function inside a mc from it's parent, but I want to have the reference to the clip be dynamic. When I path the mc directly and invoke the function it works, how would I make that same reference work dynamically.
Here's a sample of what I'm trying to do:
Code:
var myArr:Array = new Array();
myArr[0] = "galleryContainer_mc.eventGallery1_mc.imgContainer_mc";
trace(myArr[0]);
// This works
toggle_btn.onRelease = function() {
galleryContainer_mc.eventGallery1_mc.imgContainer_mc.videoToggle();
}
// But this doesn't work
toggle_btn.onRelease = function() {
myArr[0].videoToggle();
}
I know I'm fried, but that seems like it should work, am I missing something really basic here? Any advice would be really helpful at this point. Thanks!
View Replies !
View Related
How To Reference Root-level Sound From Within A Nested Movie Clip?
I've got this AS on the first frame of my main FLA:
PHP Code:
var spur1:Spur1 = new Spur1();
var playSpur1:Function = function() {
spur1.play();
}
playSpur1();
It works. When the movie starts playing, I hear the spur sound from my library immediately.
I have a cowboy MovieClip on my stage in frame 1. The 2nd frame inside that cowboy movie clip has a movieclip of some legs walking. The 1st and 6th frames of those legs walking has this actionscript:
PHP Code:
playSpur1();
This is causing an error:
Code:
1180: Call to a possibly undefined method playSpur1.
My movie will not run properly - the cowboy ignores all the internal actions and loops repeatedly.
What is the recommended way to play a sound when some deeply nested movie hits a certain frame?
View Replies !
View Related
Making Button In Movie Clip Symbol Reference Main Scene
I set up a flash movie with a scroll pane moving a movie clip. When I place instances of buttons in that movie clip and apply actions to them, they are not working.
The main movie has only one scene, so my actions for the buttons in the movie clip contained in the scroll pane have the following properties: gotoandplay, scene 1, frame label, frame label in scene 1 I'd like to jump to.
Is there a reason, the actions applied to those buttons won't take me to the corresponding frame label in my main movie?
View Replies !
View Related
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
View Replies !
View Related
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
View Replies !
View Related
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?
View Replies !
View Related
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!
View Replies !
View Related
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
View Replies !
View Related
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!
View Replies !
View Related
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
View Replies !
View Related
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
View Replies !
View Related
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.
View Replies !
View Related
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?
View Replies !
View Related
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
View Replies !
View Related
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
View Replies !
View Related
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.
View Replies !
View Related
Reference Variable On MT From Mc How?
Hi everyone,
A little brain fart here: I have some input text set to variable 'speed' on the main timeline.
I have an instance of an MC also on the maintime line. I have attached a enterframe action the mc and wish to reference the speed variable. I thought it woud be:
_x += _root.Number(speed);
but it's not working . Why?
Thanks if anyone could help. Would really appreciate!
j
View Replies !
View Related
Reference Mc With Variable Value
i have a variable containing the name of a mc i want to play.
so instead of...
home.gotoAndPlay(6);
home being the mc instance.
i have...
_root.current_selection == "home";
so how do use _root.current_selection instead of 'home' in the above statement?
Cheers guys,
Robsco!
View Replies !
View Related
Using A Variable To Reference A Mc
I want to reference a movie clip with a variable.
ie.
var section;
section = "red";
section.gotoAndStop("one");
This doesn't seem to work when the movie clip is called red.
Is there some specific syntax for this? Do I need to dereference the variable?
thanks.
View Replies !
View Related
Using A Variable In MC Reference.
I am trying to use ActionScript to create text fields and then add text to them.
So I have
Code:
for ( i = 0; i < 10; i++)
{
var textName = "mytextfield"+i;
this.createTextField(textName, 10, 10, 10, 450, 80);
textName.text = "This text isn't working";
}
Can you help me on how make it so that create 10 instances?
View Replies !
View Related
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
View Replies !
View Related
|