Hello everyone, I have a problem trying convert some timeline code into a class. I posted the whole class code but the problem I am having is at the beginning when I create the array photos.
This array consists in 6 movieclips placed on the stage. The error I am getting is the following: TypeError: Error #1034: Type Coercion failed: cannot convert one$ to flash.display.DisplayObject. at projects::ZoomViewer().
Any help would be greatly appreciated.
package projects {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import gs.*;
public class ZoomViewer extends MovieClip {
public function ZoomViewer() {
var photos:Array=new Array(one,two,three,four,five,six);
var currentPage:MovieClip=null;
removeChild(borde);
removeChild(fondo);
for (var i:int = 0; i<6; i++) {
photos*.alpha=1;
photos*.buttonMode=true;
setChildIndex(photos*, i+1);
this[photos*.name+"X"]=photos*.x;
this[photos*.name+"Y"]=photos*.y;
}
addEventListeners();
function addEventListeners():void {
for (var i:int = 0; i<6; i++) {
photos*.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
photos*.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
photos*.addEventListener(MouseEvent.CLICK, mouseClickHandler);
}
}
function removeEventListeners():void {
for (var i:int = 0; i<6; i++) {
photos*.removeEventListener(MouseEvent.MOUSE_OVER, mouseOver);
photos*.removeEventListener(MouseEvent.MOUSE_OUT, mouseOut);
photos*.removeEventListener(MouseEvent.CLICK, mouseClickHandler);
}
}
function mouseOver(e:MouseEvent):void {
var button:MovieClip=e.target as MovieClip;
TweenFilterLite.to(button, 0.5, {colorMatrixFilter:{colorize:0xff6600, amount:0.3, brightness:1.1}});
}
function mouseOut(e:MouseEvent):void {
var button:MovieClip=e.target as MovieClip;
TweenFilterLite.to(button, 0.5, {colorMatrixFilter:{amount:0}});
}
function mouseClickHandler(e:MouseEvent):void {
addChild(fondo);
fondo.alpha=0;
TweenLite.to(fondo, 1, {alpha:1});
setChildIndex(fondo, 7);
removeEventListeners();
var button:MovieClip=e.target as MovieClip;
currentPage=button;
currentPage.alpha=1;
setChildIndex(currentPage, 9);
var stage_ratio=550/290;
var page_ratio:int = new int();
page_ratio=currentPage.width/currentPage.height;
if (page_ratio>=stage_ratio) {
TweenFilterLite.to(currentPage, 0.5, {x:550/2, y:290/2,
scaleY: (550/currentPage.width)* 0.9,
scaleX: (550/currentPage.width)* 0.9,
colorMatrixFilter:{ amount:0}});
borde.width=550*0.9+10;
borde.height = (currentPage.height * 550/currentPage.width)* 0.9 +10;
} else if (page_ratio < stage_ratio) {
TweenFilterLite.to(currentPage, 0.5, {x:550/2, y:290/2,
scaleY: (290/currentPage.height)* 0.9,
scaleX: (290/currentPage.height)* 0.9,
colorMatrixFilter:{amount:0}});
borde.width = (currentPage.width * 290/currentPage.height)* 0.9 +10;
borde.height=290*0.9+10;
}
currentPage.addEventListener(MouseEvent.CLICK, currentPageClicked);
addChild(borde);
borde.alpha=0;
borde.x=550/2;
borde.y=290/2;
TweenFilterLite.to(borde, 1, {alpha:1});
setChildIndex(borde, 8);
}
function currentPageClicked(e:MouseEvent):void {
currentPage.removeEventListener(MouseEvent.CLICK, currentPageClicked);
TweenLite.to(fondo, 1, {alpha:0, onComplete:removeFondo, onCompleteParams:[currentPage]});
TweenLite.to(currentPage, 0.5, {scaleX:1, scaleY:1, x:this[currentPage.name + "X"], y:this[currentPage.name + "Y"]});
TweenFilterLite.to(borde, 0.5, {alpha:0});
}
function removeFondo(currentPage) {
removeChild(fondo);
setChildIndex(currentPage,6);
removeChild(borde);
addEventListeners();
}
}
}
}