Olá pessoal, bom dia! Estou fazendo um flash que recebe alguns parametros por flashvars como título e url da imagem para fazer um efeito grayscale. Bom, está funcionando belezinha, o problema é que o swf não consegue carregar imagens que estao fora do servidor. Apresenta o erro abaixo: SecurityError: Error #2122: Violação da área de segurança: LoaderInfo.content: http://serv1.local/DesktopModules/ListaImo...imagemmenor.swf não pode acessar http://serv2.local/Arquivos/Seminovos/2309...1dd63345ae.jpeg. É exigido um arquivo de política, mas o indicador checkPolicyFile não estava definido quando esta mídia foi carregada. at flash.display::LoaderInfo/get content() at Images/onImageLoad() Meu código: package
{
import flash.geom.Point;
import flash.filters.ColorMatrixFilter;
import flash.display.*;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.*;
import fl.motion.easing.*;
import com.gskinner.motion.GTween;
public class Images extends MovieClip
{
private var _loader:Loader = new Loader();
private var _imageUrl:String = 'yorkshire-landscape-11.2.jpg';
private var _linkUrl:String = 'http://www.google.com/';
private var _titulo:String = null;
private var _imageRGB:Bitmap;
private var _imagePB:Bitmap;
private var _mcImagens:MovieClip = new MovieClip();
private var _size:uint = 80;
private var _border:Shape;
// init
public function Images()
{
_imageUrl = getFlashVars( 'imageUrl' ) != null ? getFlashVars( 'imageUrl' ) : _imageUrl;
_linkUrl = getFlashVars( 'linkUrl' ) != null ? getFlashVars( 'linkUrl' ) : _linkUrl;
_titulo = getFlashVars( 'titulo' ) != null ? getFlashVars( 'titulo' ) : 'Residencial Bulgária' /*null*/;
imageLoad();
_loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onImageLoad );
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
bgPreto.width = stage.stageWidth;
bgPreto.height = stage.stageHeight;
}
// pega valores das flashvars
public function getFlashVars( flashvar:String ):String
{
var flashvars:Object = LoaderInfo( this.root.loaderInfo ).parameters;
return flashvars[ flashvar ];
}
// onload
private function imageLoad():void
{
_loader.load( new URLRequest( _imageUrl ) );
}
// callback
private function onImageLoad( e:Event ):void
{
// esconde grafico de loading
loadingGraph.alpha = 0;
// acessa e cria nova bitmap da resposta
_imageRGB = new Bitmap( _loader.contentLoaderInfo.content[ 'bitmapData' ] );
// duplica bitmap e transforma em preto e branco
_imagePB = toBlackWhite( duplicateImage( _imageRGB ) );
if ( _imagePB.width > stage.stageWidth ) {
_imagePB.x = - ( stage.stageWidth / 2 );
_imagePB.y = - ( stage.stageHeight / 2 );
} else {
_imagePB.x = 0;
_imagePB.y = 0;
}
_imagePB.x = - ( stage.stageWidth / 2 );
_imagePB.y = - ( stage.stageHeight / 2 );
// setup do movieclip
_mcImagens.buttonMode = true;
_mcImagens.useHandCursor = true;
_mcImagens.mouseChildren = false;
// adiciona imagem preto e branco ao movieclip
_mcImagens.addChild( _imagePB );
if ( _titulo != null )
drawTitle( false );
// adiciona movieclip ao palco
addChild( _mcImagens );
// binda eventos
bindEvents();
}
// bind de eventos do movieclip
private function bindEvents():void
{
_mcImagens.addEventListener( MouseEvent.CLICK, onClick );
_mcImagens.addEventListener( MouseEvent.MOUSE_OVER, onMouseOver );
_mcImagens.addEventListener( MouseEvent.MOUSE_OUT, onMouseOut );
}
// mouseover
private function onMouseOver( e:MouseEvent ):void
{
_imageRGB.alpha = 0;
if ( _imageRGB.width > stage.stageWidth ) {
_imageRGB.x = - ( stage.stageWidth / 2 );
_imageRGB.y = - ( stage.stageHeight / 2 );
} else {
_imageRGB.x = 0;
_imageRGB.y = 0;
}
_border = new Shape();
_border.graphics.lineStyle( 6, 0xFF0000, 1, true, LineScaleMode.NONE, CapsStyle.SQUARE, JointStyle.MITER );
_border.graphics.drawRect( 3, 3, stage.stageWidth - 6, stage.stageHeight - 6 );
_mcImagens.addChild( _imageRGB );
_mcImagens.addChild( _border );
if ( _titulo != null )
drawTitle( true );
fadeIn( _imageRGB );
}
// mouseout
private function onMouseOut( e:MouseEvent ):void
{
_imagePB.alpha = 0;
if ( _imagePB.width > stage.stageWidth ) {
_imagePB.x = - ( stage.stageWidth / 2 );
_imagePB.y = - ( stage.stageHeight / 2 );
} else {
_imagePB.x = 0;
_imagePB.y = 0;
}
_mcImagens.addChild( _imagePB );
_mcImagens.removeChild( _border );
if ( _titulo != null )
drawTitle( false );
fadeIn( _imagePB );
}
// click
private function onClick( e:MouseEvent ):void
{
navigateToURL( new URLRequest( _linkUrl ), "_self" );
}
// transforma em preto e branco
private function toBlackWhite( image:Bitmap ):Bitmap
{
const RED:Number = 1/3;
const GREEN:Number = 1/2;
const BLUE:Number = 1/3;
var _bitmapdata:BitmapData = image.bitmapData;
var _matrixFilter:Array = [RED, GREEN, BLUE, 0, 0,RED, GREEN, BLUE, 0, 0, RED, GREEN, BLUE, 0, 0, 0, 0, 0, 1, 0];
_bitmapdata.applyFilter( image.bitmapData, image.bitmapData.rect, new Point(), new ColorMatrixFilter( _matrixFilter ) );
return image;
}
// desenha titulo
private function drawTitle( over:Boolean ):void
{
// 110x29 FFF E41518 154
var _textColor:uint = 0xFFFFFF;
var _bgColor:uint = 0xE41518;
var _title:TextField = new TextField();
var _background:Shape = new Shape();
var _xPos = 0;
var _yPos = 130;
var _maxWidth = stage.stageWidth - 6;
var _maxHeight = 35;
var _fontFormat = new TextFormat();
var _font = 'Tahoma';
var _fontSize = 12;
_background.graphics.beginFill( over ? _textColor : _bgColor );
_background.graphics.drawRect( _xPos, _yPos, _maxWidth, _maxHeight );
_background.graphics.endFill();
_fontFormat.font = _font;
_fontFormat.size = _fontSize;
_fontFormat.color = !over ? _textColor : _bgColor;
_fontFormat.bold = true;
_title.text = _titulo;
_title.width = _maxWidth;
_title.height = _maxHeight;
_title.type = TextFieldType.INPUT;
_title.multiline = true;
_title.selectable = false;
_title.wordWrap = true;
_title.autoSize = TextFieldAutoSize.LEFT;
_title.setTextFormat( _fontFormat );
_mcImagens.addChild( _background );
_mcImagens.addChild( _title );
_title.x = _xPos;
_title.y = _yPos;
_title.addEventListener( MouseEvent.MOUSE_OVER, onTitleOver );
}
private function onTitleOver( e:MouseEvent ):void
{
}
// transicao
private function fadeIn( image:Bitmap ):void
{
var tweener:GTween = new GTween( image, 0.3 );
tweener.setProperty( 'alpha', 1 );
tweener.ease = Sine.easeInOut;
}
// duplica imagem
private function duplicateImage( original:Bitmap ):Bitmap
{
return new Bitmap( original.bitmapData.clone() );
}
}
} Se alguém puder dar uma força, fico muito agradecido! :rolleyes: Obs: Já publiquei o SWF como Access network only e não deu certo :S