Flash AS3 animation not running in IE9 - actionscript-3

I've got five Flash animations, that use AS3 computeSpectrum to create video animations for some of my songs.
Tested in Chrome, Firefox, Opera, and Safari just fine. Tested in IE7 and IE8 just fine. Tested in IE9, the flash player opens, but the music doesn't play, and the animations don't even start. This ONLY occurs in IE9.
Web page here: http://seanmurphy.co.cc/index4.html
The animations are under the music tab (bottom tab, main screen).
Does anyone have a line on what the heck is going on? I've made sure the Flash player is up-to-date (like I said, actually uninstalled IE9, back to IE8 and worked fine). I've made sure the linked mp3 files are in both the root folder and the attached audio folder (just in case). I've researched this all over, but no one seems to have this same problem.
Flash AS3 code below:
var url:String = "SubwayGirl.mp3";
var request:URLRequest = new URLRequest(url);
import flash.filters.*;
import fl.motion.Color;
var myBlur:BlurFilter = new BlurFilter();
myBlur.quality = 10;
myBlur.blurX = 0;
myBlur.blurY = 6;
var s:Sound = new Sound();
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(request);
var song:SoundChannel = s.play();
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();
var gr:Sprite = new Sprite();
gr.x = 150;
gr.y = 575;
addChild(gr);
var time:Timer = new Timer(.0001);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();
function completeHandler(event:Event):void {
//event.target.play();
};
function randomNumber(low:Number=0, high:Number=1):Number
{
return Math.floor(Math.random() * (1+high-low)) + low;
}
function soundCompleteHandler(event:Event):void {
time.stop();
};
function timerHandler(event:TimerEvent):void {
SoundMixer.computeSpectrum(ba, true);
var i:int;
gr.graphics.clear();
gr.graphics.lineStyle(1, 0xffffff);
myBlur.blurX = randomNumber(1, 5);
myBlur.blurY = randomNumber(1, 25);
myBlur.quality = randomNumber(1, 100);
gr.filters = [myBlur];
gr.graphics.beginFill(0xffffff);
gr.graphics.moveTo(10, 5);
var w:uint = 20;
for (i=0; i<500; i+=w) {
var t:Number = ba.readFloat();
var n:Number = (t * 100);
gr.graphics.drawCircle(w, -i, -n);
var yy = i * (t+210);
var place = yy.toString(16).toUpperCase();
while(place.length < 6) {
place = place+"0";
}
place = "0x" + place;
var myColor:ColorTransform = gr.transform.colorTransform;
myColor.color = 0xC941D0;
gr.transform.colorTransform = myColor;
};
};
Anyone with a hint on this? I've spent hours researching this with no resolution.
Any further info needed will be ASAPed over. Thanks.
EDIT: Okay, here's the scoop: I've got Flash animations playing at seanmurphy.co.cc/soundTest1.html in IE9. That is, they play if the browser cache is emptied, and you load the page once. If you reload the page, or go back to the page after visiting another page, the animations and music WON'T play, until you empty the cache again.
As well, I've copied the Flash object and embed codes over to a temporary index file at seanmurphy.co.cc/index6.html, but they won't play even with the browser cache emptied.
As you might think, this is driving me friggin' nuts! Does ANYONE have an explanation for the idiotic crap that IE is pulling here? I'd really really like to put this thing to bed. Thanks!

It may have something to do with the Security Sandbox violation:
SecurityError: Error #2121: Security sandbox violation:
SoundMixer.computeSpectrum: http://seanmurphy.co.cc/audio/IndianSummer-amped.swf
cannot access http://seanmurphy.co.cc/audio/SubwayGirl.swf.
This may be worked around by calling Security.allowDomain.
at flash.media::SoundMixer$/computeSpectrum()
at IndianSummer_fla::MainTimeline/timerHandler()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

Related

AS3 SoundChannel/Sound HZ Limit for importing

I have wav files that are at 1411kbs bit rate and varying frequencies. After I import them into the library and give them unique classes based on their frequency and other information (that is why I use getDefinitionByName below).
All of my wav files play fine in AS3 that are under 6000hz and 8000hz, however those tones don't play properly. However, they do play properly when clicking the Play icon when in Flash Adobe Animate.
I have stripped my code down to the bare essentials to see where the problem lies and still not working properly.
My question is, is there a problem with my code or does AS3/Flash have a limit on the frequency it can play?
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
btn.addEventListener(MouseEvent.CLICK, function(){
var sound_class = "L6000_0";
var soundTX:SoundTransform = myChannel.soundTransform;
soundTX.leftToLeft = 1;
soundTX.leftToRight = 0;
soundTX.volume = 1;
soundTX.rightToRight = 0;
soundTX.rightToLeft = 0;
var sclass:Class = getDefinitionByName(sound_class) as Class;
var mySound:Sound = new sclass;
myChannel.stop();
myChannel = mySound.play();
myChannel.soundTransform = soundTX;
});
It is not the scripting problem, I think. By default Flash exports sounds at very low bitrate and quality. Go to each sound properties to set the export settings or, alternately, in File > Publish Settings screen there's an option about exporting sounds.

Spritesheet animation easeljs-0.7.1.min.js

I am trying to make a spritesheet animation that keeps on looping but there is going something wrong in my code. the image doesn`t get displayed on the screen and still getting this error: Uncaught TypeError: Cannot read property 'move_obj' of null. could someone help me getting this fixed.
function init() {
canvas = document.getElementById("canvas");
stage = new createjs.Stage(canvas);
score = 0;
var munt = new Image();
munt.src = "imgs/sprite.png";
munt.onload = Tiltie;
}
function Tiltie(event){
var munt = event.target;
var container = new createjs.Container();
stage.addChild(container);
var spriteSheet = new createjs.SpriteSheet(
munt, //image to use
100, //width of each sprite
100, //height of each sprite
{
move_obj: [0, 9]
});
bmpSeq = new createjs.BitmapAnimation(spriteSheet);
bmpSeq.regX = bmpSeq.spriteSheet.frameWidth/2|0;
bmpSeq.regY = bmpSeq.spriteSheet.frameHeight / 2 | 0;
bmpSeq.gotoAndPlay("move_obj");
bmpSeq.currentFrame = 0;
stage.addChild(bmpSeq);
Ticker.addListener(window);
// Best Framerate targeted (60 FPS)
Ticker.setInterval(17);
}
Old Q :) Not very familiar with this version though, may I recommend using the new EaselJS v0.8.0+?
As for Spritesheet Animations, I've built a basic setup for EaselJS and all you'll have to do is declare a few parameters and you're done.
Also, my setup uses some new extra libraries from EaselJS which offer support for WebGL including a few fixes, check it out here
Let me know if you need any assistance, cheers

Restarting sound files in AS3

stop();
var mySound:Sound = new MyFavSong();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0;
myChannel = mySound.play();
pause_btn1.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void
{
lastPosition = myChannel.position;
myChannel.stop();
}
play_btn1.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void
{
myChannel = mySound.play(lastPosition);
}
I am trying to make a restart button however everything I have read is not correctly working on bringing it back to the start of the sound. I am not really great with flash so I made it as simple as I could. Any and all help would be great.
Your code is fine and that's the correct way to implement a pause/play method in as3.
That means the problem is elsewhere. Print lastPosition at the start of your onClickPlay function. Is it printing something other than 0?
Take this as a comment. This thing only lets me post answers.

AS3 webcam resolution/size issue

I do not really know much in regard to Flash or Action Scripts but I have been having a bit of trouble with AS3 and webcams. I have a script that connects to a webcam and then sends its output to a php script that saves the captured image. This works all except for one problem. It seems that the maximum resolution allowed for the actual Camera object is 320x240. I went to the extreme of hooking a Canon 60D up as a webcam because I have a normal webcam that is supposed to have max resolution of 1280x720 and all I can get is a 320x240 image from it. What I have found so far is the max I can get out of the Canon is also 320x240. Maybe I have been looking at this to long but I am stumped. Below is a sample of the action script where videoCapture should be 1024x768. What happens instead is a 1024x768 image is created with a black background and in the top left is a 320x240 image from videoCapture. I could obviously resize this but that would defeat the purpose being poor quality. Is there something I am missing here or maybe some limitation of Flash even?
// adds event listener to the stage for keydown events.
stage.addEventListener(KeyboardEvent.KEY_DOWN, detectEnterKey);
import flash.display.Bitmap;
import flash.display.BitmapData;
import com.adobe.images.JPGEncoder;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
var bandwidth:int = 0;
var quality:int = 100;
var cam:Camera = Camera.getCamera();
var videoCapture:Video = new Video();
var previewPortData:BitmapData = new BitmapData(1024, 768, true, 0x00000000);
var previewPort:Bitmap = new Bitmap(previewPortData);
function onCameraStatus(evt):void {
if (evt.code == "Camera.Muted") {
Security.showSettings(SecurityPanel.CAMERA);
}
}
// detects the keycode looking for enter key pressed.
function detectEnterKey(event:KeyboardEvent):void {
//trace("keycode: "+event.keyCode);
if (event.keyCode == Keyboard.ENTER) {
previewPortData.draw(videoCapture);
var myEncoder:JPGEncoder = new JPGEncoder(100);
var byteArray:ByteArray = myEncoder.encode(previewPortData);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var saveJPG:URLRequest = new URLRequest("save.php");
saveJPG.requestHeaders.push(header);
saveJPG.method = URLRequestMethod.POST;
saveJPG.data = byteArray;
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, sendComplete);
urlLoader.load(saveJPG);
function sendComplete(event:Event):void {
trace("compete");
}
}
}
if (cam == null) {
Security.showSettings(SecurityPanel.CAMERA);
} else {
cam.addEventListener(StatusEvent.STATUS, onCameraStatus)
cam.setQuality(bandwidth, quality);
cam.setMode(1024, 768, 30, false);
videoCapture.attachCamera(cam);
videoCapture.width = 1024;
videoCapture.height = 768;
addChild(videoCapture);
previewPort.x = 430;
previewPort.y = 50;
addChild(previewPort);
}
I also just had this problem. Solved it by including the width and height parameters when creating the Video object instead of setting them afterwards via Video.height and Video.width. Once i did that, all bitmapData taken from that video was correctly sized.
This is how i originally created the video that did not work (looked fine, but resulted in incorrectly sized bitmaps):
var vid = new Video();
vid.width = 640;
vid.height = 480;
...
This worked (bitmaps from this video were correctly sized):
var vid = new Video(640, 480);
...
Would love to know why the first way doesn't work. Maybe that's the bug mentioned above. (I didn't have access to that site so couldn't see it.)
Sounds like this bug was never fixed: http://bugs.adobe.com/jira/browse/FP-2138
I had a similar issue. What worked for me was that I replaced:
previewPortData.draw(videoCapture);
With:
previewPortData.draw(stage);

Stream an FLVPlayback through the internet

I have a video in flash in the size of 19 MB (5 minutes) and I want the user to see what that has been loaded so far, or even get an indication of what has been loaded - so he won't be stuck in a blank screen until the video loads.
The quality of the video is important so I won't resize it - but how can I:
stream it so the user can see what that has been loaded so far
give him an indication of how long he will need to wait until it loads.
My code looks something like this:
import fl.video.*;
var video = new FLVPlayback();
video.fullScreenTakeOver = false;
video.source = "MansfredLoop.f4v";
stage.addChild(video);
Where do I start?
import fl.video.*;
var totalBytes:int;
var loadedBytes:int;
var remainingBytes:int;
var myTimer:Timer = new Timer(100);
var video = new FLVPlayback();
video.fullScreenTakeOver = false;
video.source = "MansfredLoop.f4v";
stage.addChild(video);
myTimer.addEventListener("timer", timerHandler);
myTimer.start();
totalBytes = video.bytesLoaded;
function timerHandler(event:TimerEvent):void {
loadedBytes = video.bytesLoaded;
remainingBytes = totalBytes - loadedBytes;
}