动作脚本小错误

发布于 2024-10-26 15:04:03 字数 2393 浏览 5 评论 0原文

你好,我已经编写了这些代码,当我运行 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);
    //*************************************************
}

hello i have written these piece of code, when i run PUBLISH it shows me no error but when i run flash window on last poster it shows

TypeError: Error #1010: A term is undefined and has no properties.
    at slider_fla::MainTimeline/nextClick()

here code:

    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);
}

i use this code to load 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);
    //*************************************************
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沩ん囻菔务 2024-11-02 15:04:03

这是完整的代码:

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);
}

我只是将其最小化,只留下我认为可能有问题的代码

this is a full code:

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);
}

i just minimized it and left only the code where i think could be a problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文