question of addChild in AS3

It is an easy question.

I can't figure out how to set "relativeTo" and "position" when you use addChild in AS3. I understand how to do it in MXML.

So, how would I write this in AS3:

< relativeTo = "{v1}" mx:AddChild >

      <mx:Button id="button1"/>
  </mx:AddChild>

Thank you.

-Laxmidi

Code snippet and the page to answer the question:

Configure the AddChild for the LinkButton class.
lb = new LinkButton();
lb.label = "back at the Login ';
lb.addEventListener ("click", newLBClick);
newLinkButton = new AddChild();
newLinkButton.relativeTo = spacer1;
newLinkButton.position = "before";
newLinkButton.target = lb;

http://livedocs.Adobe.com/Flex/3/HTML/Help.HTML?content=using_states_3.html

If this post answers your question or assistance, please mark it as such.

Tags: Flex

Similar Questions

  • Question of closure of AS3

    I just started to use the closure in AS3 recently and I have a lot to learn. Here's the question. This is a loop that puts 5 balls one above the other on the stage. So far so good. However, I would like to create a situation when clicking on a button, the bottom ball is removed, and then each ball take the place of the ball below one by one, this continues for each click, until all balls have disappeared. .  I created this situation with add/remove child and I thought it might be more effective with a loop. I don't know how to access the balls because I don't have the instance name or class name can I refer too.

    var ball: gBall4M;

    var i: number;

    for (i = 0; i < 5; i ++) {}

    Prom = new gBall4M();

    ball.x = 331.30.

    ball.y = 25 + i * 17

    addChild (ball);

    }

    function release2Ball2(event: MouseEvent): void {}

    }

    using a table is a common way to keep a reference to the object ball.

    var ball: gBall4M;

    var i: number;

    var ballA: Array = [];

    for (i = 0; i< 5;="" i++)="">

    Prom = new gBall4M();

    ball.x = 331.30.

    ball.y = 25 + i * 17

    addChild (ball);

    ballA.push (ball);

    }

    function release2Ball2(event: MouseEvent): void {}

    {if(ballA.Length>0)}

     Ball = ballA .pop ();

    removeChild (ball);

    Prom = null

    for (i = 0; i<>

    ballA [i] = 17 there;

    }

    }

    }

  • question of addChild

    I have a scene titled "start" and a scene called "animals".

    I have a button 'Start' what mc library addChild.

    This mc has 20 images.

    I want to add a script to the last frame of the mc to gotoAndStop(1,"animals")

    I get 'access of undefined property '.

    How can I solve this problem?

    Thank you

    then you fake your configuration.

    If you do not understand the relationship between the main timeline and movieclip containing your code, you can still use the following (as long as the swf with this code file is not loaded into another swf):

    MovieClip (root).gotoAndStop(1,"animals");

  • Does anyone know why I make a yellow question mark by my AS3 .swf?

    I developed some Actionscript 3 animations in CS Flash 5 to use Cp5.  Instead of the green ball in the top corner icon right of the animation, I'm an exclamation mark yellow as I did when with my Actionscript 2 .swfs.  The reason why I created new in AS3 was to avoid any conflict.  Hmmm

    Screen shot 2011-03-17 at 9.52.49 PM.png

    The news that I am using is red circle Moving, Moving red Rectangle and move the Point of Exclamation.  The Green Ball items are Cp5 Gallery.

    Thank you

    Ah... it is what explains why you would be to see these icons.

    When open the Captivate library, it goes through and checks the locations of the objects in the library to see if it can still connect to the location of the source files.

    I would say that the way around this problem would be to have the path to all the source files replicated on each machine you are working on.  So if you have configured a directory C:/projects with exactly the same structure of folder on each PC that you are using, the path to the source files would remain the same.  But according to me, trying to keep all the files in three synchronized machines always upward will be more trouble than it's worth, personally.

  • Question of format XML AS3

    I'm working through a tutorial where the XML format looks like:

    < image CBC =" images/1N.jpg " name =" example 1 " />

    The AS3 code that goes with it is:

    imageText.text = xml.image[slideNum][email protected] ();

    imageText.text being the dynamic text field.  This code works very well, but I do not work with this particular format.  My XML code looks more like:

      < imgTitle>Kalamazoo< /imgTitle>
    < imgURL > images/1n.jpg < / imgURL >

    The previous AS3 code does not work with it. @imgTitle.toString () does not appear.  The Flash will trace the XML file for me, so I know it's reading, but it will not fill in my dynamic text field.

    All thoughts

    She already returns a string, and '@' is used for attributes. All you need is the following:

    myXML.imgTitle

  • Question of FlashBuilder and Flash AS3

    I'm heads down working with the tool, FlashBuilder that is heavy AS3 and Flash CSx have used it for years.

    My question: I guess my AS3 skills that I have developed with FlashBuilder will be directly applicable to Flash CSx, correct? I understand that I will need the context of the application of my AS3 code for Flash objects when you work in Flash CSx, but most of the time my skills AS3 ship from FlashBuilder for Flash CS4/5?

    Thanks in advance,

    Rich

    Skills and knowledge of AS3 has nothing to do with editors in Chief/IDE (including CSx, FlashBuilder, etc.) itself. So once you get your hands on AS3 - no matter where you write your code - it will work the same way in the final compiled swf. However, there is a learning curve involved when getting to know the new software as with any new development environment.

  • Why do AS3 highlighting some fonts, but not others (which are quite common)?

    Hi all!

    I have a simple question that hopefully has a simple answer (which mocks me with his elusive). In the code below (from "University of Programming ActionScript 3.0 Game" of Gary Rosenzweig (2nd ed.)), I declare a style sheet simple using AS3 supported all the tags/attributes to emphasize a HTML link. My question is this: why AS3 don't highlight the chosen font (Arial), but still it will highlight some other fonts I have to substitute (such as "Times New Roman" and "Garamond")?

    // create a basic format
    var myFormat:TextFormat = new TextFormat();
    myFormat.font = "Arial";
    myFormat.size = 24;
    myFormat.bold = true;
    var myStyleSheet:StyleSheet = new StyleSheet();
    myStyleSheet.setStyle("A",{textDecoration: "underline", color: "#0000FF"});
    // create a text field with a Web URL link
    var myWebLink:TextField = new TextField();
    myWebLink.defaultTextFormat = myFormat;
    myWebLink.styleSheet = myStyleSheet;
    myWebLink.selectable = false;
    myWebLink.htmlText = "Visit <A HREF='http://flashgameu.com'>FlashGameU.com</A>!";
    myWebLink.x = 80;
    myWebLink.y = 90;
    myWebLink.width = 400;
    myWebLink.height = 30;
    addChild(myWebLink);
    var myLink:TextField = new TextField();
    myLink.defaultTextFormat = myFormat;
    myLink.styleSheet = myStyleSheet;
    myLink.selectable = false;
    myLink.htmlText = "Click <A HREF='event:testing'>here</A>";
    myLink.x = 80;
    myLink.y = 190;
    myLink.width = 400;
    myLink.height = 30;
    addChild(myLink);
    addEventListener(TextEvent.LINK, textLinkClick);
    function textLinkClick(event:TextEvent) {
     trace(event.text);
    }
    

    The underscore is here, that you're not just allowing sufficient height for the textfield object to show him.  TNR is a shorter police to the same font size, he manages to appear in 30 height.

  • What scripting language is better to create games, AS2 or AS3?

    Just need to know the anser the question in the title for future reference.

    Thank you!

    AS3 by a landslide and CC4 when he made his debut. A better question would be what AS3 (3D) framework to write the game. In this case check out them here:

    http://www.Adobe.com/devnet/flashplayer/stage3d.html

  • Paint Brush tool o pencil tool

    Hi the artist just sent me a vector drawing.

    1. when I scale down it's pixelated - this is supposed to be a vector.

    2. in addition, it weighs 173 kb while similar designs head weigh only 10 KB.

    Is it because they are using the paint brush tool and if it is Yes, then why have the paint brush tool.

    In addition, it would be better to draw in illustrator? Someone told me that illustrator has too many 'points', so when you import into flash it uses more CPU.

    See you soon

    Maybe it's the AS3 forum and your question addresses a non - AS3 material... not even a Flash question - hard to tell since you mention very little about the image.  You should post questions like this in the general forum Flash.

    http://forums.Adobe.com/community/Flash/flash_general?view=discussions

  • Buttons under link to URL in SWF but not HTML?

    I am new to AS3 and have used many tutorials online to make the components needed for my Web site, including a navigation of the menu bar drop-down.

    I coded the URL links to all of the buttons on the navigation bar and buttons as on the menu drop down. My concern is that the buttons as on the menu drop-down work in the SWF file, but they do nothing in the form of an HTML file. I don't get any errors or output problems and I am completely puzzled.

    I did an EventListener for each button/sub-sub-button and on the clip as well as the buttons/sub-sub-buttons are on. Each button has a different name from MouseEvent. Here's what the code for an individual button/sub-bouton looks like:

    chgdiff.addEventListener (MouseEvent.CLICK, mouse1AClick);
    function mouse1AClick (event: MouseEvent): void {}
    var request = new URLRequest("whyischangedifficult.html");
    navigateToURL (request, "_self");
    }

    Navigation is bar that it contains is own film clip (Navbar_mc), where the main buttons are, and the secondary buttons are on another clip of film (Dropdowns_mc) in Navbar_mc. Two video clips are coded so that when the cursor hovers over one of the main keys, on Navbar_mc, part of the chronology in Dropdowns_mc will appear.

    Given that everything works on the SWF, why won't the HTML file?

    You have posted a question on the adobe AS3 forum and I've apparently subscribed to receive email from the answers - send anything.  No problem, not just somewhere at your end.

  • question for the pros on addchild

    Hey people, get help from the community as I'm still learning a few as3. I was able to get a model of a simple exercise. My question had turned around the reasoning for my object do not return to its original state. So if the circle was dragged in the defined region, that it would turn into a square, now the problem that if I dropped the element in the region, there would be a square. Now the problem that if you took the point in the target area and dragged out of the box, that it would turn into a circle (as it was supposed to), but the place would remain around it. A solution was kindly posted to remove the command below in red. How will this affect my use of multiple objects for which I use bring the child to the front. Any information would be appreciated kindly!

    backbutton.addEventListener (MouseEvent.CLICK, Precedentcliquez);

    helpbutton.addEventListener (MouseEvent.CLICK, helpclick);

    answerbutton.addEventListener (MouseEvent.CLICK, answerclick);

    circle.addEventListener (MouseEvent.MOUSE_DOWN, grabMe);

    Import fl.transitions.Tween;

    Fl.transitions.easing import. *;

    Import fl.transitions.TweenEvent;

    Import caurina.transitions.Tweener;

    import com.greensock;

    import flash.media.Sound;

    var I: Object;

    function grabMe(e:MouseEvent):void {}

    = me e.currentTarget;

    me.removeEventListener (MouseEvent.MOUSE_DOWN, grabMe);

    me.startDrag ();

    e.target.parent.addChild (e.target)

    stage.addEventListener (MouseEvent.MOUSE_MOVE, Drachma);

    stage.addEventListener (MouseEvent.MOUSE_UP, dropMe);

    }

    function dropMe(e:MouseEvent):void {}

    stage.removeEventListener (MouseEvent.MOUSE_UP, dropMe);

    stage.removeEventListener (MouseEvent.MOUSE_MOVE, Drachma);

    me.stopDrag ();

    me.addEventListener (MouseEvent.MOUSE_DOWN, grabMe);

    }

    function dragMe(e:MouseEvent):void {}

    e.updateAfterEvent ();

    If (me.x > = 368 & & me.x < = 860 & & me.y > = 103 & & me.y < = 640)

    {

    me.gotoAndStop ("Square")

    }

    on the other

    {

    me.gotoAndStop ("Circle")

    }

    }

    function backclick(event:MouseEvent):void {}

    testmenu. Visible = false;

    }

    function helpclick(event:MouseEvent):void {}

    }

    function answerclick(event:MouseEvent):void {}

    }

    Then replace this line with this:

    addChild(e.currentTarget as DisplayObject);

  • Flash CS6. AS3: How to load the image from a link on an image and addChild (image) on the other?

    How can I addChild outside of magazine images? When I try to addChild on the other images of the same charger, I get an error.
    I need to download all my 10 no images ONLY ONCE and place it on the screen in other frameworks (for the same film Clip).
    Also I can't play this once coded as3 framework. I know how to add an array of images, but I don't need to understand how do it with a single image.

    Here is my charger for images...


       var shirt1 = String()""https://static.topsport.lt/sites/all/themes/topsport2/files/images/marskineliai_png/215.pn g"" "");

       var img1Request:URLRequest = new URLRequest(shirt1);
      
    var img1Loader:Loader = new Loader();
       img1Loader
    .load(img1Request);
       myMovieClip
    .removeChildAt(0);
       myMovieClip
    .addChild(img1Loader);

    You declare the imgLoader outside the service, otherwise it is limited in the service...

    var img1Loader:Loader;

    function onLoaderComplete(e:Event):void
    {

    ...
    img1Loader = new Loader();

  • Questions of AS3

    I have an index.swf is empty and a main.swf, which is a Web site the two files are in the same folder

    the problem I have is that in the index.swf I 1 framework with the following as3 code

    var my_Loader:Loader = new Loader();
    addChild (my_Loader);

    var my_url:URLRequest = new URLRequest ("main.swf");
    my_Loader.load (my_url);

    Now if I click on the swf file index.swf he plays without problem, but if I try to view them in a html it will not load the main swf and play that I can't understand it it works aslong as I do not see html help

    first of all, let flash publish your index.html in the same directory as your index.swf and main.swf.  Open index.html in your browser.

    If there is still a problem, download the html code and SWF on your server and post a link.

  • Table MC AS3 n00b question

    OK I loaded xml in video clips created dynamically, and when the user clicks on these other dynamically created clips video clip appears with more info loaded in XML. My question is how can I go back the information individually for each clip instead of all at once. My code:

    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.events.MouseEvent;

    var theXml:XML;
    var loader: URLLoader = new URLLoader();
    var mcArray:Array = new Array();
    var boxArray:Array = new Array();
    Loader.Load (new URLRequest ("template.xml"));
    loader.addEventListener (Event.COMPLETE, loadXML);
    function loadXML(e:Event):void
    {
    Check = new XML (e.target.data);
    for (var i: Number = 0; i < theXml.name.length (); i ++)
    {
    var theMC:MovieClip = new MovieClip();
    var theText:TextField = new TextField();
    theText.text = theXml.name [i]. @ Title;
    theText.x = 20;
    theText.y = 40;
    theText.selectable = false;
    theMC.addChild (theText);
    theMC.graphics.beginFill (0xff0000);
    theMC.graphics.drawCircle (50,50,50);
    theMC.graphics.endFill ();
    theMC.x = theMC.width * i;
    theMC.name = "mc" + i;
    mcArray.push (theMC);
    mcArray [i] .addEventListener (MouseEvent.CLICK, moClick);

    var descBox:MovieClip = new MovieClip();
    var descText:TextField = new TextField();
    descText.height = 100;
    descBox.graphics.beginFill (0xff0000);
    descBox.graphics.drawRoundRect (0,0,100,200,10,10);
    descBox.graphics.endFill ();
    descBox.name = 'box' + i;
    descBox.addChild (descText);
    boxArray.push (descBox);
    mcArray [i] .addChild (boxArray [i]);
    descText.text = theXml.name [i]. @ Title + ":"+ theXml.name [i]; ".
    boxArray [i] = mcArray [i] there .height-70;
    boxArray [i] .visible = false;
    addChild (mcArray [i]);

    }

    function moClick(e:MouseEvent)
    {

    / * If I try to put a loop here obviously it would display all and when I try to target by e.currentTarget.boxArray [n] .visible = true;

    its not able to find the properties in the table and get the error:

    TypeError: Error #1010: a term is undefined and has no properties.

    to MethodInfo - 1)

    */


    }
    }

    Any help would be greatly appreciated, thank you!

    Load the data separately only must not serious.  I don't see a reason why you want to put a loop in the event handler.  If you add a descBox as a child of each object in mcArray, then you should be able to target the descBox using his name, but I would just change the name to be 'box' for each of them so that you can use the following syntax...

    MovieClip (event.currentTarget) .getChildByName ('box');

    That should be the object descBox, you have added as a child object theMC as long as you assign it the 'name' box (instead of 'box ' + i).

  • noob question AS3 extremely - by using a with the main timeline *.as file

    I'm in the middle of adding a performance monitor to a mobile app that has yet not actionscript, I just want to test the performance of animations

    https://raw.github.com/mrdoob/Hi-ReS-Stats/master/src/net/hires/debug/ Stats.as which is the stats.as file I have in my root with the .fla file

    I removed the folder "net.hires.debug" from the stats.as file location

    What should I type to load the .as file

    It is said to use the addchild function, I am new to as3 and I'm a bit confused with the classes

    now my first layer actions frame, it is said

    addChild (New Stats());

    and during the execution of this

    addChild (New Stats()); It gives me error 1180: call to undefined method possible Stats

    The file named 'stats.as' or 'Stats.as' (show you both ways)?  It should be named Stats.as

Maybe you are looking for

  • WebEx not visible in every night but active in Firefox addon

    I like to use every night with the add-on of Webex (general plugin, ActiveATouch container) but it is not visible in the tab Extensions or modules. I also have Firefox ESR 38.3 and it the add-on is visible and active and works as expected.Sometimes I

  • What displays how many Mbs of chart has your iMac?

    HI, I do not know where to see how many Mbs of graphics has my iMac and I have an idea. see you at Intel hd card, I map hd6000 Intel with 1.5 GB of memory, is the amount of MB/GB of graphics on my iMac, cordially, thijmen

  • MacBook pro locked with a password of the firmware, Help!

    I have a macbook pro, end 2011, which is locked with a password of the firmware, and I do not know. Are their any of you know how powerful hardware hacks, and no one knows a way of hacking the firmware lock? I tried to avoide paying someone to fix my

  • Where can I buy a Satellite A100-920 to the United Kingdom?

    HelloI am buying a Toshiba A100 - 920 to the United Kingdom and although I saw him on the set of PCWorld, they say its not in stock and are unable to give me news of when it could come in stock. Other major retailers such as Dixons and currys also ju

  • Script to show/hide the menu bar in the preferences

    Hi all First of all, my knowledge of script is fairly limited, so bear with me, okay? So, I was wondering if you could write a script that activates / deactivates the system preferences to show or hide the menu bar? I found this article http://goo.gl