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




Cant Use Parent To Access Vars On Root



I have a few variables on the root of my timeline. They are set to nothing right now:Code: /*************************************** vars to send to mysql*****************************************/var title:String;var description:String;var segtitle:String;var location:String;var date:String;var rights;var keywords:String;I am inside a movieclip and I want to set those variables to whatever is in the text fields so i did(when they click submit):Code:       this.parent.title = titlefield.text;      this.parent.description = descfield.text;      this.parent.segtitle = segfield.text;      this.parent.location = locationfield.text;      this.parent.date = datefield.text;      this.parent.rights = gr1.selectedData;      this.parent.keywords = searchfield.text;when I compile, I get a bunch of these errors:1119: Access of possibly undefined property title through a reference with static type flash.display:DisplayObjectContainer.any idea?



Actionscript 3.0
Posted on: Thu Mar 20, 2008 5:53 pm


View Complete Forum Thread with Replies

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

Cant Use Parent To Access Vars On Root
I have a few variables on the root of my timeline. They are set to nothing right now:

ActionScript Code:
/*************************************** vars to send to mysql*****************************************/var title:String;var description:String;var segtitle:String;var location:String;var date:String;var rights;var keywords:String;


I am inside a movieclip and I want to set those variables to whatever is in the text fields so i did(when they click submit):

ActionScript Code:
this.parent.title = titlefield.text;        this.parent.description = descfield.text;        this.parent.segtitle = segfield.text;        this.parent.location = locationfield.text;        this.parent.date = datefield.text;        this.parent.rights = gr1.selectedData;        this.parent.keywords = searchfield.text;


when I compile, I get a bunch of these errors:

1119: Access of possibly undefined property title through a reference with static type flash.displayisplayObjectContainer.


any idea?

How To Access Root-level Functions Or Vars From Inside A Class
On the main timeline I have:


PHP Code:



var someObj:Object = new Object();
function someFunc(){
    //stuff
}





In an external class code .as I have:


PHP Code:



public class example{

    public function example() {
        //want to call someFunc()
        //want to access someObj
    }

}




How do I access vars, objects, and funcs that are external to a class from within the class? Kindof driving me crazy....

Parent/root
can anyone help me here. ive had this problem before and i just scraped through it.

this is the As for a scrolling text box. the scrolling button works but its not scrolling the text when i move it up/down.

the MC for this is inside just one Mc on the main stage. ive changed all sorts and it wont scroll the text.


onClipEvent(load){
var objetivo:String = _parent.mi_objetivo;//entre comillas aquí escribe
var sostenido:Boolean = false;
var razon:Number = this._parent._parent[objetivo]._height / this._height;
var deslizar:Number;
razon = int(razon);
}

on(press){
startDrag(this, false, this._parent.barra._x, this._parent.barra._y, this._parent.barra._x + this._parent.barra._width, this._parent.barra._y + this._parent.barra._height - this._height);
this.sostenido = true;
}

on(release){
stopDrag();
this.sostenido = false;
}

onClipEvent(mouseMove){
if(this.sostenido){
deslizar = (this._y - this._parent.barra._y);
deslizar = int(deslizar);
this._parent._parent[objetivo]._y = -(razon * deslizar) / 2;
}
}

.root Or .parent?
i've got code nested in a movieclip on the stage.

i'm calling to a function that's in an external .as file on the main timeline.

its saying the functions i'm calling from within the movieclip don't exist.

what's the path back to the main timeline?

for instance in AS2 it would have been like:
root.enableButtons(begin_btn); or _parent.enableButtons(begin_btn);

how do i get back to the main timeline to call that function?????

THANKS!!

Can't Use Parent Or Root
Hey everyone!

Please help me - For some reason when using this code:


Code:
stop();
enter.addEventListener (MouseEvent.MOUSE_OVER, link1MouseOver);
enter.addEventListener (MouseEvent.MOUSE_UP, link1MouseUp);

// Functions

function link1MouseOver (event:MouseEvent):void
{
enter.buttonMode = true;
}

function link1MouseUp (event:MouseEvent):void

{

}
parent.play();
I get this error:

(Line 17)

Code:
1061: Call to a possibly undefined method play through a reference with static type flash.display:DisplayObjectContainer.
When deleting the last line, parent.play(); it works fine.
It seems that I can't use parent.

If I change parent.play(); to _parent.play(); it says:

Code:
1120: Access of undefined property _parent.
Please help.

Thanks

Do I Need .root Or .parent?
Hi guys, I'm creating a course program and im a little stuck. I have 3 frame in a movie clip (not on the root menu) that contain movie clips. I have 2 buttons in the first frame that go to the other two frames depending on which is pressed. button 1 goes to frame 2 and then inside the movie clip to play an animation. Button two does exactly the same but plays a different animation inside the 3rd frame.

What i need is for the animation that gets played to return up a level to the first frame in the movie clip above and stop ready to be played again if the same button is pressed. What would be the best coding for this? I havnt got a clue of the syntax i need. Iv seen people using .root and .parent but i dont no which i would use?

please help me if you can.

Really appreciate it!

I have included screen grabs for you to clearly see what im doing.

Root Or Parent In AS3.How?Please Help Me
Hi!
I have a MC on my stage with an instance name of news. I want to set its width and height from inside itself(when I press a button for example). In older versions of flash I would do parent. or root but I dont know how to make it with AS3.

How should I reference this news MC from inside itself?

[F8] Help With Root, Parent And Children...
hi all!
need some help with some scripting please. i really don't know much...but enough to be destructive.
i understand the relationships betweens roots, parents and children only in the sense that they reside in each other and are paths (?).
all (root, parent, child) of my buttons will be movie clips.
all of my buttons will have onRollOver, onRollOut, and onRelease animations.
i am using flash 8

here is what i am trying to do:
my root timeline is my opening page
if i click mc_button_1 it takes me to my gallery (parent timeline) where mc_buttons_4,5,6 will be pictures
if i click on a picure (mc_button_4) the picture enlarges and takes me to mc_button_7 (child timeline)
if i click on the enlarged picture (mc_button_7) the picture fades and takes me back to the gallery (parent timeline)

my main buttons on the root timeline will all have simular parents and children under them so i can do the same thing with mc_buttons_2,3 that i am doing with mc_button_1

if someone could help me get from the root to the parent then to the child i would be most grateful.
if you give me the exact coding for one path i can probably fill in the rest.

drawing of timelines and buttons is attached

thanks so much!

Root/parent Problem
I know it's a matter of targeting (aka use of _root and _parent), I'm almost sure, but can't figure out where in the script I should make the change. I tried to change what I think would be logical but buttons started to lose their functionality.

I have the main swf that loads "conceptual.swf" in a movie clip located in the main timeline, upon a button press. I had been struggling with my movie clip duplicates but finally I had them work. However these MCs work only when I control the "conceptual.swf" itself and does not work when loaded inside the main timeline.

In the "conceptual.swf" there are 4 frames:
1st: there's the preloader
2nd: dummy (all the mc's to be attached into another mc later on reside in this frame. preloader skips this when it gets to 100% and jumps to the 3rd)
3rd: there are the duplicated buttons via actionscript
4th: there's a movie clip in which loads the selected work via the buttons in the previous frame

When I control the movie, there's nothing wrong about it, but when it's loaded into the main swf I have, material to be loaded inside the duplicated buttons isn't loaded, the text that normally gets visible upon RollOver doesn't show up, and finally action fails totally.

The duplication code I wrote in the 3rd frame is:

ActionScript Code:
stop();
var menuItemNr:Number = 5;
buttonNameTag1 = "the very first button";
buttonNameTag2 = "the second button";
buttonNameTag3 = "the, uhm, third button";
buttonNameTag4 = "how 'bout a fourth?";
buttonNameTag5 = "the last one";
for (i=1; i<=menuItemNr; i++) {
    btn0.duplicateMovieClip("btn"+i, i);
    btn0._visible = false;
    _root["btn"+i].someValue = i;
    btn1._x = 329;
    btn1._y = 111;
    btn2._x = btn1._x+136;
    btn2._y = btn1._y;
    btn3._x = btn2._x+136;
    btn3._y = btn1._y;
    btn4._x = btn1._x;
    btn4._y = btn1._y+106;
    btn5._x = btn2._x;
    btn5._y = btn4._y;
    btn6._x = btn3._x;
    btn6._y = btn4._y;
    btn7._x = btn1._x;
    btn7._y = btn4._y+106;
    btn8._x = btn2._x;
    btn8._y = btn7._y;
    btn9._x = btn3._x;
    btn9._y = btn7._y;
    _root["btn"+i].btnGra.attachMovie("btn"+i+"_sb", "btnGRA"+i+"_sb", 1);
    _root["btn"+i].onRollOver = function() {
        if (myButtonVar != this.someValue) {
            myButtonVar = this.someValue;
            _root["btn"+myButtonVar].gotoAndStop("over");
            _root["btn"+myButtonVar].btnMC.btnGra.attachMovie("btn"+myButtonVar+"_sb", "btnGRA"+i+"_sb", 1);
            _root["btn"+myButtonVar].btnMC.btnOrig.attachMovie("btn"+myButtonVar+"_rnk", "btnOrig"+i, 1);
            this.btnName.text = _root["buttonNameTag"+myButtonVar];
        }
    };
    _root["btn"+i].onRelease = function() {
        _root.gotoAndStop(4);
        _root.setRecentWork("conceptual"+myButtonVar);
        trace("conceptual"+myButtonVar);
        _root.myButtonVar = 0;
    };
    _root["btn"+i].onRollOut = function() {
        _root["btn"+myButtonVar].gotoAndStop(1);
        _root["btn"+myButtonVar].btnGra.attachMovie("btn"+myButtonVar+"_sb", "btnGRA"+i+"_sb", 1);
        _root.myButtonVar = 0;
    };
}

In all these above there's only one that needs to trigger an action in the timeline of the main swf: the one called setRecentWork.

Hope someone can help.

Greetz..

Can't Tell Root Or Parent To Play
This is very simple - I have a main game interface into which I have loaded a game movieclip.

When the game is done, I have a button (in the game movieclip) that tells the main timeline to play (so we can go onto the next game).

For some reason that is not working for me. I'll attach my code below.

in addition to nextFrame I have tried play, goto statements - everything I can think of.

I don't get any errors, and the trace function works.








Attach Code

myButton.addEventListener(MouseEvent.CLICK, doSomething);
function doSomething(event:MouseEvent) {
trace("myButton clicked");
MovieClip(root).nextFrame();
}

Root, Parent, And This.. Confusion..
I'm working with several nested movie clips.

My Main container (the GUI), and the content MC's.

The Main Container loads, via a button, another SWF file into the MC "_root.content" (_root.content.loadMovie("filename.swf"))

Within that loaded swf file I've got a script to load information from an XML file, and add it to several dynamic text boxes. The XML loads fine, and the SWF file works fine, as long as it isn't in my container movie..

itmHeader = _root.attachMovie("movieName", "movieAlias")

I have tried root, parent, and this.. and none of them work while the SWF file is loaded into the container movie.. and the only one that works when I run the SWF file by it's self _root.attachMovie is the only command that shows the information as intended (at all).

The Tutorial "Root, Parent, and This" didn't help at all..

Am I doing something wrong.

-Kedaeus-

Parent And Root Problems
ok so here is my problem, I have an .fla and .as file named Main.fla and Main.as respectively, I have an object called ball that I dynamically place on stage from the library like so

//code in Main.as extends MovieClip

var ball:Ball = new Ball();
addChild(ball);

//code in Ball.as

public function Ball(){
trace(MovieClip(parent));
}

the object appears on stage
however the trace returns null, like the parent doesn't exist, any ideas

Root, Parent, And This.. Confusion..
I'm working with several nested movie clips.

My Main container (the GUI), and the content MC's.

The Main Container loads, via a button, another SWF file into the MC "_root.content" (_root.content.loadMovie("filename.swf"))

Within that loaded swf file I've got a script to load information from an XML file, and add it to several dynamic text boxes. The XML loads fine, and the SWF file works fine, as long as it isn't in my container movie..

itmHeader = _root.attachMovie("movieName", "movieAlias")

I have tried root, parent, and this.. and none of them work while the SWF file is loaded into the container movie.. and the only one that works when I run the SWF file by it's self _root.attachMovie is the only command that shows the information as intended (at all).

The Tutorial "Root, Parent, and This" didn't help at all..

Am I doing something wrong.

-Kedaeus-

Set Variable In Parent/root
I have a nav system that has button embedded inside movie clips. On press I need to set a variable to the parent. Having trouble with the scripting.

Thanks advance for any help

TSL816

Help With Root, Parent And Children Please...
hi all!
need some help with some scripting please. i really don't know much...but enough to be destructive.
i understand the relationships betweens roots, parents and children only in the sense that they reside in each other and are paths (?).
all (root, parent, child) of my buttons will be movie clips.
all of my buttons will have onRollOver, onRollOut, and onRelease animations.
i am using flash 8

here is what i am trying to do:
my root timeline is my opening page
if i click mc_button_1 it takes me to my gallery (parent timeline) where mc_buttons_4,5,6 will be pictures
if i click on a picure (mc_button_4) the picture enlarges and takes me to mc_button_7 (child timeline)
if i click on the enlarged picture (mc_button_7) the picture fades and takes me back to the gallery (parent timeline)

my main buttons on the root timeline will all have simular parents and children under them so i can do the same thing with mc_buttons_2,3 that i am doing with mc_button_1

if someone could help me get from the root to the parent then to the child i would be most grateful.
if you give me the exact coding for one path i can probably fill in the rest.

link to drawing of root, parents and button paths

thanks so much!

Get Vars From The Root Swf
hi i have two swf files, a preloader witch loads main.swf

in preloader on the maintimeline i set this var

var lang:String = "de";


but i cant trace it in my main.swf

trace(root.lang);

how do i get this var?

Inertia Probl. Root?parent?
I used this code to make my content slide using inertia code.Problem is the mc that holds the code for inertia(see below) is placed inside another mc.This mc is placed again in another mc.So code whill be _parent or _root.These two don't work so what should I call it instead to make this work.I know root is straight from the scene,parent inside an mc.But this is inside inside an mc.

Hope someone can help out.Big thx in advance.
Grtz

onClipEvent (load) {
_x = 0;
_y = 0;
div = 5; //This value just determines the speed
//the transistions.
}
_x += (endX-_x)/div;
_y += (endY-_y)/div;
_parent.home.onRelease = function() {
endX = 0;
endY = 0;
};
_parent.works.onRelease = function() {
endX = -250;
endY = 0;
};
_parent.skills.onRelease = function() {
endX = -500;
endY = 0;
};

LoadMovie Using Root Parent Or This? Or Is FF The Villian?
Hi All,

I’m kinda a newbie, not a hard core coder, more from the design side.

Scenario
I have a (“stage.swf”, 0); loaded into that are the (“header.swf”, 101); and (“footer.swf”, 100); and then the (“mainMenu.swf”, 15); All is sweet. The (“mainMenu.swf”, 15); has four buttons, three of which load linear movies, sweet. All code is on an action layer.

Check it here: http://www.spindlelegs.co.uk

PROBLEM:

Download the prob .fla here:
http://www.spindlelegs.co.uk/the_wel...econds.fla.zip

My portfolio section is interactive, built on one time line with 14 labelled sections, click a header section and the play head jumps to it’s labelled section and play it’s anim. Instantiated header sections are coded as below:


Code:
_root.brouchure_btn.onRelease = function() {
gotoAndPlay("01");
unloadMovieNum(15);

_root.catalogue_btn.onRelease = function() {
gotoAndPlay("02");
unloadMovieNum(15);

_root.dm_btn.onRelease = function() {
gotoAndPlay("03");
unloadMovieNum(15);
etc... There are 14 of them.

After a header section plays it’s anim, again on the action layer I have this code for each sub section button.


Code:
_root.popUp11_btn.onRelease = function() {
gotoAndPlay("descend");
loadMovieNum("brochure10/brochure11.swf", 15);
};
_root.popUp12_btn.onRelease = function() {
gotoAndPlay("01descend");
loadMovieNum("brochure10/brochure12.swf", 15);
};
_root.popUp13_btn.onRelease = function() {
gotoAndPlay("01descend");
loadMovieNum("brochure10/brochure13.swf", 15);
};
etc... Upto 18 _btn on some. Average around 5.
The examples above are all _root. I have also tried _this. and _parent.

Click the header sections and the play head jumps to that section, plays the anim, stops and waits user interaction. After days of testing it works fine, put it live and the play head plays that anim, the remaining 14 buttons still activate their anim on clicking but further mouse movement sends the play head back to the section 01 anim, which plays once.

WHAT IS GOING ON???

Basically, I have a movie that loads a choice of four movies, three of which work, the fourth loads an interactive movie with 14 sections which don’t work. Do I need to use _this. _Parent. or _root. And would that make a difference?
Have had to contruct a hit area only button with the code onRollover return to frame label "menuDefault" as rollOut wouldn't work. Could this be the culprit?
Any of you out there come across this kind of thing before?

As mentioned check it here: http://www.spindlelegs.co.uk
Or download the prob .fla here:
http://www.spindlelegs.co.uk/the_wel...econds.fla.zip

Bit of nightmare to explain, should anyone want to take the challenge it is best to download the .fla and test movie and see. Much appreciated any who do...

Regards,

Russell
MAC OS 10.3
Flash MX and 8.0

Could Someone Explain How .this .parent .root Works?
I have read kirupa tutorial on this however, it gives little examples on how it works for a beginner like me. Could someone give an easier explanation?

The Meaning Behind Root, Parent, This And Global
Hey guys.
Having been at this forum for a while now i've noticed many times that the use of _root is not recommended. instead its recommended that you use this instead.

My understanding of "this" is that it refers to the object itself....

could someone please explain the meaning behind root, parent, this and global as i am not sure and at the moment i am simply using _root for everything...

cheers guys :)
JacoX

Load Vars From Root Into Mc
in AC2
globvar="myvalue"
i use _root.attachMovie("edit_actives","active_editor",0) to attach mc on the root
then from within this mc i use
mcvar=_root.globvar
how to do this in AC3

Difference Between Level,root,parent,depth
Iam new to flash. Could any one guide me for difference between level,root,parent,depth?

Parent, Root, LoadMoive, And Other Confusing Things
I don't seem to be getting this whole "_parent, _root" thing.

I have my "main.fla" with a blank moive clip on it where a movie is to be loaded into. With an instance name of "dirtholder". I have my external "dirt1.swf" movie that I want to be loaded into "dirtholder". This code works, but it does not load the movie into "dirtholder":
-----------------------------------
loadMovieNum("dirt1.swf",1);
stop()
-----------------------------------

I guess this code is incorrect also:
------------------------------------------------
_parent.dirtholder.loadMovieNum("dirt1.swf",1);
stop()
------------------------------------------------
This code does not seem to work either:
----------------------------------------------
loadMovie("dirt1.swf", "_parent.dirtholder");
stop()
-----------------------------------------------
It loads the main movie but not "dirt1.swf".
If you could just explain to me how the syntax works that would be helpful.

-Thanks

Problem With Path - Parent? Root? Level?
I'm having trouble determining a path. I have a movie clip (playSlideshow) that's supposed to control the starting and stopping of a slideshow. It works perfectly when I test it as a standalone, but when I load it onto Level1 of the main movie, it stops working.

The movie clip (playSlideshow) contains two frames:

1st frame:
on (release) {
this.nextFrame();
}
on (release) {
_parent.peelProperty.startAutoPlay(3);
}
2nd frame:
on (release) {
this.prevFrame();
}
on (release) {
_parent.peelProperty.stopAutoPlay();
}

The movie clip lives on the same timeline as the instance (peelProperty) that it's supposed to start and stop. Since it works as a standalone, I'm guessing that "_parent" is the problem - what should it be?

Here it is as a standalone:
http://1144-90403.peelroom.com/1br.swf

Here it is on level1 - click "one bedroom" to load it:
http://1144-90403.peelroom.com/index.html

Thanks,

julia

Keywords: Parent, Child And Root. How Do They Work?
I'm having the following situation when using AS3:

I'm adding a movieClip from the library in Flash CS3 to the stage by using addChild. I call addChild from a function within the constructor of a class.

I do it as follows: parent.addChild(myMovieClip);

Later when i intend to remove the movieClip, then removeChild is called from within another function in the constructor.
So then i do parent.removeChild(), which works.
But in another instance i call removeChild in a function within a function in the constructor, after which i do parent.parent.removeChild(). However the last instance gives an error during runtime in the output window.

I suspect i do not fully understand the concept of the keywords, parent, child and root. I can't seem to get things to work without errors emerging in the output window during runTime.

The following errors emerge in the output window:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at MethodInfo-247()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at flash.utils::Timer/flash.utils:Timer::tick()


The way i understood the parent keyword was as follows. When i call addChild in a function in the constructor, then it is called within the scope of that function only, but not in the scope of the constructor. So by doing parent.addChild(); i expand the scope of addChild() to the constructor. So when calling removeChild() from another function i have to access the same scope as i did with addChild. So what i then do is parent.removeChild(); Which seems to work.
However the trouble comes when i have to call removeChild in a function within a function within the constructor. So that is 1 level deeper than before, but to still be able to access the original scope of the constructor to which addChild() was expanded i do parent.parent.removeChild(). Now exactly this is what i suspect creates the error during runtime, although i'm not entirely sure.
I suspect that this/my understanding of the parent keyword is wrong as i can't get it to work properly.
Can someone explain this concept to me and/or provide a solution to this problem?

Parent/Root Methods/Properties Non-Existant
My Document Class (main.as) file instantiates a MovieClip (test1.as) and adds it on stage. main also has a function, let's say it's called myFunction. How can I call that function from within test1? I've tried parent.myFunction() and root.myFunction() and even passing the parent as an argument but I get this error in all three cases:

1061: Call to a possibly undefined method myFunction through a reference with static type flash.displayisplayObject.

I've also tried to access it after Event.ADDED_TO_STAGE but it is still the same problem.

How come I can't access the parent/root functions? Is there a way around this?

I've attached my source

Keywords: Parent, Child And Root. How Do They Work?
I'm having the following situation when using AS3:

I'm adding a movieClip from the library in Flash CS3 to the stage by using addChild. I call addChild from a function within the constructor of a class.

I do it as follows: parent.addChild(myMovieClip);

Later when i intend to remove the movieClip, then removeChild is called from within another function in the constructor.
So then i do parent.removeChild(), which works.
But in another instance i call removeChild in a function within a function in the constructor, after which i do parent.parent.removeChild(). However the last instance gives an error during runtime in the output window.

I suspect i do not fully understand the concept of the keywords, parent, child and root. I can't seem to get things to work without errors emerging in the output window during runTime.

The following errors emerge in the output window:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at MethodInfo-247()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at flash.utils::Timer/flash.utils:Timer::tick()


The way i understood the parent keyword was as follows. When i call addChild in a function in the constructor, then it is called within the scope of that function only, but not in the scope of the constructor. So by doing parent.addChild(); i expand the scope of addChild() to the constructor. So when calling removeChild() from another function i have to access the same scope as i did with addChild. So what i then do is parent.removeChild(); Which seems to work.
However the trouble comes when i have to call removeChild in a function within a function within the constructor. So that is 1 level deeper than before, but to still be able to access the original scope of the constructor to which addChild() was expanded i do parent.parent.removeChild(). Now exactly this is what i suspect creates the error during runtime, although i'm not entirely sure.
I suspect that this/my understanding of the parent keyword is wrong as i can't get it to work properly.
Can someone explain this concept to me and/or provide a solution to this problem?

How To Target A Function/variable At Parent/root ?
I have a new class at .as file and linkage it to my library. It

has an event click on it.
In my time line I create a new object of that class.
The problem is, when I click the MovieClip I want to call a

function that placed in my timeline/root or change the variable

that I declare at my timeline/root.
How I suppose to do that?

=== with AS2 ===
- At root
var a:Number=1;
function func()
{
trace("whatever");
}
- I place a movieclip at root and place the script inside it
onRelease=function()
{
_parent.a=2;
_parent.func();
}
================


Anyone can help me?
Thx in advance.

Declare Vars In For Loop For Root
Hey guys, I'm trying to declare 8 vars, but without writing:

ActionScript Code:
var s1:Sound;
var s2:Sound;
var s3:Sound;
var s4:Sound;
var s5:Sound;
var s6:Sound;
var s7:Sound;
var s8:Sound;

or


ActionScript Code:
var s1:Sound,s2:Sound,s3:Sound,s4:Sound,var s5:Sound,s6:Sound,s7:Sound,s8:Sound,

This would be fine for the example, but I'm planning on using the technique for much bigger things.

For the example I want to load 8 songs into these generated vars.

That's fine, but I want to access them elsewhere in the script and/or timeline. So I have a scoping issue. Is there a way to declare a var UP a level?

So what I want to do is something like:


ActionScript Code:
for (var i:Number = 0; i<8; i++){
         var this['s'+i]:Sound = new Sound;
         this['s'+i].loadSound('sounds' + i + '.mp3');
         this['s'+i].stop();
}

Obviously that code does not work because of the var declaration, but I can't figure out how to declare multiple vars in one loop.

So my questions are:

1: How to declare multiple vars in one loop.
2: How to make them accessible to the root, or outside it's scope.

Send Vars To Parent From A Swf In A Pop Up
I can't seem to get the syntax right to target back to my parent window with vars I put into a Load Vars object. Can ne one help??

I set my vars object here:

Code:
Dates = new loadVars();
Dates.StartDate = _root.MyStartDate;
Dates.EndDate = _root.MyEndDate;


I know this is wrong but here is my trouble is, I TRY to send it to the parent window.

Code:
function onSubmit() {
Dates.send("index.cfm", "parent", "Post");
}


I can get it to open it in a new window or in itself but not back to the parent window...


BTW this is in FlashMX
Thanks for any help.

Get Vars From Parent Level
Hi, I have a contact form MC, and inside there is a Submit MC, inside Submit MC I have a hit button to send email, the code is as the following:

Code:
on (release) {
if (_root.contact_form.t2 eq "" or _root.contact_form.t4 eq "" or _root.contact_form.t5 eq "") {
stop ();
} else {
name = _root.contact_form.t2.text;
message = _root.contact_form.t4.text;
loadVariablesNum ("submit.php?t2_2=" + name + "&t4_2=" + message, 0, "GET");
//trace ("test");
_root.contact_form.gotoAndStop(2);
}
}
the submit.php is as the following:

Code:
$to = "webmaster@ac.net";
$subject = "Web Contact form";
$headers="From: webmaster<webmaster@ac.net>
";
$headers.='Content-type: text/html';
$msg = "$t2_2

";
$msg .= "$t4_2

";

mail($to, $subject, $msg, $headers);
It's working, but I want use loadVariablesNum ("submit.php" , 0, "POST") instead of listing all my variables, but somehow I do not know how to pass vars. If I just use loadVariablesNum ("submit.php" , 0, "POST") , the email is sent without any vars.

Thanks for help.

PS, sorry, this is my 1st post, is supposed to be here? or should be under aCTIONsRIPT 2.0?

Grabbing Vars From Parent
I've created a variable in the parent and I am trying to read this variable in a child. The variable is a label (corporate, editorial etc.) and changes when a button is clicked. I want the child movie to jump to the content (label) in the variable. I also want to be able to use the same variable in other movie clips. The following will give me a message in the child movie clip "Access of undefined property subject". Any hints (as simple as poss!) greatly appreciated. Real novice here..

//Code in Parent (Scene 1)

var subject:String = "opening";

gotoAndStop(subject);

trace(subject);


function moveToCorporate(event:MouseEvent):void {
var subject:String = "corporate";
gotoAndStop(subject);
}

this.button_corporate.addEventListener(MouseEvent.CLICK, moveToCorporate);

//Code in Child (movie clip)

gotoAndPlay(subject);

//Where the subject is a frame label







Attach Code

var subject:String = "opening";

gotoAndStop(subject);

trace(subject);


function moveToCorporate(event:MouseEvent):void {
var subject:String = "corporate";
gotoAndStop(subject);
//this.mcMainScreenArea.play();
trace(subject);
//this.mcMainScreenArea.mcMainScreenMovies.gotoAndPlay(subject);
//tell target thumbnail to play Corporate
}

this.button_corporate.addEventListener(MouseEvent.CLICK, moveToCorporate);

AS3 Root Access
In one of senocular's AS3 tips (http://www.kirupa.com/forum/newthrea...=newthread&f=9) he mentioned using a TopLevel class which would then be extending by the document class to create "global" root access. Instead of making my document class extend TopLevel, could I assign stage and root properties directly to the document class, from inside the constructor? For example:


ActionScript Code:
package {    import flash.display.MovieClip;           public class MyDocumentClass extends MovieClip {        public static var stage:Stage;        public static var root:DisplayObject;                public function MyDocumentClass() {            MyDocumentClass.stage = this.stage;            MyDocumentClass.root = this;        }    }}


EDIT: Or maybe not define those two properties at all, just reference MyDocumentClass.root from whichever class I need root access too?

Cheers,
ghjr

Access Mp3's Below Web Root?
Hi, does anyone have a simple way of accessing files on the SAME server, but just below the web root folder?

I'm trying to do a 'loadSound("../../mp3s/filename.mp3", true); but I've found that flash doesn't like to access files below the web root.

Any solutions?
Thanks!

Problem Calling Root Timeline On Parent Movie
Hi,

I've got this problem.

I've got a mainmovie.swf from which i use the following action


FRAME ONE
_root.loadMovie("mymovie1.swf");
stop();

Now I've got a button in mymovie1.swf which I would like to go to mainmovie.swf's timeline frame numer 2.

How is this done? I've tried

on(release) {

_parent.gotoAndPlay(2);

// _parent._parent.gotoAndPlay(2) // tried that
// _parent._root.gotoAndPlay(2) // tried that
// _root._parent.gotoAndPlay(2) // tried that

}

But this doesn't seem to work?

And I neeed to load it with _root, cause when i load it into an empty movieclip - some of mymovie1.swf's animations isn't shown properly.

Any help will be appreciated greatly ...

Thanks,

Mads

Loaded Object's Stage / Parent / Root Null?
What I'm trying to do is pretty simple: load a swf, and then have the loaded swf position something based on the stage width & height. But when I use the Loader object to load something, it seems to be unable to figure out its stage, or its parent. What am I doing wrong?


ActionScript Code:
package com.project
{
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.events.Event;

    public class Preloader extends MovieClip
    {
        private var mainLoader:Loader = new Loader();
        private var mainLoaderRequest:URLRequest = new URLRequest('main.swf');
        private var mainLoaderInfo:LoaderInfo = LoaderInfo(mainLoader.contentLoaderInfo);;

        public function Preloader():void
        {
            addChild(mainLoader);
            mainLoader.load(mainLoaderRequest);
            mainLoaderInfo.addEventListener(Event.COMPLETE, handle_mainLoader_complete);
        }

       
        private function handle_mainLoader_complete (evt:Event):void
        {
            addChild(mainLoader);
        }
    }
}
package com.project
{
    import flash.display.MovieClip;

    public class Main extends MovieClip
    {
        public function Main():void
        {
            trace(root); // returns [Object Main]
            trace(parent); // returns null
            trace(this); // returns [Object Main]
            trace(stage); // returns null
            trace(root.stage); // returns null
            trace(this.stage); // returns null
        }
    }
}

Root And And Parent Issues For Simple Navigation Menu
I have a Navigation Menu on my main timeline that then has the interactivity inside of that. When I click on a button I want it to go to the main timeline and gotoandPlay the respective label that I tell it to go to. Obviously a "root" and "parent" issue.

I looked around and I found something to the effect of using:

Code:


Code:
function onClickHandler(event:MouseEvent) {
MovieClip(this.parent.parent).gotoAndPlay("KnowledgePAGE");
}
Then I get the error message that says:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@2d52f99 to flash.display.MovieClip.
at unityrings_fla::Menu_3/onClickHandler()

With that being said - Here is all the code:
Code:

Code:
stop();
import flash.display.MovieClip;
import flash.events.MouseEvent;

knowledgeMC.addEventListener(MouseEvent.ROLL_OVER, overHandler);
knowledgeMC.addEventListener(MouseEvent.ROLL_OUT, outHandler);
knowledgeMC.addEventListener(MouseEvent.CLICK, onClickHandler);

// if you want a hand cursor
knowledgeMC.buttonMode = true;
knowledgeMC.useHandCursor = true;

function overHandler(event:MouseEvent) {
knowledgeMC.gotoAndPlay("over");
}

function outHandler(event:MouseEvent) {
knowledgeMC.gotoAndPlay("out");
}

function onClickHandler(event:MouseEvent) {
MovieClip(this.parent.parent).gotoAndPlay("KnowledgePAGE");
}
AS3 is certainly not a walk in the park. I need a long learning session considering that I was just feeling comfortable with AS2.

Thanks in advance!
Brian

How To Determine X Y Position Relative To Root Timeline Or Parent MC
Hi,
I'm sure this has been asked many times before but I was not able to find the answer even after searching...
Let's say I have a symbol inside of an MC and the same symbol outside of the MC on a different timeline. I need to know how to determine the X Y coordinates of the symbol in the child MC in relation to the symbol outside of the MC on the other timeline. I don't need actionscript to do this per say, I just want to move the position by hand during the development process and know it's going to be in the correct place.
Thanks,
DC

Accessing Root Vars From Inside Movieclips
Ok say I have on my root frame:

var Num:Number = 0;

How would I change that variable to 1 from a frame inside a movie clip on stage?

Accessing Root Vars From Inside Movieclips
Ok say I have on my root frame:

var Num:Number = 0;

How would I change that variable to 1 from a frame inside a movie clip on stage?

[Q] Disabling Parent's Button Access For Child's Button Access
Hi All,

Havent been to the forum in a long time due to an enduring school term
now that I have gotten back into it, I got into a slight problem

How do I disable the parent's onRelease attributes so that I can allow the child's onRelease function to run . It is a menuSystem where the parent shows first then the subMenu mc are attached to the main Menu.

I tried mc.enabled = false, but this disables the child button actions as well
I tried mc.onRelease = null; which doesnt seem to work
I tried delete this.onRelease BUT maybe cause of syntatical errors, theres no response

Thanks all

How The Crap Do I Access The Root?
This is so annoying. How do I simply access the root inside of a movieclip on the stage? I'm trying to do root.gotoAndPlay() but it doesn't want to do it. I've searched this forum and haven't found a simple answer.
parent.gotoAndPlay(2); doesn't work either >.<

Anyone know?

Root Stage Access
Hi all

Making the jump to AS3 - and don't get the root/stage stuff.
I just want to know how to access root variables/ and then how to access root movieclips from within movieClip instances

eg.

Here's my fla code:

ActionScript Code:
var myX:int = 200;
function Start():void {
    var newCircle:Ball = new Ball();
    addChild(newCircle);
}
Start();

Here's my Ball Class:

ActionScript Code:
package {
    import flash.display.*;
    import flash.events.*;

    public class Ball extends MovieClip {
        public function Ball() {
            this.x = stage.myX;
            this.y = 40;
        }
    }
}


So why does stage.myX not reference my var myX??

Access Root Variables
I want to do something like this:


Code:
class blah {

public function handleClickEvent ( event:MouseEvent ) : void {

this.setIndex ( _root.index );

}


}
I know _root.index doesn't work in ActionScript 3.0, so how do I access root variables from within a class or how do I accomplish what I'm trying to do?

Cannot Access Main(root)
i'm getting null any ideas?

How To Have Access To Parent MC?
How can I access to the stage or to a parent MC from a child MC?

Pass One Movies _root Vars To Its Parent ?
what is the syntax for saying "this swf's _root level" does: _top.varname or _parent.varname do this? when i do _root.varname then the vars get jacked when i try to load the movie into another one because the other movie thinks it's _root is _root ??

AS3 - Acccessing Vars From Parent When Loading External Swf
Hi all!

I'm missing something crucial here I think...

I'm making a preloader/container swf for a site we're producing. My idea is to have a generic preloader swf that gets a number of settings from an xml file, saves them all in a Dictionary and then loads an external swf that is used to display the content. A pretty common approach I think, or isn't it?

The problem though is how do I access variables created in my preloader swf from the externally loaded swf? In AS2 I could just get the vars by starting with _root.whatever but that doesn't seem to be possible in AS3, right?

Can Flash Access Files Outside Of The Web Root
Hi Guys,

Is there a way for flash to load files (images) outside the web root folder
of a website. The reason I want to do that is to prevent the users from
downloading the image files.

Thanks a lot!

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