2012-02-18 65 views
0

好的,所以我得到了这个演示Flash文件,它通过XML加载图像并添加不同的效果。目前它被用作页面上的横幅。现在我被要求保留效果,但要在Flash中嵌入图片(这样才能摆脱XML)。我无法知道如何将其更改为不从XML读取。任何帮助将不胜感激,因为我停止使用闪回在MX时代...:SFlash加载图像不使用XML

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"); 
} 

更新的代码与新的错误:

TypeError: Error #1010: A term is undefined and has no properties. 
at original_fla::GridSliderClick_1/create_photo_rotator() 
at original_fla::GridSliderClick_1/load_gallery() 
at original_fla::MainTimeline/frame1() 
+1

您能否澄清 - 您是否希望不仅摆脱外部XML,而且还摆脱外部图像,这意味着图像将被嵌入到swf中? – redhotvengeance 2012-02-18 22:26:30

+0

是的确切而不是从XML加载从嵌入式图像加载,但保持效果,据我所知,这加载图像在XML中的数组,然后它使用该数组的效果? – Andres 2012-02-19 05:37:57

回答

2

有几件事情你必须做将其转换为不使用XML和外部图像。我会尽我所能地引导你,但是我没有很多基于你提供的代码的信息(例如,我没有看到这段代码是如何初始化的,因为它看起来像loadGallery()正在由未张贴的东西调用)。

你需要做的第一件事是嵌入所有的外部图像。要做到这一点,您需要使用文件>导入>导入库来将图像导入到Flash库中...

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

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

转换此代码的一个挑战是代码严重依赖于XML。

它看起来像我的代码初始化通过调用方法load_gallery()的东西。但是,我不知道这是什么。所以保持这种方法,但只是将其去掉:

function load_gallery(xml_file:String):void 
{ 
    create_photo_rotator(); 
} 

这将绕过加载XML。接下来,你需要大量修改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 = <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(); 
} 

更新:
基本上,你必须手工打造出来的照片数据的阵列的,因为你不再有XML。只需复制推送对象数据的代码块到flashmo_photo_list中即可获取尽可能多的照片。确保将bitmapData分别设置为您之前嵌入的相关位图类的新实例,然后手动设置其他属性(只需通过XML并复制它们设置的位置)。因此,如果在库中有一个名为“Photo1”的位图,并且在Photo1的属性中单击了“为ActionScript导出”并将“类”设置为“Photo1”,则代码将为:bitmapData: new Photo1()

现在,改变load_photo()方法实际上移除加载照片:

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

    load_circle(); 
} 

最后,改变on_photo_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); 
} 

你正在做一个new Bitmap的原因是因为您之前嵌入的照片导出为BitmapData类,所以您使用该BitmapData来创建照片Bitmap已更新:请确保您引用对象上的“bitmapData”值而不是以前使用的“文件名”值。

根据您提供的代码,这些更改应完成您所要求的内容。但是,我无法自己测试,所以你可能仍然需要调整一些东西。

+0

**免责声明:**由于您发布的原始代码非常糟糕,我的建议是重写整个事情。但是如果你的背部靠墙,希望上述建议能帮助你。请记住,这些变化充其量只是“冒险”,并且认为它们是“紧急事件”,因为它们实际上不是最佳实践(最佳实践可能需要对整个项目进行重大改革)。 – redhotvengeance 2012-02-19 18:53:49

+0

好吧,一切都应该如此,但现在即时通过我的导入错误:import caurina.transitions.Tweener; 它说的是它找不到? – Andres 2012-02-22 05:40:42

+0

这个错误只是在您做出更改后才开始?您是否移动FLA或删除任何内容?编译器因为找不到Tweener类而引发错误。 FLA旁边应该有一个名为“caurina”的文件夹。如果你找不到它,那么你可以在这里下载它:http://code.google.com/p/tweener/downloads/detail?name=tweener_1_33_74_as3.zip – redhotvengeance 2012-02-22 19:33:39