Need a simple Flash preloader for Actionscript 2 using ProgressBar component - actionscript-2

I've been looking for an ActionScript 2.0 preloader using the ProgressBar component, and I can't find an example of this. Can anyone direct me to a nice tutorial for this? I just want to add a simple preloader to the beginning of my movie. It doesn't load any external movies. Thanks!!

I finally tracked down the coded I needed to use with the ProgressBar component:
myProgressBarListener = new Object();
myProgressBarListener = function (eventObject) {
myProgressBar._visible = false;
gotoAndPlay(2);
};
myProgressBar.addEventListener("complete", myProgressBarListener);
myProgressBar.mode = "polled";
myProgressBar.source = "_root";
myProgressBar.conversion = "1";
myProgressBar.label = "LOADING %3%%";
myProgressBar.direction = "right";
myProgressBar.labelPlacement = "bottom";
stop();
This is good for AS 2.0 and I'm using CS6. I'm not sure how this works for other versions of Flash.

Related

Wheelnav adding OnMouseDown event to Spreader

My donut chart works excellent I am using the wheel nav but I can't seem to find anywhere in the docs info on onmousedown for the spreader. When the spreader is in I'd like to add a pop up on mousedown. Any ideas?
I tried to use an on clock method but that didn't seem to work. Great library but very little info on how to manipulate it without changing the entire source.
You can achieve your needs via onmouseup event:
var wheel = new wheelnav("wheelDiv");
wheel.spreaderEnable = true;
wheel.createWheel(["This", "is", "custom", "spreader"]);
var wheelspreader = document.getElementById("wheelnav-wheelDiv-spreader");
var wheelspreadertitle = document.getElementById("wheelnav-wheelDiv-spreadertitle");
wheelspreader.onmouseup = function() {alert("spread it!");}
wheelspreadertitle.onmouseup = function() {alert("spread it!");}
Here is a JS Bin sample.

Windows 8 app with FabricJS Free Drawing Support?

I'm trying to implement free drawing in my windows 8 app but I keep getting this error:
"0x800a01bd - JavaScript runtime error: Object doesn't support this action
File: fabric.js, Line: 12857, Column: 7"
Adding images to the canvas etc. all works as it does in the demos but in VS when I hovered over "fabric" in this code, fabric.Shadow is not shown as an option in the list:
setShadow: function(options) {
return this.set('shadow', new fabric.Shadow(options));
},
Does anyone know why this isn't working for me? I created a build of the api from www.fabricjs.com and included all modules. I've copied the code from the free drawing demo (http://fabricjs.com/freedrawing/) but no joy. I also tried removing any reference to creating a shadow as I don't plan on using that functionality but it still crashes. Thank you
Thank you! It's working for me now. I did have to change the JavaScript provided by the demo to make it work though. Just as a reference to anyone who may want to use it with Windows 8 in future, the jquery code needs to be made more strict for it to update the selectors.
Provided code:
var $ = function(id){return document.getElementById(id)};
var drawingModeEl = $('drawing-mode'),
drawingOptionsEl = $('drawing-mode-options'),
drawingColorEl = $('drawing-color'),
drawingShadowColorEl = $('drawing-shadow-color'),
drawingLineWidthEl = $('drawing-line-width'),
drawingShadowWidth = $('drawing-shadow-width'),
drawingShadowOffset = $('drawing-shadow-offset'),
clearEl = $('clear-canvas');
I did away with the above and just used the standard jquery selector $('#drawing-mode') each time I needed it. Then the events were provided as:
drawingModeEl.onclick = function() {}
drawingColorEl.onchange = function() {}
so I changed the above to:
$('#drawing-mode').on('click', function () {});
$('#drawing-color').change(function (){});
Now everything works as it does in the demo. Love this API, thank you!

Web Audio API. Play sound on click of button

I am a complete novice with HTML5 and coding for that matter. I have been trying to get to grips with the web audio API. I want a sound to play at a click of a button. I used a tutorial posted on HTML5Rocks, but cannot get it to work. I have tried to use jfiddle to help me troubleshoot, but to no avail.
here is my code:
http://jsfiddle.net/ue8WP/
Try this:
function playsound()
{
var filepath='sounds/'+....+'.mp3'; //example
var audio = new Audio();
audio.src = filepath;
audio.controls = true;
audio.autoplay = true;
}
Here's a simplified version of your code that should work fine. You only need to load some other sample sound, since there is a problem with fetching the one you provided (not allowed by Access-Control-Allow-Origin).
http://jsfiddle.net/WB6Pw/3/

Using dojo dojox/dtl in AMD outside of a widget

I want to use dojo doxox/dtl in AMD, OUTSIDE OF A WIDGET!
Currently (2012-02-10) the documentation is not updated to dojo 1.7 AMD (http://dojotoolkit.org/reference-guide/dojox/dtl.html).
In the old documentation the non-AMD example is:
dojo.require("dojox.dtl");
dojo.require("dojox.dtl.Context");
var template = new dojox.dtl.Template("Hello {{ place }}!");
var context = new dojox.dtl.Context({ place: "World" });
console.debug(template.render(context)); // Hello World!
To produce the same output with the new Dojo 1.7 framework, my solution would be to subclass "dojox/dtl/_Templated" and in the constructor of the new class set the template value to the attribute "templateString".
My question is:
Can anybody help me doing dtl templates outside of a widget without subclassing "dojox/dtl/_Templated"?
Thanks alot in advance
Wolfgang
I found the solution:
define(["dojox/dtl/_base", "dojox/dtl/Context"], function (dtl, Context) {
var compiledTemplate, templateObj, contextObj;
templateObj = new dtl.Template ("Hello {{ place }}!");
contextObj = new Context({ place: "World" });
compiledTemplate = templateObj.render(contextObj);
...

YouTube video on Flash Banner CS4 AS3

I am trying to make a flash banner in CS4 with AS3.
In this banner I have to embed youtube videos.
My problem is.. after the video loaded I cant have/see usual controls (fullscreen, pause, stop, etc) on the video.. and the video has the autoplay by default.
I am using this code:
Security.allowDomain("*");
Security.allowDomain("www.youtube.com");
Security.allowDomain("youtube.com");
Security.allowDomain("s.ytimg.com");
Security.allowDomain("i.ytimg.com");
var my_player1:Object;
var my_loader1:Loader = new Loader();
my_loader1.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
my_loader1.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
function onLoaderInit(e:Event):void{
addChild(my_loader1);
my_player1 = my_loader1.content;
my_player1.addEventListener("onReady", onPlayerReady);
}
function onPlayerReady(e:Event):void{
my_player1.setSize(200,100);
/////////////////////////////////
//this example is with parameter//
//my_player1.loadVideoByUrl("http://www.youtube.com/v/ID-YOUTUBE?autohide=1&autoplay=0&fs=1&rel=0",0);
//////////////////////////////////
// this one is only the video id//
my_player1.loadVideoByUrl("http://www.youtube.com/v/ID-YOUTUBE",0);
}
I was trying to pass the parameter in the url to try but seems to be is not working.
I was checking too the google API for AS3 (http://code.google.com/apis/youtube/flash_api_reference.html) but honestly I dont find the way to implement that I need.
Whats is the way to see this controls in the video??
Thank you :)
I was trying different thing and I found a partial solution that i want to share with:
Security.allowDomain("www.youtube.com");
Security.allowDomain("youtube.com");
Security.allowDomain("s.ytimg.com");
Security.allowDomain("i.ytimg.com");
Security.allowDomain("s.youtube.com");
var my_player1:Object;
var my_loader1:Loader = new Loader();
//before I used that:
//my_loader1.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
//Now is use this:
my_loader1.load(new URLRequest("http://www.youtube.com/v/ID_VIDEO?version=3));
my_loader1.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
function onLoaderInit(e:Event):void{
addChild(my_loader1);
my_player1 = my_loader1.content;
my_player1.addEventListener("onReady", onPlayerReady);
}
function onPlayerReady(e:Event):void{
my_player1.setSize(200,100);
my_player1.loadVideoByUrl("http://www.youtube.com/v/ID_VIDEO",0);
}
Basically Instead of use the "Loading the chromeless player" I use the "Loading the embedded player"
My problem now is How I can modify for example the size of the controls bar.. because is taking 35px height and I want to reduce it
Thank