Форум 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=136236)

Dumpil 13.02.2010 01:55

Цитата:

Сообщение от udaaff (Сообщение 885910)
Непонятно, как должно выглядеть то, что вы хотите.

Необходимо что бы при нажатии на кнопку botNextImage грузилась следующая картинка, другими словами счетчик к получает +1 значение при каждом нажатии
куда это втулить ?
вот ас который пытаюсь сделать ... он не верный потому что не знаю как работать с .src

Код AS1/AS2:

function pressBot () {
        mcLoader.loadClip (this.src, container);
}
function nextImage () {
        mcLoader.loadClip (next.src, container);
}
for (var k = 1; k < 28; k++) {
    main["bot" + k].src = "people/" + k + "/f" + k + ".jpg";
    main["bot" + k].onPress = pressBot;
        next.src = "people/" ++k "/f" ++k  ".jpg";
        botNI.onPress = nextImage;
}


udaaff 13.02.2010 02:44

Код AS1/AS2:

var length:Number = 28;
var currentID:Number = 0;
 
botNI.onPress = botNI_onPressHandler;
 
for (var i = 1; i < length; i++)
{
        var mc:MovieClip = main["bot" + i];
        mc.id = i;
        mc.onPress = mc_onPressHandler;
}
 
function mc_onPressHandler():Void
{
        loadImage(this.id);
}
 
function botNI_onPressHandler():Void
{
        if (++currentID > length)
                currentID = 0;
 
        loadImage(currentID);
}
 
function loadImage(id:Number):Void
{
        mcLoader.loadClip("people/" + id + "/f" + id + ".jpg", container);
        currentID = id;
}


Dumpil 13.02.2010 13:58

спасибо огромное ) все работает ) можноли на основе этого ас сделать что бы загружаемые картинки отматывались назад ?

udaaff 13.02.2010 14:22

Сделайте по аналогии с "вперед".

Dumpil 13.02.2010 14:27

я просто не совсем могу розобраться где тут плюсуеться id

udaaff 13.02.2010 14:38

Код AS1/AS2:

if (++currentID > length)


Dumpil 13.02.2010 15:00

вот что получилось. все работает ) огромное спасибо
Код AS1/AS2:

var length:Number = 27;
var currentID:Number = 1;
 
back.botNI.onPress = botNI_onPressHandler;
back.botPI.onPress = botPI_onPressHandler;
 
for (var i = 1; i < length; i++)
{
        var mc:MovieClip = main["bot" + i];
        mc.id = i;
        mc.onPress = mc_onPressHandler;
}
 
function mc_onPressHandler():Void
{
        loadImage(this.id);
}
 
function botNI_onPressHandler():Void
{
        if (++currentID > length)
                currentID = 1;
 
        loadImage(currentID);
}
 
function botPI_onPressHandler():Void
{
        if (--currentID < 1)
                currentID = 27;
 
        loadImage(currentID);
}
 
function loadImage(id:Number):Void
{
        mcLoader.loadClip("people/" + id + "/f" + id + ".jpg", container);
        currentID = id;
}


Hauts 13.02.2010 15:02

В конце только подправьте:
Код AS1/AS2:

function botPI_onPressHandler():Void
{
        if (--currentID < 1)
                currentID = length;
 
        loadImage(currentID);
}


Dumpil 13.02.2010 15:43

точно ) спс за замечание )


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

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