File not found AS3 - actionscript-3

I am writing a program in AS3. It's exact contents don't seem to matter here. I basically have 4 classes, split in 4 files. Thing is, it can't find one of these files, and I can't understand why. I have checked it several times and even had my teacher check it, and we still can't find what is wrong with it. Did anyone else have a similar problem, or have any idea on how to solve this problem?
EDIT:
Line 37 1046: Type was not found or was not a compile-time constant: CustomTextField.
Line 37 1180: Call to a possibly undefined method CustomTextField. (Twice)
package
{
// Import stuff
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.utils.*;
public class CustomButton extends MovieClip
{
// Private variables:
private var animationsListAR_:Array = [];// Array for the animations.
private var textArea_:CustomTextField = new CustomTextField();
private var curState_:int = 1;// The current state (1 = Normal, 2 = Pressed, 3 = Over).
private var active_:Boolean;
private var type_:String;// Multi choice, single choice, normal.
private var group_:int;
private var animated_:Boolean = false;
// Protected variables:
// Public variables:
// Constructor:
// This constructor sets up the event listeners and the button's properties.
public function CustomButton( animationAR:Array, buttonlabel:String = "Hello", animated:Boolean = false, active:Boolean = true, type:String = "free", group:int = 0 )
{
this.gotoAndStop( curState_ );
// Prevents the start of the animations.
// Deals with the text inside the button.
this.buttonMode = true;
active_ = active;
this.addChild( textArea_ );
if (animated == true)
{
animated_ = true;
/*
animationsListAR_[0] = 1;
for (var i:int = 1; i < animationAR.length; i++)
{
animationsListAR_[i] = animationAR[i - 1];
}
*/
}
// If active_ is true the game will add EventListeners to this object.
if (active_ == true)
{
this.addEventListener(MouseEvent.MOUSE_DOWN,mouseOverHandler);
this.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler);
this.addEventListener(MouseEvent.MOUSE_OUT,mouseOutHandler);
}
// Needed to monitor the active_ var.
this.addEventListener(Event.CHANGE, activeChangeHandler);
}
// This function swaps the active_ variable value and calls activeChangeHandler.
public function ActiveChange()
{
active_ = ! active_;
this.dispatchEvent(new Event(Event.CHANGE));
}
public function mouseOverHandler( evt:MouseEvent )
{
if(evt.type == MouseEvent.MOUSE_DOWN)
{
curState_ = 2;
if (animated_ == true)
{
loopSegment( ( animationsListAR_[1] + 1 ), animationsListAR_[2] );
}
else
{
this.gotoAndStop( curState_ );
}
this.addEventListener( MouseEvent.MOUSE_UP, function( evt:MouseEvent ):void
{
evt.target.removeEventListener( MouseEvent.MOUSE_DOWN, arguments.callee );
curState_ = 3;
evt.target.gotoAndStop( curState_ );
});
}
else if( evt.buttonDown != true )
{
curState_ = 3;
if (animated_ == true)
{
loopSegment( ( animationsListAR_[2] + 1 ), animationsListAR_[3] );
}
else
{
this.gotoAndStop( curState_ );
}
}
dispatchEvent(new CustomButtonEvent(CustomButtonEvent.OVER));
}
public function mouseOutHandler(evt:MouseEvent)
{
curState_ = 1;
if (animated_ == true)
{
loopSegment( ( animationsListAR_[0] ), animationsListAR_[1] );
}
else
{
this.gotoAndStop( curState_ );
}
dispatchEvent(new CustomButtonEvent(CustomButtonEvent.OUT));
}
public function activeChangeHandler(evt:Event)
{
if (active_ == true)
{
this.addEventListener(MouseEvent.CLICK,mouseOverHandler);
this.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler);
this.addEventListener(MouseEvent.MOUSE_OUT,mouseOutHandler);
}
else
{
this.removeEventListener(MouseEvent.CLICK,mouseOverHandler);
this.removeEventListener(MouseEvent.MOUSE_OVER,mouseOverHandler);
this.removeEventListener(MouseEvent.MOUSE_OUT,mouseOutHandler);
}
// modifyMaskButton();
}
/*
public function modifyMaskButton():void
{
if (active_ = true)
{
}
else
{
}
}
*/
public function playSegment( begin:int, end:int ):void
{
if (begin != end)
{
gotoAndPlay( begin );
addEventListener(Event.ENTER_FRAME,function( evt:Event ):void
{
if( currentFrame == end )
{
stop();
removeEventListener(Event.ENTER_FRAME, arguments.callee);
}
});
}
else
{
this.gotoAndStop( end );
}
}
// This loops continuosly an animation. Should, at least...
public function loopSegment( begin:int, end:int ):void
{
if (begin != end)
{
gotoAndPlay( begin );
addEventListener(Event.ENTER_FRAME,function( evt:Event ):void
{
if( currentFrame == end )
{
gotoAndPlay( begin );
}
});
}
else
{
this.gotoAndStop( end );
}
}
}
}
Second File:
package
{
import flash.display.MovieClip;
import flash.text.TextField;
public class CustomTextField extends MovieClip
{
private var textArea:TextField;
private var boldText:TextFormat = new TextFormat();
function CustomTextField()
{
textArea = new TextField;
}
override function CustomTextfield( labelText:String, font:String = "Arial", color:uint = 0xFFFFFFFF, size:uint = 10 )
{
textArea = new TextField;
boldText.font = font;
boldText.color = color;
boldText.size = size;
this.text = labelText;
}
function changeFont( font:String ):void
{
boldText.font = font;
updateText();
}
function changeColor( color:uint ):void
{
boldText.color = color;
updateText();
}
function changeSize( size:uint ):void
{
boldText.size = size;
updateText();
}
function embedText( choice:Boolean ):void
{
this.embedFonts = choice;
}
function updateText():void
{
this.setTextFormat( boldText );
}
}
}

Check this line in the second file:
override function CustomTextfield( labelText:String, font:String = "Arial"
"CustomTextfield" // should be "CustomTextField",within your script missing the capital letter.
I think your getting 2 errors as this function is triggered twice within script or some related change it and let us know.

Related

ActionScript3, dropping on stage not working after using MouseEnabled

I'm trying to do do a BattleShip Flash game using ActionScript 3.
1- I draw a grid (class: com.Battleship.grid) using a gridCell:movieClip (class: com.battleship.GridCell)
2- I draw a ship (class: com.battleship.Bateau)
My objective is when I drag the ship to the grid the alpha cell under the mouse changes, and if I drop:
1- if the droptarget is a gridCell, the ship takes place (works fine)
2- if the droptarget is stage, the ship return to originPosition (not working)
My problem: after I used MouseEnabled= false, the ship can drop on the grid, but not on the stage and still dragging.
Here is my code:
var grid:Grid = new Grid(10,new Point(20,20));
var b1:Bateau = new Bateau();
b1.x = 490;
b1.y = 300;
b1.originPos = new Point(b1.x,b1.y);
addChild(b1)
addChild(grid);
package com.battleship {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.events.Event;
public class Bateau extends MovieClip {
private var _originPos:Point;
public function Bateau() {
originPos = new Point();
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, onDrag);
}
protected function onDrag(e:MouseEvent):void
{
e.currentTarget.parent.addChild(e.currentTarget);
e.currentTarget.startDrag();
e.currentTarget.mouseEnabled = false;
//e.currentTarget.mouseChildren = false;
addEventListener(MouseEvent.MOUSE_UP, onDrop);
parent.addEventListener(MouseEvent.MOUSE_UP, onDrop);
}
protected function onDrop(e:MouseEvent):void
{
e.currentTarget.mouseEnabled = true;
e.currentTarget.mouseChildren = true;
e.currentTarget.stopDrag();
if(dropTarget == null){
x = originPos.x;
y = originPos.y;
}else{
trace(e.currentTarget.name);
if(dropTarget.parent is GridCell)
{
x = dropTarget.parent.x+20;
y = dropTarget.parent.y;
}
}
}
public function get originPos():Point
{
return _originPos;
}
public function set originPos(originPos:Point):void
{
_originPos = originPos;
}
}
}
package com.battleship {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class GridCell extends MovieClip {
private var _row:int;
private var _col:int;
private var _val:int;
public function GridCell()
{
addEventListener(MouseEvent.CLICK,onClick);
addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT,onMouseOut);
}
public function onClick(e:MouseEvent)
{
//trace("(" + e.currentTarget.row+ ", " + e.currentTarget.col + ")");
trace(e.currentTarget.name);
}
public function onMouseOver(e:MouseEvent)
{
alpha = 0.6;
}
public function onMouseOut(e:MouseEvent)
{
alpha = 1;
}
public function get row():int
{
return _row;
}
public function set row(row:int):void
{
_row = row;
}
public function get col():int
{
return _col;
}
public function set col(col:int):void
{
_col = col;
}
public function get val():int
{
return _val;
}
public function set val(val:int):void
{
_val = val;
}
}
}
package com.battleship {
import flash.geom.Point;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class Grid extends Sprite {
private var _size:int;
private var _position:Point;
public function Grid(size:int,position:Point):void
{
_size = size;
_position = position;
var gridCells:Array = new Array(size,size);
var i,j:int;
for(i=0;i<size;i++)
{
gridCells[i] = new Array();
for(j=0;j<size;j++)
{
var cell:GridCell = new GridCell();
cell.row = j+1;
cell.col = i+1;
cell.x = this.position.x + cell.width * (i+1);
cell.y = this.position.x + cell.height * (j+1);
cell.name = "cell" + (j+1) + (i+1);
//cell.addEventListener(MouseEvent.CLICK,onClick);
gridCells[i][j] = cell;
this.addChild(gridCells[i][j]);
}
}
}
public function get size():int
{
return _size;
}
public function set size(size:int):void
{
_size = size;
}
public function get position():Point
{
return _position;
}
public function set position(position:Point):void
{
_position = position;
}
}
}

Flash An Error- 1013: The private attribute may be used only on class property definitions

I'm trying to make a timer countdown, I believe I have all the pieces there its just keeps giving me this error when whenever I test it.
Any idea what's going on?
package
{
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class MainTimer extends MovieClip {
private var currentMin:int;
private var currentSec:int;
private var oneSecondTimer:Timer = new Timer (1000,1);
public var timeHasStopped:Boolean=false;
public function MainTimer() {
// constructor code
trace("the main timer is here");
currentMin = 2;
currentSec = 5;
minBox.text = String(currentMin);
if(currentSec < 10)
{
secBox.text = "0" + String(currentSec);
}
else {
secBox.text = String(currentSec);
}
oneSecondTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
oneSecondTimer.start();
private function onTimerComplete(event:TimerEvent):void {
currentSec = currentSec -1;
if(currentSec <0)
{
currentSec =59;
currentMin -=1;
} //end if
if(currentMin < 0) {
currentMin =0;
currentSec =0;
timerHasStopped = true;
}
else
{
oneSecondTimer.start();
}
minBox.text =String(currentMin);
secBox.text =String(currentSec);
if(currentSec <10)
{
secBox.text = "0" + String(currentSec);
}
}
} // Ends Function
} // Ends Class
} // Ends Package
A functon must have opening { braces and must be closed with a } before you make another new function. Your } // Ends Function should be placed after the line oneSecondTimer.start(); and from there onwards you can define you other second function function onTimerComplete
It might help if you indent your code so you can see easily where things begin & end (use TAB key).
An example of your indented code would be like below (texts removed), see how this structure makes it easier to see braces & therefore spot any missing or extra braces?
public function MainTimer()
{
// constructor code
.......
if(currentSec < 10)
{
.......
}
else
{
.......
}
.......
} //Ends function called MainTimer
private function onTimerComplete(event:TimerEvent):void
{
.......
if(currentSec <0)
{
.......
} //end if
if(currentMin < 0)
{
.......
}
else
{
.......
}
.......
if(currentSec <10)
{
.......
}
} //Ends function called onTimerComplete
The function onTimerComplete is inside the function MainTimer; it is not a class member so the private keyword is not applicable.

AS3 Trouble accessing a static class from inside a nested symbol

So basically this is a question about why my calling class (Door) can not identify this static variable class (Game State). it is throwing a #1009 error saying I can not access with GameState.gameState. On my stage I have a Symbol (CampaignLevel_001) that contains additional symbols like the calling symbol (Door) and above that as a separate Symbol (GameState) so essentially I am having trouble getting a nested symbol / class talking to another class.
package game.GameStates
{
import game.Assets.Player;
import game.Assets.Turret;
import game.Assets.Door;
import flash.events.Event;
import flash.display.MovieClip;
import flash.geom.Point;
import game.Levels.CampaignLevel_001;
public class GameState extends MovieClip
{
//VARIABLES
public var enemyArray : Array;
public var Bullets : Array = new Array();
public var Keys : Array = new Array();
public var HeldKeys : Array = new Array ();
public var Door : Array = new Array();
public var Terrain : Array = new Array();
public var Turrets : Array = new Array ();
public var Blood : Array = new Array ();
public var Shields : Array = new Array ();
public var Levels : Array = new Array ();
public var NumKeys : int;
public var DoorLock : Boolean = false;
public var PlayerSpawnPoint : Point;
public var CampaignSpawnPoint : Point;
public static var gameState : GameState;
public var player : Player;
public var turret : Turret;
public var PlayerLives : int = 99;
public function GameState()
{ // constructor code
gameState = this;
addEventListener(Event.ADDED_TO_STAGE, Awake);
} // constructor code
private function Awake (e : Event) : void
{
enemyArray = new Array();
trace(enemyArray.length);
}
public function OpenDoor () : void
{
if (NumKeys <= 0)
{
DoorLock = true;
}
if (NumKeys > 0)
{
DoorLock = false;
}
}
public function NextLevel () : void
{
RemoveListeners();
trace("SHOULD BE GOING TO THE NEXT LEVEL");
while (Levels.length > 0)
{
for each (var level in Levels)
{
level.NextLevel ();
}
}
}
public function RespawnPlayer () : void
{
//Spawn Player at player start point
player = new Player();
player.x = PlayerSpawnPoint.x;
player.y = PlayerSpawnPoint.y;
addChild(player);
trace("PLAYER ARRAY IS THIS LONG " + enemyArray.length);
trace("spawned Player!");
}
public function setSpellIcons (spell : String , opacity : int) : void
{
if (spell == "dodge")
{
if (opacity == 0)
{
dodgeSymbol.alpha = 0;
}
if (opacity == 1)
{
dodgeSymbol.alpha = 1;
}
}
if (spell == "shield")
{
if (opacity == 0)
{
shieldSymbol.alpha = 0;
}
if (opacity == 1)
{
shieldSymbol.alpha = 1;
}
}
} //public function setSpellIcons (spell : String , opacity : int) : void
public function RemoveListeners() : void
{
while (enemyArray.length > 0)
{
for each (var enemy : MovieClip in enemyArray)
{
enemy.RemovePlayer ();
}
}
while (Door.length > 0)
{
for each (var door : MovieClip in Door)
{
door.RemoveDoorFunctions ();
}
}
while (Bullets.length > 0)
{
for each (var bullet : MovieClip in Bullets)
{
bullet.RemoveProjectile();
}
}
while (Keys.length > 0)
{
for each (var key : MovieClip in Keys)
{
key.RemoveKey ();
}
}
while (Terrain.length > 0)
{
for each (var terrain : MovieClip in Terrain)
{
terrain.RemoveTerrainListeners();
}
}
while (Turrets.length > 0)
{
for each (var turret in Turrets)
{
turret.RemoveTurretListeners();
}
}
while (Blood.length > 0)
{
for each (var splatter in Blood)
{
splatter.RemoveBlood();
}
}
while (Shields.length > 0)
{
for each (var shield in Shields)
{
shield.RemoveShield();
}
}
} //public function RemoveListeners() : void
}
}
The Class that holds (door)
package game.Levels
{
import game.GameStates.GameState;
import flash.display.MovieClip;
import flash.events.Event;
public class CampaignLevel_001 extends MovieClip
{
var currentLevel : int = currentFrame;
public function CampaignLevel_001()
{ // constructor code
addEventListener(Event.ADDED_TO_STAGE, Awake);
}
private function Awake (e : Event) : void
{
GameState.gameState.Levels.push(this);
gotoAndStop(currentLevel);
trace ("CURRENT LEVEL IS " + currentLevel);
}
public function NextLevel () : void
{
var nextLevel : int = currentFrame + 1;
gotoAndStop(nextLevel);
trace ("NEXT LEVEL IS " + nextLevel);
}
}
}
and the calling class (door) is
package game.Assets
{
import flash.display.MovieClip;
import flash.events.Event;
import game.GameStates.GameState;
public class Door extends MovieClip
{
public function Door()
{ // constructor code
addEventListener(Event.ADDED_TO_STAGE, Awake);
}
private function Awake (e : Event) : void
{
GameState.gameState.Door.push(this);
GameState.gameState.OpenDoor ();
stage.addEventListener(Event.ENTER_FRAME, update);
open.alpha = 0;
}
private function update (e : Event) : void
{
if (GameState.gameState.DoorLock == true)
{
open.alpha = 1;
}
if (GameState.gameState.DoorLock == false)
{
open.alpha = 0;
}
}
public function RemoveDoorFunctions () : void
{
GameState.gameState.Door.splice(GameState.gameState.Door.indexOf(this),1);
stage.removeEventListener(Event.ENTER_FRAME, update);
parent.removeChild(this);
}
}
}
It looks like you're trying to make a Singleton, but haven't added the instance function.
change this:
public static var gameState:GameState;
to:
private static var _gameState:GameState;
and remove the constructor gamestate = this;
and add a function:
public static function get gameState():GameState {
if{_gameState == null) {
_gameState = new GameState();
}
return _gameState;
}
You can then call it and only get the one instance of GameState by:
GameState.gameState.DoorLock == true;
and any other function in GameState the same way

1180: Call to a possibly undefined method FlipUntilHead

package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.MouseEvent;
public class coinFlip extends MovieClip {// class
var bool:Boolean;
var num1:Number;
var counter:int;
public function coinFlip() {// constructor
RandomTruth();
var textF1:TextField = new TextField();
FlipUntilHead(RandomTruth); // the error is right here*
if (bool == false) {
textF1.text = "tails";
} else {
textF1.text = "heads";
}
addChild(textF1);
function RandomTruth() {
num1 = Math.random();
//trace(num1);
if (num1 < 0.5) {
bool = false;
return;
} else {
bool = true;
return;
}
function FlipUntilHead(RandomTruth) {
while (bool == false) {
RandomTruth();
counter ++;
return
}
//trace(counter);
}
}
}// end of constructor
}// end of class
}// end of package (program)
The program is supposed to "flip" a coin until it lands on heads using Math.random and boolean variables to declare if its "heads" or "tails".
I think it might be a very simple error and I am just dumb (beginner in programming).
The error is:
"1180: Call to a possibly undefined method FlipUntilHead"
Problem 1: You do not have to pass any parameters into your FlipUntilHead() function, because that function already calls RandomTruth().
Instead of function FlipUntilHead(RandomTruth) use function FlipUntilHead().
Then, instead of
RandomTruth();
var textF1:TextField = new TextField();
FlipUntilHead(RandomTruth);
use
var textF1:TextField = new TextField();
FlipUntilHead();
Although the function name indeed existed, the error was being thrown because it didn't understand the way that you were passing RandomTruth into it.
Problem 2: Also, there should be a } just before function FlipUntilHead(){, and one less } at the end of your program.
Problem 3: Finally, the while loop within FlipUntilHead() is not looping properly, because there is a return statement that immediately ends the function at the first loop. Here is the final code:
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.MouseEvent;
public class coinFlip extends MovieClip {
var bool:Boolean;
var num1:Number;
var counter:int;
public function coinFlip() {
var textF1:TextField = new TextField();
FlipUntilHead();
if (bool == false) {
textF1.text = "tails";
} else {
textF1.text = "heads";
}
addChild(textF1);
function RandomTruth() {
num1 = Math.random();
if (num1 < 0.5) {
bool = false;
return;
} else {
bool = true;
return;
}
}
function FlipUntilHead() {
while (bool == false) {
RandomTruth();
counter++;
}
}
}
}
}

LoaderMax image resize

I am trying to load xml images using LoaderMax and resize them using LiquidArea. When I try to load in a different image with resize using next or thumbnails, I get a weird error I can't understand. I was not able to get help so I've come here. The error message and code can be seen below.
RangeError: Error #2006: The supplied index is out of bounds.
at flash.display::DisplayObjectContainer/addChildAt()
at com.greensock.layout::AutoFitArea/set preview()
at com.greensock.layout.core::LiquidData/refreshLevel()
at com.greensock.layout::LiquidStage/refreshLevels()
at com.greensock.layout.core::LiquidData$/addCacheData()
at com.greensock.layout::LiquidArea/pinCorners()
at com.greensock.layout::LiquidArea/autoPinCorners()
at com.greensock.layout::LiquidArea()
at Main/loadImage()
at Function/<anonymous>()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.greensock.core::TweenCore/complete()
at com.greensock::TweenMax/complete()
at com.greensock::TweenMax/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.DisplayObject;
import com.greensock.TweenMax;
import com.greensock.layout.*;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.XMLLoader;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.ImageLoader;
import com.greensock.loading.data.ImageLoaderVars;
import com.greensock.loading.display.ContentDisplay;
public class Main extends MovieClip
{
private static const THUMB_WIDTH:Number = 100;
private static const THUMB_HEIGHT:Number = 64;
private static const IMAGE_WIDTH:Number = 550;
private static const IMAGE_HEIGHT:Number = 355;
private var ls:LiquidStage;
private var la:LiquidArea;
private var xImgList:XMLList;
public var arrowRight:MovieClip;
public var arrowLeft:MovieClip;
private var currentImage:String;
private var image:ImageLoader;
private var index:Number = 0;
public function Main()
{
// load in xml
var xPhotography:XMLLoader = new XMLLoader("assets/data.xml");
xPhotography.addEventListener( LoaderEvent.COMPLETE, xmlLoaded );
xPhotography.load();
arrowRight.alpha = arrowLeft.alpha = 0;
arrowRight.addEventListener(MouseEvent.ROLL_OVER, rollOverArrowHandler, false, 0, true);
arrowRight.addEventListener(MouseEvent.ROLL_OUT, rollOutArrowHandler, false, 0, true);
arrowRight.addEventListener( MouseEvent.CLICK, onArrowClick );
arrowLeft.addEventListener(MouseEvent.ROLL_OVER, rollOverArrowHandler, false, 0, true);
arrowLeft.addEventListener(MouseEvent.ROLL_OUT, rollOutArrowHandler, false, 0, true);
arrowLeft.addEventListener( MouseEvent.CLICK, onArrowClick );
}
private function xmlLoaded( e:LoaderEvent ):void
{
var xData:XML = e.target.content;// get copy of xml
xImgList = new XMLList(xData.image);// grabbing xml image nodes
loadImage( 0 );
}
// load in the image
private function loadImage( index: Number ):void
{
ls = new LiquidStage(this.stage,550,419);
la = new LiquidArea(imgContainer, 0, 0, 550, 419);
var file:String = xImgList[index]. # url;
var image:ImageLoader = new ImageLoader("assets/images/" + file, new ImageLoaderVars()
.container( imgContainer )
.x(0)
.y(0)
.alpha( 0 )
.width( IMAGE_WIDTH )
.height( IMAGE_HEIGHT )
.onComplete(completeHandler)
.scaleMode( "proportionalOutside" )
);
image.load();
la.attach(image.content, {scaleMode:ScaleMode.PROPORTIONAL_OUTSIDE, crop:true});
}
private function completeHandler(event:LoaderEvent):void
{
TweenMax.to(event.target.content, 1.5, {alpha:1});
}
private function rollOverArrowHandler(e:MouseEvent):void
{
TweenMax.to(e.currentTarget, 0.5, {alpha:1});
}
private function rollOutArrowHandler(e:MouseEvent):void
{
TweenMax.to(e.currentTarget, 0.5, {alpha:0});
}
private function onArrowClick( e:MouseEvent ):void
{
switch (e.target)
{
case arrowRight :
index++;
break;
case arrowLeft :
index--;
break;
}
if (index == xImgList.length())
{
index = 0;
} else if (index < 0)
{
index = xImgList.length() - 1;
}
checkOldImage( index );// needed to help loading times
}
private function checkOldImage( index:Number ):void
{
var oldClip:DisplayObject = imgContainer.getChildAt( 0 );
var nextIndex = index;
TweenMax.to( oldClip, .5, { autoAlpha: 0, onComplete: completeFadeHandler, onCompleteParams:[oldClip] } );
function completeFadeHandler(child:DisplayObject):void {
if (child.parent) {
child.parent.removeChild(child);
}
loadImage(nextIndex);
}
}
}
}