Flash AS3 Security Sandbox Violation / s.ytimg.com - actionscript-3

I have been reading about this trouble for days now and i'm going mad. Please Help!
I'm trying to load in vain a YouTube video into my portfolio. I'v uploaded the video on Youtube and it's Public.
I've tried the code with a bunch of other Youtube videos and it works perfect with them all except with mine...
Like i said i'm going MAD!!! please help!!
* Security Sandbox Violation *
SecurityDomain 'http://s.ytimg.com/crossdomain.xml' tried to access incompatible context 'file:///M|/Architecture/PORTFOLIO/WEB/PORTFOLIO.swf'
Here's the code of the part in context:
import flash.display.Loader;
import flash.net.URLRequest;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import fl.controls.ProgressBar;
import fl.controls.ProgressBar;
import fl.transitions.TweenEvent;
import flash.events.Event;
import fl.controls.ProgressBar;
import flash.ui.MouseCursor;
import flash.system.Security;
pages.visible = false;
pages.fullPage.alpha = 0;
var my_images:XMLList;
var my_total:Number;
var page_no:Number = 1;
pages.pb.alpha = 0;
pages.btnBallon.visible = false;
pages.btnBallon.removeEventListener(MouseEvent.CLICK, lVid);
pages.btnBallon.buttonMode = false;
//Youtube loader
Security.allowDomain("*");
Security.allowDomain("www.youtube.com");
Security.allowDomain("youtube.com");
Security.allowDomain("s.ytimg.com");
Security.allowDomain("i1.ytimg.com");
Security.allowDomain("i.ytimg.com");
Security.allowDomain("http://s.ytimg.com/crossdomain.xml");
Security.allowDomain("popslinger.org");
Security.allowDomain("http://www.box.net/api/crossdomain.xml");
Security.loadPolicyFile("http://i.ytimg.com/crossdomain.xml");
Security.loadPolicyFile("http://www.youtube.com/crossdomain.xml");
Security.loadPolicyFile("http://s.ytimg.com/crossdomain.xml");
Security.loadPolicyFile('http://youtube.com/crossdomain.xml');
Security.loadPolicyFile("http://www.box.net/api/crossdomain.xml");
function video():void{
pages.btnBallon.visible = true;
pages.btnBallon.addEventListener(MouseEvent.CLICK, lVid);
pages.btnBallon.buttonMode = true;
}
function lVid(e:Event = null):void{
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
}
function onInit(e:Event):void{
addChild(loader);
player = loader.content;
player.addEventListener("onReady",onPlayerReady);
}
function onPlayerReady(e:Event):void{
var pageTween:Tween = new Tween(pages.fullPage, "alpha", Strong.easeOut,pages.fullPage.alpha, 0, 1, true);
player.setSize = (560,315);
player.x = pages.x + 120;
player.y = pages.y;
pages.visible = false;
pages.btnBallon.visible = false;
pages.btnBallon.removeEventListener(MouseEvent.CLICK, lVid);
pages.btnBallon.buttonMode = false;
/*pages.btnNext.removeEventListener(MouseEvent.CLICK, nextPage);
pages.btnNext.visible = false;
pages.btnPrev.removeEventListener(MouseEvent.CLICK, nextPage);
pages.btnPrev.visible = false;*/
player.loadVideoByUrl("www.youtube.com/embed/omcl93EYTrM",0);
//player.loadVideoById("omcl93EYTrM",0);
}

Try change this value:
File -> Publish settings

Related

Video not showing using netstream(bytes)

im working on video streaming i have a php api that return the video and then play it using byte array,but video is not showing, but when i look at the trace is hows the downloaded bytes and bytesloaded.Can you give me idea what i'm doing wrong i'm new in actionscript.
import flash.display.Sprite;
import flash.events.NetStatusEvent;
import flash.events.ProgressEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.NetStreamAppendBytesAction;
import flash.net.URLRequest;
import flash.net.URLStream;
import flash.utils.ByteArray;
var video:Video;
var video_nc:NetConnection;
var video_ns:NetStream;
var video_stream:URLStream;
video_nc = new NetConnection();
video_nc.connect(null);
video_ns = new NetStream(video_nc);
video_ns.client = this;
video_ns.addEventListener(NetStatusEvent.NET_STATUS, ns_statusHandler);
video = new Video(1280, 720);
video.attachNetStream(video_ns);
video.smoothing = true;
video_ns.play(null);
video_ns.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
video_stream = new URLStream();
video_stream.addEventListener(ProgressEvent.PROGRESS, videoStream_progressHandler);
video_stream.load(new URLRequest("https://www.xxxx.com/test.php"));
addChild(video);
function ns_statusHandler(event:NetStatusEvent):void
{
trace(event.info.code);
trace("zzz");
}
function videoStream_progressHandler(event:ProgressEvent):void
{
trace(event.bytesLoaded);
var bytes:ByteArray = new ByteArray();
video_stream.readBytes(bytes);
video_ns.appendBytes(bytes);
//trace(bytes);
}

Text doesn't appear in MovieClip after added as child. What's wrong with my ActionScript 3?

I'm pulling data from external XML. i created a sprite to serve as container for my pages. Those pages are movieclips which i then add each of them to stage as child to container using a for loop. For each movieclip i will add text & images which i will then animate using greensock. but the problem now is a simple text wont appear when i export swf movie. i have no problems loading external xml files and what not. i dont believe this to be a xml or loader problem. where did i go wrong? :~( .I believe i imported all the necessary package too.
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.text.*;
import flash.text.TextFieldAutoSize;
import flash.media.Sound;
import flash.media.SoundTransform;
import flash.media.SoundChannel;
import flash.net.navigateToURL;
import flash.display.*;
import flash.text.TextFormat;
import flash.display.StageScaleMode;
import flash.display.Stage;
public class menu extends Sprite {
protected var container:Sprite = new Sprite();
public function buildPages(e:Event):void {
var menu:XML=new XML(e.target.data);
menu.ignoreWhitespace=true;
container.x = menu.config.frxpos;
container.y = menu.config.frypos;
addChild(container);
var i:Number;
totalPages = menu.pages.page.length();
for(i=0; i<totalPages; i++) {
var pageMc:MovieClip = new MovieClip();
pageMc.name = menu.pages.page[i].#name;
pageMc.id = menu.pages.layoutNum.layNum[i];
container.addChild(pageMc);
pageMc.x = 100;
pageMc.y = 100;
pageMc.width = 200;
pageMc.height = 200;
pageNames[i] = pageMc.name;
pageLayoutNo[i] = pageMc.id;
if(pageMc.name == "registration") {
var myTxt:TextField = new TextField();
myTxt.text = menu.pages.intro.htext;
myTxt.textColor = 0xff0000;
myTxt.x = 150;
myTxt.y = 150;
myTxt.border = true;
myTxt.borderColor = 0x747474;
pageMc.addChild(myTxt);
}
}
}
}

Audio upload not working on server

I have an app which records and upload mic input encoding in mp3.
When I test locally, in Flash IDE, it works fine, my audio file is uploaded.
What I have tried:
All my files are on swf_dir (see in the code below)
My embed tag already have allowScriptAcess set to always;
Already put a generic crossdomain.xml in my host root and in swf_dir;
My main class already load a policy file and allow all domains (even this being unnecessary, because it's in the same server): system.security.loadPolicyFile("http://www.host.com/swf_dir/crossdomain.xml") and system.Security.allowDomain("*")
Here is the upload/encode class.
package
{
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.HTTPStatusEvent;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLRequestHeader;
import flash.net.URLRequestMethod;
import flash.utils.ByteArray;
import org.bytearray.micrecorder.encoder.WaveEncoder;
import fr.kikko.lab.ShineMP3Encoder;
/**
* ...
* #author Marcelo de Assis
*/
public class Mp3Helper extends EventDispatcher
{
var loader:URLLoader = new URLLoader();
var LOCAL_PATH:String = "http://www.host.com/swf_dir/upload.php"; // URL used to test on Flash IDE
var PRODUCTION_PATH:String = "upload.php"; // URL used to test on server
var mp3Encoder:ShineMP3Encoder;
var urlRequest:URLRequest = new URLRequest();
var urlLoader:URLLoader = new URLLoader();
public function Mp3Helper()
{
urlRequest.url = PRODUCTION_PATH;
urlRequest.contentType = 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary();
urlRequest.method = URLRequestMethod.POST;
urlRequest.requestHeaders.push( new URLRequestHeader( 'Cache-Control', 'no-cache' ) );
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
}
function upload_s(soundByteArray: ByteArray)
{
var waveEncoder:WaveEncoder = new WaveEncoder();
var wavData:ByteArray = waveEncoder.encode(soundByteArray, 1);
mp3Encoder = new ShineMP3Encoder(wavData);
mp3Encoder.addEventListener(Event.COMPLETE, mp3EncodeComplete);
mp3Encoder.start();
}
function mp3EncodeComplete(event: Event) : void
{
urlRequest.data = UploadPostHelper.getPostData("audio.mp3", mp3Encoder.mp3Data);
urlLoader.load(urlRequest);
urlLoader.addEventListener(Event.COMPLETE, loaderCompleted);
}
private function loaderCompleted(event: Event):void
{
dispatchEvent(event);
var fileLoader: URLLoader = URLLoader(event.target);
trace("loaderCompleted: ", fileLoader.data);
}
}
}
In case of URLLoader security error try to turn on policy logging (PolicyFileLog = 1) in mm.cfg file (check out this article where to locate mm.cfg file in your OS http://jpauclair.net/2010/02/10/mmcfg-treasure/, for win7 the default log location is C:\Users\user\AppData\Roaming\Macromedia\Flash Player\Logs\policyfiles.txt), it will helps in case of Socket as well.

How to resize my imported external swf file to fit(fullscreen) into stage? please give some sample codes

I used this code to import my swf file.now I want my swf file to fill all my stage(fullscreen).please give some sample code.
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.display.StageScaleMode;
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest("File/game.swf");
ldr.load(urlReq);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
addChild(ldr);
function loaded(event:Event):void
{
var content:Sprite = event.target.content;
content.scaleX = 1 ;
}
This will stretch the loaded swf to fill the stage:
function loaded(event:Event):void
{
var content:Sprite = event.target.content;
content.scaleX = stage.stageWidth/content.width;
content.scaleY = stage.stageHeight/content.height;
}

As3 Flash: property of 3d mesh

Below i have purposely made a test script: you can see it live at www.parele.com/plane.html
All source code is below, what im trying to do is change my mesh...please note:i want to change material of my model mesh , to another color , any color not create a new plane as this sample is an example to test this out not my actual hobby project, any files or info needed im happy to supply..I have been at this for a full over 20 hours stuck here and its killing me
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.containers.ObjectContainer3D;
import away3d.debug.AwayStats;
import away3d.entities.Mesh;
import away3d.containers.ObjectContainer3D;
import away3d.loaders.Loader3D;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import away3d.*;
import away3d.materials.ColorMaterial;
import away3d.materials.TextureMaterial;
import away3d.textures.BitmapTexture;
import sunag.animation.AnimationTarget;
import sunag.events.SEAEvent;
import sunag.sea3d.SEA3D;
import away3d.materials.methods.*;
import away3d.primitives.*;
import away3d.textures.*;
import away3d.utils.*;
import away3d.events.*;
[SWF(width = "955",height = "600",frameRate = "50")]
var view:View3D;
var scene:Scene3D;
var sea3d:SEA3D;
var _container:ObjectContainer3D = new ObjectContainer3D();
[Embed(source = "Models/plane.sea",mimeType = "application/octet-stream")]
var homepage:Class;
stage.stageFocusRect = false;
stage.showDefaultContextMenu = false;
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
scene = new Scene3D();
view = new View3D(scene);
view.backgroundColor = stage.color;
view.antiAlias = 4;
var dat:BitmapData = new BitmapData(256, 256, false, WHATEVERCOLOUR);
var mMaterial = new TextureMaterial(new BitmapTexture(dat));
scene.addChild(_container);
addChild(view);
sea3d = new SEA3D();
view.blendMode = BlendMode.NORMAL;
sea3d.addEventListener(SEAEvent.COMPLETE, onComplete);
sea3d.loadBytes(new homepage());
function onEnterFrame(e:Event):void
{
var body1:Mesh = sea3d.getMesh("body");
body1.material = mMaterial;
view.render();
}
function onComplete(e:SEAEvent):void
{
view.camera = sea3d.getCamera("Camera001");
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
scene.addChild(sea3d.container);
}
I believe this is what you are looking for: SubMeshes
A mesh you pull from a model is usually made of at least on SubMesh, but can contain several. Changing the Material on that "root" Mesh object doesn't propagate to its SubMeshes. You need to iterate through its SubMeshes and change their material.
hth.