[fmx] Problems With Loading Into A MovieClip Via A String [renamed]
Alright, I know this is a mess, please forgive me. I'm trying to get it to load into one of the movies that its creating but it doesn't seem to like the string, if I manually enter _root.holder_mc.mc_0 it works fine.
Any ideas?
Code: #include "com.qlod.LoaderClass.as" var depth = 0; var myLoader = new com.qlod.LoaderClass(); var picPath = ""; var pics = ['winterrangep1.jpg', 'winterrangep2.jpg', 'winterrangep3.jpg', 'winterrangep4.jpg', 'winterrangep5.jpg', 'winterrangep6.jpg']; var picText = ['']; var picCount = _root.pics.length - 1; var objIndex= 0; var nextX = 265.4; var nextY = 293.9; var prevX = 0; var prevY = 297.4; MovieClip.prototype.loadObj = function (file, i) { if (file.length) { trace(i); objWhereToLoad = "_root.holder_mc.mc_"+i; objWhereToLoad = objWhereToLoad.toString(); trace(objWhereToLoad); myLoader.load(objWhereToLoad, file); var mc_loader = _root.attachMovie("loader", "mc_loader", 4); mc_loader._x = nextX-mc_loader._width/2; mc_loader._y = nextY; mc_loader.loadBar.onLoadProgress = function(loaderObj) { this._xscale = loaderObj.getPercent(); trace(this + ' Progress: ' + loaderObj.getPercent()); }; mc_loader.loadBar.onLoadComplete = function(success, loaderObj) { removeMovieClip(mc_loader); current_index++; load****(); trace(this + ' Complete'); }; myLoader.addListener(mc_loader.loadBar); } else { trace(this + ' No Image to Load'); } }; var holder_mc = _root.createEmptyMovieClip("holder_mc", _root.depth++); current_index = 0; load**** = function () { //var mc = loadMovie(""+pics[current_index]+"", holder_mc["mc_"+current_index]); loadObj(pics[current_index], current_index); if (last_index == current_index) { break; } var last_index = current_index; }; load****(); for (i=0; i<pics.length; i++) { holder_mc.createEmptyMovieClip("mc_"+i+"", depth++); }
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 04-23-2004, 08:27 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[fmx] Problems With Loading Into A MovieClip Via A String [renamed]
Alright, I know this is a mess, please forgive me.
I'm trying to get it to load into one of the movies that its creating but it doesn't seem to like the string, if I manually enter _root.holder_mc.mc_0 it works fine.
Any ideas?
Code:
#include "com.qlod.LoaderClass.as"
var depth = 0;
var myLoader = new com.qlod.LoaderClass();
var picPath = "";
var pics = ['winterrangep1.jpg',
'winterrangep2.jpg',
'winterrangep3.jpg',
'winterrangep4.jpg',
'winterrangep5.jpg',
'winterrangep6.jpg'];
var picText = [''];
var picCount = _root.pics.length - 1;
var objIndex= 0;
var nextX = 265.4;
var nextY = 293.9;
var prevX = 0;
var prevY = 297.4;
MovieClip.prototype.loadObj = function (file, i) {
if (file.length) {
trace(i);
objWhereToLoad = "_root.holder_mc.mc_"+i;
objWhereToLoad = objWhereToLoad.toString();
trace(objWhereToLoad);
myLoader.load(objWhereToLoad, file);
var mc_loader = _root.attachMovie("loader", "mc_loader", 4);
mc_loader._x = nextX-mc_loader._width/2;
mc_loader._y = nextY;
mc_loader.loadBar.onLoadProgress = function(loaderObj) {
this._xscale = loaderObj.getPercent();
trace(this + ' Progress: ' + loaderObj.getPercent());
};
mc_loader.loadBar.onLoadComplete = function(success, loaderObj) {
removeMovieClip(mc_loader);
current_index++;
load****();
trace(this + ' Complete');
};
myLoader.addListener(mc_loader.loadBar);
} else {
trace(this + ' No Image to Load');
}
};
var holder_mc = _root.createEmptyMovieClip("holder_mc", _root.depth++);
current_index = 0;
load**** = function () {
//var mc = loadMovie(""+pics[current_index]+"", holder_mc["mc_"+current_index]);
loadObj(pics[current_index], current_index);
if (last_index == current_index) {
break;
}
var last_index = current_index;
};
load****();
for (i=0; i<pics.length; i++) {
holder_mc.createEmptyMovieClip("mc_"+i+"", depth++);
}
Loading An Image Into A MovieClip, Then Into BitmapData [renamed]
Hello,
I am trying to load an image into a movieclip and then draw the contents of the movieclip to a bitmapData object. Below is some sample code.
Code:
target.jpg_mc.loadMovie(url);
target.createEmptyMovieClip("loader_mc", 100);
target.loader_mc.bmc = target.jpg_mc; // movieclip where to load original image
target.loader_mc.tmc = target.bmp_mc; // movieclip with smoothed image
target.loader_mc.onEnterFrame = function(){
bl = this.bmc.getBytesLoaded();
bt = this.bmc.getBytesTotal();
if (bl >= bt && bt > 4 && this.bmc._width > 0 && this.bmc._height > 0){
//target._parent._visible = true;
this.bmc._visible = false;
var bitmap = new BitmapData(this.bmc._width, this.bmc._height, true);
this.tmc.attachBitmap(bitmap, 100,"auto", true);
bitmap.draw(this.bmc);
Stage.addListener(target);
target.gotoAndPlay("in");
this.removeMovieClip();
}
}
For some reason it always draws a white box rather than the image. Has anyone ever seen this happen with the bitmapData class?
Thanks for any help!
Wade
How To Determine Length Of A String [renamed]
Sorry about that, but its obvious that while scanning a forum, the eye will be drawn to threads that are titled in caps and Ill hopefully hit the jackpot ....anyway, Im using variables pulled in from a .cfm, and have split them into an array using .split("|"), so I can dynamically populate a nav bar...so now Ive got an Array of all the menu button names stored in the file...SOOOoooo...Say Ive got a button called "Home", and the other "The Dysfunctional Properties of the Human Mind", obviously I need the duplicate buttons to scale in width. Is there a way of finding out the number of letters in a string that is part of my array?
To reposition my duplicate buttons I used this -
setProperty("cats_clip"+i, _x, xstart+i*_root.cats_clip._width);
To change the width I want to use this
setProperty("cats_clip"+i, _width, widthstart+i*((number of characters in current string*width of one letter)+a buffer to allow for space on the sides);
or something to that effect
So could anyone tell me what to use to replace the bit in red?
How To Determine Length Of A String [renamed]
Sorry about that, but its obvious that while scanning a forum, the eye will be drawn to threads that are titled in caps and Ill hopefully hit the jackpot ....anyway, Im using variables pulled in from a .cfm, and have split them into an array using .split("|"), so I can dynamically populate a nav bar...so now Ive got an Array of all the menu button names stored in the file...SOOOoooo...Say Ive got a button called "Home", and the other "The Dysfunctional Properties of the Human Mind", obviously I need the duplicate buttons to scale in width. Is there a way of finding out the number of letters in a string that is part of my array?
To reposition my duplicate buttons I used this -
setProperty("cats_clip"+i, _x, xstart+i*_root.cats_clip._width);
To change the width I want to use this
setProperty("cats_clip"+i, _width, widthstart+i*((number of characters in current string*width of one letter)+a buffer to allow for space on the sides);
or something to that effect
So could anyone tell me what to use to replace the bit in red?
Button Inside MovieClip Not Functioning [renamed]
I have a MovieClip called "mousetest" that I can move from a button on the stage:
Code:
Código:
on (click) {
_root.mousetest._visible = 1;
_root.mousetest._x=210;
_root.mousetest._y=201;
}
Inside this MC "mousetest" I have a buttom that "close" (hide/move) the MC but I can't make this WORK, I try evrything I don't know if is a problem using _root
Boton dentro del MC
Code:
on (click) {
_root.mousetest._visible = 0;
_root.mousetest._x=800;
_root.mousetest._y=800;
}
But until know I don't know how to make _global work or if this is the best solution someone can give a hand on this one? (step by step plz)
Thank you.
_LOBO_
I Don't have a clue how to implement _global
http://www.kirupa.com/developer/acti...addressing.htm
Button Inside MovieClip Not Functioning [renamed]
I have a MovieClip called "mousetest" that I can move from a button on the stage:
Code:
Código:
on (click) {
_root.mousetest._visible = 1;
_root.mousetest._x=210;
_root.mousetest._y=201;
}
Inside this MC "mousetest" I have a buttom that "close" (hide/move) the MC but I can't make this WORK, I try evrything I don't know if is a problem using _root
Boton dentro del MC
Code:
on (click) {
_root.mousetest._visible = 0;
_root.mousetest._x=800;
_root.mousetest._y=800;
}
But until know I don't know how to make _global work or if this is the best solution someone can give a hand on this one? (step by step plz)
Thank you.
_LOBO_
I Don't have a clue how to implement _global
http://www.kirupa.com/developer/acti...addressing.htm
Loading Two Swf's Next To Each Other [renamed]
ok wow!! i need HELP big time with some stuff! first of all..im trying to load an .swf movie (or file which ever it is) into my main movie...well the way im doing that is by clicking a button and then the movie loads...then im wanting to be able to click another button and load a different movie BUTTTT when i do this right now the second button's movie loads right over the first buttons movie!! what do i do?!?
also im wanting to make a text scroller with JUST the slider. how can i go about this?
p.s.
would appreciate just verbal help b/c i would like to try to do this without using someone elses stuff ...if thats ok...?!
Loading Two Swf's Next To Each Other [renamed]
ok wow!! i need HELP big time with some stuff! first of all..im trying to load an .swf movie (or file which ever it is) into my main movie...well the way im doing that is by clicking a button and then the movie loads...then im wanting to be able to click another button and load a different movie BUTTTT when i do this right now the second button's movie loads right over the first buttons movie!! what do i do?!?
also im wanting to make a text scroller with JUST the slider. how can i go about this?
p.s.
would appreciate just verbal help b/c i would like to try to do this without using someone elses stuff ...if thats ok...?!
How'd They Do That? - Loading External Content With Transitions [renamed]
This is the site: http://www.void.pt/void.php?lng=en
the opening squence i suppose it's all just movie tweens between files, but how is this thing done, when you click a button, the middle screen/part of the site, has a transition effect, loads, and there is a new page! i know how to do the transitions, and the loading bar, but how do i exactly tell my button, where to load an external movie file!...
basically, i want it when somone goes to the site, the while site opens, there are transition effects, and three different movies open at three different spots on the site...just like it happens at www.void.com when you enter their site, they got the main window, and the botton right and left windows!
Please if someone could give me a helping hand on this i would really appriciate it!!!!
-AlBERT
Loading Random Background Problems [renamed]
I am looking for someone skilled with Flash, a Wizard hopefully...
I have been trying to create a .swf that loads a Random background image (like the one on Kirupa's MX tutorial on this site) ... and my skills are just too insuficient.. I got it working but the images loads in sequence too fast and my general composition and work is kinda messy...
Is there someone here who is interested in helping out ?
The project is for our website, we are a non-commercial gaming clan, and alot of programmers, but none of us have any serious Flash experience. We are able to advertise/link back to anyone who might wanna help us out.
Contact me on email: therseus@gmail.com
How'd They Do That? - Loading External Content With Transitions [renamed]
This is the site: http://www.void.pt/void.php?lng=en
the opening squence i suppose it's all just movie tweens between files, but how is this thing done, when you click a button, the middle screen/part of the site, has a transition effect, loads, and there is a new page! i know how to do the transitions, and the loading bar, but how do i exactly tell my button, where to load an external movie file!...
basically, i want it when somone goes to the site, the while site opens, there are transition effects, and three different movies open at three different spots on the site...just like it happens at www.void.com when you enter their site, they got the main window, and the botton right and left windows!
Please if someone could give me a helping hand on this i would really appriciate it!!!!
-AlBERT
Loading Random Background Problems [renamed]
I am looking for someone skilled with Flash, a Wizard hopefully...
I have been trying to create a .swf that loads a Random background image (like the one on Kirupa's MX tutorial on this site) ... and my skills are just too insuficient.. I got it working but the images loads in sequence too fast and my general composition and work is kinda messy...
Is there someone here who is interested in helping out ?
The project is for our website, we are a non-commercial gaming clan, and alot of programmers, but none of us have any serious Flash experience. We are able to advertise/link back to anyone who might wanna help us out.
Contact me on email: therseus@gmail.com
Problems With GetURL Targeting - Loading Into _self [renamed]
Hi!
I'm having a problem using getUrl, can anyone pleeease help??
I've written my own code and used code from here:
on (release) {
getURL("http://www.kirupa.com", "_blank");
}
Everything works fine while testing in Flash, but if you try to load a page into "_self" whilst in a browser window, nothing happens. I'm sure this is something really simple I've missed, but what???
The code I'm using is from a function and goes like this...
//release instructions from function
mc.onRelease = function() {
this.gotoAndStop("down");
this.btnMask._x = btnOut;
getUrl (link, "_self");
}
//function call
btnMC1.onEnterframe =
function() {
menuControl(this, "http://www.google.co.uk")
};
Everything's working fine, except loading pages into _self. Can anyone please help??
Cheers in advance!!
A Little Help With Loading Web Site Content With Button Click Please [renamed]
hi all!
i'm getting closer to my finished site just a few final glitches to clear up.
i have the main guts of the site load up and then when you click on a button i have action script that loads content upon release and the buttons stay put and the page loads up on the left hand side.
http://www.freewebs.com/ex_iled/
however, i do have a page (left side) that i want to have load when the initial page loads up for the first time (the home page). now the buttons and the pictures stay put during all page transitions, okay? so no reloading of those.
how do i get my home page (left side) to load at the same time as you first open the site and also to load if you were to press the home button without causing the buttons and the pics to reload again?
sorry, if this is hard to understand.
i know what the hell i'm trying to say, the question is do you understand what i'm saying!? lol!
thanks!
Loading Dynamic Text Breaks Formmail Forms [renamed]
This matter is something I haven't been able to solve for long and now I'm really desperate to find out an answer.
Here's a link to a very simple zip file (as example) containing the conflictive fla and other files, for those of you who may want to have a look at it.
TO SIMPLIFY THINGS:
It seems that whenever I use a couple of AS instructions to load some Dynamic text from a text file, Forms which are based in formmail, stop working (no matter if these forms are made of dynamic or static text). Why??
INTO MORE DETAILS:
In the attached fla example file here, I've simplified things very much by just leaving 2 Forms (one made with Dynamic text and another one without any dynamic text on it).
Very peculiar, if in frame 1 I call the variables from the text file:
ActionScript Code:
webcontent= "File.txt"loadVariablesNum (webcontent, 0);
the 2 Forms stop working properly: The static one doesn't even seem to submit data and the dynamic one, it seems data has been sent but data is never received.
As soon as I delete these 2 lines of AS, they work properly again (although of course, no words can be seen in the Form made with dynamic text).
Both submit buttons contain the following AS:
ActionScript Code:
on (release) { subject = "Customer Form from your Web"; recipient = "info@mydomain.com"; loadVariables ("http://www.mydomain/cgi-bin/formmail.pl", "", "POST"); _root.Form.gotoAndStop ("Thanks");}
So...I don't have the least idea of what's going on with this all.
Perhaps any of you could explain what's wrong with such a simple thing like this and how to avoid this strange behaviour.
Thank you very much!
Loading Dynamic Text Breaks Formmail Forms [renamed]
This matter is something I haven't been able to solve for long and now I'm really desperate to find out an answer.
Here's a link to a very simple zip file (as example) containing the conflictive fla and other files, for those of you who may want to have a look at it.
TO SIMPLIFY THINGS:
It seems that whenever I use a couple of AS instructions to load some Dynamic text from a text file, Forms which are based in formmail, stop working (no matter if these forms are made of dynamic or static text). Why??
INTO MORE DETAILS:
In the attached fla example file here, I've simplified things very much by just leaving 2 Forms (one made with Dynamic text and another one without any dynamic text on it).
Very peculiar, if in frame 1 I call the variables from the text file:
ActionScript Code:
webcontent= "File.txt"loadVariablesNum (webcontent, 0);
the 2 Forms stop working properly: The static one doesn't even seem to submit data and the dynamic one, it seems data has been sent but data is never received.
As soon as I delete these 2 lines of AS, they work properly again (although of course, no words can be seen in the Form made with dynamic text).
Both submit buttons contain the following AS:
ActionScript Code:
on (release) { subject = "Customer Form from your Web"; recipient = "info@mydomain.com"; loadVariables ("http://www.mydomain/cgi-bin/formmail.pl", "", "POST"); _root.Form.gotoAndStop ("Thanks");}
So...I don't have the least idea of what's going on with this all.
Perhaps any of you could explain what's wrong with such a simple thing like this and how to avoid this strange behaviour.
Thank you very much!
String To MovieClip
Hi. I have the code the following code:
in root frame I:
var prevSec:*;
var currentSec:*;
var lastPage:String = "Default/Index";
var currentPage:String = "Default/Index";
switch (lastPage) {
case "Default/Index" :
prevSec = "slide2.pic6.mcdefault";
break;
}
switch (currentPage) {
case "Default/Index" :
currentSec = "slide2.pic6.mc1";
break;
}
andi in root frame 16:
MovieClip(root).prevSec.visible = false;
MovieClip(root).currentSec.visible = true;
And it's not working ("canno't create property visible on String"). I understand that if finds the variable to be of String type.
What i need to do is based on the switch to set a certain movieclip to go visible false or true on frame 16.
I need to know how to cast the String into MovieClip.
Thank you.
String To MovieClip
Hi. I have the code the following code:
in root frame I:
var prevSec:*;
var currentSec:*;
var lastPage:String = "Default/Index";
var currentPage:String = "Default/Index";
switch (lastPage) {
case "Default/Index" :
prevSec = "slide2.pic6.mcdefault";
break;
}
switch (currentPage) {
case "Default/Index" :
currentSec = "slide2.pic6.mc1";
break;
}
andi in root frame 16:
MovieClip(root).prevSec.visible = false;
MovieClip(root).currentSec.visible = true;
And it's not working ("canno't create property visible on String"). I understand that if finds the variable to be of String type.
What i need to do is based on the switch to set a certain movieclip to go visible false or true on frame 16.
I need to know how to cast the String into MovieClip.
Thank you.
String To MovieClip
Hi. I have the code the following code:
in root frame I:
var prevSec:*;
var currentSec:*;
var lastPage:String = "Default/Index";
var currentPage:String = "Default/Index";
switch (lastPage) {
case "Default/Index" :
prevSec = "slide2.pic6.mcdefault";
break;
}
switch (currentPage) {
case "Default/Index" :
currentSec = "slide2.pic6.mc1";
break;
}
andi in root frame 16:
MovieClip(root).prevSec.visible = false;
MovieClip(root).currentSec.visible = true;
And it's not working ("canno't create property visible on String"). I understand that if finds the variable to be of String type.
What i need to do is based on the switch to set a certain movieclip to go visible false or true on frame 16.
I need to know how to cast the String into MovieClip.
Thank you.
String To MovieClip?
I have some MovieClips in my library, each with a class name and exported for actionscript. What I want to do is add the movieclips to my stage by having the user click on a relevant button. To keep things simple, I have named each individual button after the movieclip I want to load... but obviously, the 'e.target.name' is a string.
So when I call my function createItem(e.target.name)... I need a want to turn that string into a reference for my movieclip class
Can anyone tell me how this is done?
How Can I Get A Movieclip To Run In A String Variable
I am trying to use the gotoAndStop(x) method of a movie clip to a movie that I keep a reference to in a string variable. How can I get the stringvariable content and use gotoAndStop() to make sure that the movie plays like I hardcoded the reference? I am confused here.
I tried doing like this but no luck
strMovie="myTestMovie";
gotoAndStop(strMovie,15);
Any suggestions? Thanks
Converting A String To Movieclip
node.onRelease = nodeMove
function nodeMove(){
// records position initial Pos of currently selected person
_root.lastX = this._x;
_root.lastY = this._y;
// if this is the second person selected we must move the first one back to the network
if(_root.firstgo==true){
trace("fired");
trace("currentnode "+ this)
// reposition position previously selected person
trace("_root.lastnode "+ _root.lastnode + " is a " + typeof _root.lastnode);
eval(_root.lastnode)._x=30;
eval(_root.lastnode)._y=30;
n1._x = 0;
n1._y = 0;
}
// move the selected person to expanded view
this.onEnterFrame = function(){
this.xslide = (500 - this._x)*.3;
this._x += this.xslide;
this.xscale = (1000 - this._xscale)*.3;
this._xscale = this.xscale;
this.yscale = (1000 - this._yscale)*.3;
this._yscale = this.yscale;
this.yslide = (200 - this._y)*.3;
this._y += this.yslide;
}
// sets the position of the last selected
_root.firstgo = true;
_root.lastnode = this._name;
}
heres a function that is fired when any one of a network of nodes (dynamically generated with names n0 to n25) is clicked. The nodes are placed randomly on the stage. If one is clicked the idea is to move it to an expanded postion to the right hand side of the screen, which works here. But i need to reference the previously clicked mc so i can move it back to a random position (or even back to 30,30 as intended here).
I can reference it but im not sure how to manipulate correctly it while its reference exists as a string.
for example this part is wrong :
// reposition position previously selected person
trace("_root.lastnode "+ _root.lastnode + " is a " + typeof _root.lastnode);
eval(_root.lastnode)._x=30;
eval(_root.lastnode)._y=30;
n1._x = 0;
n1._y = 0;
in this case the _root.lastnode moves back to 30,30 but then slides back to the expanded postion on right simultaneously as the new one moves into place.
however if i test
n1._x = 0;
n1._y = 0;
this node moves to 0,0 as expected and stays in the correct postion
btw the trace("_root.lastnode "+ _root.lastnode + " is a " + typeof _root.lastnode);
reveals : _root.lastnode n10 is a string
i think there is a simple syntax or scope problem here, anyone help???
appreciated
z
Get Movieclip By Instance Name String
This is a really simple newb question:
Given an instance name in a string variable like var x = "instancename", how can I get the actual movieclip with that instance name?
Thanks in advance!
Define The String As A Movieclip
Ive got a simple one here , Im trying to set a movieclips property remotly like the last time , Basicly im trying to define the string _root.CurrentWindow as a movieclip .
Ive tried var Owner:MovieClip = _root.CurrentWindow; but when i trace Owner._visible but insted of true etc i get undifined .
Does anyone know a way to get around this ?
Movieclip.STRING.visible
i have a problem that is a little hard to explain
basicly this is what i have
var page:String="home";
function changep()
{
myMovieClip.home.visible= false;
}
that is a really basic version of what i am trying to do
thanks for helping
For(var....evaluate A String As A MovieClip?
Hi,
As3 presenting an annoying problem for me when I'm so used to being able to evaluate a string into a movieclip so i can repeat the same function on multiple movieclips.
But it wont let me do it the way I was used to doing, can anyone correct me on the right way to do it?
ie- movieClips named m1, m2, m3, m4, m5
for(var i:int = 1; i < 6; i++) {
trace("m" + [i])
var objectA:MovieClip = "m"+i;
}
Which won't allow me to do it as it can't change the string into a movieClip when I try to apply it.
Help!
Replace String With MovieClip
Now this seems farely simple. But, I'm struggling to find resources on this topic.
It will need to work similar to a chat application. Finding and replacing ": )" with .
Obviously you cant place a MovieClip inside a Dynamic TextField, but will need to atleast line up and add space needed to adjust the right side of the string.
Now, to be able to work out the space and width requirements. Would I need to be using TextLineMetrics (AS3)?
If anyone can point me in the right direction... or even better show me something that works? I'd be very grateful.
Kieran
Instantiate MovieClip From Name String
I want to instantiate lots of MC's based on their name (linkage idetifier) that I would get from an XML as String .
How can I do that ? (without xml ,i think I'll figure that out)
Thanks
Using String To Turn Into Movieclip
Hello guys!
How do i turn a string to movieclip?
i tried something like this and is not working:
function funcaoMenuCom(choice:Number){
var myMovie:MovieClip = _parent["button" + String(choice)];
}
String To Movieclip Instance Name
Hi,
I have a function to set focus to a movieclip. Something's wrong, not sure what... I'm blinded by this, and need help!
First I'm creating a movieclip container and populating this with movieclips that will make up a menu. Next step is to give focus to the first "tab" initially, and then to have a selecteditem variable that changes as the focus changes...
//Creates an empty movieclip for containing the menu
menu_container = this.createEmptyMovieClip("main_menu_mc", this.getNextHighestDepth());
menu_container._y = 20;
//Counts through the categorynodes_array and adds buttons
//Adds the category name and description to the textfields in "tab"
for (var i = 0; i<_root.categorynodes_array.length; i++) {
var m = menu_container.attachMovie("tab", "tab"+i+"_mc", i);
m.categoryname_txt.text = _root.categorynames_array[i];
m.categorydescription_txt.text = _root.categorydescriptions_array[i];
m._x = 30;
m._y = (m._height+20)*i;
function setTabFocus(tab) {
var tab:Number = tab;
var tab_mc:String = "main_menu_mc.tab" + tab + "_mc";
trace (tab_mc);
if (selectedItem == null) {
//Selection.setFocus(main_menu_mc.tab0_mc);
Selection.setFocus[tab_mc];
} else {
Selection.setFocus(selectedItem);
}
}
setTabFocus(1);
trace(Selection.getFocus());
Pretty please, help me!
Flash & XML: String To MovieClip?
Hi! I've have an XML file and from that in Flash (Actionscript 2.0) I pulled from a node an attribute that returns the name of the MovieClip I want to call. So this returns a string say "chicken_mc". There is already an existing chicken_mc placed on the root. I want to call that, so how do I use that string I pulled from the XML to call or turn into a movie clip?
Right now I have:
var cTemp:MovieClip = pTemp.attributes.movieclip;
That's not working because a MovieClip can not = a String. Is there some function I can use to change the String. I tried cTemp._name = that too, but _name is read-only.
I need the movie clip to be called this way because there are a number of different movie clips on the root that the XML might call. Also, there will be a number of iterations as well.
I am really stuck on this! Please help if you can! Or suggest alternate solutions.
Thanks!
Converting A String To MovieClip?
I have a string that I want to covert to a MovieClip so it can
reference an instance on my timeline. How do I do that,
with extends or something?
String Reference To Movieclip?
Hey guys, I have a stage full of movieclips (90 of them), each of which has an instancename. I've placed them on the stage manually because each has an irregular shape that has to fit neatly with the other movieclips.
I also have an xml file holding info corresponding to each of the 90 movieclips. I'd like each of these movieclips to display it's specific set of information on mouseover. The problem I'm having is that I can't quite figure out how to write a reference to an existing movieclip in actionscript 3, I know I can manually push each of the 90 movieclip instancenames into an array but I'd rather find a slightly more automated way of referring to a movieclip.
Say I have a movieclip named mc85, I'd like to be able to do something like:
var temp_mc:MovieClip = 'mc' +85;
Obviously doing the above is going to throw an error about supplying a string where a movieclip is expected.
Is there a proper way of writing the above pseudocode in AS3 or am I better of just writing an array and pushing the 90 instancenames into it manually?
String To MovieClip... Is That Possible? XML-Related
Hi guys,
I'm trying to put together an XML based Flash map. On the right side, is a dynamically loaded XML menu. Now, my problem is that the rollover and rollout effects for the menu doesn't work.
Basically, I have a movie clip that contains a dynamic textfield and another movieclip (the latter contains a button - I wanted it so that when the user rolls over this button, it plays, and when the user rolls out, it plays an exit "fade")
This is the actionscript below:
Code:
function countyMenu(menuXML) {
var itemCount = menuXML.firstChild.nextSibling.nextSibling.childNodes;
for (var i=0; i<=itemCount.length; i++) {
if (itemCount[i].attributes.type == "county") {
var countyName = itemCount[i].firstChild;
var linkName = itemCount[i].firstChild.nextSibling;
var menuContainer = mcContainer.attachMovie("menuButton","menuItem"+menuCounter,menuCounter);
menuContainer._y = menuCounter * menuSpacing;
menuContainer.trackAsMenu = true;
menuCounter++;
menuContainer.countyText.text = countyName.firstChild.nodeValue;
menuContainer.linkText = linkName.firstChild.nodeValue;
menuContainer.onRelease = function() {
// var menuItem = this._name;
// trace(typeof menuItem);
// mcContainer.menuItem.bCountyBG.gotoAndPlay(2);
emptyTextContainer = this.linkText;
trace(emptyTextContainer);
}
bGoToCounty.onRelease = function() {
getURL(emptyTextContainer,"_blank");
}
}
}
}
As you can see, everything works quite well, except for the fact that I can't reach the individual "path" of each of my dynamically loaded buttons.
I've tried using "var menuItem=this._name" to retrieve the "path" of my buttons when you rollOver them (which should be something like "mcContainer.menuItem.bCountyBG.gotoAndPlay(2) ;"), although I need the menuItem to change to whatever this._name is.
It doesn't work because menuItem's returned value is considered a string, so I can't use it in my command---> "mcContainer.menuItem.bCountyBG.gotoAndPlay(2) ;"
I was wondering if anyone can tell me if it's possible to convert this string to a movieclip by some sort of function or other means?
Thanks in advance. Please take it easy on me, I'm really fairly new to this.
[CS3/AS2.0]MovieClip Instance Name To String How?
Hello there , nice joinin the forum....I have a question for you dear folks!
I would like to pass the name of a movieclip to a string so my attachmovie method can work. what I m doin is :
function createBlocks(slot:MovieClip)
{
...
...
for (var i = 4; i < 10; i++)//lines
{
grid[j] = new Array();
for (var j = 0; j < 9; j++)//columns
{
var bName = "block_" + i + "_" + j;
holderClip.attachMovie(slot, bName, depth);
...
...
}
when I call the above function on a keyframe I call it like :
this.createBlocks(block4);
block4 is the id name of a movieclip in the library.
the problem is that the attachMovie method needs a string as a parameter!
how can I convert that to a string? so afterwards, slot , has inside the name "block4" (with the quotation marks)
String To Movieclip Instance Name
Hi All,
Is there a way to convert a string to a movieclip instance?
function buttonClicked(e:MouseEvent) {
var myMc = e.target.parent.name;
trace(myMc.x);
}
i get this error
ReferenceError: Error #1069: Property x not found on String and there is no default value. at MethodInfo-99()
Thanks in advance!
Replacing Sections Of A String With A Movieclip
I am currently working on a project where i have a fairly long string. I am trying to be able to take this string and find say all examples of 'hello', then replace them with a few spaces such as ' ' and then get a duplictaed movie clip to go and sit in this space.
I have worked out how to find all the examples of 'hello' and replace them. My only problem is working out the position for the new movie clip to go to. I am completely stuck as to how to achieve this.
Any help greatly appreciated
Xeonzinc
NOTE: i am using ActionScript 2
String To MovieClip Problem In Dot Syntax
Code:
var block_count=0;
function loadObject(ob_url){//OBJECT's URL
ob_id="block"+block_count;
this.createEmptyMovieClip(ob_id, this.getNextHighestDepth());
loadMovie(ob_url, ob_id);
block_count++;
ob_id._x=-200;
}
loadObject("objects/buildings/Comrades-HQ.swf");
loadObject("objects/tiles/grass1.swf");
The line - ob_id._x=-200; does not work..
even when i tried to do it with a new function with some_fc(id:MovieClip){}
It only works when i pass in a exact name such as "block0"
Any solutions?
Convert String Into MovieClip Instance Name
I want to do something like -
Code:
var theMC:String = "myMovieClip";
value(theMC).getBytesLoaded();
That is, I have a string of movieClip names, and want to get an object var with the same name.
How do I convert a string into an object ?
Thanks
[FP8] Using Array Keys As Var:String And Var:MovieClip?
Hi, just wondering if this is possible and/or if I am thinking correctly (I prob need a break, cause I have a feeling this is going to be an easy one for you guys/gals):
PHP Code:
// Main container names:
var frontBack:Array = ["front_mc", "back_mc"];
// Create containers:
this.createEmptyMovieClip(frontBack[1], this.getNextHighestDepth());
frontBack[1]._x = Stage.width / 2;
frontBack[1]._y = Stage.height / 2;
...
...
...
I know that is wrong... because the second and third use of the frontBack array can not be used as a :MovieClip because it is a string.
Is it possible to do the above but change the type from String to MovieClip and back to String again? Does that make sense? I am a bit tired... Hehe, so feel free to tell me to RTFM.
Only other option I can think of would be to create two more keys in array with non-string values...
Something like this maybe:
PHP Code:
var frontBack:Array = ["front_mc", "back_mc", front_mc, back_mc];
Any help would be great.
Cheers,
M
Converting String Variable To MovieClip
I'm trying to reference a variable of type String as a MovieClip that is linked from the library. For example, I have a linked library movieclip called HomeFrame, in my class I have a variable with "Home" and need to create an instance of HomeFrame based on the string I receive.
//Here's the normal way of doing it
var foo1:MovieClip = new HomeFrame();
addClip(foo1)
//What I have and know is wrong but simplified to get my point across
var homeStr:String = "Home";
var foo2:MovieClip = new MovieClip(homeStr + "Frame") //error
addClip(foo2) //which should display HomeFrame
I know in AS2 you could do this using attachMovie
var mc:MovieClip = test.attachMovie(homeStr + "Frame", "movie1");
so anyone know a solution?
Thanks.
Converting A String To Access A Movieclip
I have buttons with intancenames like aberdeenRed, dundeeRed.
Each one of these has an address (aberdeenRedAddress) moviclip which is the correct address for the place.
I tried to do this:
map.aberdeenRed.addEventListener (MouseEvent.ROLL_OVER, showAddress);
function showAddress (event:MouseEvent) {
trace(event.target.name + "Address");
var addressName = event.target.name + "Address" as Object;
trace(addressName);
addressName.alpha = 1;
}
but I get this error
ReferenceError: Error #1056: Cannot create property alpha on String.
at actionscripts::salonFinder/showAddress()
how do I convert the string to a movieclip name?
Passing String Info Via MovieClip?
Hello.
I'll try to explain what I'm looking for, I haven't started coding yet so have nothing to show.
I have 190 movieclips which display various types of information. When a user clicks on a movieclip, it has to tween larger but also send a string to a method. I'll probably e.currentTarget to use one function which contains a tween and I wondered if there was a quick way to pass string info in a similar way?
So, each movieclip has it's own value which can be passed to a method which will use that value. The only way I can think of so far is to have 190 functions which send the string data to the appropriate place. I'm trying to avoid that if I can.
Thank you.
Converting A String To A MovieClip Instance
hi there guyz,
I needed your help on flash action script…
I wanted to know whether there is any way to convert a variable/string to a movie-clip object/instance?
I know we can use toString() to do it the other way around… But I need to extract a value from an array [which has values pushed into the array that are movie-clip instances and its x & y positions] and then convert this extracted value into a movie-clip instance to set its properties to change the x & y positions of the movie-clip. There seems to be a type mis-match coz the setProperty() returns an undefined value.
M not able to find anything relevant or even close to doing such a thing on the net… if u know… do let me know… its kinda really really urgent… will really appreciate your help.
Thanks in advance,
Regards,
Kavini
Changing A Variable From MovieClip To String
I have assigned a MovieClip as a variable so I can use the _x and _y properties
var correctAnswer:MovieClip = radio4;
but I also want to use the name of the instance in the following if/else statement
if (this._parent.radioGroup.selectedData == correctAnswer){
//do something
The problem comes from the correctAnswer being _level0.radio4 when all I need is Radio4.
Any clues on what a solution might be. I know my details are sketchy at best (I blame copious amounts of caffiene!).
Mike
Attach Code
var correctAnswer:MovieClip = radio4;
Coercing String To MovieClip Class
I've been learning coercion between String and Number and simple stuff, but now I have a class that the books don't cover. This is best explained by example (this isn't the end goal, just a learning example).
On the stage in frame 1, I have a MovieClip instance named shape_mc.
Attach Code
var pre:String="shape";
var suf:String="_mc";
var fubar:*;
fubar=(pre+suf);
trace(fubar);
trace(MovieClip(fubar));
TypeError: Error #1034: Type Coercion failed: cannot convert "shape_mc" to flash.display.MovieClip.
Edited: 08/22/2008 at 04:16:02 PM by Fleshpope
Reaching A MovieClip From A String Path
Hello everyone
I have the path to a movieclip, in a string format. For example:
var pathString:String = "container.boxMC.ball"
I want to be able to reach that movieclip type (ball). I tried using something like getDefinitionByName(pathString), but gives me the error:
Variable ball is not defined.
Any ideas?
Accessing A Movieclip With String Variable As Name
I have a button called px (p1 - p8). When you press it I want to call a function that returns the x position of globalWrapper.px (p1 - p8) (different movieClips).
So I tried:
PHP Code:
p1.addEventListener(MouseEvent.MOUSE_UP, buttonMouseUp);
...
p8.addEventListener(MouseEvent.MOUSE_UP, buttonMouseUp);
function buttonMouseUp(event:MouseEvent):void{
var targetP:String = 'globalWrapper.'+event.target.name;
var end:MovieClip = targetP;
trace(end.x);
}
But obviously this does not work as I am trying to change the variable type.
Anyone know how to do this correctly?
Target:MovieClip With=converted:String
Hi!
I need to target a mc with a string that is converted. I dont know if I'm actually doing the right thing here. So here it is:
ActionScript Code:
currentobject = new Object();
currentobject.bla = "_level0.mymc";
var mc_ = currentobject.bla;
var mc:MovieClip = mc_;
_root.createEmptyMovieClip("mymc", 100);
mc.lineStyle(2, 0x000000, 100);
mc.lineTo(200, 300);
mc.lineTo(100, 200);
mc.createTextField("tex", this.getNextHighestDepth(), 200, 300, 125, 50);
mc.tex.text = "yeah";
if i put _root.mymc instead of the variable mc, it works. I need this bad! Just dont know why flash doesn't accept my variable in the target!!
PLEASE HELP!!
|