I'm trying to use a carrousel thing that I've downloaded and iIm
adapting the as3 for that...but I have this odd problem...
I'm not sure what it is, the code looks, anyway it has to be
wrong...could you help me out.
this is the error in flash .
ReferenceError: Error #1069: Property 0 not found on
flash.display.Loader and there is no default value.
at CarouselinAS3_fla::MainTimeline/init()
at CarouselinAS3_fla::MainTimeline/CarouselinAS3_fla::frame1()
this is the code:
/*
AS 3.0 carousel by Matt Bury.
Adapted from Lee Brimelow's carousel tutorials at http://
gotoandlearn.com/
This code goes on frame 1 of a 1 frame FLA file.
The 'reflections' will only work if 'bitmap caching' for the Icon
instance 'ref' and the 'masker' instance is turned on in the
properties panel.
The silhouette in the FLA is from a photo of a friend I took of, Rew
Lowe, who performs with Aitherios Theatre: http://
aitheriostheatre.com/ They're an
international troupe that performs around western Europe.
*/
var names:Array = new Array
("models","portrait","weddings","children","commercial");
var numOfItems:uint = names.length; // number of Items to put on stage
var radiusX:uint = 250; // width of carousel
var radiusY:uint = 75; // height of carousel
var centerX:Number = stage.stageWidth / 2; // x position of center of
carousel
var centerY:Number = stage.stageHeight / 2; // y position of center
of carousel
var speed:Number = 0.05; // initial speed of rotation of carousel
var itemArray:Array = new Array(); // store the Items to sort them
according to their 'depth' - see sortBySize() function.
init();
// place Items on stage
function init():void {
for(var i:uint = 0; i < numOfItems; i++) {
var item:Item = new Item();
//adcionamos las fotos/
var newNames = names[i];
var itemPics:Loader = new Loader();
itemPics.load(new URLRequest("menuImages/"+
newNames +".jpg"));///this is the part with the problems//
item.addChild(itemPics[i]);
// public var angl:Number; is in Item class.
// Item class extends ItemInner in FLA library.
item.angl = i * ((Math.PI * 2) / numOfItems);
item.ref.mask = item.masker;
item.alpha = 0.5;
itemArray.push(item);
addChild(item);
item.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
// listen for MouseEvents only on icons, not on reflections
item.icon.addEventListener(MouseEvent.CLICK, clickHandler);
item.icon.addEventListener(MouseEvent.ROLL_OVER,
rollOverHandler);
item.icon.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
}
}
// position Items in elipse
function enterFrameHandler(event:Event):void {
event.target.x = Math.cos(event.target.angl) * radiusX + centerX; //
x position of Item
event.target.y = Math.sin(event.target.angl) * radiusY + centerY; //
y postion of Item
// scale Item according to y position to give perspective
var s:Number = event.target.y / (centerY + radiusY);
event.target.scaleX = event.target.scaleY = s;
event.target.angl += speed; // speed is updated by mouseMoveHandler
sortBySize();
}
// set the display list index (depth) of the Items according to their
// scaleX property so that the bigger the Item, the higher the index
(depth)
function sortBySize():void {
// There isn't an Array.ASCENDING property so use DESCENDING and
reverse()
itemArray.sortOn("scaleX", Array.DESCENDING | Array.NUMERIC);
itemArray.reverse();
for(var i:uint = 0; i < itemArray.length; i++) {
var item:Item = itemArray[i];
setChildIndex(item, i);
}
}
function clickHandler(event:MouseEvent):void {
// clean up your listeners before you do anything else to free up
// user's CPU resources
for(var i:uint = 0; i < itemArray.length; i++) {
var item:Item = itemArray[i];
item.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
item.icon.removeEventListener(MouseEvent.CLICK, clickHandler);
item.icon.removeEventListener(MouseEvent.ROLL_OVER,
rollOverHandler);
item.icon.removeEventListener(MouseEvent.ROLL_OUT,
rollOutHandler);
// optional:
removeChild(item);
// to replace the carousel again see reInit() function
}
// put your own code here.
}
function rollOverHandler(event:MouseEvent):void {
event.target.parent.alpha = 1;
}
function rollOutHandler(event:MouseEvent):void {
event.target.parent.alpha = 0.5;
}
addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
/*
Update the speed at which the carousel rotates accoring to the
distance of the mouse from the center of the stage. The speed
variable only gets updated when the mouse moves over the Item Sprites.
*/
function mouseMoveHandler(event:MouseEvent):void {
speed = (mouseX - centerX) / 6000;
}
// click to put Items back on stage
rewButton.buttonMode = true;
rewButton.addEventListener(MouseEvent.CLICK, reInit);
// put items back on stage
function reInit(event:MouseEvent):void {
for(var i:uint = 0; i < itemArray.length; i++) {
var item:Item = itemArray[i];
item.alpha = 0.5;
addChild(item);
item.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
item.icon.addEventListener(MouseEvent.CLICK, clickHandler);
item.icon.addEventListener(MouseEvent.ROLL_OVER,
rollOverHandler);
item.icon.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
}
}
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders