ActionScript 1/2 :: Movieclip Cannot Access Root Object
Jul 6, 2009I am making another game, and I'm having a problem with the level loader.[code]...
View 9 RepliesI am making another game, and I'm having a problem with the level loader.[code]...
View 9 RepliesI am trying to build an MXML application with Flash Builder 4.5, and I am integrating an API that requires the root of a display object to be a MovieClip. Personally I think this is bad design but I have to go with it. The root object always seems to end up as the stage, because of course I have to add the object to the stage for it to be added to the display list. Is there some way that I can either change the stage type in an MXML application to a MovieClip or is there some way to force a MovieClip wrapper to become the root of a display object?
View 1 RepliesPHP Code:var Root:MovieClipvar container=MovieClip;function menuPress() {trace("trace");}function doIT(parameters,WIDTH,HEIGHT) {container=MovieClip(parent.parent.parent);trace(container.name)//HELP Root=MovieClip(parent.parent.parent.parent);
[Code]...
What I'm trying to do is very very basic however its flat out not working. I'm trying to add a event listener to a button located within a movieclip thats on the root time line.Here's the code:
Code:
function main_init():void
{
[code].....
I have a movielclip, nav_mc, inside which contains my navigation buttons. Lets say I want to effect the time timeline. Before in AS 2.0 I could simply go
jan1_mc.onRelease = function() {
_root.january_mc.gotoAndStop(2);
}
Now in AS 3.0, nothing works.
button_mc.addEventListener(MouseEvent.MOUSE_UP, doIt);
function doIt(evt:MouseEvent):void {
_root.january.gotoAndStop(2);
}
That doesn't work. Returns this in errors:
Warning: 1058: Migration issue: The property _root is no longer supported. This property has been removed. The closest equivalent is the Stage, which serves as the root of the ActionScript 3.0 display list..
Neither does
root.january.gotoAndStop(2)
or
stage.january.gotoAndStop(2)
(1119: Access of possibly undefined property ball_mc through a reference with static type flash.display:Stage.)
or
_stage.january.gotoAndStop(2)
or anything!
How do we do this very simple thing now in AS 3.0
TLDR;
How do I reference the _root timeline in AS 3.0 since _root. no longer works in 3.0
In AS3, how can you access a relative variable within a specific movieclip on the stage?I have a test file that changes the variable "myVar" in one of the displayobject movieclips drawn on the stage. I want to simply trace the current value of this displayobject's myVar for additional purposes.In AS2, you would achieve this by calling the instance name and then the variable contained within.Assuming 3 movieclips existed on the stage named Container1¯, Container2¯ and Cotainer3¯trace(_root.myContainer2.myVar);// returns Hello which is value of variable "myVar" within the movieclip instance named "Container2".How would you do this in AS3?[code]
View 6 RepliesI have a root stage, and a MC that is called from the root stage.Now from that MC, i will called in another MC2, and I wanted to placed the MC in the center of the stage. The reason I could not use normal ADDED_TO_STAGE at MC and define the center is because MC is not place in the exact position of the root stage (as in x, y=0). So if I would target MC2 at MC stage center, it would not be the exact center of the root stage/screen.How can I called the root stage properties rather than adding MC2 into the stage?
View 1 RepliesHow do you tell the root timeline to root.gotoAndStop(2); from the timeline of a movieClip added using addChild?In the maintime line I have
addChild(fade_eng);
and in fade_eng I have the following on frame 20
root.gotoAndStop(2);
this.gotoAndStop(1);
But I am getting 1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:Stage.
i made thumbnails dynamically and i waana access it's child movieclip
var totalThumbs:Array=new Array()
var ThumbMC:MovieClip()
var childThumb:MovieClip()
[Code].....
I have a movie clip symbol placed on the main timeline. The class linkage to that movie clip is Sheet. Inside Sheet class, I make a public string call _textRow. Inside the Sheet's constructor, I create a new TextField call values_txt. Inside the Sheet class again, I create a public function call updateTable().
The document class is Main. From the Main.as, I need to call updateTable() function to update the text inside values_txt. And I need to find a way to get to values_txt. That's where my problem lies.
Actionscript Code:
package{//imported stuff herepublic class Sheet extends MovieClip{public var _textRow:String = " Lorem
Lorem again";public function Sheet(){addEventListener(Event.ADDED_TO_STAGE, initSheet);}public function
[Code]....
Basically, I need to run Sheet's updateTable() from Main.as and update the values_txt.text with _textRow string. But I don't know value_txt's target path.
How can i access an object (movieclip) at a specific frame which is located inside another movieclip. It's something like this : first movieclip - and inside it, on frame 10 i have the second movieclip. I want to access that second movieclip ont that 10th frame.
View 1 RepliesI've dynamically created a whole bunch of movieclips.
I've given each clip a name based on a variable number:
mc.name = "mc"+i;
I've also use addChild to add a couple of dynamic text fields to each movieClip, named myText1 and myText2.[code]...
I'm stunned as to why I cant access the textfield object placed inside a movieClip objectI'm doing this in a subclass as so:I gave the movieClip an instance name of "myMC" and the
Code:
package {
import flash.display.MovieClip;
[code].....
I want to know the difference between [object main timeline], [object Stage] and root in as3? I have read from the topic How stage, root, and MainTimeline Fit Together. But I didn't get clearly.
View 3 RepliesI cant believe how the simpliest things are more complex to do in AS3.I tried to target a movieclip from inside another movieclip called bat_mc and these dont work!root.ball_mc.gotoAndPlay(2);orlevel0.ball_mc.gotoAndPlay(2);
View 1 RepliesSay I have code in my main mxml and in a function like this:
this.addChild(someContainer);
and now I want to refactor code and move this to it's own class and method in a separate file. How could I access root now, since this obviously now points to the new class I created.
I'm currently learning AS3.0 and I'm wondering how to access the root like example in AS2.0 you use the following to access the root.[code]
View 2 RepliesI am migrating to AS 3.0 from AS 2.0 and I am unable to access the root of the main swf from the loaded swf. In AS 2.0 i simply used "_root.gotoAndPlay(frame number); I have also tried Movieclip(this.root).gotoAndPlay(frame number); but it doesn't work.
View 1 Replieshow to add a listener to a button inside of a movieclip that is in the library? Example:Root->work_mc(timeline)->workss_mc(added with Addchild)There is workss_mc in the library that gets loaded when someone clicks a button inside of work_mc. This is achieved with addChild. Within workss_mc there is a close button to close this. I've run into problems with working the navigation with this b/c I need to declare and create a single instance of workss_mc at a scope where it is visible to both click handlers, Doing this will place both handlers in one location. So in order to do that I would need them all to be where the navigation code is, the root. So how can I access workss_mc from the root?
View 17 RepliesThe code below returns the error message "Error 1120: Access of undefined property stage."
function select(event) {
if (event.target.name is Stage) {
currTool.target = null;
} else if (event.target is Sprite) {
[Code]....
I understand the reason for the error is because I'm trying to access the "Stage" when I'm not at my Document Root. The question I have it how do I do this same thing when I'm not at the Document Root?
I have a button in the frame 1 when i clicked it,it goes to the nextframe in nextframe i have movie clip named "circle". in frame 1 in action layer i have variable named "i" it has a number equal 20; now i'm in "circle" movieclip in the action layer i want to write a command for checking "i" if it's equal 20 the "circle" movieclip play but i can't find "i" how can i access to "i" variable in frame 1 ?
View 4 RepliesI am migrating to AS 3.0 from AS 2.0 and I am unable to access the root of the main swf from the loaded swf.In AS 2.0 i simply used "_root.gotoAndPlay(frame number);I have also tried Movieclip(this.root).gotoAndPlay(frame number); but it doesn't work.
View 3 RepliesI created a movieclip called holder in my Stage and I name it, inside them i put a variable called
name = "whatever"
Now I can't access the variable from root timeline, I try this:
trace(holder.name);
The result gives me undefined! what mean this?
I fixed this error before where the source of the problem was that 'stage' was inaccessible from where I was putting the code (not in root). I deleted it and it ran fine, but the Event listeners that they were attatched to did not work anymore. I need these event listeners but when I try to put 'stage.' back infront it wont work.
This is what I had when it worked (when this file was still the root):
stage.addEventListener(KeyboardEvent.KEY_DOWN, keypressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyreleased);
Now my code is this, and it runs, just without the event listeners working:
addEventListener(KeyboardEvent.KEY_DOWN, keypressed);
addEventListener(KeyboardEvent.KEY_UP, keyreleased);
I am having problems accessing my xml on the server. On my local drive, it works fine. As soon as I load it on my site, it no longer pulls the xml rss feed.
Here is the working example, to get it to work, I had to copy the feed into an xml file, and place it in my fla root folder[code]...
I have this in my fla (Actionscript 2)
import com.pw.Pts;
var gUnitId:String;
I have this in Pts.as
class com.pw.Pts {
function Pts()
{
trace ("Inside constructor");
[Code]....
I want the variable gUnitId in the fla file inside the class file.
I am working on a complex application that was originally developed with AS1 for Flash player6. I am trying to update this to Flash player 9 while keeping the script to AS1.
Now my main movie is published in Flash player 6 and the child movie is published for Flash player 9.
I am opening the main movie in Flash player 9 and it works but from my child movie I am trying to acces a method on the root timeline of the main movie.
Can someone tell me how can I acces the main movie root from within the child swf?
I am migrating to AS 3.0 from AS 2.0 and I am unable to access the root of the main swf from the loaded swf.
In AS 2.0 i simply used "_root.gotoAndPlay(frame number);
I have also tried Movieclip(this.root).gotoAndPlay(frame number); but it doesn't work.
Here's the function with the line with the error:
public static function getViewX():Number
{
return -MovieClip(root).x;
}
For some reason, the same code works now, without any problem at all. I don't know what happened, or why, but I no longer have this problem Here's the original post: To put simply, I created a MovieClip, put it with addChild() to stage, and when I tried to call this piece of code:
[Code]...