Author

Topic: [CLOSED] Minor Flash Action Script touch up needed - 1 BTC bounty (Read 1238 times)

full member
Activity: 168
Merit: 100
Movin' on up.
Received payment.  Thanks!

I'm glad the code has worked for you.
newbie
Activity: 30
Merit: 0
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.

full member
Activity: 168
Merit: 100
Movin' on up.
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.
newbie
Activity: 30
Merit: 0
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.


legendary
Activity: 892
Merit: 1013
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.
newbie
Activity: 30
Merit: 0
Do you have the actual .mp3 ?
[EDIT] didn't saw the .fla... i'll have a look Smiley
Do you have a version compatible with flash CS3 ? ( do not have above... )

CS4 is the lowest I can save in Sad

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 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);
legendary
Activity: 892
Merit: 1013
Do you have the actual .mp3 ?
[EDIT] didn't saw the .fla... i'll have a look Smiley
Do you have a version compatible with flash CS3 ? ( do not have above... )
newbie
Activity: 30
Merit: 0
[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!



Jump to: