Bitcoin Forum
May 07, 2024, 11:47:04 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [CLOSED] Minor Flash Action Script touch up needed - 1 BTC bounty  (Read 1220 times)
speedybugsy (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0



View Profile
July 12, 2012, 06:39:23 PM
Last edit: July 17, 2012, 06:12:18 PM by speedybugsy
 #1

[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!



You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
glub0x
Legendary
*
Offline Offline

Activity: 892
Merit: 1013



View Profile
July 12, 2012, 10:22:59 PM
 #2

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... )

The cost of mediation increases transaction costs, limiting the
minimum practical transaction size and cutting off the possibility for small casual transactions

Satoshi Nakamoto : https://bitcoin.org/bitcoin.pdf
speedybugsy (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0



View Profile
July 12, 2012, 11:33:24 PM
 #3

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<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);
glub0x
Legendary
*
Offline Offline

Activity: 892
Merit: 1013



View Profile
July 13, 2012, 12:14:07 AM
 #4

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.

The cost of mediation increases transaction costs, limiting the
minimum practical transaction size and cutting off the possibility for small casual transactions

Satoshi Nakamoto : https://bitcoin.org/bitcoin.pdf
speedybugsy (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0



View Profile
July 14, 2012, 11:00:46 AM
 #5

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.


Khanduras
Full Member
***
Offline Offline

Activity: 168
Merit: 100

Movin' on up.


View Profile
July 14, 2012, 12:10:55 PM
 #6

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.

Bitcoin Address: 1N1sex4rktWdxBJcFTczYZF5Xa75C47j4c                 |
Mining Income Address: 15wgpV7fDN8fVYn1q9QaPb9XSLjGRhry5L    |
speedybugsy (OP)
Newbie
*
Offline Offline

Activity: 30
Merit: 0



View Profile
July 17, 2012, 06:11:17 PM
 #7

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.

Khanduras
Full Member
***
Offline Offline

Activity: 168
Merit: 100

Movin' on up.


View Profile
July 18, 2012, 03:58:14 AM
 #8

Received payment.  Thanks!

I'm glad the code has worked for you.

Bitcoin Address: 1N1sex4rktWdxBJcFTczYZF5Xa75C47j4c                 |
Mining Income Address: 15wgpV7fDN8fVYn1q9QaPb9XSLjGRhry5L    |
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!