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;
}
}
}
}