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








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)];

}




Adobe > ActionScript 1 and 2
Posted on: 09/14/2007 01:03:27 PM


View Complete Forum Thread with Replies

Sponsored Links:

Turn String Into Array
Hi all,
If i have the following:

Code:
sloj = "new Array(new Array(26,311,9062912,100,100,100,0,'spray',33), new Array(28,311,9062912,100,100,100,0,'spray',34));";
how can i change this so the sloj variable isn't a string but an actual multi demensional array? At the moment it is just a string.
Cheers,
macca

View Replies !    View Related
How To Turn A String Into A Variable Name
I've searched this forum for this, but I don't think I found a similar question, so here it goes:

I created a string variable called EMCaption, that gets its value by calling a variable previously defined and adding it to a string:

var EMCaption = "text" + thumbNum;

For example: if thumbNum is "3", EMCaption gets to be "text3".

What I need next is to transform EMCaption's content, "text3" in this case, into a variable name. For example, if "unknownCode" is the code I need, when I write

unknownCode.setTextFormat(myformat); ,

the interpreted code would be in fact

text3.setTextFormat(myformat);

In other words, I need to assign a variable a name created from a string variable's content in a way that I can use it with dot syntax.

View Replies !    View Related
Get Character, Out Of String And Turn It Into An Integer, How To?
Hi,

I generate comboboxes on the stage for user input! The amount of comboboxes can go from 3 to n where n can be anything.

The comboboxes recieve a name like :
Combobox1
Combobox2
..
ComboboxN


Later I want to get the last character(being the number) and turn it (back) into an integer.
Getting the number(as a string) is not a problem:
number = charAt(8)

Is there a way to turn the number-variable from a string to an integer?

View Replies !    View Related
Adding Commas To Turn String Into Dollars
Hi all,

I have a dynamic textfield that is bringing in a number from a txt file.

the number is displaying like this:

1853600

I want it to look like this:

$1,853,600

I can have it display as dollars in another field if that's how this gets done.

oh...How would I adjust it to deal with a number in the tens of millions?

Thanks

-Lemorris

View Replies !    View Related
How To Turn Animated Gif Into A Movieclip?
OK, so I have an animated gif that I would like as a movieclip in my FLA file...so what I did was put that animated gif into its own FLA and compiled it into a swf...and it worked fine. But when I import it into my main FLA, it comes into the library as a bitmap, and thus only one frame of the animated gif...am I missing something obvious here?


BTW, if anyone knows where I can download a simple animated loading swf (like those AJAXy circles), you can ignore this question

View Replies !    View Related
Making One MovieClip Turn Into Another
Right now I have a MovieClip that is an array and when it collides with an object, it gotoAndPlay('s) a specified frame of the same MovieClip. Is there a way I can just have it so that MovieClip1 doesn't go to MovieClip1(Frame2) but goes to a MovieClip2?

View Replies !    View Related
How To Turn Movieclip Clickable Like A Button
Hi,

I have a movie clip it contains animation

how can I make i as a button and when i rollover my mouse over it, it will go to the specific fram number in that similar movie clip i mention ?

thank you

View Replies !    View Related
Turn Grapic/movieclip Symbol Into Movie Back Again
I have created a small animation and turned it into a 'graphic symbol' . Now I want it as a separate flash movie (something like 'un-symbolize') (so that I can edit it, perhaps add some scenes etc..). How can I do that? Please help me..

View Replies !    View Related
Flash In Kiosk Mode - Turn Off / Turn On Launch Schedule
Hi Forum

I am creating a little flash app for a kiosk. We will be using a Mac. (not sure about OS yet, but probably 10.4 or up. )

1) Is there a way to automatically launch the flash app on startup on a mac?
2) Is there a way to schedule a shut off and launch time on a mac? We'd like the machine to automatically shut down at midnight and relaunch at 7am for example. Is there an application that handles tasks like these built in the OS or is there some application out there that would handle this?

Any advice or insight appreciated.

Thank you

Best

Stephan K

View Replies !    View Related
Changing Instaint Turn To Gradual Turn
I have this code that makes object one turn and face another object. They both move. How could I change this code so instead of the object instantly facing the other object, it gradually turns to face it?

k = Math.atan2(_root.man._x-this._x, this._y-_root.man._y);
g = k*180/Math.PI;
this._rotation = g;

View Replies !    View Related
Is It Posible To Turn The Turn The Visibility Of A Whole Layer Off?
I kniow you can set the visibility of individual symbols in a layer by targeting their instance names, but is it possible to target the whole layer?

View Replies !    View Related
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.

View Replies !    View Related
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.

View Replies !    View Related
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.

View Replies !    View Related
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?

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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!

View Replies !    View Related
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 ?

View Replies !    View Related
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

View Replies !    View Related
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!

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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!

View Replies !    View Related
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!

View Replies !    View Related
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?

View Replies !    View Related
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?

View Replies !    View Related
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.

View Replies !    View Related
[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)

View Replies !    View Related
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!

View Replies !    View Related
Page Turn Effect / Turn Off
Is anyone familiar with the page turn effect here: http://www.iparigrafika.hu/pageflip/?

If so, do you know how I can turn off the effect? What I want is to be able to go directly to page 14, for example, without having to wait for all the pages to turn to get there. Thanks for any help.

My goal is to offer the "turn off" option for users with slow processors.

http://www.iparigrafika.hu/pageflip/

View Replies !    View Related
Make Line Movieclip Turn To Dotted Line
hey Everyone

Just wanting to know how to use actionscript to make a line dotted. I want to have a movieclip (a solid line) and when u click on it it will become a dotted line, then be able to switch it back to solid with another click.

Cheers

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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

View Replies !    View Related
[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

View Replies !    View Related
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.

View Replies !    View Related
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?

View Replies !    View Related
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.

View Replies !    View Related
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

View Replies !    View Related
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;

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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?

View Replies !    View Related
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!!

View Replies !    View Related
String / MovieClip Variable Question
I am trying to have a handful of mcs in the library that are going to be attached using an array, instead of handcoding each one.

attachMovie needs string variables, hence the quotes...

The below code works...

Code:

var ThreeHundredArray:Array = new Array("small_big_rack_main_grey_mc",
               "small_auto_spot_curl_mc",
               "small_bar_bands_mc",
               "small_belts_chains_mc",
               "small_dip_weights_mc",
               "small_j_cup_top_mc",
               "small_red_pads_mc",
               "small_seat_mc",
               "small_squat_bar_mc",
               "small_squat_spotter_mc",
               "small_straps_mc",
               "small_dip_bar_mc");

//WRITE a LOOP Array here...then call the array based on the clicked button etc...
var i:Number;
var m:Number;

for (i = 0; i<ThreeHundredArray.length ; i++) {
   var levelNumber:Number = 100 + i;
   
   attachMovie(ThreeHundredArray[i], ThreeHundredArray[i], levelNumber);
   trace(ThreeHundredArray[i]+ " Level Number: "+levelNumber);
}

BUT when I add this

Code:

ThreeHundredArray[i]._visible = false;


I get undefined??

I assume, because the array has the quotes.

But How can I have an array of mcs, that is able to be called upon for attachMovie, AND for things like _visible etc...

[/code]

View Replies !    View Related
MyArray String To A Movieclip[array].play
I am using array's at the moment to log a list of numbers i.e.
1,4,23,45,64

these numbers relate to particular movieclips within the swf movie.....Want I want to do is to take those numbers and make the movie clips that relate to them play i.e.

movieclip1.play
movieclip4.play
movieclip23.play
movieclip45.play
movieclip64.play

What I don't know how to do is to strip those numbers out of the string and get flash to play the related movieclips.

Can any one help

ta. stu

View Replies !    View Related
How To Convert String To Object (movieclip Instance Name)
this is a function on my _root :


function callMsg(title,msg,btn) {
trace("_root.msgBox() is called");

_root.x += 1;
var newName = "x"+_root.x;
duplicateMovieClip("_root.msgBox",newName,_root.x) ;

//////////////////////////////////////////////
//Need to call function startMsg() in the created movieclip
//////////////////////////////////////////////

var xx = (Stage.width/2 - _root.msgBox._width/2);
var yy = (Stage.height/2 - _root.msgBox._height/2);
setProperty(newName,_x,xx);
setProperty(newName,_y,yy);
}


with that i added a line

_root.newName.startMsg();

but it wouldnt work, i thought the reason must be "newName" is a String hence it wouldnt refer to a _root.String but looking for a _root.object


example if newName is "x1", the duped movie clip would be named x1 too
hence i need to call out :
_root.x1.startMsg();

qns is how do i get it to refer newName as a movie clip ?
thx in advance, btw whats the difference between depth and level ? and can i delete my own post here ?

View Replies !    View Related
Variable String Data To Reference Movieclip
I've been trying to search for this but I'm not really sure how to word what I'm trying to do.

I have all these movieclips that start with a naming scheme like mc_1, mc_2, mc_3, etc. and I want to assign a listener to all the movieclips. I was thinking an array for each of the different end numbers ( only because sometimes it might not be a number, maybe mc_aa43g) and then a for loop to go through the array and assign the listeners. Perhaps there's a better way, or perhaps I'm not grasping the reference movieclip title through a string variable... the actionscript (this was just a concept of the logic and obviously doesn't work) I was thinking of was something like this...


mcArray = new Array('1','2','3','aa43g');

for(i=0;i<mcArray.length;i++){
mcName = 'mc_' + mcArray[i];
mcName.addListener('someListener');
}

Any advice is appreciated. Thanks

View Replies !    View Related
Problem With String Variable To Target A MovieClip...
Ok, here is a sample of what I am trying to do. Basically, I want to use a string variable to target a movieClip with the same name.


ActionScript Code:
var pageName:String = root.loaderInfo.parameters.page;
if (pageName){
    pageName.alpha = .5;
}

I know the variable is a String, but how do I convert it to target the movieClip that has the same name?

View Replies !    View Related
[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++);
}

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