Here is the situation, I am currently building a XML gallery. The thumbnails are created inside the FLA file, and it’s driven with a XML file. When a thumbnail is clicked, it will bring up the Detail movieclip. And inside the Detail movieclip, I’ve created some buttons with an external class of “DetailButtons”.
Inside the DetailButtons class, the buttons dispatch a custom event that the FLA is listening for. The problem is I can’t figure out how to have one of the buttons open the corresponding url link in the XML file. I just keep getting the 1069 error. Can anyone explain to me what I’m doing wrong?
ReferenceError: Error #1069: Property link not found on DetailButtons and there is no default value.
at com.julianchan.portfolio.pages::ProjectsPage/launchProject()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at DetailButtons/onLaunchClick()
XML File:
.....
<project title="Project01" date="2010/01" type="Flash/ActionScript 3" thumb="project01_thumb.jpg" detail="project01.jpg" link="[http://www.google.ca](http://www.google.ca/)">
<![CDATA[
Project01<br/><br/>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi suscipit scelerisque bibendum.
]]>
</project>
.....
import flash.net.*;
import flash.text.*;
import fl.motion.easing.*;
import fl.controls.ProgressBar;
import gs.TweenLite;
import com.DetailButtons;
var imgNum:int = projectsData.project.length();
var spacing:int = projectsData.@spacing;
var cols:int = projectsData.@cols;
var rows:int = Math.ceil(imgNum / cols);
var imgCount:int = 0;
var preloader:MovieClip;
var projects:MovieClip = new MovieClip();
var detailImage:Loader = new Loader();
addChild(projects);
buildProjectsGrid();
setupDetail();
function setupDetail():void {
detail.visible = false;
detail.buttonMode = false;
detail.desc.mouseEnabled = false;
detail.addChild(detailImage);
addChild(detail);
}
function buildProjectsGrid():void {
var maxWidth:Number;
var maxHeight:Number;
for (var py:int = 0; py<rows; py++) {
for (var px:int = 0; px<cols; px++) {
var thumb:MovieClip = new Thumb();
thumb.x = thumb.width / 2 + (thumb.width + spacing) * px;
thumb.y = thumb.height / 2 + (thumb.height + spacing) * py;
preloader = new MovieClip();
preloader.x = thumb.x;
preloader.y = thumb.y;
projects.x = 40.15;
projects.addChild(thumb);
if (imgCount < imgNum) {
var imageData:XML = projectsData.project[imgCount];
var loader:Loader = new Loader();
var path:String = projectsData.@folder + imageData.@thumb;
loader.load(new URLRequest(path));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onThumbComplete);
thumb.addChild(thumb.background);
thumb.addChild(loader);
thumb.addChild(thumb.hover);
thumb.addChild(thumb.thumbTitle);
thumb.background.alpha = 0;
thumb.hover.alpha = 0;
thumb.thumbTitle.alpha = 0;
thumb.thumbTitle.mouseEnabled = false;
thumb.buttonMode = true;
thumb.thumbTitle.text = imageData.@title;
thumb.desc = imageData;
thumb.detailTitle = imageData.@title;
thumb.detailType = imageData.@type;
thumb.detailDate = imageData.@date;
**thumb.link = imageData.@link.toString();**
thumb.hasImage = true;
thumb.detail = projectsData.@folder + imageData.@detail;
addChild(preloader);
var preloader_pb:ProgressBar = new ProgressBar();
preloader_pb.source = loader.contentLoaderInfo;
preloader_pb.x = projects.x - thumb.width / 2;
preloader_pb.y = 0 - thumb.height / 2;
preloader_pb.width = thumb.width;
preloader_pb.height = thumb.height;
preloader.addChild(preloader_pb);
preloader_pb.addEventListener(Event.COMPLETE, donePb);
} else {
thumb.alpha = 0;
thumb.background.alpha = 0;
thumb.hover.alpha = 0;
thumb.thumbTitle.alpha = 0;
}
imgCount++;
maxWidth = projects.width;
maxHeight = projects.height;
}
}
for (var i:int = 0; i<projects.numChildren; i++){
thumb = MovieClip(projects.getChildAt(i));
TweenLite.from(thumb, 0.75, {alpha:0, delay: i/10, onComplete:onThumbsAnimated, onCompleteParams:[thumb], ease:Cubic.easeOut});
}
}
function onThumbsAnimated(thumb:MovieClip):void{
if (thumb.hasImage){
thumb.addEventListener(MouseEvent.CLICK, onThumbClick, false, 0, true);
thumb.addEventListener(MouseEvent.ROLL_OVER, onThumbOver, false, 0, true);
thumb.addEventListener(MouseEvent.ROLL_OUT, onThumbOut, false, 0, true);
}
}
function onThumbComplete(evt:Event):void {
var img:Bitmap = Bitmap(evt.target.content);
img.x = -img.width/2;
img.y = -img.height/2;
evt.target.removeEventListener(Event.COMPLETE, onThumbComplete);
}
function onThumbOver(evt:MouseEvent):void {
var thumb:MovieClip = MovieClip(evt.target);
TweenLite.to(thumb.hover, 0.35, {alpha:1, ease:Cubic.easeOut});
TweenLite.to(thumb.thumbTitle, 0.35, {alpha:1, ease:Cubic.easeOut});
}
function onSortThumb(thumb:MovieClip):void{
if (thumb.scaleX>.75){
projects.addChild(thumb);
}
}
function onThumbOut(evt:MouseEvent):void {
var thumb:MovieClip = MovieClip(evt.target);
TweenLite.to(thumb.hover, 0.35, {alpha:0, ease:Cubic.easeOut});
TweenLite.to(thumb.thumbTitle, 0.35, {alpha:0, ease:Cubic.easeOut});
}
function onThumbClick(evt:MouseEvent):void {
TweenLite.to(detail, 0.5, {autoAlpha:1, ease:Cubic.easeOut});
TweenLite.to(projects, 0, {autoAlpha:0});
detail.desc.condenseWhite = true;
detail.desc.htmlText = evt.currentTarget.desc;
detail.detailTitle.text = evt.currentTarget.detailTitle;
detail.detailType.text = evt.currentTarget.detailType;
detail.detailDate.text = evt.currentTarget.detailDate;
try{
detailImage.close();
}catch (e:Error){
//trace(e);
}
detailImage.load(new URLRequest(evt.currentTarget.detail));
detailImage.alpha = 0;
detailImage.contentLoaderInfo.addEventListener(Event.COMPLETE, onDetailComplete);
}
function onDetailComplete(evt:Event):void {
TweenLite.to(detailImage, .5, {alpha:1});
detailImage.contentLoaderInfo.removeEventListener(Event.COMPLETE, onDetailComplete);
}
addEventListener("backClick", backToGallery);
**addEventListener("launchClick", launchProject);**
function backToGallery(evt:Event):void {
if (detailImage.alpha > .9){
detailImage.unload();
TweenLite.to(detail, 0, {autoAlpha:0});
TweenLite.to(projects, 0.5, {autoAlpha:1, ease:Cubic.easeOut});
}
}
**function launchProject(evt:Event):void {
var thumb:MovieClip = MovieClip(evt.target);
var urlRequest:URLRequest = new URLRequest(thumb.link);
navigateToURL(urlRequest, "_blank");
}**
function donePb(evt:Event):void{
var pb:ProgressBar = ProgressBar(evt.target);
pb.parent.removeChild(pb);
pb.removeEventListener(Event.COMPLETE, donePb);
}