Problem with accessing dynamically created movie clips, returns null...

Hopefully this is a stupid question with an easy answer, if my code is straight forward enough.
I am using this snippet of code to create menu items, and then use the jCount variable below to give the clips an index number, like so (which seems to be working just fine):
for(var j:Number=0;j<xmlSubMenuLength;j++){ 
    var mcSubMenuItem:mcSubMenu=new mcSubMenu();   
    addChild(mcSubMenuItem);    
    jCount++;   
    mcSubMenuItem.name = "mcSubMenuItem" + jCount;
    //traces out names correctly
    trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
    mcSubMenuItem.x=mcMenuHolder.x+20;
    mcSubMenuItem.y =mcMenuHolder.y;
    mcSubMenuItem.y+= nextBtnY;
    nextBtnY+=subtopicSpace;
    global_subi.text = String(jCount); //i see the proper count of 10 in the text field
However, when I try to access the clips using this snippet:  
for(var j:Number=0;j<Number(global_subi.text);j++)//
  trace("GLOBAL SUBI = "+ String(global_subi.text));  //traces out 10, which it should
  var scSubMenuItem:String = "mcSubMenuItem" + j;  
  var scSubContent:Object = this.getChildByName(scSubMenuItem);
  trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent); //returns null!
My last trace statement returns null. Can anyone see my error, or explain why I can't access my clips after they have been created?
Thank you muchly,
~Chipleh

Hi kglad,
Thanks for the response.
"it's not clear from the shown code that jCount is initialized." - I've posted the relevant code below, which shows that I'm initializing jCount.
"and it's not clear why you don't use j instead of jCount in that for-loop" - j is used as loop for creating the subtopic movie clips within the i for-loop. So, for each topic in i for-loop, create a group of suptopics using the j for-loop. The j for-loop re-initiates j every time the length of the subtopics is reached(if that makes any sense) - i.e. topic1>subtopic 1,2,3,4 : topic2>subtopic>1,2 : topic3>subtopic1,2,3,4
jCount is used to keep a running count of the total number of subtopcs created - i.e. per the example above, jCount will display 10.
var topicSpace:uint=button_mc.height;
var subtopicSpace:uint = button_mc.height;
var nextBtnY:uint = 0;//whatever;
var jCount:Number = 0;
function createXMLMenu(menuLength:Number,itemName:XMLList):void{
     var navItemText:XMLList = itemName;
      for(var i:Number=0;i<menuLength;i++)
           var mcMenuItem:mcMenu=new mcMenu();        
           addChild(mcMenuItem); 
           mcMenuItem.btnTxt.htmlText = i+1 +". " +navItemText[i];  
           mcMenuItem.ivar = i;  
           mcMenuItem.name = "mcMenuItem" + i;  
           mcMenuItem.x=mcMenuHolder.x;
           mcMenuItem.y =mcMenuHolder.y;
          //kglad's addition
           mcMenuItem.y+= nextBtnY;
           nextBtnY+=topicSpace; 
           var subVar:Number = i;//mcMenuItem.ivar 
           //Submenu content
           var xmlSubMenuLength:Number = xml.sim.bodyText.page[i].subpage.length()
           var menuItemAttachment:MovieClip = MovieClip(mcMenuItem); 
           for(var j:Number=0;j<xmlSubMenuLength;j++)
                 var xmlSubPageNumber:XMLList = xml.sim.bodyText.page[subVar].subpage;
                 var subNavLinkNumber:Number = xmlSubPageNumber[j];
                 var subTitleText:String = xml.sim.bodyText.page[subVar].subpage.subNavItem[j];
                 var mcSubMenuItem:mcSubMenu=new mcSubMenu();
                 trace("mcSubMenuItem.ivar = "+ j+1);
                 var mc2Attach2:MovieClip = MovieClip(menuItemAttachment);
                 mcSubMenuItem.btnTxt.htmlText = j+1 +". " +subTitleText;   
                 mcSubMenuItem.ivar = Number(subVar);
                 mcSubMenuItem.jvar = Number(j);
                 addChild(mcSubMenuItem);
                 jCount++;   
                 mcSubMenuItem.name = "mcSubMenuItem" + jCount;
                 trace ("---------------------------------jCount NAME = "+ mcSubMenuItem.name);
                 mcSubMenuItem.x=mcMenuHolder.x+20;
                 mcSubMenuItem.y =mcMenuHolder.y;
                 //kglad's addition
                 mcSubMenuItem.y+= nextBtnY;
                 nextBtnY+=subtopicSpace;    
                 global_subi.text = String(jCount);
            mcSubMenuItem.lExtend.visible = false;  
global_i.text = String(i);
Then I try to access the clips like so:
-The first for-loop access the topic movie clips, no problem, and traces out scContent correctly.
-The second for-loop traces out null everytime, when I would expect it to be tracing out the names of the subtopic movie clips.
function accessClips(){
     //This will access the topic movie clips
     for(var i:Number=0;i<Number(global_i.text);i++)
           var scMenuItem:String = "mcMenuItem" + i;
           var scContent:Object = this.getChildByName(scMenuItem);            
           trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scContent:Object = "+ scContent);
     //This is supposed to access the subtopic movie clips
     for(var j:Number=0;j<Number(global_subi.text);j++)//
           var scSubMenuItem:String = "mcSubMenuItem" + j;
           var scSubContent:Object = this.getChildByName(scSubMenuItem);
           trace(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>scSubContent:Object = "+ scSubContent);
Hope this makes sense, Chipleh confused. If the code is not clear enough, let me know and I'll try to further clarify.
Thanks again,
~Chipleh

Similar Messages

  • Problem with Access Policies (create multiple resources)

    I'm having a problem with Access Policies:
    The first policy must create a resource.
    And the following policies should create childs on the resource.
    The problem here is that when policies will add the childs, the resource is not provisioned yet.
    And then each one will create a resource but i just want one resource with the childs.
    When the resource is already provisioned, the policies update this resource properly.
    How can I fix this?
    tks

    Ricardo,
    I had a similar problem. In a post-process handler I was managing the user membership in specific roles through the removeMemberUser and the addMemberUser of the tcGroupOperationsIntf class.
    The last parameter of this method was a boolean which, when true, would automatically trigger the access policies programmatically in the post-process.
    The problem is that there also is an OOTB event handler for triggering access policies, so I was basically triggering the access policies twice and duplicated resources were appearing.
    Hope this helps.
    Cheers

  • Problems with button inside draggable movie clip

    I am building a click through presentation that has some small text in it. To maintain the design and allow for readability, I have added a zoom feature.
    Here is the structure of the movie,
    Stage - contains pages movie clip and forward/reverse click buttons for changing pages
         pages_mc - contains 24 frames, one page per frame and buttons
    There is a button at the _root level that uses a tweener to scale the pages_mc up to 170%. When this is clicked, it allows the pages to be dragged around the screen so you can look at different sections. When you click the button again, it returns the pages back to their original size stops drag.
    My problem is, on the pages, there are buttons with links to external sites. Once startDrag has been invoked, I cannot touch the buttons inside the movie clip. Is there a way to make these buttons work?
    I need the finished quickly so any assistance is welcome.
    Code below
    magUp_btn.onRelease = function() {
    this._visible = false;
    TweenLite.to(pages_mc, .25, {_x:-250, _y:-193, _xscale:170, _yscale:170});
    TweenLite.to(magUp_mc, .75, {_alpha:0});
    TweenLite.to(magDown_mc, .75, {_alpha:25});
    magDown_btn._visible = true;
    pages_mc.onPress = function(){
    this.startDrag();
    pages_mc.onRelease = function(){
    this.stopDrag();
    pages_mc.onReleaseOutside = function(){
    this.stopDrag();
    pages_mc.useHandCursor = false;
    TweenLite.to(instr_mc, 1, {_alpha:100});
    magDown_btn.onRelease = function() {
    TweenLite.to(pages_mc, .25, {_x:0, _y:0, _xscale:100, _yscale:100});
    TweenLite.to(magUp_mc, .75, {_alpha:25});
    TweenLite.to(magDown_mc, .75, {_alpha:0});
    this._visible = false;
    magUp_btn._visible = true;
    pages_mc.onPress = function(){
    this.stopDrag();
    TweenLite.to(instr_mc, 1, {_alpha:0});
    I don't know how to turn drag off when I zoom out without using the onPress command, but I know that this is probably what is getting in the way of the button working?
    Thanks!

    One option is to make the background of the pages be the draggable parts rather than the movieclips that contain the pages and buttons.  That way, the buttons could be atop the background and not have their access blocked.
    Instead of coding the pages_mc, you would essentially have the background coded for the drag...
    pages_mc.bkgnd.onPress = function(){
        startDrag(this._parent);

  • Problem with printing dynamically created pages

    Hello,
    I have created a form in Designer 7.1 with one page. When clicking the Print button the script generates additional pages with the instance manager (addInstance) and then I want to print the generated pages. However, when using 'xfa.host.numPages - 1' in the print statement only the first page is printed. When I use a static end value, I get an error message with 'wrong end value for print'. Does anybody know, what I have been missing?
    Thanks, Karin

    No problem with Adobe Reader 8 or 9 .

  • Problem with string dynamically created

    Hi all,
    I have a problem a bit complex I don't know how to solve it: I have a dynamically created program that give a syntax error because a string created inside it is too long and don't stay on a single line, so the program created has some lines like this:
    tot = d_1 + d_2 + d_3 + d_4 + d_5 +
    d_6 + d_7 +  d_8 + d_9 .
    this code doesn't pass the syntax-check before it is executed and the error given is about the second line. So how can I avoid this error ? remember that the program is dynamically created so the code reported is for sample: it's possible to have more than 2 lines.
    Thanks to anyone will give me an hint.
    Gabriele

    Hi!
    Explicitely control the length of your statements when generating them. In your sample you could code your program to create the follwoing lines:
    tot = d1 + d2 + ........ + d8.
    tot = tot + d9 + d100 ...... + d150.
    tot = tot + d151 ..... d999.
    And so on ....
    Regards,
    Volker

  • Problems with accessing website created in iweb

    Hi peops, Have created a website with iWeb and published it to my friends and family. Some can see it, but some get a 'NOT FOUND' message..... has anyone else had that problem? The site is not password protected....
    iMac PowerPC G5   Mac OS X (10.4.2)  

    Some can see
    it, but some get a 'NOT FOUND' message
    Most likely this is because those getting the "not found" message are using a misspelled url. This can happen when you send a too-long version of the url by email or for other reasons. The url everyone should use is just
    http://web.mac.com/username
    It would help if you would provide your url here so people can verify there are no other problems.

  • Trying to dynamically Rotate a Dynamically Created Movie Clip

    Hi As3 Gods...
    I want to rotate a movieClip that is created and animated by a function in the same Code window.
    var electron:MovieClip=new MovieClip
    createElectron(electron)
    electron.rotation=90 ------> I expect the whole animated MovieClip to rotate. nothing happens though.
    // I have a function that receives the electron and build / animates it
    function createElectron( receives the MovieClip + more parameters ):MovieClip
    { bunch of codes
    returns the MovieClip
    It is achievable if I create an external MovieClip through library, and put the createElectron codes inside that movieClip and export it to ActionScipt and then rotate it, but then i donno how to assign Parameters to an external function in the movieClip when i call the electron, i want to be able to tell the function what is the radius, speed, etc. I have never tried creating Classes, donno if it helps me here or not. I think i m failing to sort of WRAP the MOvieClip and the animation inside, so i can rotate the whole thing when returned.

    var electronsH:Array=new Array
    var electron:Sprite = new Sprite();
    buildElectronBeam(8,50,50)
    function buildElectronBeam(atom,repeatHorizontal,wide)
                 For loop{
                       var electron2:Sprite = new Sprite();
                      singleElectron(radius,4,electron2)  // here i send electron2 to be animated and built up in the called function
                      electron2.rotation=90 // This does rotate the electron but not the animation defined for it.
                       electronsH[h]= electron2
                       addChild(electronsH[h]) // shows that animation is still horizontal
    function singleElectron(radius,pixel,electron:Sprite)
    createPoint(pixel)
        function createPoint(radio:uint)
            electron.graphics.beginFill(0xFFFFFF,1)
            electron.graphics.drawRect(0,0,pixel,pixel)
            addChild(electron)
            electron.addEventListener(Event.ENTER_FRAME, movepixels) 
         function Animatepixels(e:Event)
         {   pixel starts to spin on a horizontal line}
    I think my problem is I dont know how to attach this animation to be part of the MovieClip so i Can rotate the whole thing. What i was trying to achieve here is to say flash "Consider whatever going on in this singleElectron function as my MovieClip" but as we both see, electron is the movieClip and animate function just performs something without being a part of MovieClip itself.

  • Accessing dynamically created movieclips

    I have an application that I am adding movieclips to a
    container movieclip through a for loop and repeatedly calling
    myClip.addChild(theNewClip). Now I have a dozen clips in my
    container and it seems like the only way to access the clip is to
    use the getChildByName() method and cast it into a temporary clip
    so I can get at the its properties.
    Is this the best and/or only way to do this? Does the old AS2
    myContainer["theName"].property not work with dynamically created
    movieclips? It doesn't seem to work for me anymore.
    Anyway I am getting the clips now, but I was hoping someone
    could show me a better way to access a dynamically created movie
    clip.

    In AS3, this is probably not much better, but you can
    generically loop through all movie clips:

  • Need help returning correct name from a code created movie clip

    Hello. I am an AS3 n00b with hopefuly a simple question I am designing a simple game in flash. This code creates an array of movie clips and asigns a picture to each one. It is a map screen. What I need is when I click on one of the created movie clips, I need it to return either the index of the clip in the array or the name of the clip. Basicaly anything I can use to tell them apart in the code. Here is the code:
    import flash.display.MovieClip;
    var MapLoader:Array = new Array();
    var strJPGext:String = ".jpg";
    var intContTileNumber:int;
    var strContTilePath:String;
    var intDistStartX:int = 63;
    var intDistStartY:int = 64;
    var intDistMultiplyY:int = 0;
    var intDistMultiplyX:int = 0;
    var intDistCount:int = 0;
    var MapSquare:Array = new Array();
    for (var i:int = 0; i < 729; i++)
             //var MapSquare:MovieClip = new MovieClip();
            MapSquare.push (new MovieClip());
            MapSquare[i].x = intDistStartX + (intDistMultiplyX * 30);
            MapSquare[i].y = intDistStartY + (intDistMultiplyY * 30);
            MapSquare[i].name = "MapSquare" + i ;
            addChild(MapSquare[i]);
            intContTileNumber = i;
            MapLoader.push (new Loader);
            strContTilePath = intContTileNumber + strJPGext;
            MapLoader[i].load(new URLRequest(strContTilePath));
            MapSquare[i].addChild(MapLoader[i]);
            intDistCount++;
            intDistMultiplyX++;
            if (intDistCount > 26){
            intDistCount = 0;
            intDistMultiplyX = 0;
            intDistMultiplyY++;
    stage.addEventListener(MouseEvent.CLICK, reportClick);
    function reportClick(event:MouseEvent):void
        trace("movieClip Instance Name = " + event.target.name);   
    Now all this works fine, it creates the map and assigns the correct picture and places them in the correct X,Y position and it is the correct grid of 27x27 squares. The problem is with the name, when I click on the movie clip, it returns "Instance2" or "Instance5" or whatever. It starts with 2 and then increases each number by 3 for each clip, so the first one is 2, then 5 then 8 and so on. This is no good. I need it to return the name that I assigned it
    . If I put the code in trace(MapSquare[1]) it will return the name "MapSquare1" so I know the name was assigned, but it isnt returning.
    Please assist
    Thanks,
    -red

    Thanks for the resopnse,
    I know I dont really need the name, I just need the index number of the array, but I cant figure out how to get the index name without specificaly coding for it. That is why in the listener event I use event.target.name because I dont know what movie clip is being clicked until it has been clicked on. Basically when a movie clip is clicked it needs to return which index of the array was clicked.
    I could do it this way:
    MapSquare[0].addEventListener(
      MouseEvent.MOUSE_UP,
      function(evt:MouseEvent):void {
        trace("I've been clicked!");
    MapSquare[1].addEventListener(
       MouseEvent.MOUSE_UP,
       function(evt:MouseEvent):void {
         trace("I've been clicked!");
    MapSquare[2].addEventListener(
       MouseEvent.MOUSE_UP,
       function(evt:MouseEvent):void {
         trace("I've been clicked!");
    ... ect
    but that is unreasonable and it kind of defeats the purpose of having the array in the first place. The code that each movie clip executes is the same, eventualy that index will be passed into a database and the data at that primary key will be retrieved and returned to the program. So I just need to know, when one of those buttons is clicked, which one was clicked and what is its index in the array.
    I am a VB programer and in VB this is very easy, the control array automatically sends its own index into the function when one of the buttons is clicked. It seems simple enough, I just dont know how to do it in action script.
    Thanks again,
    -red

  • Problem with Billing due list, relating to Returns Credits

    Hi
    I have a query/ problem with the billing due list
    I cannot seem to be able to create billing documents via VF04 for Returns credits, only via VF01
    I have changed Billing relevance of Item category REN to be A - Delivery related,
    As we previously had problems with incorrect qty being billed IF returned delivery quantity was different to Returns order quantity   - this resolved the problem but I now cannot create billing via billing due list
    Messsage appears ' delivery type LR cannot be invoiced with billing type F2'
    If i enter billing type RE then the document is not gettting picked up at all
    when Billing relevance of item category was B, order related - all seemed to be working ok
    I have copy controls set up from LR to RE with item category REN, with pricing type G
    Please advise how i can get the Returns to appear in the billing due list
    many thanks for your help
    Tony

    Hi,
    In copy controll VTFL
    LR to F2 at item level
    REN >>> Deatila >>> Put billing quantity as - D delivery related
    Kapil

  • Problem with access to SMTP, IMAP, POP3 protocols in CAS 2013.

    Hi,
    we have problem with access thgrough SMTP, IMAP, POP3 protocols in CAS 2013.
    If I test connection to SMTP 25 port from other computer, session end quickly.
    Test from CAS2013 to localhost or public IP is OK (similar also for IMAP and POP3).
    Receive connectors are with defaults settings, firewall is disabled.
    Service Microsoft Frontend Transport Services restarted, but no success.
    Certificate is assigned to IMAP, POP3, SMTP, IIS.
    IIS and HTTP(s), protocols are OK. Clients can connects only thgrough web, mobile (ActiveSync), or with Outlook with proxy.
    Do you have some tip, what to test?
    If I create new testing receive connector on port 26 for anonymous, behaviour is same, quick disconnecting.
    Thank's Mirek

    Hi,
    Pleaser try to use the following link to test your STMP/POP/IMAP e-mail, and check the test if successful:
    https://testconnectivity.microsoft.com/
    If unsuccessful, please check the test result, it will tell us what caused the problem.
    Thanks.
    Niko Cheng
    TechNet Community Support

  • I have problem with Access Connections on L412 after that utilyty upgrade

    I have problem with Access Connections on L412 after that utilyty upgrade in early August. Windows 7 Ultimate/x64.
    It stops connecting to WPA2 Enterprise (AES-CCMP), Microsoft PEAP, no server cert, with any credentials I try to use. The same account(s) works with native Intel manager on other notebooks and on mobile devices. I lost the wireless connectivity to enterprise WiFi network.
    And, after deinstallation of Access Connections, the inability to connect keeped intact with native Win7 WiFi management.
    I think, something was broken in Access Connections 5.83 Build 83C753WW and some registry settings/ dll modules were altered but not returned to normal after deinstall.

    Access Connections is definitely broken for WPA encryption.  Both versions 5.02 and 5.84 fail for me.  If I use the Windows XP wireless configuration instead of Access Connections, everything works.
    Does anyone know how to report this to Lenovo?  I chased links around the web site but couldn't find a place.

  • Can Play iTunes Library from PC on MacBook Air but cannot import, problem with access rights?

    I can play Itunes library from Windows Vista PC on my MacBook Air using homeshare but cannot import the library . Error message is problem with access rights. Latest OS and Itunes installed. Both computers registered with Apple on same Apple ID. Wifi Router turned on and off. Still does not allow importing. Any suggestions please?

    Might be an alternative for you here > iTunes: How to move your music to a new computer

  • HT204370 I downloaded an HD movie onto my laptop from i-tunes.  It plays fine on my laptop, but when I plug in my HD projector, the movie quits.  When I unplug the projector, the movie starts again. I have never had a problem with projecting an itunes mov

    I downloaded an HD movie onto my laptop from i-tunes.  It plays fine on my laptop, but when I plug in my HD projector, the movie quits.  When I unplug the projector, the movie starts again. I have never had a problem with projecting an itunes movie before this. Someone told me that i-tunes changed something so that movies can no longer be projected.  We have a home theatre and have watched movies this way quite regularly, so it would be a drag if Apple will prevent us from doing this in the future. 

    I don’t know about projection, but I’m unable to watch HD content in iTunes because my Apple 30-inch Cinema Display is not HDCP-compliant (which is part of an HD copy-protection scheme).
    The other movies you’ve projected, were they HD as well? If not, it could be the same problem: your projector is not HDCP-compliant.

  • I have the problem with the eFax Create Account button being grayed out for my newly purchased 6525.

    I have the problem with the eFax Create Account button being grayed out for my newly purchased 6525.
    Can you help?

    Hi Marv13, disregard my last post. The 6520 does have eFax capabilities and the support document I provided a link to needs updating. If you contact HP Cloud Services phone support they will be able to resolve this issue for you. The number and available times are posted below:
    HP Cloud Services
    1-855-785-2777
    Hours of Operation
    Monday-Friday 8am-11pm ET
    Saturday 10am-6:30pm ET
    Best.
    If my reply helped you, feel free to click on the Kudos button (hover over the "thumbs up").
    If my reply solved your problem please click on the Accepted Solution button so other Forum users may benefit from viewing the post.
    I am an HP employee.

Maybe you are looking for

  • How to send generated form in PDF form through email

    hi, i am working on interactive form in Webdynpro Java, when i am trying to send pdf form as an attachment. i kept Email Submit button in the form and when i am clickink on send email button it is taking local outlook user in default and attachment a

  • ITunes 7 not downloading album only material

    I just purchased an album, and the digital booklet and one of the songs--the "album only" items--hung in the download. I clicked on the "Downloads" link, and the window said that it had downloaded the full MB but it said it was still "processsing." A

  • My RD Gateway cert is going to expire soon

    Is it best to open IIS and just create a new cert or renew it? I've searched around and saw that some blogs new certs were created. Not sure why they just didn't use the renew button in IIS ? Can someone suggest the best path please? Windows 2008 R2

  • Looping in smart forms

    HI EXperts,                    I have a problem in Samrt forms. Can anyone tell me what's the answer of that loop at lt_price1 to ls_price1            """"Table that contains material no...    like 8646,8647,8648,8646,8646    loop at lt_price1 to ls_

  • ITunes store - shopping in an other country?!

    Hello, I have an account for Switzerland, now I found a song in the US shop from. How can I shop in the US shop? It always tells me I don't have the rights for the US shop and sends me to the Swiss shop. But there the song does not exists. The same h