你好我写了这段代码,当我运行PUBLISH时它显示我没有错误但是当我在最后一张海报上运行flash窗口时显示
TypeError: Error #1010: A term is undefined and has no properties.
at slider_fla::MainTimeline/nextClick()
这里代码:
var sliderNum:int = 0;
var sliderMaxNum:int = 0;
function nextClick(event:MouseEvent):void
{
if (sliderNum > sliderMaxNum){
sliderNum = 0;
}
var myTween:Tween = new Tween(poster[sliderNum],'x',Strong.easeOut,poster[sliderNum].x,-800,2,true);
if (sliderNum == sliderMaxNum){
trace(String(sliderNum));
trace(String(sliderMaxNum));
sliderNum = 0;
} else {
sliderNum = sliderNum +1;
}
var myTween2:Tween = new Tween(poster[sliderNum],'x',Strong.easeOut,poster[sliderNum].x,(myStage.stageWidth - 640)/2,2,true);
}
我使用此代码加载XML:
function loadXML(event:Event):void{
sliderXML=XML(sliderXMLloader.data);
var xmlDoc:XMLDocument = new XMLDocument();
xmlDoc.ignoreWhite = true;
var menuXML:XML = XML(sliderXMLloader.data);
xmlDoc.parseXML(menuXML.toXMLString());
//var X:int = 100;
for each(var listItem:XML in sliderXML..listItem){
strTitle[sliderMaxNum] = listItem.itemTitle.toString();
strPosterLink[sliderMaxNum] = listItem.posterLink.toString();
strVideoLink[sliderMaxNum] = listItem.videoLink.toString();
var _temp:Loader = new Loader();
poster.splice(sliderMaxNum, 0, _temp);
poster[sliderMaxNum].load(new URLRequest(strPosterLink[sliderMaxNum]));
//var posterClip:MovieClip = new MovieClip(); //load the movieclip
//posterClip.addChild(poster[sliderMaxNum]); //convert poster[sliderMaxNum] to movieClip
addChild(poster[sliderMaxNum]);
poster[sliderMaxNum].x = myStage.stageWidth;
poster[sliderMaxNum].y = 28;
poster[sliderMaxNum].addEventListener(MouseEvent.CLICK, poster_click(sliderMaxNum));
sliderMaxNum = sliderMaxNum+1;
}
LastSliderNum = sliderMaxNum - 1;
//*************************************************
var myTween:Tween = new Tween(poster[sliderNum],'x',Strong.easeOut,poster[sliderNum].x,(myStage.stageWidth - 640)/2,2,true);
//*************************************************
}
答案 0 :(得分:0)
这是一个完整的代码:
import flash.display.Stage;
import flash.events.Event;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.xml.XMLDocument;
import flash.text.TextField;
//tween - start
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.events.MouseEvent;
//tween - end
var myStage:Stage = this.stage;
myStage.scaleMode = StageScaleMode.NO_SCALE;
myStage.align = StageAlign.TOP_LEFT;
var sliderXML:XML = new XML();
var sliderXMLurl:String = 'sliderXML.xml';
var sliderXMLreq:URLRequest = new URLRequest(sliderXMLurl);
var sliderXMLloader:URLLoader = new URLLoader(sliderXMLreq);
sliderXMLloader.addEventListener("complete",loadXML);
var sliderNum:int = 0;
var sliderMaxNum:int = 0;
var LastSliderNum:int = 0;
var strTitle:Array = [];
var strPosterLink:Array = [];
var strVideoLink:Array = [];
var poster:Array = [];
var Playing:int = 1;
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler);
myStage.addEventListener(Event.RESIZE, ResizeHandler);
function fl_EnterFrameHandler(event:Event):void
{
var swfWidth:int = myStage.stageWidth;
var swfHeight:int = myStage.stageHeight;
slider_bg.width = swfWidth;
slider_bg.height = swfHeight;
slider_header.width = swfWidth;
slider_bg.height = myStage.stageHeight - slider_header.height - slider_footer.height;
slider_footer.width = swfWidth;
slider_footer.y = slider_header.height + slider_bg.height;
back_btn.x = myStage.stageWidth / 2 - 25 - 65;
back_btn.y = myStage.stageHeight - 66;
next_btn.x = myStage.stageWidth / 2 + 30;
next_btn.y = myStage.stageHeight - 66;
if (Playing == 0){
play_btn.x = (myStage.stageWidth - 50) / 2;
play_btn.y = (myStage.stageHeight - 50 - 31);
pause_btn.x = play_btn.x;
pause_btn.y = myStage.stageHeight + 100;
} else if (Playing == 1) {
pause_btn.x = (myStage.stageWidth - 50) / 2;
pause_btn.y = (myStage.stageHeight - 50 - 31);
play_btn.x = pause_btn.x;
play_btn.y = myStage.stageHeight + 100;
}
}
function loadXML(event:Event):void{
sliderXML=XML(sliderXMLloader.data);
var xmlDoc:XMLDocument = new XMLDocument();
xmlDoc.ignoreWhite = true;
var menuXML:XML = XML(sliderXMLloader.data);
xmlDoc.parseXML(menuXML.toXMLString());
//var X:int = 100;
for each(var listItem:XML in sliderXML..listItem){
strTitle[sliderMaxNum] = listItem.itemTitle.toString();
strPosterLink[sliderMaxNum] = listItem.posterLink.toString();
strVideoLink[sliderMaxNum] = listItem.videoLink.toString();
var _temp:Loader = new Loader();
poster.splice(sliderMaxNum, 0, _temp);
poster[sliderMaxNum].load(new URLRequest(strPosterLink[sliderMaxNum]));
//var posterClip:MovieClip = new MovieClip(); //load the movieclip
//posterClip.addChild(poster[sliderMaxNum]); //convert poster[sliderMaxNum] to movieClip
addChild(poster[sliderMaxNum]);
poster[sliderMaxNum].x = myStage.stageWidth;
poster[sliderMaxNum].y = 28;
poster[sliderMaxNum].addEventListener(MouseEvent.CLICK, poster_click(sliderMaxNum));
sliderMaxNum = sliderMaxNum+1;
}
LastSliderNum = sliderMaxNum - 1;
//*************************************************
var myTween:Tween = new Tween(poster[sliderNum],'x',Strong.easeOut,poster[sliderNum].x,(myStage.stageWidth - 640)/2,2,true);
//*************************************************
}
function ResizeHandler(event:Event):void{
var i:int = 0;
for (i=0; i < poster.length; i++) {
poster[i].x = myStage.stageWidth + 100;
}
poster[sliderNum].x = (myStage.stageWidth - 640)/2;
}
function poster_click(i:int):Function{
var foo:Function = function (evt:MouseEvent):void {
trace(String(i));
}
return foo;
}
function poster_next(i:int):void{
}
//play button*********************************************
play_btn.buttonMode = true;
play_btn.addEventListener(MouseEvent.MOUSE_OVER, playOver);
play_btn.addEventListener(MouseEvent.MOUSE_OUT, playOut);
play_btn.addEventListener(MouseEvent.CLICK, playClick);
function playOver(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('playOver');
}
function playOut(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('playOut');
}
function playClick(event:MouseEvent):void
{
Playing = 1;
}
//pause button*********************************************
pause_btn.buttonMode = true;
pause_btn.addEventListener(MouseEvent.MOUSE_OVER, pauseOver);
pause_btn.addEventListener(MouseEvent.MOUSE_OUT, pauseOut);
pause_btn.addEventListener(MouseEvent.CLICK, pauseClick);
function pauseOver(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('pauseOver');
}
function pauseOut(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('pauseOut');
}
function pauseClick(event:MouseEvent):void
{
Playing = 0;
}
//back_btn **************************************************
back_btn.buttonMode = true;
back_btn.addEventListener(MouseEvent.MOUSE_OVER, backOver);
back_btn.addEventListener(MouseEvent.MOUSE_OUT, backOut);
back_btn.addEventListener(MouseEvent.CLICK, backClick);
function backOver(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('backOver');
}
function backOut(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('backOut');
}
function backClick(event:MouseEvent):void
{
}
//next_btn ***************************************************
next_btn.buttonMode =true;
next_btn.addEventListener(MouseEvent.MOUSE_OVER, nextOver);
next_btn.addEventListener(MouseEvent.MOUSE_OUT, nextOut);
next_btn.addEventListener(MouseEvent.CLICK, nextClick);
function nextOver(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('nextOver');
}
function nextOut(event:MouseEvent):void
{
event.currentTarget.gotoAndPlay('nextOut');
}
function nextClick(event:MouseEvent):void
{
if (sliderNum > sliderMaxNum){
sliderNum = 0;
}
var myTween:Tween = new Tween(poster[sliderNum],'x',Strong.easeOut,poster[sliderNum].x,-800,2,true);
if (sliderNum == sliderMaxNum){
trace(String(sliderNum));
trace(String(sliderMaxNum));
sliderNum = 0;
} else {
sliderNum = sliderNum +1;
}
poster[sliderNum].x = myStage.stageWidth;
var myTween2:Tween = new Tween(poster[sliderNum],'x',Strong.easeOut,poster[sliderNum].x,(myStage.stageWidth - 640)/2,2,true);
}
我只是最小化它,只留下我认为可能成为问题的代码