Skip to main content
Known Participant
October 14, 2016
Question

AS 3 Combo box and XML to load and unload SWFs

  • October 14, 2016
  • 1 reply
  • 315 views

I'm using Flash CC 2015, I have a combo box (myCB), and a empty movieClip (content). I able to parse the xml and display items in combo box , but no luck with loading and unloading swf in movieclip.

Any help be nice, I think one I should do is have a for loop in the listListner function

My xml looks like this

<?xml version="1.0" encoding="UTF-8"?>

<playlist id="CCCC- Playlist" >

<vid desc="(U) I have boogers"

  src="CS4_Sahkoinen_lehti_large.swf" />

<vid desc="(U) num 2"

  src="Lehti2.swf" />

<vid desc="(U) num 3"

  src="Lehti3.swf" />   

</playlist>

my AS code:

package{
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import fl.controls.ComboBox;
import flash.display.Loader;

public class Axxx extends MovieClip
{
  private var xmlLoader:URLLoader;
  private var moveLoad:URLLoader;

  public function Axxx():void
  {
   // Load the playlist file, then initialize the media player.
   xmlLoader = new URLLoader();
   xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
   xmlLoader.load(new URLRequest("Vidlib.xml"));
  }
 
  public function initMediaPlayer(event:Event):void
  {
   var vidXML:XML = new XML(xmlLoader.data);
   var item:XML;
   for each (item in vidXML.vid)
   {
    // populate list.
    // Send data to List.
    //myCB.addItem({label: "Choose "});
    myCB.addItem({label:item.attribute("desc").toXMLString(),
    data:item.attribute("src").toXMLString()});
   }
   // Listen for item selection.
   myCB.addEventListener(Event.CHANGE, listListener);
   // Select the first swf.;
   //myCB.selectedIndex = 0;
   // And automatically load swf.
   //content.gotoAndStop(myCB.selectedItem.data);
  }

  // Detect when new video is selected, and play it
  function listListener(event:Event):void
  {
   //var content:MovieClip(loader.content);
   //addChild(content);
   content.load(event.target.selectedItem.data);

   trace("HI! Awesome!");
  }
}
}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 15, 2016

1. i don't see where content is defined.

2. content needs to be a loader, not a movieclip and needs to be added to the display.