PDA

View Full Version : Talk to a class on a loaded swf



rondog
February 17th, 2009, 01:22 PM
I have my main swf that loads another swf:


private function initPreview(e:MouseEvent):void
{

v.stop();

var req:URLRequest = new URLRequest("Presenter.swf");
var ldr:Loader = new Loader();

ldr.load(req);

presenterHolder.addChild(ldr);

}


In my loaded swf (presenter.swf) I have this code:


import com.dopeditor.VideoLoader;
import com.dopeditor.PlaylistLoader;
import com.dopeditor.HorizontalSlider;

stage.showDefaultContextMenu = false;

var lowStream:String = baseURL + "ate_indicators_low.flv";
var highStream:String = baseURL + "ate_indicators_high.flv";


var vid:VideoLoader = new VideoLoader(this,highStream);
var playlist:PlaylistLoader = new PlaylistLoader(this);
var volumeObj:HorizontalSlider = new HorizontalSlider(this);
addChild(vid);
addChild(playlist);
addChild(volumeObj);


Where I am loading I need to talk to that playlist object. In my PlaylistLoader class I have a function called setPlaylistID(). I need to somehow pass a number to that function of the loaded swf. I cant figure this out for the life of me. Can anyone help??

rondog
February 17th, 2009, 01:52 PM
I figured it out:


private function initPreview(e:MouseEvent):void
{

v.stop();

var req:URLRequest = new URLRequest("Presenter.swf");
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPL ETE, onComplete);

ldr.load(req);

presenterHolder.addChild(ldr);

}

private function onComplete(e:Event):void
{
var loaderInfo:LoaderInfo = e.target as LoaderInfo;
var swf:Object = loaderInfo.content;
swf.playlist.setPlaylistID(String(playlistID));
}