Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不使用XML快速加载图像_Xml_Flash_Actionscript 3_Actionscript - Fatal编程技术网

不使用XML快速加载图像

不使用XML快速加载图像,xml,flash,actionscript-3,actionscript,Xml,Flash,Actionscript 3,Actionscript,好的,我得到了这个演示Flash文件,它通过XML加载图像并添加了不同的效果。目前它被用作网页上的横幅。现在我被要求保留这些效果,但要将其嵌入Flash中的图片中(这样可以去掉XML)。我不知道如何将其更改为不从XML读取。任何帮助都将不胜感激,因为我在MX时代停止使用Flash back…: import caurina.transitions.Tweener; import caurina.transitions.properties.ColorShortcuts; import flash

好的,我得到了这个演示Flash文件,它通过XML加载图像并添加了不同的效果。目前它被用作网页上的横幅。现在我被要求保留这些效果,但要将其嵌入Flash中的图片中(这样可以去掉XML)。我不知道如何将其更改为不从XML读取。任何帮助都将不胜感激,因为我在MX时代停止使用Flash back…:

import caurina.transitions.Tweener;
import caurina.transitions.properties.ColorShortcuts;
import flash.events.MouseEvent;

ColorShortcuts.init();

var hover_effect:Boolean;
var auto_play:Boolean;
var auto_play_duration:Number = 3000;
var no_of_rows:uint = 4;
var no_of_columns:uint = 8;

var tween_duration:Number = 0.7;
var tween_delay:Number = 0.03;
var block_scale:Number = 0.1;
var flashmo_margin:Number = 10;
var offstage_position:Number = 300;

var i:Number;
var j:Number;
var new_x:Number;
var new_y:Number;
var pic:Number = 0;
var previous_no:Number = 0;
var current_no:Number = 0;
var total:Number;

var timer:Timer;
var flashmo_xml:XML;
var flashmo_photo_list = new Array();
var mc:MovieClip;
var photo_group:MovieClip = new MovieClip();
var circle_group:MovieClip = new MovieClip();
var photo_array:Array;
var photo_group_array:Array;
var size_width:uint;
var size_height:uint;
var photo_width:uint;
var photo_height:uint;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

photo_group.mask = flashmo_photo_area;
photo_group_array = [];
photo_button.alpha = 0;
flashmo_cover.visible = false;
flashmo_bar.flashmo_next.visible = false;
flashmo_bar.flashmo_previous.visible = false;
flashmo_bar.flashmo_play.visible = false; 
flashmo_bar.flashmo_pause.visible = false;

flashmo_bar.addChild(circle_group);
this.addChildAt(photo_group, 1);
this.addChild(photo_button);
this.addChild(flashmo_bar);

function load_gallery(xml_file:String):void
{

create_photo_rotator();
}

//remove argument since it is no longer being passed the Event
function create_photo_rotator():void
{   
    //manually set a bunch of properties that the XML normally would have
    hover_effect=true;
    auto_play=true; 
    auto_play_duration=2.4;
    //grid_row=3;
    //grid_column=9; 
    tween_duration=0.7; 
    tween_delay=0.03;

    //manually build array of photo objects
    //notice that "Photo1" is the filename, same as the photo Class name we set above
    //add as many of this code block as there are embedded photos
    flashmo_photo_list.push({
        filename: "slide1",
        flow: "in",
        direction: "right",
        rotation: ""
    });

    flashmo_photo_list.push({
        filename: "slide2",
        flow: "in",
        direction: "left",
        rotation: ""
    });

    flashmo_photo_list.push({
        filename: "slide3",
        flow: "in",
        direction: "down",
        rotation: "-180"
    });

    flashmo_photo_list.push({
        filename: "slide4",
        flow: "in",
        direction: "up",
        rotation: ""
    });

    total = flashmo_photo_list.length;

    load_photo();

}

function load_photo():void
{
    //manually call on_photo_loaded and pass it current photo index
    on_photo_loaded(pic);
    pic++;

    load_circle();

}

function load_circle():void
{
    var fm_circle:MovieClip = new flashmo_circle();
    fm_circle.x = 5 + ( fm_circle.width + 4 ) * ( pic - 1 ) + fm_circle.width * 0.5;
    fm_circle.y = ( flashmo_bar.bar.height - fm_circle.height ) * 0.5;  
    fm_circle.name = "flashmo_circle_" + circle_group.numChildren;
    fm_circle.visible = false;
    circle_group.addChild( fm_circle );

    if( circle_group.numChildren == 1 )
    {       
        Tweener.addTween( fm_circle , { _color_redOffset: 255, _color_greenOffset: 255, 
                     _color_blueOffset: 255, time: tween_duration, transition: "easeIn" } );
    }
}

function on_photo_progress(e:ProgressEvent):void
{
    var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);

}

//change argument to expect photo index instead of Event
function on_photo_loaded(photoIndex:int):void
{   
    mc = MovieClip( circle_group.getChildAt( pic - 1 ) );
    mc.visible = true;

    //create Bitmap from embedded image's BitmapData
    var photoBitmap:Bitmap = new Bitmap(flashmo_photo_list[photoIndex].filename);

    if( pic == 1 )
    {
        //adjust values on newly created Bitmap
        photo_width = photoBitmap.width;
        photo_height = photoBitmap.height;

        adjust_size();
    }
    else if( pic > 1 )
    {
        enable_circle( mc );

        if( pic == 2 )
        {
            flashmo_bar.flashmo_previous.addEventListener( MouseEvent.CLICK, pic_previous );
            flashmo_bar.flashmo_next.addEventListener( MouseEvent.CLICK, pic_next );            
            flashmo_bar.flashmo_play.addEventListener( MouseEvent.CLICK, pic_play );
            flashmo_bar.flashmo_pause.addEventListener( MouseEvent.CLICK, pic_pause );
            flashmo_bar.flashmo_previous.visible = flashmo_bar.flashmo_next.visible = true;

            timer = new Timer(auto_play_duration);
            timer.addEventListener(TimerEvent.TIMER, auto_play_timer);

            if( auto_play )
            {
                flashmo_bar.flashmo_play.visible = false;
                flashmo_bar.flashmo_pause.visible = true;

                timer.start();
            }
            else
            {
                flashmo_bar.flashmo_play.visible = true;
                flashmo_bar.flashmo_pause.visible = false;
            }           
        }
    }

    if( pic < total )
    {
        load_photo();
    }

    //pass the Bitmap to create_effect (which is already expecting a Bitmap)
    create_effect( photoBitmap );

}

function adjust_size():void
{
    flashmo_photo_area.width = photo_button.width = flashmo_bar.bar.width = photo_width;
    flashmo_photo_area.height = photo_button.height = photo_height;

    flashmo_bar.flashmo_next.x = 
            flashmo_bar.bar.width - flashmo_bar.flashmo_next.width - flashmo_margin * 0.5;

    flashmo_bar.flashmo_previous.x = flashmo_bar.flashmo_next.x - flashmo_bar.flashmo_next.width;

    flashmo_bar.flashmo_play.x = flashmo_bar.flashmo_pause.x = 
            flashmo_bar.flashmo_previous.x - flashmo_bar.flashmo_previous.width;

    flashmo_bar.y = photo_height;
    photo_group.x = flashmo_photo_area.x;
    photo_group.y = flashmo_photo_area.y;
    photo_group.mask = flashmo_photo_area;
}

function create_effect( bitmap:Bitmap ):void
{   
    var flashmo_pic_mc:MovieClip = new MovieClip();

    size_width  = Math.ceil( photo_width / no_of_columns );
    size_height = Math.ceil( photo_height / no_of_rows );
    photo_array = [];

    if( photo_group.x == flashmo_photo_area.x )
    {
        photo_group.x += size_width * 0.5;
        photo_group.y += size_height * 0.5;
    }

    for( j = 0; j < no_of_rows; j++ )
    {
        for( i = 0; i < no_of_columns; i++ )
        {                                                       
            var temp_bitmap_data:BitmapData = new BitmapData ( size_width, size_height, true, 0xFFFFFF );
            var source_rect:Rectangle = new Rectangle ( i * size_width, j * size_height, 
                                                       size_width, size_height );

            temp_bitmap_data.copyPixels ( bitmap.bitmapData, source_rect, new Point );

            var temp_bitmap:Bitmap = new Bitmap ( temp_bitmap_data );
            var temp_sprite:Sprite = new Sprite;

            temp_bitmap.smoothing = true;
            temp_bitmap.x = - temp_bitmap.width * 0.5;
            temp_bitmap.y = - temp_bitmap.height * 0.5;

            temp_sprite.addChild ( temp_bitmap );
            temp_sprite.x = i * size_width;

            if( photo_group.numChildren > 0 )
                temp_sprite.y = photo_height;
            else
                temp_sprite.y = j * size_height;

            photo_array.push ( temp_sprite );
            flashmo_pic_mc.addChild( temp_sprite );
        }
    }

    flashmo_pic_mc.name = "flashmo_pic_" + photo_group.numChildren;
    photo_group_array.push( photo_array );
    photo_group.addChild ( flashmo_pic_mc );
}

function auto_play_timer(te:TimerEvent):void
{
    current_no++;
    change_photo();
}

function change_photo():void
{
    if( current_no >= photo_group.numChildren ) 
        current_no = 0;
    if( current_no < 0 )
        current_no = photo_group.numChildren - 1;

    var flashmo_direction:String = flashmo_photo_list[current_no].direction;
    var flashmo_rotation_str:String = flashmo_photo_list[current_no].rotation;
    var flashmo_rotation:Number = 0;

    if( flashmo_direction == "" )
        flashmo_direction = "center";

    if( flashmo_rotation_str != "" )
        flashmo_rotation = parseInt( flashmo_rotation_str );

    if( flashmo_photo_list[current_no].flow == "in" )
        transition_in( current_no, flashmo_direction, flashmo_rotation );
    else
        transition_out( previous_no, flashmo_direction, flashmo_rotation );

    disable_buttons();
}

function transition_in( pic_index:uint, from_direction:String, flashmo_rotation:Number ):void
{
    photo_group.addChild( photo_group.getChildByName( "flashmo_pic_" + pic_index ) );
    photo_array = photo_group_array[ pic_index ];

    var row_no:uint;
    var column_no:uint;

    for (i = 0; i < photo_array.length ; i++)
    {       
        if( flashmo_rotation != 0 )
            photo_array[i].rotation = flashmo_rotation;

        photo_array[i].scaleX = photo_array[i].scaleY = block_scale;
        photo_array[i].alpha = 0;

        if( from_direction == "left" )
        {
            photo_array[i].x = - size_width;            
            photo_array[i].y = Math.floor( i / no_of_columns ) * size_height;
        }
        else if( from_direction == "right" )
        {
            photo_array[i].x = photo_width;
            photo_array[i].y = Math.floor( i / no_of_columns ) * size_height;
        }
        else if( from_direction == "up" )
        {
            photo_array[i].x =  ( i % no_of_columns ) * size_width ;
            photo_array[i].y =  - size_height;
        }
        else if( from_direction == "down" )
        {
            photo_array[i].x = ( i % no_of_columns ) * size_width;
            photo_array[i].y = photo_height;
            photo_array[i].scaleX = photo_array[i].scaleY = 0;
        }
        else
        {
            photo_array[i].x = ( i % no_of_columns ) * size_width;
            photo_array[i].y = Math.floor( i / no_of_columns ) * size_height;           
        }
    }

    for ( i = 0; i < photo_array.length ; i++ )
    {       
        if( from_direction == "left" )
        {
            j = photo_array.length - i - 1;
            j = ( j % no_of_rows ) * no_of_columns + Math.floor( j / no_of_rows );

            new_x = ( j % no_of_columns ) * size_width;
            new_y = photo_array[j].y;
        }
        else if( from_direction == "right" )
        {
            j = ( i % no_of_rows ) * no_of_columns + Math.floor( i / no_of_rows );
            new_x = ( j % no_of_columns ) * size_width;
            new_y = photo_array[j].y;
        }
        else if( from_direction == "up" )
        {
            j = photo_array.length - i - 1;
            new_x = photo_array[j].x;
            new_y = Math.floor( j / no_of_columns ) * size_height;
        }
        else if( from_direction == "down" )
        {
            j = i;
            new_x = photo_array[j].x;
            new_y = Math.floor( j / no_of_columns ) * size_height;
        }
        else
        {
            j = i;
            new_x = photo_array[j].x;
            new_y = photo_array[j].y;
        }

        Tweener.addTween ( photo_array[j], { x: new_x, y: new_y,
            alpha: 1, scaleX: 1, scaleY: 1, rotation: 0,
            delay: tween_delay * i, time: tween_duration, transition: "easeOutQuart",
            onComplete: transition_complete, onCompleteParams:[i, true] }   );
    }
}

function transition_complete( no:Number, transition_in:Boolean ):void
{
    if( no == photo_array.length - 1 )
    {       
        if( transition_in )
        {
            photo_array = photo_group_array[ previous_no ];

            var sprite_index:Number = 0;

            for ( j = 0; j < no_of_rows; j++ )
            {
                for ( i = 0; i < no_of_columns; i++ )
                {   
                    photo_array[ sprite_index ].x = -1000;
                    photo_array[ sprite_index ].y = -1000;          
                    sprite_index++;         
                }
            }
        }

        enable_buttons();
    }
}

function transition_out( pic_index:uint, to_direction:String, flashmo_rotation:Number ):void
{
    photo_group.addChild( photo_group.getChildByName( "flashmo_pic_" + current_no ) );
    photo_group.addChild( photo_group.getChildByName( "flashmo_pic_" + pic_index ) );
    photo_array = photo_group_array[ pic_index ];

    var flashmo_effect:String = "easeInQuart";

    for ( i = 0; i < photo_array.length ; i++)
    {       
        if( to_direction == "left" )
        {
            j = ( i % no_of_rows ) * no_of_columns + Math.floor( i / no_of_rows );
            new_x = - offstage_position;
            new_y = photo_array[j].y;
        }
        else if( to_direction == "right" )
        {
            j = photo_array.length - i - 1;
            j = ( j % no_of_rows ) * no_of_columns + Math.floor( j / no_of_rows );
            new_x = photo_width + offstage_position;
            new_y = photo_array[j].y;
        }       
        else if( to_direction == "up" )
        {
            j = i;
            new_x = photo_array[j].x;
            new_y = - offstage_position;
        }
        else if( to_direction == "down" )
        {
            j = photo_array.length - i - 1;
            new_x = photo_array[j].x;
            new_y = photo_height + offstage_position;           
        }
        else
        {
            j = i;
            new_x = photo_array[j].x;
            new_y = photo_array[j].y;
            flashmo_effect = "easeInOutQuart";
        }

        Tweener.addTween ( photo_array[j], { x: new_x, y: new_y,
            scaleX: block_scale, scaleY: block_scale, alpha: 0, rotation: flashmo_rotation, 
            delay: tween_delay * i, time: tween_duration, transition: flashmo_effect,
            onComplete: transition_complete, onCompleteParams:[i, false] } );
    }

    to_normal_position( current_no );
}

function to_normal_position( pic_index:uint ):void
{
    photo_array = photo_group_array[ pic_index ];

    var sprite_index:Number = 0;

    for ( j = 0; j < no_of_rows; j++ )
    {
        for ( i = 0; i < no_of_columns; i++ )
        {   
            photo_array[ sprite_index ].rotation = 0;
            photo_array[ sprite_index ].alpha = 
            photo_array[ sprite_index ].scaleX = 
            photo_array[ sprite_index ].scaleY = 1;         
            photo_array[ sprite_index ].x = i * size_width;
            photo_array[ sprite_index ].y = j * size_height;            
            sprite_index++;         
        }
    }
}


function pic_over(e:MouseEvent):void
{
    Tweener.addTween( photo_button, { alpha: 0.15, time: tween_duration, transition: "easeIn" } );
}

function pic_out(e:MouseEvent):void
{
    Tweener.addTween( photo_button, { alpha: 0, time: tween_duration, transition: "easeOut" } );
}

function pic_previous(e:MouseEvent):void
{
    current_no--;
    change_photo();
}

function pic_next( e:MouseEvent ):void
{
    current_no++;
    change_photo();
}

function pic_play(e:MouseEvent):void
{
    flashmo_bar.flashmo_pause.visible = true;
    flashmo_bar.flashmo_play.visible = false;
    auto_play = true;

    if( circle_group.alpha == 1 )
        timer.start();
}

function pic_pause(e:MouseEvent):void
{
    flashmo_bar.flashmo_pause.visible = false;
    flashmo_bar.flashmo_play.visible = true;
    auto_play = false;
    timer.reset();
}

function circle_out( me:MouseEvent ):void
{
    mc = MovieClip( me.target );
    Tweener.addTween( mc, { _color_redOffset: 0, _color_greenOffset: 0, 
                     _color_blueOffset: 0, time: tween_duration, transition: "easeIn" } );
}

function circle_over( me:MouseEvent ):void
{
    mc = MovieClip( me.target );
    Tweener.addTween( mc, { _color_redOffset: 255, _color_greenOffset: 255, 
                     _color_blueOffset: 255, time: tween_duration, transition: "easeIn" } );
}

function circle_click( me:MouseEvent ):void
{
    mc = MovieClip( me.target );
    current_no = parseInt( mc.name.slice( 15,17 ) );
    change_photo();
}

function enable_buttons():void
{
    if( auto_play )
        timer.start();
    else
        timer.reset();

    photo_button.visible = true;
    flashmo_bar.flashmo_previous.mouseEnabled = true;
    flashmo_bar.flashmo_next.mouseEnabled = true;

    flashmo_bar.flashmo_previous.addEventListener( MouseEvent.CLICK, pic_previous );
    flashmo_bar.flashmo_next.addEventListener( MouseEvent.CLICK, pic_next );
    circle_group.alpha = 1;

    for( i = 0; i < circle_group.numChildren; i++ )
    {
        if( i == current_no )
            continue;

        mc = MovieClip( circle_group.getChildAt( i ) );
        enable_circle( mc );
    }

    previous_no = current_no;
}

function disable_buttons():void
{
    if( auto_play )
        timer.reset();

    photo_button.visible = false;
    flashmo_bar.flashmo_previous.mouseEnabled = false;
    flashmo_bar.flashmo_next.mouseEnabled = false;

    flashmo_bar.flashmo_previous.removeEventListener( MouseEvent.CLICK, pic_previous );
    flashmo_bar.flashmo_next.removeEventListener( MouseEvent.CLICK, pic_next );
    circle_group.alpha = 0.5;

    for( i = 0; i < circle_group.numChildren; i++ )
    {
        mc = MovieClip( circle_group.getChildAt( i ) );
        disable_circle( mc );
        Tweener.addTween( mc, { _color_redOffset: 0, _color_greenOffset: 0, 
                     _color_blueOffset: 0, time: tween_duration, transition: "easeIn" } );
    }

    mc = MovieClip( circle_group.getChildAt( current_no ) );
    Tweener.addTween( mc , { _color_greenOffset: 255, _color_redOffset: 255,
                     _color_blueOffset: 255, time: tween_duration, transition: "easeIn" } );
}

function enable_circle( mc:MovieClip ):void
{
    mc.addEventListener( MouseEvent.CLICK, circle_click );
    mc.addEventListener( MouseEvent.MOUSE_OUT, circle_out );
    mc.addEventListener( MouseEvent.MOUSE_OVER, circle_over );
    mc.buttonMode = true;
}

function disable_circle( mc:MovieClip ):void
{
    mc.removeEventListener( MouseEvent.CLICK, circle_click );   
    mc.removeEventListener( MouseEvent.MOUSE_OUT, circle_out );
    mc.removeEventListener( MouseEvent.MOUSE_OVER, circle_over );
    mc.buttonMode = false;
}


Object(root).grid_slider.logo.cotton.addEventListener(MouseEvent.CLICK,fl_ClickToGoToWebPage);
function fl_ClickToGoToWebPage(event:MouseEvent):void
{
    navigateToURL(new URLRequest("http://www.google.com"), "_self");
}

要将其转换为不使用XML和外部图像,您必须做几件事。我会尽我所能让您了解它,但根据您提供的代码,我没有太多的信息(例如,我不知道此代码实际上是如何初始化的,因为它看起来像是
loadGallery()
被未发布的东西调用的)

首先要做的是嵌入所有外部图像。为此,您需要使用文件>导入>导入到库将图像导入Flash库

将所有图像导入到库中后,库中的每个图像现在都应有一个位图和一个符号。忽略或删除符号-您将不需要它们。右键单击每个位图,并打开属性。在这里,在顶部对话框中命名位图(例如,
Photo1
),然后单击“链接”区域中的“导出操作脚本”按钮。“类”对话框应自动填充位图名称(例如
Photo1
),而“基类”对话框应为
flash.display.BitmapData

图像现在将嵌入到swf中-您所做的是将每个图像转换为ActionScript可访问的
BitmapData
类。现在,您需要对代码进行更改,以使用这些嵌入图像,而不是外部图像

转换此代码的挑战之一是代码严重依赖XML

在我看来,代码是通过调用方法
load\u gallery()
初始化的。然而,我不知道这叫什么。因此,保留该方法,但只需将其删除:

function load_gallery(xml_file:String):void
{
    create_photo_rotator();
}
这将绕过加载XML。接下来,您需要大量修改
create\u photo\u rotator()
方法:

//remove argument since it is no longer being passed the Event
function create_photo_rotator():void
{
    //manually set a bunch of properties that the XML normally would have
    hover_effect = <set true or false>;
    auto_play = <set true or false>;
    auto_play_duration = <set number>;
    no_of_rows =  <set number>;
    no_of_columns =  <set number>;
    tween_duration = <set number>;
    tween_delay = <set number>;

    //manually build array of photo objects
    //notice that "Photo1" is the filename, same as the photo Class name we set above
    //add as many of this code block as there are embedded photos
    //**UPDATE**:store an instance of the BitmapData class instead of the name of the class as a string - notice the key name has changed to "bitmapData" instead of "filename"
    flashmo_photo_list.push({
        bitmapData: new Photo1(),
        flow: "<flow string>",
        direction: "<direction string>",
        rotation: "<rotation string>"
    });

    total = flashmo_photo_list.length;

    load_photo();
}
最后,更改\u photo\u loaded()上的
以使用嵌入的位图:

//change argument to expect photo index instead of Event
function on_photo_loaded(photoIndex:int):void
{   
    mc = MovieClip( circle_group.getChildAt( pic - 1 ) );
    mc.visible = true;

    //create Bitmap from embedded image's BitmapData
    //**UPDATE**: reference the stored bitmapData instead of filename string
    var photoBitmap:Bitmap = new Bitmap(flashmo_photo_list[photoIndex].bitmapData);

    if( pic == 1 )
    {
        //adjust values on newly created Bitmap
        photo_width = photoBitmap.width;
        photo_height = photoBitmap.height;

        adjust_size();
    }
    else if( pic > 1 )
    {
        enable_circle( mc );

        if( pic == 2 )
        {
            flashmo_bar.flashmo_previous.addEventListener( MouseEvent.CLICK, pic_previous );
            flashmo_bar.flashmo_next.addEventListener( MouseEvent.CLICK, pic_next );            
            flashmo_bar.flashmo_play.addEventListener( MouseEvent.CLICK, pic_play );
            flashmo_bar.flashmo_pause.addEventListener( MouseEvent.CLICK, pic_pause );
            flashmo_bar.flashmo_previous.visible = flashmo_bar.flashmo_next.visible = true;

            timer = new Timer(auto_play_duration);
            timer.addEventListener(TimerEvent.TIMER, auto_play_timer);

            if( auto_play )
            {
                flashmo_bar.flashmo_play.visible = false;
                flashmo_bar.flashmo_pause.visible = true;

                timer.start();
            }
            else
            {
                flashmo_bar.flashmo_play.visible = true;
                flashmo_bar.flashmo_pause.visible = false;
            }           
        }
    }

    if( pic < total )
    {
        load_photo();
    }

    //pass the Bitmap to create_effect (which is already expecting a Bitmap)
    create_effect( photoBitmap );
}
//将参数更改为期望照片索引而不是事件
加载的照片上的函数(照片索引:int):void
{   
mc=MovieClip(circle_group.getChildAt(pic-1));
mc.visible=true;
//从嵌入图像的位图数据创建位图
//**更新**:引用存储的位图数据,而不是文件名字符串
var photoBitmap:Bitmap=新位图(flashmo\u photo\u列表[photoIndex].bitmapData);
如果(pic==1)
{
//调整新创建的位图上的值
photo_width=photoBitmap.width;
照片高度=照片位图高度;
调整_大小();
}
否则,如果(图片>1)
{
启用_圆(mc);
如果(pic==2)
{
flashmo_bar.flashmo_previous.addEventListener(MouseEvent.CLICK,pic_previous);
flashmo_bar.flashmo_next.addEventListener(MouseEvent.CLICK,pic_next);
flashmo_条、flashmo_播放、addEventListener(MouseEvent.CLICK、pic_播放);
flashmo_栏、flashmo_暂停、addEventListener(MouseEvent.CLICK、pic_暂停);
flashmo\u bar.flashmo\u previous.visible=flashmo\u bar.flashmo\u next.visible=true;
定时器=新定时器(自动播放持续时间);
timer.addEventListener(TimerEvent.timer、自动播放定时器);
如果(自动播放)
{
flashmo_bar.flashmo_play.visible=false;
flashmo_bar.flashmo_pause.visible=true;
timer.start();
}
其他的
{
flashmo_bar.flashmo_play.visible=true;
flashmo_bar.flashmo_pause.visible=false;
}           
}
}
如果(pic<总计)
{
加载照片();
}
//传递位图以创建_效果(已经需要位图)
创建_效果(照片位图);
}
制作
新位图
的原因是,先前嵌入的照片被导出为
位图数据
类,因此使用该
位图数据
创建照片
位图
更新:确保您引用的是对象上的“bitmapData”值,而不是以前使用的“filename”值


根据您提供的代码,这些更改应该可以满足您的要求。但是,我自己无法测试它,因此您可能仍然需要调整一些东西。

您可以澄清一下吗-您是否不仅要删除外部XML,还要删除外部图像,这意味着图像将嵌入到swf中?是的,完全不是从XML加载到从嵌入图像加载,而是要保留效果,据我所知,这会将XML格式的图像加载到一个数组中,然后使用该数组来实现效果?免责声明:由于您发布的原始代码非常糟糕,我的建议是重写整个过程。但是如果你的背碰到了墙,希望上面的建议能帮助你。请记住,这些变化充其量只是“哈奇”,并认为它们只是“急诊科”,因为它们实际上不是最佳实践(最佳实践可能需要对整个项目进行重大的检查)。OK做了所有应该做的事情,但是现在我的导入中出现了一个错误:它所说的是找不到它?。这个错误是在您进行更改后才开始的吗?您是否移动了FLA或删除了任何内容?编译器正在抛出错误,因为它找不到Tweener类。FLA旁边应该有一个名为“caurina”的文件夹。如果你找不到它,那么你可以在这里下载:伙计,我讨厌现在这么多的窃听使得它工作,但现在我得到了这个:TypeError:Error#1010:A ter
function load_photo():void
{
    //manually call on_photo_loaded and pass it current photo index
    on_photo_loaded(pic);
    pic++;

    load_circle();
}
//change argument to expect photo index instead of Event
function on_photo_loaded(photoIndex:int):void
{   
    mc = MovieClip( circle_group.getChildAt( pic - 1 ) );
    mc.visible = true;

    //create Bitmap from embedded image's BitmapData
    //**UPDATE**: reference the stored bitmapData instead of filename string
    var photoBitmap:Bitmap = new Bitmap(flashmo_photo_list[photoIndex].bitmapData);

    if( pic == 1 )
    {
        //adjust values on newly created Bitmap
        photo_width = photoBitmap.width;
        photo_height = photoBitmap.height;

        adjust_size();
    }
    else if( pic > 1 )
    {
        enable_circle( mc );

        if( pic == 2 )
        {
            flashmo_bar.flashmo_previous.addEventListener( MouseEvent.CLICK, pic_previous );
            flashmo_bar.flashmo_next.addEventListener( MouseEvent.CLICK, pic_next );            
            flashmo_bar.flashmo_play.addEventListener( MouseEvent.CLICK, pic_play );
            flashmo_bar.flashmo_pause.addEventListener( MouseEvent.CLICK, pic_pause );
            flashmo_bar.flashmo_previous.visible = flashmo_bar.flashmo_next.visible = true;

            timer = new Timer(auto_play_duration);
            timer.addEventListener(TimerEvent.TIMER, auto_play_timer);

            if( auto_play )
            {
                flashmo_bar.flashmo_play.visible = false;
                flashmo_bar.flashmo_pause.visible = true;

                timer.start();
            }
            else
            {
                flashmo_bar.flashmo_play.visible = true;
                flashmo_bar.flashmo_pause.visible = false;
            }           
        }
    }

    if( pic < total )
    {
        load_photo();
    }

    //pass the Bitmap to create_effect (which is already expecting a Bitmap)
    create_effect( photoBitmap );
}