Creating Variable for MC in External .FLA

I have got a AS3 Dock Menu script from http://www.reloc.org/2008/2/23/os-x-dock-in-as3-and-flex

And I am trying to get it to Load content in to a Movie Clip when an icon is pressed but I am having some serious trouble doing it. I had it sugested to me that I try using cases so I did but then I needed to create a Variable in the .AS file(below) but I am totally lost.

Would some one tell me what I am doing wrong or what I could do to get it working.
My movie Clip that I want to load images in to in the .Fla is called “ldr”.

original code:

package
{
    import flash.display.MovieClip;
    import org.reloc.dock.*;
    
    public class DocumentClass extends MovieClip
    {
        private var items = [
                    { icon: new finder(128, 128), id: 'finder' },
                    { icon: new safari(128, 128), id: 'safari' },
                    { icon: new mail(128, 128),   id: 'mail' },
                    { icon: new itunes(128, 128), id: 'itunes' },
                    { icon: new ichat(128, 128),  id: 'ichat' },
                    { icon: new search(128, 128), id: 'search' },
                    { icon: new help(128, 128),   id: 'help' },
                    { icon: new trash(128, 128),  id: 'trash' }
                    ];

        public function DocumentClass()
        {
            stage.scaleMode = 'noScale';

            var dock:Dock = new Dock('bottom', 128, 32, 128, 2, 0, 0, items);
            dock.x = stage.stageWidth / 2;
            dock.y = stage.stageHeight;
            addChild(dock);
            
            addEventListener(DockEvent.CLICK, onClick);
        }
        
        private function onClick(event:DockEvent):void
        {
            var icon:DockIcon = event.target as DockIcon;
            trace(icon.info.id)
        }
    }
}

My changes


package
{
    import flash.display.MovieClip;
    import org.reloc.dock.*;
    
    public class DocumentClass extends MovieClip
    {
        private var items = [
                    { icon: new finder(128, 128), id: 'finder' },
                    { icon: new safari(128, 128), id: 'safari' },
                    { icon: new mail(128, 128),   id: 'mail' },
                    { icon: new itunes(128, 128), id: 'itunes' },
                    { icon: new ichat(128, 128),  id: 'ichat' },
                    { icon: new search(128, 128), id: 'search' },
                    { icon: new help(128, 128),   id: 'help' },
                    { icon: new trash(128, 128),  id: 'trash' }
                    ];

        public function DocumentClass()
        {
            stage.scaleMode = 'noScale';

            var dock:Dock = new Dock('bottom', 128, 32, 128, 2, 0, 0, items);
            dock.x = stage.stageWidth / 2;
            dock.y = stage.stageHeight;
            addChild(dock);
            
            addEventListener(DockEvent.CLICK, onClick);
        }
        
        private function onClick(event:DockEvent):void
        {
            var icon:DockIcon = event.target as DockIcon;
            var ldr:MovieClip
            //trace(icon.info.id)
            switch(this.DockIcon) {
                case 'finder':
                this.ldr.source = "clip1.swf";
                Break;
            }
        }
    }
}

try this

package
{
import flash.display.MovieClip;
import flash.net.URLRequest;
import org.reloc.dock.*;
import flash.display.Loader;

public class DocumentClass extends MovieClip
{
	private var ldr:Loader;
    private var items = [
    			{ icon: new finder(128, 128), id: 'finder' },
    			{ icon: new safari(128, 128), id: 'safari' },
    			{ icon: new mail(128, 128),   id: 'mail' },
    			{ icon: new itunes(128, 128), id: 'itunes' },
    			{ icon: new ichat(128, 128),  id: 'ichat' },
    			{ icon: new search(128, 128), id: 'search' },
    			{ icon: new help(128, 128),   id: 'help' },
    			{ icon: new trash(128, 128),  id: 'trash' }
    			];

	public function DocumentClass()
	{
	    stage.scaleMode = 'noScale';

		var dock:Dock = new Dock('bottom', 128, 32, 128, 2, 0, 0, items);
        dock.x = stage.stageWidth / 2;
        dock.y = stage.stageHeight;
		addChild(dock);
		ldr = new Loader();
		this.addChildAt(ldr,0);
		addEventListener(DockEvent.CLICK, onClick);
	}
	
	private function onClick(event:DockEvent):void
	{
	    var icon:DockIcon = event.target as DockIcon;
		switch(icon.info.id) {
            case 'finder':
			ldr.load(new URLRequest("clip1.swf"));
            break;
        }

	}
}

}

The mistake you had done
1.

switch(this.DockIcon) {

here you cant add switch element to a class Name insted use an instance or any function of the class
which returns some value.

Break;

it is break; not Break;

var ldr:MovieClip
//trace(icon.info.id)
switch(this.DockIcon) {
case ‘finder’:
this.ldr.source = “clip1.swf”;
Break;
}

you have declared a movieClip name ldr which is not the child of this(here it is the root).
Try loader class.to load the swf and add it to the root at your desired depth.

Cheers
Sudhansu
if you have any query plz visit
http://www.sudhansurana.wordpress.com/