What is root in AS3?

Hi guys,
for example, in this .as file, what is root? And "this" is a reference to the class?
ps. This .as is connected with a .fla
package  {
    import flash.display.MovieClip;
    import flash.events.Event;
    public class FlashVars extends MovieClip {
        public function FlashVars() {
            carregarFlashVars ();
        private function carregarFlashVars (): void {
            this.root.loaderInfo.addEventListener (Event.COMPLETE, mostrarValor);
        private function mostrarValor (e: Event): void {
            texto_txt.text = e.target.parameters.nome;

"But if the SWF is loaded into another SWF, root becomes the hosting SWF."
This is not true. root is the same for the same swf and doesn't change even when it is loaded into another swf.
Here are three classes that will demonstrate it. Just compile them into the same directory with respective names. When GrandParent swf is run the following traces are displayed:
[object GrandParent] root = [object GrandParent]
[object Parent] root = [object Parent]
[object Child] root = [object Child]
Which, again, shows that root did not change.
package
     import flash.display.Loader;
     import flash.display.Sprite;
     import flash.events.Event;
     import flash.net.URLRequest;
     public class GrandParent extends Sprite
          public function GrandParent()
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          private function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
               trace(this, "root =", root);
               var loader:Loader = new Loader();
               loader.load(new URLRequest("parent.swf"));
               addChild(loader);
package
     import flash.display.Loader;
     import flash.display.Sprite;
     import flash.events.Event;
     import flash.net.URLRequest;
     public class Parent extends Sprite
          public function Parent()
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          private function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
                        trace(this, "root =", root);
               var loader:Loader = new Loader();
               loader.load(new URLRequest("child.swf"));
               addChild(loader);
package
     import flash.display.Sprite;
     import flash.events.Event;
     public class Child extends Sprite
          public function Child()
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          private function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
               trace(this, "root =", root);

Similar Messages

  • What is root when converting AS3.0 to Create js?

    Hi All,
    Does anyone know what MovieClip(root).play(); is when converting to Create JS for Html5 Canvas?
    Many thanks.

    I wanted to come back and update this thread in regards to CreateJS and 'root' It seems that as well as using this.parent.play(); exportRoot.play(); also works.
    I am however struggling to check variables on the main time line from inside a movieClip.
    // MainTimeline
    var animVar = 1;
    //Inside movieClip
    this.stop();
    if( animVar == 1 ) {
            alert('animVar is one!');  
        else {
            alert('animVar is not one!');
    I have tried this.parent.animVar = 1 exportRoot.animVar = 1 but neither can check the variable on the main timeline from inside a movieClip. Any help would be appreciated.

  • What is wrong with as3

    this is not a question about 'how i do X'. is rather a 'discussion' (flame or whatever, but to defend or argue about aspects, not people) about 'what is wrong with as3' and what aspects whould be taken into consideration for updates. right now i am using as3, and since i paid for this license, i choose this tool over some alternatives and i am using it to do stuff for other people who pay me to do it, i think it can be helpful for all of us if some actions are started in the right direction. i have already posted about 'all people in adobe are dumbasses that do not know how to make a scripting tool and are messing up my work', but i was pissed at the time (i still am pissed) but i believe this is not the right aproach. instead, if this goes to the right people in adobe, we all may get something in the future, like better and easier todo apps and web presentations.
    pre: not only about the as3 specification, but COMPLY with the specification that you set. for example, some time ago there were problems with matrix transforms. this was corrected later with a patch. but this means it is not even doing what is is supposed to do
    1. scriptable masks and movement, sprites and child sprites: there is a sprite with a mask, the mask is a shape drawn via script, something like
    somemask=new shape();
    somemask.graphics.beginfill();
    (...etc)
    somesprite.mask=somemask;
    just like that. now add some child sprites to 'somesprite', and make 'somesprite' move, scale and rotate. there you will have something like a kaleidoscope, but not what you expected to do with your script. as the child sprites move in the parent mask, you will see that the child sprites appear or dissapear kind of randomly, and if the child sprites are textfields, it may be that the text is rendered outside the mask, or partially rendered outside the mask (as in only part of the text), rendered with the wrongf rotation or in the wrong place. some child sprites are clipped correctly, some dissapear totally when only a part should dissapear (clipped) etc.
    way around: have not tried it yet, but i have the impression that bitmaps have different criteria for clipping, so i am thinking of trying this: appli an empty filter (a filter with params so it does not have any effect on the sprite or in the textfield) so the sprite is rendered as bitmap before doing anything else with it. as i said, i have not done it yet, but it may be a way around this problem, to avoid all this inconsistency with clipping
    1-b. inconsistency between hierarchy and coordinates, specially masks: you apply a mask to a sprite, yet the sprite has a set of coordinates (so 'x' in the sprite means an x relative to its container), yet the mask applied to the very same sprite, as another reference as reference for coordinates (like the stage)
    2. painting via script: in any other languaje, in any other situation, something like:
    beginFill(params);
    (...stuff 1)
    endFill();
    beginFill(params);
    (...stuff 2)
    endFill();
    (...etc)
    means: render region of block 1, then render region of block 2 etc, and no matter what, it should be consistent, since there is noplace for ambiguity. if you read it, you may think what that means, even if you dont run it you may have an idea of the picture you want to draw, but not with as3. as3 somehow manages to screw something that simple, and mixes all the blocks, and somehow uses the boundaries of one block as boundaries for other block. is like all blocks are dumped into whatever, and then uses all lines defined into it as boundaries for a unique block. it changes all boundaries and generates inconsistency between what is shown and redraw regions of the resulting picture, like lines that go to the end of the screen and then dont go away in the next frames, even tough the beginfill endfill block should prevent it
    3. event flow: i dont know what was the policy behind as3 event flow design. it is in no way similar or an extension to previous event flow, neither with any event flow in any other plattform. i dont know how most people start with as3; in my case, i unpacked, installed and when i tried to do something with what i already knew i could not, so i started reading the as3 docs, and since is like 800 pages long, i just read the basics and the rest i would 'wing it'. in the part of the event flow, there was something about bubbling and stuff, it was not clear at all and when i tried to do what is was said in the documentation (like preventing events to 'bubble', as is called in the documentation), i could not see any effect but i could see it was a mess. flash is not the only thing out there to work with pictures or to work with mouse events, but is the only one that deals with things like 'target' and 'currentTarget'. my first experience on needing this was when i was dealing with my own event handlers (so the only thing that had control over mouse was the stage, and i would admin everything via script). there were events generated everywhere, the stage got events that were not genrated directly over the stage, but got there not with stage coordinates but the coordinates relative to the sprite that generated the event. so if i hover the mopuse over the stage, and the stage has some things on it how does it work? i get multiple event calls, like it was hovering multiple times over the stage in a single frame, but in each call with different coordinates? and what if i set all child sprites as mouseenabled=false or compare like 'if (event.target != event.currenttarget)', what if i move the mouse over a child, does it prevent the move mouse event at all? or does it filter only the event call with only stage coordinates? in my case, every time i move over another clip (with mouseenabled = true), the stage gets it as 'mouse up', even tough there was never a mouse release, what the hell? do even the people at adobe know how to handle events with their own tool when they require it? why does an event 'bubble' when i have not specifically tell it to do it? mi thought is that this event flow was very poorly conceived, and tough the intention may have been that there were different cases and it shopuld cover all cases, they actually introduced new problems that were not present in traditional ways to handle it, and it is neither the easier way to handle things, and this way, a very simple problem turns into a very ugly thing because it must handle things that were not neccesary to handle, or were implicit in other situations.
    4. legacy: since as3, all interaction is different, and if you want to do things in the new plattform, using the new features, what you already knew just goes to the garbage can. when a new tool arrives, it should be an extension to previous tools (which is a reason to update instead of just buying a new tool from a different vendor). if everything i had or knew just means nothing from now on, then i can not say 'i know flash script', and my previous knowledge gives me no advantage when aproaching the new version. as3 is a new aproach that requires doc reading and stuff, even if you knew something about previous as specifications or other oo languajes. if you decide to change things from now on, like the things mentioned in this post, instead of just throwing away everything the users alerady knew about the tool, do like in java releases, they mark some things as 'deprecated', they keep working as they should, give a warning, but also a message saying this feature is deprecated, we suggest you use this library instead.
    5. lack of previous functionality: if you 'update' something, it meand all previos functionality is still there (probably improved, but not with bugs if it was working fine), plus something else. now it seems backwards, there are some things that could be done in previous versions but not in this one, like 'duplicatemovieclip'
    6. inconsistency with scripting/programming paradigms: (ok, fancy work, but fits perfectly here): as3 proposed ways to handle things, but the people who designed it got 'too creative', and they did something that is not consistent neither with previous versions of as or with other languajes. the documentations is full of things like 'it looks like x languaje or languaje family, but instead of using XXX word, you must use YYY'. great, what is this? namespaces 'work like', but 'differently' for example from java, .net, .c. its got the idea that a namespace means a grouped functionality but there are rules about where should be placed the file (ok, java has this also, .net takes care of it automatically if all files are registered in the project), but what you got is a mess that 'if you know other languajes you got the general idea, but nonetheless, even if you knew this or previosu versions of as, you still have to read whatever we decided arbitrarily just to be different'. namespaces, event handling, vars definition which is not like previous scripting neither like fully typed languajes.. is just a mess.
    7. lack of scripting and graphics integration: unlike flash and adobe tools that just got on the graphics side leaving all the scripting integratuion apart, most tools from other vendors integrate very well interacton with what is on the screen. the script editor: very poor. autocompletion? a drop down list that does not heklp at all, appears in the wrong places, and when you need it to go, it does not go (so if i want to move away from the uncalled drop down list, i have to click somewhere else, making developement slowewr instead of helping, so the drop down list does not capture all events when i dont want to). in other ides you double click somewhere and it will go to the part of code relevant to that event or whatever. for example microsoft tools, ok i am antimicrosoft, and one of the reasons was that when windows 95 got to market proposing itself as the ONLY pc os you could use if you wanted to keep useing the apps you already had, it was a lousy product full of flaws but you had to keep using it because you had no choice. what is so different from what is happening with flash just now? yet the ide of c# is awesome, works very well and seems reliable.
    adobe people: not all user are designers that just make pretty pictures. if it is not intended for scripting then why is it there. and if there are corrections to be done, they should patch all versions, not only the last one. previous version users also paid for their versions.

    Well, there is no point in arguing.
    I personally believe AS3 does exactly what it promises to do within limits (read: reasonable limits) of ECMA type of language. And sometimes it doesn’t do what we expect it to for it cannot possibly emulate everyone’s thinking process. The task, I guess, is to learn to think in terms of AS3 – not to try to make AS3 think like us. No language covers all the grounds. And no, it is not Java - with no negative or positive connotation. It is what it is. Period. I just hope that AS5 will be more Java like.
    You are right about the fact that it is not necessary to know all the aspects of language in order to perform the majority of tasks. But it is paramount to have a clear idea about such fundamental concepts as display list model and events. For instance, depth swap has no meaning in terms of AS3 because display list object stacking is controlled automatically and there is no need for all these jumping through hoops one has to perform in order to control depth in AS2. There no more gaps in depths and one always know where to find things.
    Similarly, there is no point in having duplicateMovieClip method. More conventional OOP ways of object instantiation accomplishes just that and much more. Just because OOP object instantiation needs to be learned doesn’t mean past hacks have place in modern times. duplicateMovieClip is a horse carriage standing next to SUV. What one should choose to travel?
    Events are implemented to the tee in the context of ECMA specifications. I consider Events model as very solid, it works great (exactly as expected) and never failed me. True, it takes time to get used to it. But what doesn’t?
    By the way, speaking about events, contrary to believe in Adobe’s inconsideration to their following. Events are implemented with weakly reference set to false although it would be better to have it set to true. I think this is because there are smart and considerate people out there who knew how difficult it would be for programming novices to deal with lost listeners.
    I think AS3 is million times better than AS2. And one of the reasons it came out this way is that Adobe made a very brave and wise decision to break totally loose from AS2’s inherent crap. They have created a totally new and very solid language. If they had tried to make it backward compatible – it would be a huge screw up, similar to how our friends at Microsoft are prostituting VB and VBA – extremely irritating approach IMHO.
    Also, Flash legacy issues shouldn’t be overlooked. Flash did not start as a platform for programmers. Entire timeline concept in many ways is not compatible with the best OOP practices and advancements. I think for anyone who is used to writing classes the very fact of coding on timeline sounds awkward. It feels like a hack (and AS2 IS a pile of hacks) – the same things can be nicely packaged into classes and scale indefinitely. As such I wouldn’t expect Adobe to waste time on hacking timeline concept issues by making smarter editor. They have made a new one – FlexBuilder – instead. Serious programmers realize very soon that Flash IDE is not for developing industrial strength applications anyway. So, why bother with channeling great minds into polishing path to the dead end?
    I would like to state that all this is coming form a person who knew Flash when there was no AS at all. And I applaud every new generation of this wonderful tool.
    I believe Adobe does a great job making transition from timeline paradigm to total OOP venue as smooth as possible. And no, they don’t leave their devoted followers behind contrary to many claims. They are working on making developing Flash applications as easy as possible for people of all walks. Welcome Catalyst!
    Of course there is not enough information about AS3 capabilities and features. But, on the other hand, I don’t know any area of human kind activities that does.

  • What is root AM

    Hi,
    I made some changes in seeded AM (LearnerSearchAM). But I want to extend this AM and deploy the extended AM in server so extend of version does not affect the changes.
    But I find there is bug in substitute the root AM .
    I am not sure what is root AM ? Is root AM means seeded AM ?
    This AM is for search region only. Can I sustitute this AM ?
    Thanks,

    Thanks Pratap,
    I did as you told me and I get that the AM which I want to sustitute is not a root AM.
    But I extend AM and substitute it but I find that there are not changes reflected on server.
    First I take whole folder structure in my jDeveloper.
    I made a new business component and add new AM and extend the old one.
    After that I generate jpx file and updated in database
    But still I am not able to see the changes..
    When I click on about this page the AM is shown old one. So will it be new AM name?
    Thanks,
    Krunal

  • What is rooting and flashing

    can anybody help me to understand what is rooting and flashing phone means?
    what are the benefits and disadvantages of it ?
    and how it can done ?
    Solved!
    Go to Solution.

    Root is just access to core files of system                   
    Rooting is a procedure which grants you the administrator/superuser/ permissions so that you can modify any file inside your Android OS
    Flashing is installing firmwares on a phone
    Discussion guidelines.
    Message me or any other moderator to seek help regarding moderation.

  • In SAP-BW what is ROOT Analysis?

    what are the steps to be followd in root analysis?
    thanx.
    siva

    Hi Siva,
    Check this link
    http://en.wikipedia.org/wiki/Root_cause_analysis
    Regards
    Prakash

  • What is root password ?

    Hi there,
    I tried a few commands in the X terminal with the sudo prefix and it asked me for the root password.
    Does anyone know what it is ?
    Cheers
    Fred

    fhumbert wrote:
    Hi there,
    I tried a few commands in the X terminal with the sudo prefix and it asked me for the root password.
    Does anyone know what it is ?
    Cheers
    Fred
    Just to be pedantic.. if you're using SUdo and it prompts for a password, it is usually asking for YOUR password, not the root password..
    that's one of the differences between su and sudo..
    sudo will only let you run gainroot (sudo gainroot) which will start a root shell if:
      a) you have R&D mode activated, or
      b) you have installed the rootsh package
    otherwise it will tell you R&D mode isn't active..

  • What is root level of backup drive

    I have instructions  to transfer backups from current backup drive to new backup drive. It says to drag the current backup drive to the ROOT LEVEL of the new backup drive. What is the root level?
    Thanks,
    Kathy

    That is not the proper method. Here is the right way to do that:
    Clone using Restore Option of Disk Utility
      1. Open Disk Utility in the Utilities folder.
      2. Select the destination volume from the left side list.
      3. Click on the Restore tab in the DU main window.
      4. Select the destination volume from the left side list and drag
           it to the Destination entry field.
      5. Select the source volume from the left side list and drag it to
          the Source entry field.
      6. Double-check you got it right, then click on the Restore button.
    Destination means the New backup drive. Source means the Old backup drive.

  • Accessing button in root file as3

    Hi, I have created one flash as3 (main.fla) file with next, previous buttons and I have loaded one child swf (firstchild.swf) file into main file. In child swf also I have loaded another child swf (grandchild.swf) [grand child to main file]. I have disabled the next button in main.fla file and trying to enable the button from grandchild.
    My coding look like:
    main.fla:
    next_btn.mouseEnabled = false;.
    grandchild.fla:
    I have tried two scirpts:
    MovieClip(root).next_btn.mouseEnabled = true;
    (root as MovieClip).next_btn.mouseEnabled = true;
    but any one of them doesn't works for me. can any one help me to solve my problems.
    Thanks in advance........
    Note:  Output says...
    TypeError: Error #1010: A term is undefined and has no properties.
      at grandchild_fla::MainTimeline/frame1()[grandchild_fla.MainTimeline::frame1:1]

    If that is line 1 of the grandchild's code then it appears you do not need to have it in the grandchild and could have it execute in the child instead when it loads the grandchild.
    A proper way of having a child talk to a parent is to just have the child dispatch an event for which the parent (main file) assigns a listener when that child is first loaded.  Example:
    Add something to trigger the event in the child:
    dispatchEvent(new Event("eventTriggered"));
    In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf.
    // event handler triggered when external swf is loaded
    function loaderCompleteHandler(event:Event) {
        MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
    function eventHandler(event:Event):void {
        trace("event dispatched in loaded swf");

  • What's wrong with AS3?

    Hi.
    Is it me, or is AS 3 completely different from AS 2? I mean i
    haven't been able to write a single line of code that would work in
    AS 3. I wasn't a master in AS 2 and now i can't create anything in
    AS 3.
    Is there a setting or something for AS 3 to work like AS 2 or
    do i have to learn it all over again, starting from ground zero?
    Can someone help me with some hints?
    Thank you. Any help is much appreciated.

    The best book IMO is "Essential Actionscript 3.0" by Colin
    Moock. It takes you back to the rudimentary basics and guides you
    through them to the more advanced stuff. For me, going from AS2 to
    AS3 was a big leap and Colin's approach of starting back at square
    1 is very helpful.
    Some online resources that are good are:
    1. This forum.
    2. The Adobe Developer Center for Flash -
    http://www.adobe.com/devnet/flash/
    3.
    http://www.gotoandlearn.com/
    - great Flash how-to VIDEOS
    4.
    http://www.kirupa.com/developer/flash/index.htm
    Some good articles on OOP in AS3:
    http://www.awestyproductions.com/tutorials/flash-tutorials/learning-how-to-oop-in-flash/
    http://www.adobe.com/devnet/flash/quickstart/creating_class_as3/
    http://www.communitymx.com/content/article.cfm?page=1&cid=197DE
    http://www.actionscript.org/resources/articles/698/1/Make-your-own-reusable-classes-using- Flash-and-AS3/Page1.html
    http://www.test1labs.com/?p=13

  • What is root cause of Error in InitVXI library. Allocation error in initialization?

    The error result after executing ResMan;  Error: Error in InitVXI library. Allocation error in initialization.
    Hope you can help, thanks....

    Hi ctapa,
    If by chance you receive this error when attempting to run ResMan outside of Measurement & Automation Explorer (MAX), then you will want to refer to this KnowledgeBase article, which details how to fix such an error/crash.
    Curious--what operating system do you run for your VXI system? Also, what version of NI-VXI do you have installed? (You can check this in MAX, beneath the Software tree) In addition to the "Error in InitVXI Library..."  message you receive, do you see your system
    exhibiting any of the problematic symptoms mentioned here? Replying with any additional information on your system and setup would be most welcome and aid in finding the cause of the issue.
    Kind regards, and happy holidays!
    Warm regards,
    pBerg

  • Beginner: Whats a good beginner as3 coding book?

    Can anyone recommend a super basic beginner as3 coding book?

    I've heard that Learning ActionScript 3, A Beginner's Guide is good but I've not read it. I have read Essential AS3 by Colin Moock, but that is not for beginners. I would suggest going to Amazon and searching ActionScript 3 and reading some of the reviews.

  • Our live apps are crashing upon launch and our only insight is that it is a "Viewer" crash - any ideas what the root cause could be?

    They are crashing on iOS 7

    Once you’ve run v32 on a device your keystore winds up getting modified with data that can’t be processed with the v29 viewers, which is why you are seeing the v29 apps crash.
    Neil

  • What is a root folder and how to find folders afte...

    Can someone tell me what a 'root folder' is and how to find icons once you've moved it there?
    It's actually my boyfriend's phone and he uses it for construction site pictures and this morning he woke me up as he couldn't find it anymore. He needs to locate the folder asap as he needs to download pics onto the computer and send them to clients straightaway in batches.
    I connected the phone to the computer using the usb cord and it asks for options on the mass storage transfer. I selected 'images' and then on the control panel of windows, select digital still camera. At this point, the computer stalls as it is trying to search for the pictures folder but cannot locate.
    I'll never move anything to this 'root folder' again. I was just trying to put the icon on the main menu (the way you can do with a blackberry)
    He's already gone for work so took the phone with him, so I thought of giving this forum a try.
    Thanks for help in advance

    Hi there! 
    Well If what you did is you transfered the Pictures from one folder to another using your phone, the Root folder is the main folder so lets say you transfered it to the memory card the root folder is the memory card.
    Hope tis' help!
    "If you think this post is helpful, please click on the green button"

  • What would prevent AS3 to function in an otherwise working copy...

    of Flash CS5.5? I upgraded from Flash 8 to CS5.5 recently. I've used Flash strictly for animations until recently so haven't really tinkered with AS3 at all. I tried some tutorials and got "1120 Property not recognized errors" and assumed that there was something wrong with my settings or my code. After uninstalling, reinstalling, reformatting, and trying several sample files I've found online, it's clear that the AS3 function just is not compatible with my computer. The animation functions work perfectly, but I cannot get the debugger to connect and AS# refuses to recognize any instances on the stage (and, yes, I have triple checked that publish settings are set to do so. ) Is this unusual? What would prevent the AS3 from working when everything else is fine?

    Below is a link to an fla I just created that uses your code with the two objects identified by the code.  This file is created using CS3.  See if it tests okay for you.  If so, see what is different about it that might be the cause for yours not working.  If not, there are some Adobe folks infrequently in the Flash General forum you might want to try to get the attention of.
    http://www.nedwebs.com/Flash/Move_trun.fla

Maybe you are looking for

  • Reset airport  extreme ac not finding old extreme 802.11n

    Have supplanted an Airport Extreme 802.11n with an Airport Extreme 802.11ac. I have performed a hard reset on the .11n. I have configured the .11ac to functionally duplicate the network as managed by the .11n.  Uses the same network ID as before. Wor

  • How to open a file in a JTextArea

    hi.. m having difficulty in opening a file in a textarea..if anyone could help me out.. Parul

  • Windows 8 update fiasco

    My Touch Smart 300-1025uk on which I have installed Windows 8 sucessfully.  Then a few days later an automatic update took place and....... It has gone into a 3 stage  loop, first saying Diagnosising a fault, finishing with "cannot fix the fault". No

  • HT1212 What if the backup is putting in that passcode every time that I have forgotten?

    Okay so everytime I go to restore to an old backup the old passcode automatically is put onto the iPhone so I can't access it because I don't remember it.... A) What do I do now? B) Itunes is now saying this everytime I go to restore: "iTunes could n

  • 2013 is almost over... Where is IPv6?

    Has anyone got IPv6 working or know when it will be available?  I currently have an MI424WR-GEN3I with the right firmware and have "enabled" IPv6, but not getting an address block. What's the latest?