Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   1046: Type was not found or was not a compile-time constant: left. (http://www.flasher.ru/forum/showthread.php?t=96206)

Фломастер 25.05.2007 14:52

1046: Type was not found or was not a compile-time constant: left.
 
1046: Type was not found or was not a compile-time constant: left.

что означает это сообщение?
ошибка в строчке
var xmlDoc:XMLStructure = new XMLStructure("images.xml");

XMLStructure - это мой класс, реализующий проходы по XML-файлу. он был написан на AS2.0

я в нём добавил package{} и XML типы поменял на XMLDocument

что надо сделать, чтобы AS3 увидел мой класс?

ещё флеш выдаёт такие ошибки

1046: Type was not found or was not a compile-time constant: XMLStructure.
1180: Call to a possibly undefined method XMLStructure.

etc 25.05.2007 15:05

Покажите весь класс. Так вот просто добавить package и чтобы заработал, как AS3, не получится.

Фломастер 25.05.2007 15:27

вот мой класс

Код:

package {
        import flash.xml.XMLDocument;
        import flash.xml.XMLNode;
        import flash.xml.XMLNodeType;
        import flash.system.System;

        class XMLStructure {
                static var currentImage:Image = new Image();
                static var currentFolder:Folder = new Folder();
                static var input_xml = new XMLDocument();
                function XMLStructure(xml_document:String) {
                        var nodeDepth = 0;
                        XMLNode.prototype.nextNodeTab = function() {
                        if (this.firstChild != null) {
                        this.firstChild.attributes.tab = ++nodeDepth;
                        return this.firstChild;
                        }
                        var n = this;
                        while (n.nextSibling == null) {
                        if (n.parentNode) {
                        nodeDepth--;
                        n = n.parentNode;
                        } else {
                        return null;
                        }
                        }
                        n.nextSibling.attributes.tab = nodeDepth;
                        return n.nextSibling;
                        };
                        XMLNode.prototype.nextNode = function() {
                        if (this.firstChild != null) {
                        //this.firstChild.attributes.tab = ++_root.nodeDepth;
                        return this.firstChild;
                        }
                        var n = this;
                        while (n.nextSibling == null) {
                        if (n.parentNode) {
                        //_root.nodeDepth--;
                        n = n.parentNode;
                        } else {
                        return null;
                        }
                        }
                        //n.nextSibling.attributes.tab = _root.nodeDepth;
                        return n.nextSibling;
                        };
                        XMLNode.prototype.previousNode = function() {
                        var n = this;
                        if (n.previousSibling == null) {
                        if (n.parentNode) {
                       
                        n = n.parentNode;
                        return n;
                        } else {
                        return null;
                        }
                        }
                        n = n.previousSibling;
                        while (n.lastChild != null) {
                       
                        n=n.lastChild;
                        }
                       
                        return n;
                        };
                        XMLNode.prototype.get_parentNode = function() {
                        var n = this;
                        return n.parentNode;
                        };
                        System.useCodePage = true;
                        input_xml.ignoreWhite = true;//  было XMLDocument.prototype.ignoreWhite = true;
                        input_xml.load(xml_document);
                        //var intervalID:Number = setInterval(checkProgress, 1, input_xml);
                        input_xml.onLoad = function(success) {
                        //clearInterval(intervalID);
                        //trace("intervalID: "+intervalID);
                        if (success) {
                        if (this.status != 0) {
                        trace("xml - invalid");
                        } else {
                        trace("successfull");
                        this.addAttributes();
                        this.init();
                        }
                        } else {
                        trace("error opening URL");
                        }
                        };
                        input_xml.addAttributes = function() {
                        var i = 0;
                        var nod = this.firstChild;
                        while (nod) {
                        nod.attributes.ID = i++;
                        nod = nod.nextNodeTab();
                        }
                        this.parseXML(this.firstChild);
                        };
                        input_xml.init = function() {
                        var nod = input_xml.firstChild;
                        while (nod.attributes.ID == 0) {
                        nod = nod.nextNode();
                        }
                        if (nod == null) {
                        trace("no images");
                        return null;
                        } else {
                        currentFolder = nod.parentNode.attributes;
                        while (nod.nodeName.toUpperCase() != "IMAGE") {
                        nod = nod.nextSibling;
                        if (nod == null) {
                        trace("no images");
                        return null;
                        } else {
                        currentFolder = nod.parentNode.attributes;
                        }
                        }
                        currentImage = nod.attributes;
                        return currentImage.name;
                        }
                        };
                }
                var checkProgress = function () {
                var bytesLoaded:Number = input_xml.getBytesLoaded();
                var bytesTotal:Number = input_xml.getBytesTotal();
                var percentLoaded:Number = Math.floor((bytesLoaded/bytesTotal)*100);
                if (isNaN(percentLoaded)) {
                return 0;
                } else {
                return percentLoaded;
                }
                };
                function nextImage() {
                        var nod = input_xml.firstChild;
                        while (nod.attributes.ID != currentImage.ID) {
                                nod = nod.nextNode();
                        }
                        nod = nod.nextNode();
                        if (nod == null) {
                                trace("images ends");
                                return null;
                        } else {
                                currentFolder = nod.parentNode.attributes;
                                while (nod.nodeName.toUpperCase() != "IMAGE") {
                                        nod = nod.nextNode();
                                        if (nod == null) {
                                                trace("images ends");
                                                return null;
                                        } else {
                                                currentFolder = nod.parentNode.attributes;
                                        }
                                }
                                currentImage = nod.attributes;
                                return currentImage.name;
                        }
                }
                function previousImage() {
                        var nod = input_xml.firstChild;
                        while (nod.attributes.ID != currentImage.ID) {
                                nod = nod.nextNode();
                        }
                        nod = nod.previousNode();
                        if (nod == null) {
                                trace("images ends");
                                return null;
                        } else {
                                currentFolder = nod.parentNode.attributes;
                                while (nod.nodeName.toUpperCase() != "IMAGE") {
                                        nod = nod.previousNode();
                                        if (nod == null) {
                                                trace("images ends");
                                                return null;
                                        } else {
                                                currentFolder = nod.parentNode.attributes;
                                        }
                                }
                                currentImage = nod.attributes;
                                return currentImage.name;
                        }
                }
                function get_currentImage() {
                        return currentImage;
                }
                function set_currentImage(identificator:Number) {
                        var nod = input_xml.firstChild;
                        while (nod.attributes.ID != identificator) {
                                nod = nod.nextNode();
                        }
                        if (nod == null) {
                                trace("images ends");
                                return null;
                        } else {
                                currentFolder = nod.parentNode.attributes;
                                while (nod.nodeName.toUpperCase() != "IMAGE") {
                                        nod = nod.nextNode();
                                        if (nod == null) {
                                                trace("images ends");
                                                return null;
                                        } else {
                                                currentFolder = nod.parentNode.attributes;
                                        }
                                }
                                currentImage = nod.attributes;
                                return currentImage.name;
                        }
                }
        }
}


etc 25.05.2007 15:31

О боже, это AS1 код, который запихнули в конструктор AS3 класса. Нужно переписывать код целиком, с нуля. Писать нормальный класс и т.п.

Фломастер 25.05.2007 15:47

ясно... вот этого я больше всего и не хотел...


Часовой пояс GMT +4, время: 17:19.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.