Просмотр полной версии : text files
Здраствуйте, столкнулся с такой проблемой:
Можно ли подгрузить какой-то текст из файла, при этом чтобы в начале файла не стоял указатель переменной? :confused:
load (XML.load method)
public load(url:String) : Boolean
Loads an XML document from the specified URL, and replaces the contents of the specified XML object with the downloaded XML data. The URL is relative and is called using HTTP. The load process is asynchronous; it does not finish immediately after the load() method is executed.
When the load() method is executed, the XML object property loaded is set to false. When the XML data finishes downloading, the loaded property is set to true, and the onLoad event handler is invoked. The XML data is not parsed until it is completely downloaded. If the XML object previously contained any XML trees, they are discarded.
You can define a custom function that executes when the onLoad event handler of the XML object is invoked.
Note: If a file being loaded contains non-ASCII characters (as found in many non-English languages), it is recommended that you save the file with UTF-8 or UTF-16 encoding as opposed to a non-Unicode format like ASCII.
When using this method, consider the Flash Player security model:
For Flash Player 8:
Data loading is not allowed if the calling SWF file is in the local-with-file-system sandbox and the target resource is from a network sandbox.
Data loading is also not allowed if the calling SWF file is from a network sandbox and the target resource is local.
For more information, see the following:
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash
The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security
The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/fp8_security_apis
For Flash Player 7 and later websites can permit cross-domain access to a resource via a cross-domain policy file. In SWF files of any version running in Flash Player 7 and later, the url parameter must be in exactly the same domain. For example, a SWF file at www.someDomain.com can load data only from sources that are also at www.someDomain.com.
In SWF files running in a version of the player earlier than Flash Player 7, the url parameter must be in the same superdomain as the SWF file that issues this call. A superdomain is derived by removing the leftmost component of a file's URL. For example, a SWF file at www.someDomain.com can load data from sources at store.someDomain.com, because both files are in the same superdomain of someDomain.com.
Availability: ActionScript 1.0; Flash Player 5 - The behavior changed in Flash Player 7.
Parameters
url:String - A string that represents the URL where the XML document to be loaded is located. If the SWF file that issues this call is running in a web browser, url must be in the same domain as the SWF file.
Returns
Boolean - A Boolean value of false if no parameter (null) is passed; true otherwise. Use the onLoad() event handler to check the success of a loaded XML document.
В переводе Antares'а:
XML.load()
Доступность
Flash Player 5; behavior changed in Flash Player 7.
Синтаксис
my_xml.load(url:String) : Void
Параметры
url Строка, представляющая собой URL, откуда загружается XML документ. Если SWF, выполняющий данный запрос, запущен в браузере, url должен быть в том же домене, что и SWF файл; подробнее смотри в разделе Описание ниже.
Возвращает
Ничего.
Описание
Метод; загружает XML документ с указанного URL и заменяет содержимое вызвавшего его XML объекта загруженными XML данными. URL может быть относительным и должен быть доступен по HTTP. Загрузка проходит асинхронно; она не завершается сразу после вызова метода load() и требует определенного времени.
В SWF файлах, опубликованных для версий Flash Player, младше 7й, параметр url должен находиться в том же наддомене (superdomain), что и SWF файл, осуществляющий запрос. Наддомен получается путем удаления самой левой части из адреса URL. Например, SWF файл по адресу www.someDomain.com может загружать данные с store.someDomain.com, потому что оба файла находятся в одном наддомене, someDomain.com.
В SWF файлах, опубликованных для Flash Player 7 или более поздних версий, параметр url должен указывать на файл в том же самом домене (смотри "Безопасность во Flash Player" в Использовании ActionScript во Flash). Например, SWF файл по адресу www.someDomain.com может загружать данные только из источников, находящихся в том же самом домене, www.someDomain.com. Если Вы хотите загружать данные с других доменов, вам необходимо поместить файл с разрешением на кросс-доменный доступ (cross-domain policy file) на сервер, с которого SWF файл будет получать данные. Для более подробной информации смотри "О кросс-доменной загрузке данных " в Использовании ActionScript во Flash.
При исполнении метода load(), свойство loaded XML объекта делается равным false. Когда XML документ загружен, свойство loaded становится равным true и вызывается обработчик события onLoad. XML данные не обрабатываются анализатором (парсером) до момента полной загрузки документа. Если объект XML до начала загрузки содержал XML дерево, оно уничтожается.
Вы можете задать собственную функцию, вызываемую при срабатывании обработчика события onLoad объекта XML.
или так:
readXML = function(file){
b = new XML();
b.ignoreWhite = true;
b.onLoad = function (success) {
if (!success) {
trace ("Облом системы, N ошибки: " + this.status + "(" +errno[-this.status]+ ")");
} else {
if (this.status!=0) trace ("Некритичная ошибка в данных, N ошибки: " + this.status + "(" +errno[-this.status]+ ")");
r = (b.toString()).split("\n");
texter.text_blok.htmlText = "";
for (i=0; i<r.length; i++){
texter.text_blok.htmlText += " " + r[i];
}
}
}
b.load(file);
}
СПАСИБО огрромное :) Только что такое texter.text_blok?
texter - я так понял это мувиклип который содержит в себе текстовое поле text_blok?
Но дело в том что я пытаюсь откыть html, и скрипт не показывает все после тега <HEAD> </HEAD>
А можешь сказать где найти русский хелп на флеш старше 6й версии?
http://www.flasher.ru/forum/forumdisplay.php?f=61
№3
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.