Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   Прелоадер в прелоадере ? =(( (http://www.flasher.ru/forum/showthread.php?t=75353)

CORSAiR 10.02.2006 14:19

Прелоадер в прелоадере ? =((
 
Привет всем.. Нужна идея =)

Вынес прелоадер во внешний .AS файл ... все намана.. работает...

в прелоадере есть переменная ver изменяя которую, при публикации мувиков, браузеры загружают новую версию мувика, картинок и т.п..

т.е. где то там в скрипте:

Код:

MovieClip.prototype.preload = function(extFile, ...) {
....
....
_root.ver == undefined ? ver = 1.0.0.0 : ver=_root.ver;
....
....
this.PH_mc.loadMovie(extFile+"?ver="+ver);
....
....

решил эту переменную вынести во внешний файл (config.xml), чтоб не компилить весь проект каждый раз.. и вот тут наткнулся на проблему.. как эту переменную вытащить из файла.. делать прелоадер для xml внутри своего скрипта? Как? onLoad тут не помогает.. скрипт успевает отработать полностью, прежде чем загрузится файл config.xml...

Antares 10.02.2006 14:33

А что, выполнять скрипт только по загрузке никак?

CORSAiR 10.02.2006 14:47

ну.. пробовал, но.. так как только начинаю с AS работать, то получается корявенько + проблемы с видимостью переменных возникает много =) надеялся, может попроще что есть =)

ну например в скрипте такой код работал:
Код:

this.createEmptyMovieClip("bar_mc", 2);
...
...
with (this.bar_mc) {
beginFill(0x434343, 100);
lineTo(barWidth, 0);
lineTo(barWidth, 1);
lineTo(0, 1);
lineTo(0, 0);
}

в функции (onLoad)он перестает работать... с ошибкой: A 'with' action failed because the specified object did not exist

Antares 10.02.2006 18:13

Цитата:

A 'with' action failed because the specified object did not exist
Трейсим this.bar_mc и что видим?

CORSAiR 10.02.2006 22:32

Мы там видим конечно же undefined ...

чет я запутался.. я так полагаю, что проблема решается просто.. Вот сам файл:


Код:

MovieClip.prototype.preload = function(image, barWidth, imgWidth, imgHeight) {
// Определяем переменные
var barWidth = barWidth == undefined ? 100 : barWidth;
var imgWidth = imgWidth == undefined ? 0 : imgWidth;
var imgHeight = imgHeight == undefined ? 0 : imgHeight;

var str:String = new String();

_root.config == undefined ? config = "config.xml" : config=_root.config;
_root.ver == undefined ? ver = "1.0.0.0" : ver=_root.ver;


// создаем  и загружаем XML
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = loadData;
data_xml.load(config);

// Получаем нужное значение параметра ver и грузим мувик
function loadData(success) {
if (success)
 {
 ver = this.firstChild.attributes.ver;

 this.createEmptyMovieClip("PH_mc", 0);
 this.createEmptyMovieClip("updater_mc", 1);
 this.createEmptyMovieClip("bar_mc", 2);
 this.createEmptyMovieClip("text_mc", 3);

 this.bar_mc._xscale = 1;

 if(barWidth<>0)
  with (this.bar_mc)
  {
  beginFill(0x434343, 100);
  lineTo(barWidth, 0);
  lineTo(barWidth, 1);
  lineTo(0, 1);
  lineTo(0, 0);
  }

 this.format = new TextFormat("Arial", 6, 0xFFFFFF, false, false, false, null, null, "center");

 if(barWidth<>0)
 {
  with (this.text_mc)
  {
    createTextField("preload_txt", 0, 0, 0, barWidth, 0);
    with (preload_txt)
    {
    setNewTextFormat(this.format);
    border = true;
    borderColor = 0x434343;
    text = " ";
    selectable = false;
    }
  }
 }

 this.text_Height = this.text_mc.preload_txt.textHeight+2;
 this.text_mc.preload_txt._height = this.text_Height;
 this.bar_mc._height = this.text_Height;

 if (imgWidth != 0)
 {
  this.bar_mc._x = this.text_mc._x=imgWidth/2-barWidth/2;
 }

 if (imgHeight != 0)
 {
  this.text_mc._y = imgHeight/2-this.text_mc._height/2;
  this.bar_mc._y = imgHeight/2-this.bar_mc._height/2+1;
 }

 this.PH_mc.loadMovie(image+"?ver="+ver);

 this.updater_mc.onEnterFrame = function() {
 this.Loaded = this._parent.PH_mc.getBytesLoaded();
 this.Total = this._parent.PH_mc.getBytesTotal();
 this.Percent = Math.ceil((this.Loaded/this.Total)*100);

 if (this.Loaded != this.Total || this.Total<=0)
 {
  this.Percent = this.Total == 0 ? 0 : this.Percent;
  this._parent.bar_mc._xscale = this.Percent;
 } else
 {
  this._parent.bar_mc._xscale = this.Percent;
  delete this.onEnterFrame;
  this._parent.bar_mc.removeMovieClip();
  this._parent.text_mc.removeMovieClip();
  this.removeMovieClip();
 };       
 };               
  delete data_xml;
                }
          }       
};


Antares 10.02.2006 22:37

Версия плеера -- 6 ?

CORSAiR 11.02.2006 00:06

Восьмая....

CORSAiR 15.02.2006 11:13

м-да... никакими способами не получается... =)


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

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