Bitcoin Forum

Bitcoin => Project Development => Topic started by: speedybugsy on July 12, 2012, 06:39:23 PM



Title: [CLOSED] Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: speedybugsy on July 12, 2012, 06:39:23 PM
[removed link] uses a small action script that loops mp3's.

the source file is at [removed link] (Adobe Flash CS4)

I want the mp3 to autostart on pageload instead of waiting for the user to click the play button.

It should be fairly simple to do, however, I know nothing about Action Scripts.

Bounty: 1 BTC


Let me know if you need additional info!





Title: Re: Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: glub0x on July 12, 2012, 10:22:59 PM
Do you have the actual .mp3 ?
[EDIT] didn't saw the .fla... i'll have a look :)
Do you have a version compatible with flash CS3 ? ( do not have above... )


Title: Re: Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: speedybugsy on July 12, 2012, 11:33:24 PM
Do you have the actual .mp3 ?
[EDIT] didn't saw the .fla... i'll have a look :)
Do you have a version compatible with flash CS3 ? ( do not have above... )

CS4 is the lowest I can save in :(

Here's the code, maybe that helps:



Code:
var timerResolution:int = 200;
var glp:GLPlayer;
var curPath:String;
var playOnce:Boolean = root.loaderInfo.parameters.playOnce;

pauseButton.visible = false;

function playTune(s:String) : void {
if (!glp || curPath != s) {
glp = new GLPlayer(new URLRequest(s));
curPath = s;
}
glp.position = 0;
if (playOnce) {
glp.playOnce();
} else {
glp.playLoop();
}
}

function pauseTune() : void {
if (!glp) return;
glp.pause();
}

function getTunePosition() : Number {
if (!glp) return 0.0;
return glp.position-50;
}

function getTuneLength() : Number {
if (!glp) return 0.0;
return glp.length;
}

function isTuneLoaded() : Boolean {
if (!glp) return false;
return glp.canSeek;
}


var pline:Sprite = new Sprite();
var progressTimer:Timer = new Timer(timerResolution);
progressTimer.addEventListener(TimerEvent.TIMER, showProgress);

pline.visible = false;
addChild(pline);

function drawProgress(cur:Number, total:Number) : void {
if (!total || total == 0) return pline.graphics.clear();
pline.graphics.clear();
var max:Number = cur/total*360.0;
var rad, cx, cy : Number;
var r:Number = 12.5;

pline.graphics.lineStyle(0.1, 0x888888);
for (var i=0; i<max; i++) {
rad = i*Math.PI/180.0;
cx = r*Math.sin(rad);
cy = r*Math.cos(rad);
pline.graphics.drawCircle(cx+15, cy+15, 1);
}
}

function showProgress(ev:TimerEvent):void {
var cpos:Number = getTunePosition();
var totalLen:Number = getTuneLength();
drawProgress(cpos, totalLen);

if (playOnce && cpos >= totalLen-timerResolution-100) {
setTimeout(function() {
onPauseClick();
}, timerResolution+150);
}
}

function onPlayClick(ev:MouseEvent):void {
playButton.y = 100;
pauseButton.y = 0;
pauseButton.visible = true;
playButton.visible = false;
pline.visible = true;

ExternalInterface.call("js_playTune", root.loaderInfo.parameters.pid);
playTune(root.loaderInfo.parameters.mp3_path);
progressTimer.start();
}


function onPauseClick(ev:MouseEvent=null):void {
pauseButton.y = 100;
playButton.y = 0;
pauseButton.visible = false;
playButton.visible = true;
pline.visible = false;

progressTimer.stop();
progressTimer.reset();
ExternalInterface.call("js_pauseTune", root.loaderInfo.parameters.pid);
pauseTune();
}

function onPauseOver(ev:MouseEvent):void {
pline.visible = false;
}

function onPauseOut(ev:MouseEvent):void {
pline.visible = true;
}
Security.allowInsecureDomain("*");
Security.allowDomain("*");
ExternalInterface.addCallback("halt", onPauseClick);
playButton.addEventListener(MouseEvent.CLICK, onPlayClick);
playButton.addEventListener(MouseEvent.MOUSE_OVER, onPauseOver);
pauseButton.addEventListener(MouseEvent.MOUSE_OVER, onPauseOver);
pauseButton.addEventListener(MouseEvent.MOUSE_OUT, onPauseOut);
pauseButton.addEventListener(MouseEvent.CLICK, onPauseClick);


Title: Re: Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: glub0x on July 13, 2012, 12:14:07 AM
Well i can not try anything i do not have the class GLPlayer anyway.
but you can try to add
onPlayClick(null);
at the end of the code, it might just work.


Title: Re: Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: speedybugsy on July 14, 2012, 11:00:46 AM
Well i can not try anything i do not have the class GLPlayer anyway.
but you can try to add
onPlayClick(null);
at the end of the code, it might just work.



No doesn't work.
Also when I do that it shrinks the .swf file from 4kb to 1kb and doesn't load at all.

Perhaps somebody else here has at least CS4 to have a look at it.




Title: Re: Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: Khanduras on July 14, 2012, 12:10:55 PM
Try adding the following lines at the very end of the file.

Code:
function firstStart():void {
playButton.y = 100;
pauseButton.y = 0;
pauseButton.visible = true;
playButton.visible = false;
pline.visible = true;

ExternalInterface.call("js_playTune", root.loaderInfo.parameters.pid);
playTune(root.loaderInfo.parameters.mp3_path);
progressTimer.start();
}

firstStart();

This should work unless the code has issues elsewhere.  I haven't really thoroughly checked it, but it seemed to be okay, elsewhere, at a quick glance.


Title: Re: Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: speedybugsy on July 17, 2012, 06:11:17 PM
Try adding the following lines at the very end of the file.

Code:
function firstStart():void {
playButton.y = 100;
pauseButton.y = 0;
pauseButton.visible = true;
playButton.visible = false;
pline.visible = true;

ExternalInterface.call("js_playTune", root.loaderInfo.parameters.pid);
playTune(root.loaderInfo.parameters.mp3_path);
progressTimer.start();
}

firstStart();

This should work unless the code has issues elsewhere.  I haven't really thoroughly checked it, but it seemed to be okay, elsewhere, at a quick glance.


That made it work. Thank you very much!

Sent 1 Bitcoin to the address in your signature.



Title: Re: [CLOSED] Minor Flash Action Script touch up needed - 1 BTC bounty
Post by: Khanduras on July 18, 2012, 03:58:14 AM
Received payment.  Thanks!

I'm glad the code has worked for you.