Something simple that I'm missing: switching XML text problem

I'm sure it's something simple I'm missing. I was looking at this code for some time now, I'm hoping that a fresh pair of eyes can help out me:

I have a title for my videos of xml that are loaded with the video of the scene. When you click on a thumbnail of the image of the video, what is supposed to happen is the title of the video could appear above of the new video and remove the previous title of the video. Instead, remains the previous title and the new title of stacks on top of the other.

Here are some of my code:

          //Process XML==================================================================================================================
          public function processXML(e:Event):void{
               var myXML:XML = new XML(e.target.data);

               thumb_width = myXML. @ THUMB_WIDTH;
               thumb_height = myXML. @ THUMB_HEIGHT;
               video_x = 200;
               video_y = -20;
               my_videos = myXML.VIDEO;
               my_total = my_videos.length();

               makeContainers();
               thumbs_x = thumb_container.x;
               thumbs_y = thumb_container.y - 20;
               callThumbs();
               makePlayer();
          }
          
          //Make Containers=================================================================================================================
          public function makeContainers():void{
               main_container = new Sprite();
               thumb_container = new MovieClip();
               addChild(main_container);
               titles = new Sprite();
               
               thumbs = new Sprite();
               thumbs.addEventListener(MouseEvent.CLICK, playVideo);
               thumbs.addEventListener(MouseEvent.MOUSE_OVER, onOver);
               thumbs.addEventListener(MouseEvent.MOUSE_OUT, onOut);
               thumbs.x = thumbs_x;
               thumbs.y = thumbs_y;
               thumbs.buttonMode = true;
               main_container.x = -10;
               main_container.y = -10;
               thumb_container.addChild(thumbs);
               main_container.addChild(thumb_container);
               main_container.addChild(titles);
               thumb_container.mask = thumbScroller.vThumbMask;
                              
               thumbScroller.next_btn.addEventListener(MouseEvent.MOUSE_DOWN, doAction);
               thumbScroller.previous_btn.addEventListener(MouseEvent.MOUSE_DOWN, doAction);               
               thumbScroller.next_btn.addEventListener(MouseEvent.MOUSE_UP, releaseButton);
               thumbScroller.previous_btn.addEventListener(MouseEvent.MOUSE_UP, releaseButton);
          }

     
          //Call Thumbs==================================================================================================================
          public function callThumbs():void{
               
               for (var i:Number = 0; i < my_total; i++)
               {
                    var thumb_url = my_videos[i].@THUMB;
                    var thumb_loader = new Loader();
                    thumb_loader.name = i;
                    thumb_loader.load(new URLRequest(thumb_url));
                    thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
                    thumb_loader.y = (thumb_height+10)*i;
               }
          }

          public function thumbLoaded(e:Event):void{
               var my_thumb:Loader = Loader(e.target.loader);
               thumbs.addChild(my_thumb);
          }
          
          
          //Make Player==================================================================================================================
          public function makePlayer():void{
               my_player = new FLVPlayback();
               my_player.skin = "SkinOverPlaySeekMute.swf";
               my_player.skinBackgroundColor = 0x70A16C;
               my_player.skinBackgroundAlpha = 0.5;
               my_player.skinAutoHide = true;

               my_player.x = video_x;
               my_player.y = video_y;
               my_player.width = 450;
               my_player.height = 338;

               main_container.addChild(my_player);
               my_player.source = my_videos[0]. @ URL;
          }
          
          //stop audio and video
          public function stopPlayer():void{
               my_player.stop();
          }
          
     
          //Thumbnail Functions-----------------------------------------------------------------------------------------------------------
          public function playVideo(e:MouseEvent):void{
               var video_url = my_videos[e.target.name]. @ URL;
               my_player.source = video_url;
               thumbs.addEventListener(MouseEvent.CLICK,getTitle);

          }

          public function getTitle(e:MouseEvent):void{
                    var thumb_title = my_videos[e.target.name].@TITLE;
                    var title_txt:TextField = new TextField();

                                 //THIS DOESN'T WORK. FOR SOME REASON IT DOESN'T SEEM TO EVER GET CALLED 
                    if(titles.contains(title_txt)){
                                     trace("remove previous title");
                         titles.removeChild(title_txt);
                    }
                    
                    var myFormat:TextFormat = new TextFormat();
                    myFormat.font = "Helvetica";
                    myFormat.color = 0x000000;
                    myFormat.size = 25;
                    title_txt.defaultTextFormat = myFormat;
                    
                    title_txt.text = thumb_title;
                    title_txt.y = video_y - 40;
                    title_txt.x = video_x + 50;
                    title_txt.width = thumb_width;
                    title_txt.height = thumb_height;
                    title_txt.wordWrap = true;
                    titles.addChild(title_txt);
          }


Also, for some reason, when the swf first loads, the title does not appear for the first thumbnail clicked but it starts to appear when you click a second thumbnail.
Any help will be very much appreciated!

 

The likely problem of lies between the following lines...

var title_txt:TextField = new TextField();

if (titles.contains (title_txt))

{

titles.removeChild (title_txt);

}

You just create an instance named title_txt.  So any reference to it thereafter is the newly created instance, no matter what that may already exist.

I have just to keep a textfield and replace what is in it.  But if you want to continue to create instances and accumulate them in memory, then probably just want to use something like...

if (titles.numChildren > 0)

{

titles.removeChildAt (0);

}

Tags: Adobe Animate

Similar Questions

  • Selection of the menu XML text problem

    Hi all

    I built a video menu xml that displays a simple text of my XML document in a movieclip that is added to a sprite called btnContainer, the btnContainer is then added to the scene. Once these buttons are selected, they load the appropriate video. The problem I have is that I want the selected button to change color. There are three different XML files loaded according to 3 static buttons on the stage, that is to say 2009 / 2008 / 2007. By default the code 2009 XML file is loaded. My code works fine the first time that the script runs - when one of the XML buttons is selected it changes color and returns all other buttons to their default color - but when I click on the button 2008 or 2007 and load their XML files, and the buttons do not change their color. Then when I click on back button 2009 and 2009 XML load button changes color but the rest of the buttons do not change in their default state? My code is below

    Thanks in advance for any help

    Fl.video import. *;

    Import gs.*;

    Gs.easing import. *;

    //----------------------------------VARIABLES--------------------------------

    var vid:FLVPlayback;

    vid = new FLVPlayback();

    VID.source = "video/press_long_beach_2009.flv";

    VID. Width = 480

    VID. Height = 360

    VID. Skin = "SkinUnderPlayStopSeekMuteVol.swf";

    vid.skinBackgroundColor = 0 x 000000;

    vid.skinBackgroundAlpha =.5

    addChild (vid)

    VID.x = 385

    VID.y = 80

    var myLoader:Loader = new Loader();

    var container: MovieClip = new MovieClip;

    var xml = new XML;

    var xmlList:XMLList = new XMLList;

    var xmlLoader:URLLoader = new URLLoader;

    var dateLoader:Loader

    var dateBtn:mcDateBtn

    var items_array:Array = new Array();

    var btnContainer:MovieClip = new MovieClip;

    var boxContainer:Sprite = new Sprite();

    //-------------------------------------------ADD LISTENERS------------------------------

    xmlLoader.load (new URLRequest("data/2009videos.xml"))

    xmlLoader.addEventListener (Event.COMPLETE, xmlComplete)

    yearBtnContainer.btn09.addEventListener (MouseEvent.CLICK, showYearBtns)

    yearBtnContainer.btn08.addEventListener (MouseEvent.CLICK, showYearBtns)

    yearBtnContainer.btn07.addEventListener (MouseEvent.CLICK, showYearBtns)

    //------------------------------------------FUNCTIONS------------------------------------

    function showYearBtns(event:Event):void

    {

    if (this.contains (btnContainer))

    {

    for (var i: int = 0; i < xmlList.length (); i ++)

    {

    btnContainer.removeChildAt (0);

    }

    }

    if(event.target == yearBtnContainer.btn09)

    {

    xmlLoader.load (new URLRequest("data/2009videos.xml"))

    }

    other if (event.target == yearBtnContainer.btn08)

    {

    xmlLoader.load (new URLRequest("data/2008videos.xml"))

    }

    other if (event.target == yearBtnContainer.btn07)

    {

    xmlLoader.load (new URLRequest("data/2007videos.xml"))

    }

    }

    function xmlComplete(event:Event):void

    {

    xml = XML (event.target.data);

    xmlList = xml.children ();

    for (var i: int = 0; i < xmlList.length (); i ++)

    {

    trace ("working")

    dateBtn = new mcDateBtn;

    items_array.push (dateBtn);

    btnContainer.addChild (dateBtn)

    dateBtn.x = 20;

    dateBtn.y = i * 60 + 100;

    dateBtn.name = xmlList [i] .attribute ("videoURL")

    dateBtn.dateTxt.htmlText = xmlList [i];

    dateBtn.dateTxt.wordWrap = true

    dateBtn.dateTxt.width = 270;

    dateBtn.dateTxt.height = 90;

    dateBtn.dateTxt.background = true;

    dateBtn.dateTxt.backgroundColor = 0 x 333333;

    dateBtn.mouseChildren = false;

    dateBtn.buttonMode = true;

    dateBtn.id = i;

    dateBtn.addEventListener (MouseEvent.CLICK, showImage)

    trace ('underneath')

    }

    addChild (btnContainer)

    }

    function showImage(event:MouseEvent):void

    {

    for (var j: int = 0; j < xmlList.length (); j ++)

    {

    //trace(event.target.id)

    if(j==event.currentTarget.id)

    {

    trace ("working color")

    TweenLite.to (event.target,.3, {tint: 0xFFDB00, ease:Strong.easeOut});})

    }

    to another if(!event.currentTarget.select)

    {

    trace ("working without color")

    ([ //trace(items_array[i])

    items_array [j]. Select = false;

    items_array [j] .mouseEnabled = true;

    TweenLite.to (items_array [j],.5, {tint: 0xFFFFFF, ease:Strong.easeOut});})

    }

    }

    vid.source = event.target.name

    }

    It's not like you're clearing items_array()

  • Pages won't open the files that I've updated 2 days ago missing index.xml extension?

    I've updated several documents marketing two days ago. When I saved the files, there was a pop-up notice that they have been saved as a newer version of the file as a result of the most recent update. Today, I went to a few final tweeks before loading the changes on my printer and files will not open. It is said that the error message "missing index.xml file. I just checked and downloaded/installed all the updates available and rebooted my macbook, but the files will still not open. PLEASE HELP ME TO RECOVER MY FILES!

    You have two versions of Pages on your Mac, probably the Pages ' 09 and 5.6.1 Pages.

    When you have clicked on your Pages ' 09 version previously opened in Pages 5, 6.1 and was converted into a format of Pages 5.6.1.

    When you double click on the document today you opened in Pages ' 09, who cannot open the format of Pages 5.6.1.

    To open the document in the correct application, right-click on the document and choose. Pages ' 09 has a bottle of blue ink icon, Pages 5 has a generic research paper Orange.

    If you want to convert your document to Pages ' 09, because it has over more than 100 features and is much more productive:

    Open the document in Pages 5.x > file > export > Pages ' 09

    Peter

  • I must be missing something simple, but I can't figure out how to remove my Adobe account?

    I must be missing something simple, but I can't figure out how to remove my Adobe account?

    http://livingtext.WordPress.com/2009/03/13/delete-an-Adobe-account/

  • I must be missing something simple...

    I just started usng a new Epson R3000. Print letter size is no problem. However, I can't get it printed at 13 x 19. No matter what I do a 8.5x11 print (on a big, expensive piece of paper!). This happens with the driver set to "Super B", and also with a custom paper size, I created. The driver claims it will print to the appropriate size, but the output is 8.5 x 11.

    It's as if there is a kind of selection that replaces what I do in PS.

    Furthermore, I use PS CS 5.5, Mac Lion, printing via ethernet.

    What Miss me?

    I found it... Under management of the paper, there is a box that says 'fit to paper size' or something like that. I need to check that, even if the image was already on the right size. Without checking that the pilot decreased things down for a reason any.

  • After the migration to the new Mac Pro Dreamweaver will not launch, said missing menus.xml file. How to solve this?

    After migrating to a new Mac Pro Dreamweaver CS6 launch. It is said that missing menus.xml file. How to solve this?

    Hi rustyg12,

    Go to/Applications/Adobe Dreamweaver CS6/Configuration/Menus/menus.bak

    You will see a menus.xml file here - it is a backup copy of the actual menus.xml file that uses DW.

    Copy it from this folder, paste 1 level above (in the file menu).

    Launch DW. See if it works.

  • Is there a way to the target url by using the power of Attorney (I want to say is possible to use the proxy to target a site something like that.)?

    Is there a way to the target url by using the power of Attorney (I want to say is possible to use the proxy to target a site something like that.)?

    By default, you can not in Firefox.

    But you can use an add-on like FoxyProxy Standard, I think he understands the functionality you need.

  • I couldn't install the firefox 16.0.2, the message I got was: that "${MinUnsopportedVer} is missing." That what it means?

    I couldn't install the firefox 16.0.2, the message I got was: that "${MinUnsopportedVer} is missing." That what it means?

    See also:

  • whenever I click on something on that I get pop up as I'm right click how to make this stop?

    whenever I click on something on that I get pop up as I'm right click how to make this stop?

    Cindy,

    What should I have selected in system preferences... > mouse > Point & Click > secondary click?

  • Hello I (IPAD MINI DEVICE) and problem in my memory I have 12.5 GB, and using less of it and A Nofticate it indicates your size will end soon, or something like that I deleted the apps and that he got 100 MB and after all the Nofticate come back and some

    Hello I Have (IPAD MINI DEVICE) and have problem In My Memory I have 12.5 GB, and using less of it and A Nofticate it indicates your size will end soon, or something like that I deleted the apps and got 100 MB and after all in the Nofticate come back and something has my size and it says Iam using fully 12.5 GB and I amnt Iam using just use it 4 or 5 GB

    Try to provide the exact text of the message you see. "size will end or something" identifies not enough information for anyone to be able to solve the problems.

    In addition, check if reference is made to the size on the device, called space iCloud.

  • How can I access the album artwork for printing. It is used to be simple, that now I can not find anything

    How can I access the album artwork for printing on a CD? It is used to be simple, that now I can not find anything

    (Retina Powerbook 15, OSX 10.11.2, Itunes 12.3 2.35)

    Right-click on the right track... Get info... Select album art... Drag it to the desktop

    print it from there.

  • I got the auto update on but when it was over Secunia showed that kb2585542 was missing. I tried all the suggestions given by Microsoft but am unable to open this file.

    Original title: update problems

    I got the auto update on but when it was over Secunia showed that kb2585542 was missing.  I tried all the suggestions given by Microsoft but am unable to open this file.

    Hello

    1 have. the troubleshooting steps you tried to solve the problem?

    You try to install the update (KB2585542) manually and check if updates installed.

    Update security for Windows XP x 64 Edition (KB2585542)

    http://www.Microsoft.com/download/en/details.aspx?displaylang=en&ID=28625

    In case you have 64-bit Windows XP operating system installed on the computer you can download the update manually the link provided below.

    Update security for Windows XP x 64 Edition (KB2585542)

    http://www.Microsoft.com/download/en/details.aspx?ID=28590

    See also:

    You cannot install some programs or updates

    http://support.Microsoft.com/kb/822798

  • Win32/Qhost.ci or something like that

    Hello I have something like that but you didn't exactly know please help!

    The full spelling of the name of the infection is important.  Open MSE and its history tab.  If you're quite sure MSE deleted or quarantined Trojan:Win32 / Qhost.CI, see this article from Microsoft Protection Center.

    http://www.Microsoft.com/security/portal/threat/encyclopedia/entry.aspx?name=Trojan%3aWin32%2fQhost.CI

    Note in particular the reference to recreate a file HOSTS here:

    http://support.Microsoft.com/kb/972034

    If you continue to have problems with this infection or redirects,

    Start here - https://support.microsoftsecurityessentials.com/

    and select the link that says - I think my computer is infected - and support and select the option for phone, chat or email (options vary depending on the region)

    If you are in North America, you can call 866-727-2338 for a free Microsoft Help for infections of virus and spyware.

  • I try to run the security essentials and it tells me that I'm missing msvcp90.dll

    I try to run the security essentials, and he tells me that I'm missing msvcp90.dll. Same problem occurring with a real player has not re - install. How can I recover file?

    Hi BradleyMitchell,

    1. did you of recent changes on the computer?

    2 when was the last time it was working fine?

    3. what version of Real player installed on the computer?

    Msvcp90.dll error can be caused if the Visual C++ Library Runtime components are missing or corrupt on the computer.

    Method 1

    I suggest that scan you SFC on the computer that would be a system file corrupt on the computer search and replace.

    The analysis may take some time, so be patient. Windows allows to fix corrupt or missing files it finds. If the information of the installation CD is required to fix the problem, you may be asked to insert your Windows XP installation CD.

    Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe)

    http://support.Microsoft.com/kb/310747

    Method 2

    If the previous step fails, then install the Package redistributable Microsoft Visual C++ 2008 and check if it helps.

    Microsoft Visual C++ 2008 Redistributable Package (x 86)
    http://www.Microsoft.com/downloads/details.aspx?FamilyId=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=en

     

    You can also post your request in the Microsoft security essentials forums using the link below.

    http://answers.Microsoft.com/en-us/protect/Forum/protect_start

  • After shut my computer off for the night I seems to have lost all sound. I get a message telling me that I'm missing 1 or more codecs. Help?

    There is no sound when I start it or turn it off.  Windows Media player shows the audio streaming, but I have no volume.

    I checked all audio devices and they are fine.  I get a message saying that I'm missing 1 or more codecs.  I put it through all the help troubleshooting I can find with no luck.  Only once have I not an error code 0 x 80004005

    Any ideas?

    I suggest you uninstall your sound card in Device Manager (Control Panel - System - Hardware - Device Manager) and restart. The sound card must be reinstalled the next time Windows starts. Who help me?

Maybe you are looking for