FORUMS: list search recent posts

Actionscript Help. Calling a function...

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
HalifaxMediaManiac2334
Actionscript Help. Calling a function...
on Sep 17, 2006 at 3:08:08 pm

Hi,

If anyone could help me on this problem, I would be very appreciative. I have created a new website for a client (http://www.sandboxstudios.ca/ChrisGallant) and have built in an mp3 player (from various code snippets) that does not auto play on start. The mp3 player loads its data from an xml file once you click the play button. The client has now changed their mind and would like it to autostart, and I would rather not recode the mp3 player too much. Is there anyway that I can call the function, that is attachedd to the button, from elsewhere in the movie?

example:

playBttn.onRelease = function(){
my code here;
}

Is it possible to call it from frame one when the movie clip loads?

Thanks,

Jeffrey Coleman
Sandbox Multimedia Solutions
Halifax, Nova Scotia
jeff@sandboxstudios.ca


Return to posts index

Sher Ali
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 5:48:48 pm

I thank you are saying that you have attached the code to a
button instance named playBttn as

playBttn.onRelease = function(){
my code here;
}

because in the above script the function is an Anonymous function
so you cannot call this function from somewhere else. I would suggest
that put the script inside a named function and call it from anywhere
e.g.

function myFunction(){
my code here;
}


playBttn.onRelease = function(){
myFunction();
}


//to autoplay
myFunction();





Sher Ali
http://www.webeyestudio.com


Return to posts index

HalifaxMediaManiac2334
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 6:32:28 pm

This still does not work. Would it have to do with the mp3 player being a component?



Return to posts index


Sher Ali
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 6:39:03 pm

there might be certainly path issues, if possible post the
code or .fla, always use trace function as a means to debug
your code. e.g. if you have now put the code, previously attached
with button, in a named function, and calling that function from
withing button works, but not when you call like this

myFunction();

then it means that there is path conflict.



Sher Ali
http://www.webeyestudio.com


Return to posts index

HalifaxMediaManiac2334
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 6:42:09 pm

Do you mean that my scoping is wrong? Here is the code sample:

function playStart(){
if (pauseSignal == true) {
MySound.start(pausePos, 0);
pauseSignal = false;
playSignal = true;
delete pausePos;
kugel_mc._visible = 1;
} else {
MySound = new Sound();
if (volstatus < volume) {
volume = volstatus;
} else if (volstatus > volume) {
volume = volstatus;
} else if (volstatus == 100) {
volume = 100;
}
if (balstatus < balance) {
balance = balstatus;
} else if (balstatus > balance) {
balance = balstatus;
} else if (balstatus == 0) {
balance = 0;
}
MySound.loadSound(AudioPath, StreamSignal);
MySound.setVolume(volume);
MySound.setPan(balance);
MySound.onSoundComplete=function(){
kugel_mc._visible = 0;
playSignal = false;
status = "Status: stopped";
}
volstatus = volume+1;
balstatus = balance;
pauseSignal = false;
playSignal = true;
wahlSignal = false;
_parent.onEnterFrame = function() {
total = MySound.getBytesTotal();
geladen = MySound.getBytesLoaded();
if (geladen != total) {
if (geladen != undefined && total != undefined) {
status = "Status: " + Math.round((geladen*100/total)) + "% loaded";
}
mc._xscale = Math.round((geladen*100/total));
} else {
status = "Status: 100% Loaded";
delete _parent.onEnterFrame;
kugel_mc._visible = 1;
if (!StreamSignal) {
MySound.start(pausePos, 0);
}
}
}
}
}

// Play
play_btn.onRelease = function () {
playStart();
}

This code is all contained in the first frame of a component clip. I would just like it to auto start once upon initial load. I really appreciate you help too!

Thanks


Return to posts index

Sher Ali
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 6:48:43 pm

try adding this line at the bottom of the script

playStart();


Sher Ali
http://www.webeyestudio.com


Return to posts index


HalifaxMediaManiac2334
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 6:57:11 pm

Do you know where maybe I could find a mp3 player component that would work in this situation? http://www.sandboxstudios.ca/ChrisGallant is the url to see what I am talking about.


I can't think of why it is not working, but I'm sure there has to be a solution somewhere. Maybe we could connect over email and I could have you look at the fla? I don't want to be a bother but I am coming up on a deadline and any help would be appreciated.

Thanks


Return to posts index

HalifaxMediaManiac2334
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 6:53:21 pm

I'm sorry but "playStart();" did not work either. Does it make a difference that it is within a component?

I'm really stumped!

Thanks again for your help, if you have any other ideas, they would be greatly appreciated.

Thanks


Return to posts index

Sher Ali
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 6:57:15 pm

can you post the .fla?


Sher Ali
http://www.webeyestudio.com


Return to posts index


HalifaxMediaManiac2334
Re: Actionscript Help. Calling a function...
on Sep 17, 2006 at 7:03:31 pm

I could post the fla, but what are the risks? This is for a client and I am uneasy about releasing the raw data like that. If there is a secure way for me to do so, then definitely I would.



Return to posts index

graham quince
Re: Actionscript Help. Calling a function...
on Oct 1, 2006 at 10:43:26 am

You may have fallen for a trap I find myself plummeting into almost daily. :)

Flash may need more time to pull in the files from the xml then you're allowing. Originally it had more time because of the time for a user to hit the button. If you add in an empty movieclip with an action frame to call the function after 30 frames (approx) then flash may cope better. Just a guess, but it might help

Graham

http://www.quinceweb.com - web design
--------
http://www.shiveringcactus.bravehost.com - Free FX for amateur films


Return to posts index

HalifaxMediaManiac2334
Re: Actionscript Help. Calling a function...
on Oct 1, 2006 at 12:06:48 pm

Thanks very much for the help, its sounds like a very possible solution.

Thanks again,


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]