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




Simple _root Or...? Please Help



In a movie I have on the main timeline a mc which contain an arrow, some buttons, a hitarea and a small dot, that's supposed to work as a slider (named "slidebut"). The hitarea got this script:

onClipEvent (load) {
function elastic (target, track) {
if (!track) {
track = 347;
}
diff = track-target._x
move = (diff*speed)+(move*elastisity);
target._x += move;
}
speed = 0.3;
elastisity = 0.4;
this._alpha = 0;
}
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
elastic(_root.slidebut, _root._xmouse);
_root.exit = _root._xmouse;
} else {
elastic(_root.slidebut, _root.exit);
}
}

And it's not working!
But if i put the slidebut on the main timeline it's workking perfectly. Only that gives med some other problems, so i would like to keep it in the mc.
Any ideas???
I would really appiciate some help, cause i'm getting pretty desperate!



FlashKit > Flash Help > Flash ActionScript
Posted on: 06-17-2003, 09:45 AM


View Complete Forum Thread with Replies

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

A Simple _root Problem. I Think.
hey guys.

A simple drag and drop function.

this script below works fine.

on (press) {
startDrag ("box");
}
on (release) {
stopDrag ();
if (getProperty("box", _droptarget) eq "circle") {
tellTarget ("complete") {
gotoAndPlay (2);
}
}
}



NOW im trying to embed it into a MC,
and it's not working.

it drags fine but when i drop it on my target(circle), it does not play my MC(complete)


on (press) {
startDrag (_root.box);
}
on (release) {
stopDrag ();
if (getProperty(_root.box, _droptarget) eq _root.circle) {
_root.complete.gotoAndPlay(2);
}
}


Any help would be great.

Shaun

_root Problem - Probably Simple
Hi all, I'm having a problem with my _roots when loading swfs into other swfs.

Ok here is what I have...
- 2 swfs stock.swf and scrollPanel.swf

within stock.swf i have...
-main timeline > reel_mc > cell_mc > titleText_txt, infoText_txt and placeholder_mc in the cell_mc

I am loading stock.swf into a scroll panel component on the main stage in scrollPanel.swf. The instance name of this component is scrollPanel.

I am loading text from a text file, jpegs externally and creating buttons in actionscript. At the moment the jpegs load into the scroll panel, the buttons load onto the top timeline of scrollPane.swf and the text doesn't load at all!

I'll paste my script below and hopefully some one can help. ...

I have added some comment to say things I have already tried.




var originalClip:MovieClip;
var newClip:MovieClip;
var jpegName:String;
var carMovie:String;
var titleVar:String;
originalClip = this.reel_mc.cell_mc;
numberVar = new LoadVars();
numberVar.onLoad = function(success) {
if (success) {
var n = parseInt(this.numberOfJpegs);
}
for (i=0; i<n; i++) {
jpegName = i+".jpg";
newClip = originalClip.duplicateMovieClip("cell"+i, i+100);
content = newClip.placeholder_mc;
content.loadMovie(jpegName, i);
newClip._y = i*120;
//create buttons
//I have tried using _parent and this instead of _root here and also tried
//adding _root.scrollPanel but this doesn't work
_root.createEmptyMovieClip("button"+i, i);
//newButt = eval(_root["button"+i]);
_root["button"+i].lineStyle(2, 0x000000, 50);
_root["button"+i].beginFill(0xff9797, 50);
_root["button"+i].moveTo(133, 0);
_root["button"+i].lineTo(0, 0);
_root["button"+i].lineTo(0, 100);
_root["button"+i].lineTo(133, 100);
_root["button"+i].endFill(20, 0);
_root["button"+i]._y = 20+(i*120);
_root["button"+i]._x = 50;
_root["button"+i].onRelease = function() {
//newButt.i = i;
loadMovie(i+".swf", i);
trace(i+".swf");
};
}
};
numberVar.load("number.txt");
loadVarsTextTitle = new LoadVars();
loadVarsTextTitle.load("titleText.txt");
loadVarsTextTitle.onLoad = function() {
for (i=0; i<4; i++) {
//have tried including a scrollPanel after the root in this expression but no
//luck
_root.reel_mc["cell"+i].titleText_txt.text = this["t"+i];
}
};
loadVarsTextInfo = new LoadVars();
loadVarsTextInfo.load("infoText.txt");
loadVarsTextInfo.onLoad = function() {
for (i=0; i<4; i++) {
_root.reel_mc["cell"+i].infoText_txt.text = this["a"+i];
}
};


Thanks again

_root, This And _parent In Simple Terms Please
i'm always getting this confused and i keep seeing posts where someone writes back and says

"you should be using _root.whatever instead of..."


Questions:

1. if i use _root inside a movieclip's timeline, will that relate to the MCs timeline or the main timeline?

2. if i use _parent inside a movieclip's timeline, will that control the main timeline?

3. if i have something simple like:

this._x -= 3;

in a movieclip's instance, how can i change it to make the same code work inside the movieclips timeline?
can you control the movement of a movieclip from frames in the movieclips own timeline???


any help apreciated as always, especially on that third question.
thanks again.

Having Trouble Accesing _root...simple Problem?
I have a button inside of an MC. When one pushes the button I want it to tell a movie clip in the root directory to play a frame label.

on (release)
tellTarget (_root.SAMPS) {
gotoAndPlay("ORGANIC");
}

SAMPS is the name of the movie clip, ORGANIC is the frame label. Why isn't this working?

Simple _root.gotoAndStop Not Working, Any Ideas?
I have a movie clip playing, once the movie clip finishes there are two buttons displayed on the last frame of the movie clip (which has a stop action on it); thus giving you the choice to proceed to one of two pages. I want the button to send you back to the main timeline, so I had this script:

on (release) {
_root.gotoAndStop(6);
}

And the other button was the same script, but frame 5 instead of 6. The button that is supposed to send you to frame 5 doesn't work at all, and the button assigned to send you to frame 6 sends you to frame three.

EDIT: I noticed that frame six was going to 3 (half the value of what it was supposed to go to) and frame five wasn't going anywhere (I guess because there is no frame 2.5). I tried changing the code to:

on (release) {
_root.gotoAndStop(12);
}

And the other code to (10); The above code places you on frame 6, and the code set to (10); sends you to frame 5. Why is it cutting the numbers in half? I can leave it like this for now because it works fine.. I'm just wondering why it is doing this.

What Is The Simple Equivalent For Referencing The _root Timeline?
I've got a .swf (movie B) that gets loaded into a clip in my main movie(movie A). Movie B needs to control another clip within movie A.

In AS2, i would simply start off with a _global var on the main _root timeline, like this:

_global.home=this;

then, later in my seconday movie (movie B) i would reference that timeline simply like: home.myClip.gotoAndStop("whatever");

What is the simple equivalent for referencing the _root timeline? I've tried _parent with no results.

I'm looking forward to utilizing classes more, but for now I've got timeline code (on a single frame at least), with aspirations of moving toward a 'class-based' development style.

thanks for any help!

Flashmx-Im Trying To Make It So That When _root.lazer Collides With _root.bad It Goto
Im trying to make it so that when _root.lazer collides with _root.bad it gotoandplays("Explode"); im using this script

onClipEvent (load) {
if (this.lazer(_root.bad)) {
this.gotoandplay("Explode");

My fla is attached.

_root.play() / _root.gotoAndPlay() Not Working
Hi,

I am working on an interactive movie, the movie consists of a number of small movie clips. I need each clip to play and when it reaches it’s end stop and tell the main time line to move to next frame, on that frame the next MC will [play and do the same.

I am trying to use this script for the last frame of the movie:


_root.play()

I also tried “_root.gotoAndPlay()” and “_root.nextFrame()

It doesn’t seem to work.
Anyone has any idea why ???

? -- TellTarget(_root.man_0 && _root.man_1) { -- ?
Can you tellTarget multiple targets?

Loading .swf To _root And Performing Actions On _root
Hello, I have a loader which should load a movie which should be placed on the _root so that all of it's actions will still work. also, i need to perform some actions on the _root which is specified in my loader. f.eks. say I load my movie at _level0 and then I trace "movieLoaded" all the time.

And I use flash MX

This _root And That _root, Parents, Children, LoadMovie...
I'm building a showcase to show a bunch of my work. Let's call my work "children" and the showcase file the "parent".

A lot of the children files have some actionscript that references functions and variables on the root level. However, when those files are loaded into the parent file, the root is now the root of the parent file, not the child file.

SOME of the stuff, I've been able to remedy by opening each flash file and copying and pasting all that crud into the shell flash movie.

Unfortunately, not all of my wizardry is working, and hey, who knows what's wrong. Since the individual files each have functionality that works on it's own, is there some way of telling those children files to look at the root ONLY on their own file, or, as soon as the swf is loaded, the root is changed?

How can I avoid this in the future?

ALSO, is there some way to globally override the "getURL" function call so any and all clicks are now dead links?

_root.layer.layer? Simple Question
so im having some problems getting the right item targeted and feel that im writing the as wrong.. so here is what i have.. the stage. with a mc .. then inside that a button.. so wouldnt it be like this?

_root.mc.button

_root.xyzxyz What This _root Means?
What is the meaning of _root. What does it represent.

_root.link / _root.page Help
hi gang, ive got a flash template im trying to edit for a friend, id say im fairly good at flash ive made alot of sites with actions but having trouble with this.

the problem i have got is the _root.link=

this is the action script:
on (release) {
if (_root.link <> 8) {
_root["page"+_root.page].gotoAndPlay("w2");
_root.link = 8;
_root.page = _root.link;

}
}


(there was more but that was just controling the button animation, ive just posted this to keep it simple , for me atleast)


what im having trouble doing is working out where the route is?
i want to be able to creat another movie and link it

eg:

on (release) {
if (_root.link <> 9) {
_root["page"+_root.page].gotoAndPlay("w2");
_root.link = 9;
_root.page = _root.link;

}
}


how would i lable the movie to be '9' where would i do this, i have looked and ive had no joy, some help would be good, if u need more info from me please do ask

_root._root[eelmine].nextFrame(); ?
if a condition is true, then:
_root.(MC with instance name that is the value of "_root.eelmine").nextFrame();

is this correct?

_root._root[eelmine].nextFrame();

_root._root[eelmine].nextFrame(); ?
if a condition is true, then:
_root.(MC with instance name that is the value of "_root.eelmine").nextFrame();

is this correct?

_root._root[eelmine].nextFrame();

_root._root.testbox?
I have this small problem.
I have 2 swfs(main.swf and links.swf)

I then load links into main. In links I loadvar using php and sql.
I fetch links from my sql databas and print it in php.
But it doesnt work when I load links into main.
It only works when I view links.swf directly.

Example:
links.php

databas connection etc etc
mysql query etc etc
print"&name=$name";
print"&link=$link";
print"&status=DONE";

in flash(links.swf)i then have this:
status = "LOADING";
loadVariablesNum("links.php", 0, "POST");
if (status eq "LOADING") {
gotoAndPlay (_currentframe-1);
} else {
gotoAndPlay (2);
}

I have 3 dynamic boxes called:name,link and status.

and a stop() on frame 2.

So how do I get this to work? I´m sure you guys know the answer to this.

I also have another question.
When I look at the links.swf directly only the first post appears and I want the whole list so that the user/visitor can scroll the link list. How do I loop that in flash or is it in php/sql It should be done and if so,, how would the php code look like.
Would this work?
$query="select * from links";
$result=mysql_query($query);
$name=mysql_result($result,"name");
$name=mysql_result($result,"link");
print"&name=$name";
print"&url=$link";
print"&status=DONE";

How do I then make the name linkable?
I can only have one dynamic box in the flash right?
So that the name flashkit is the link to flashkit.

Please help me with the above,, really need to get this to work.

_root._parent.? Problem With "_root" Etc
I have been using flash for some time now and understand basic actionscript. However only just recently(last few days), i have gone onto more advanced stuff like cursors (advanced for me )

Well i am making a flash movie that incorporates all of my testings for people to see.

I am current;y working on a movie where the cursor is a knife, and when the cursor goes over this picture of someone, the knife (cursor) should go to and play the second frame of the knife (cursor) which has added blood.

I.e, when the mouse goes over the picture, the knife becomes a picture with blood, so in effect you are stabbing the picture. (don't worry, i'm not a sadist!)

At the moment my movie is like this...

drag drag2
(pic) (knife)
^ ^
| |
<<drag_mc>>
^
|
Scene 1 -----> navigation...
(root?)

Description: The scene one has two movies in it, "navigation" (which is OK) and the "drag_mc". The "navigation" is fine so i won't go into that. The "drag_mc", then has two movie clips in it, "drag" and "drag2".

I assume that to make the "drag2"(cursor) go to frame 2 when it hovers over "drag"(picture) that the "drag" should have a on(rollover)
command. I've put in the command, but i'm having troubles linking that to the "drag"'s frame 2.
I have just messed about with _parent and stuff, but never understood it.

Please could someone help me here, and/or tell me exactly how the _root and stuff works??


P.S. the on (rollover) is actionscript for the drag movie, and not in the movie if you get what i mean....



---newbie in distress---

EDIT: the picture did not come out as planned, but it is still readable. Just remember that the two movies ("drag" and "drag2") are placed in the "drag_mc" movie

A Button In A MC In Frame 1 Of _root Hiding An MC In Frame 2 Of _root?
Hi. I have a button, "auroraB" in a movie clip "startupMC" which is in frame 1 of _root. There is another MC, "scenic" in frame 2 of _root.

The button "auroraB" is clicked and takes the user to frame 79 of the MC in frame 1. From there the user clicks another button to go to frame 2 of the _root.

How do I get it to hide MC "scenic" in frame 2 of _root when the button "aurroraB" is clicked? Thanks

_root.send1.text = _root.total3.text;
Ok I have this script in a Movie Clip! First frame has

_root.send1.text = _root.total3.text;

2nd frame
gotoAndPlay(1);

So it updates!

Both send1.text and total3.text are input text fields in Flash! When I test this out it works fine but when I get it up online it doesn't work! The information in total3.text doesn't get sent to send1.text!! Also note both have Var titles asigned to them! Let me know if you can figure out what's wrong! Thanks!

Convert "_root" To _root
anyone know how to convert a string "_root" to the path specifier _root???
The Object() converstion function doesn't seem to be doing the trick..
hmmm
any help would be appreciated
cheers

If (this._url = _root._url && _root:leiaSala) {
SORRY ABOUT MY ENGLISH!

WHAT MEANS THIS LINE

if (this._url != _root._url && _root:leiaSala) {

IN SPECIAL THE :

I'M NEED TO EXPORT SWF IN AS 2.0, AND THIS "OPERATOR" IS DEPRECATED.

THANKS

[F8] From Text "_root.home.score" To Variable _root.home.score ?
Hej

How can i convert this string "_root.home.score" to a varialbe, so i can use it for actionscripting

"_root.MCname" + "_root.MCvalue"
Hallo,
how can I grab the value contained within a MC name, e.g.:


Code:
duplicateMovieclip(_root.myMC, "_root.myMC"+someIntegerVariable, level);
_root.myMC+someIntegerVariable._x = 100;
It happens that the parser cannot parse the second row, since
"Left side of assignment operator must be variable or property".

My target is to make the sum of two instance names as a single instance name.

thank you very much!
s---

_root?
hello
i have a clip inside a clip.. and in THAT clip i have a button that want to close the MAIN clip to be removed from the main time line.. it is located there....
doesent work with :
on (release) {
removeMovieClip (_root.news);

_root
Help I've got some flash 5 code that I have to edit yet I don't know flash 5 code well enough.

The problem is that all the code is referencing the _root directory, but I need to put it into another file. Now when I was using flash 4 code I would simply use relative references, but I don't know how to move outside of a file in flash 5. For Flash 4 I would go ../blah.

How can I do this???

Please help

What Is _root?
i have a movie with many Mc controlled by tell target action in it.now i want to add preloader scene to this movie.when i add the scene ,it works fine but in the movie some buttons in the MCs have goto _root and play <frame no.> these button send the movie to preloader,why???
what is root for the flash player---the maintime line of the scene it is right now OR maintime line of the first scene???

_root.a._x Eq -271 {
if (_root.a._x eq -270) {
stop ();
} else if (_root.a._x ne -270) {
gotoAndPlay (21);
}

Can someone tell me what's wrong with this if anything?
It should be working.. i dont get it..

-Paradoxz

_root
I'm reading and reading and I still don't understand for what is the _root on Flash.

And I neither understand the function of with (I used Tell Target).

Bye::::::::::::

Help With '_root'
Erm, I got this from a previous post....

_root.MUSIC.gotoAndPlay("MUSICOFF")

What would I do if I wanted it to be the same but to level 7??

_root
Where is the _root command in the actionscript menu

If _root ?
Hello friendly flashers,
I have a new problem.;-)
Here is the idea.
It has to be a check for a button. And then goto the correct frame.

if it's onframe 1 goto frame 40
on (release) {
tellTarget ("_root") {
gotoAndPlay (40);


if (_root) {has to check frame 2
tellTarget ("_root") {
gotoAndPlay (41);
}
}
}
}


Hope you understand my question.
Thanks in advance

J

_root Help
i'm desiging a website for my friend. on request, i made all buttons in a movie clip that have pull down buttons. a nifty trick, but i cannot get the buttons to work properly.

i use normal mode, and it hasn't worked properly. i've heard that to function, it needs the _root. command, but i have fooled around with it and am better off asking for some real help. if you could get one button to work, i could copy/paste/edit for the others.

i'd like the buttons to work when pressed. the content is on scene1.

please help

stews

_root. What? Please Help
hey flashers,

ok, i have a movie clip, inside the movie clip is a button that when clicked, is supposed to load a movie into a blank movie clip on the main timeline. its not working as you probably figured. I gave the blank movie clip on the main timeline an instance name of "dtext". the action script i have for the button is this.


Code:
on (release) {
loadMovie ("dynamic text box.swf", "dtext");
}
i know it has something to do with that .root command, but i cant figure it out. where does the root command go, and is there anything else i am doing wrong? please help.

Jacob

_root?
I want to go down multable levels in movie clips.
and i thought you use root and give each movie an instance name. so like

_roor.movie1.movi2.gotoAndPlay(5);

but it does not do anything, am i writing the code wrong

_root.?
what's the difference b/w for example -root.gotoAndPlay() and gotoAndPlay()?

Something Other Than _root ?
I'm that annoying guy who asks questions about every little detail without trying it himself, but this time, i swear, i have a legit question.

I'm using some script to fade out a sound...i found a post here that was WAY helpful. One problem though. I'm using: _root.interClip.s.setVolume(25); This works when fading sounds in the same scene. BUT, i want to fade a sound from another scene. is there something other than _root I need to be using?

Thanks!!!

To _root Or Not To _root
Here's a dilemma...

I'm building an online course that uses a navigation function (menu buttons) as a movie, hence the links use _root to specify the frames to jump to.

Here's the problem. These functions work when they are standalone but when I upload it as a swf inside an html page, it refuses to recognize the _root functions.

Any comments!!!

_root.
What's the root action?!
I have a button in a movieclip and I want that button to link frame nr. 76 in my main timeline, not nr.76 in the movieclip where the button is placed in...

i think it's something like: _root.scene1.GotoAndplay(76) but I'm not shure, let me know something ASAP !

THNX,
Wouter

_root.
hi all,

I am writing an action in a movie clip to read a particular variable(in the movie) is 1 or 0.

if (_root.Number(a1)==1) {
play();
} else {
stop();
}

something is not right, as its not working can someone tell me if there is a problem with the script?

thanks

nixthinx

_root
on (release) {
_root.home_mc.help_mc.gotoAndStop(1);
}

I have a button name Help out side of the movie clip but it just wont load that like...

and I don't want to move the button and put it inside the movie clip.

any suggestions?

_root
Here is my situation. Im a beginer in AS. I have a window that scrolls a MC wich has a bunch photo clips. When a user clicks one of these photos I want it to display the photo enlarged in a window above the scrolling window. All the large photo's are in the main time line on seperate key frames with stop actions. How do I tell the button wich is the "photo clips" to go the main time line and stop on specific key frame?
Any help would be apreciated. Because I kinda suck at AS syntax.

_root.?
Hi,

Need to understand how this work, why must use
_root.walk_bgclp.gotoAndPlay("start"); and not just gotoandplay("start")? what is _root. for?

Thanks

_root?
I have a loader on my main ' _root ' that counts the bytes of the _root obviously. I also want to use this loader on a movie that is being loaded into a target. I put the loader in the ' _root ' of the movie being loaded, but I need to change the code. I'm not sure what to put. I've tried ' _level2 ', but that's not working.

_root.getBytesTotal()


_level2.getBytesTotal() *Not working.

My target name is 'mcload '.

mcload.getBytesTotal() *Not working.


Any recommendations?

Getting The _root._y From Within A MC
How can I tell if a movie clips _y property is below a _y property of the root? This is for Flash 5.

The part that i need help with is on the second line.

Code:
onClipEvent (enterFrame) {
if (this._y>????????) {
this._y=0;
} else {
if (this._rotation == 0) {
move = -1;
}
if (this._rotation == -45) {
move = 1;
}
this._rotation = this._rotation+move;
this._y = this._y+3;
}
}
Help?

_root[ ]
I am trying to access beyond the _root level of a moive by using _root[myTarget] where myTarget == "test.myMovie" but it doesn't seem to like anything beyond the _root level. How can I dynamically access movies that are embeded deeper than the _root?

_root.var+n Becomes 1 :-(
_root.var+n becomes 1 :-(

im trying to do this:

i have _root.var1, _root.var2, _root.var3, etc
each var has a different value, i need to asign this value to a new txt block after i duplicatemovieclip it.

variable: _root.txt+n (expression)
value: _root.var+n (expression)

the variable part returns
_root.txt1
_root.txt2
_root.txt3 etc, as i want.
BUT
the value part is giving me hassle
value: _root.var+n (expression)
returns
1
2
3 etc

value: "_root.var"+n (expression)
returns
_root.var1
_root.var2
_root.var3 etc

it returns the var name, not the actual value that the var holds

help!

if i am being realy vague with the above explanation let me know
thnx
-thomas

_root?
This may be a stupid question, but what is _root?
Does it have a value? What part does it play in flash mx?
A brief explanation would be greatly apreciated.

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