IDE :: Importing A Mp3 File - Nested Anonymous Function?

Apr 20, 2009

I am trying to play an MP3 File in Flash Lite 2.1 (I'm using Flash 8 to develop it). The filename of the MP3 file is imported from an XML file.Here is a copy and paste from the help file on how to do this:

// create a new Sound object
var my_sound:Sound = new Sound();
// If the sound loads, play it; if not, trace failure loading.
my_sound.onLoad = function(success:Boolean) {

[code]....

When I test this code on its own, it does work fine for me. However, I want the above to be executed inside a function that does a number of other things...
Here is a sample of what I'm trying to get working.

function myMusic() {
// create a new Sound object
var my_sound:Sound = new Sound();
// If the sound loads, play it; if not, trace failure loading.

[code]....

I think it's got to do with the fact that once I put it inside a function you are nesting functions (there is a function call from the onLoad event).

I tried changed the line:

my_sound.onLoad=function(success: Boolean) {
to
my_sound.onLoad=myFunctionName(parameters go here)

and then I created a funciton called myFunctionName but I wasn't sure how to send the sound object or what parameters the function should have or how to get the .start() method to work inside the new function.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Nested Button On A Imported Swf That Targets Contact Forms On The Importing File

May 15, 2011

I have a swf named garage. When you click the garage door it opens and a tool chest emerges. You can either click on the gargage door again to close it or click on the top of the tool chest to close it. The drawers on the tool chest represent buttons that will bring up a contact form to be sent to the perspective person. These buttons are a secondary navigation. The main movie that is importing garage.swf has navigation for the contact forms. I need to code the buttons on the tool chest to match the code on the main movie so if you click the buttons on the tool chest they will respond as if they were the buttons in the main movie that it has been imported by.

[Code]....

View 1 Replies

ActionScript 3.0 :: RemoveEventListener() For An Anonymous Function?

Jan 31, 2008

I have an event listener with an anonymous function literal, rather than a function reference. What I am trying to figure out is how to remove that event listener.Obviously, I need a reference to the anonymous function, so the two functions are ===. But, something is going wrong... it just doesn't work, ad this situation doesn't generate any feedback to tell me what might be wrong.There is some good info here, but not a clear explanation.

Code:
private static var _myFunc:Function;
public static function addCreditsToolTip(clip:DisplayObject):void

[code].....

View 4 Replies

AS3 :: Flex / Pass Parameter In Anonymous Function?

Aug 4, 2010

In as3, I am adding event listener and then attaching the anonymous function to it:[code]Now this whole piece of code is looped n times. Now, I have n myBoxes and whenever I roll my mouse over the box, it should alert the name. But, what I see is that the last value of count is used by each box. How can I pass parameter or value to the anonymous function? ( as roll over , I believe, expects only one variable)

View 2 Replies

ActionScript 2.0 :: Anonymous Function Return Values?

Aug 23, 2007

little bit what Im trying to do: I have 2 SWF, one.swf and two.swf 1 LocalConnection to send 1 variable from one.swf to two.swf

one.swf code:

var param:Number = new Number(5);
var sending_lc:LocalConnection = new LocalConnection();
sending_lc.send("_Connection1", "myMethod", param);

[code]...

I need to be able to use param value out of the function, because a I need to perform a switch with this value, since the function wich receives de param value is an anonymous function I dont know how to do to get the value from outside the function because a dont have a reference name to the function so, the normal way to return a value is not going to do the job.

View 2 Replies

Actionscript 3 :: Flash - Remove A Listener That Has An Anonymous Function?

Jan 6, 2010

up.addEventListener(MouseEvent.CLICK,
function clickFunc(event:MouseEvent):void
{
revealSpinner(event,51.42,1,spinner);

[Code].....

The above code adds a listener to a couple of MC's. Originally the methods were anonymous but I have named them clickFunc() in order to try an reference them in my remove listener.

Here is my remove listener code. Both of these snippets are in separate functions. The add listener method is called before the remove method.

up.removeEventListener(MouseEvent.CLICK, clickFunc );
down.removeEventListener(MouseEvent.CLICK, clickFunc);

As soon as I publish the movie I get this error:

1120: Access of undefined property clickFunc.

View 5 Replies

Actionscript 3 :: Anonymous Objects Creation When Calling A Function?

Feb 14, 2010

If I want to send an object to a function with one child called foo equals "bar", i need to do the following:[code]is there a way to declare the object in the function itself ? something like that:[code]

View 1 Replies

Actionscript :: Return Anonymous Getter Function In Flex?

Aug 26, 2010

Getter functions allow obj.meth syntax instead of obj.meth(), I'd like to create an anonymous one of these to return from another function. function get ():Object { } is invalid syntax. I don't suppose Flex offers an easy way to get this functionality, if it's even possible?

View 2 Replies

Actionscript 3 :: HaXe, Differentiate Anonymous Function At Runtime?

Mar 8, 2011

I'm trying to differentiate anonymous functions like:

function() { trace("WOO"); }

from the other ones ('named'?) like

var _FUNC:Dynamic = function() { trace("WOO"); }

The reason I want to do that is because I can't compare between two anonymous functions, because they are two different ones.

var _TEST:Dynamic = function(a:Dynamic):String {
var _TESTA:Dynamic = function() { trace("WOO"); };
var _TESTB:Dynamic = _FUNC;
return (a == _TESTA) + ", " + (a == _TESTB);
}

If I run _TEST(_FUNC);, I'll get back "false, true". Even though they are the same function, they are NOT the same object.Is there a way to compare those such that functions that they are the same if they perform the same task? Is there a way to serialize functions? So that maybe I can compare the serialized representations and see if they share the same 'code'.

View 1 Replies

Actionscript 3 :: Anonymous Class Passed As Variable To Function?

Jun 20, 2011

In c++ if I have a function that takes a class I have defined elsewhere as a parameter like so:void moveto(CPoint2D point) { ... }I can invoke it and pass along data to it like this:moveto(CPoint2D(0,0));basically creating the object and invoking it's constructor to be passed to the functionIs there an equivalent to this in AS3?if I have a function like this:function initialize(min:Point, max:Point): void { ... }how do I do something along the lines of :initialize(Point(0,0), Point(10,10))This throws an error im assuming because it thinks I want to cast something to a point and the notation I found earlier to do something similar only seemed to work if using the basic Object class.

View 1 Replies

Actionscript 3 :: Passing Local Variable To Loader Anonymous Handler Function

Oct 22, 2011

Why isn't this working as I am thinking it would:

var i:int=-1;
for each(obj in myData)
{
i++;

[Code]....

If I add i to an array (like myArr.push(i)) it will have 3 elements, 0, 1 and 2.

View 2 Replies

Actionscript 3 :: Symbol Binding - Each Copy Of The Anonymous Function Gets Bound To A Single Reference To F?

Apr 20, 2011

I'm new to AS3, and can't figure out why this loop isn't behaving the way it "should."

[Code]...

How can I give each anonymous function a reference to each object represented by f, rather than a simple reference to f each time? Specifically, why is it that each copy of the anonymous function gets bound to a single reference to f? How (I should say why) exactly does AS3 differ from JavaScript in this regard?

View 1 Replies

ActionScript 3.0 :: Importing Caurina... For Nested Mc?

Jan 22, 2009

I am building my short flash as3 tweener driven movie.I have some mcs that have their own animation and they are placed on the stage.I am finding that flash is requiring me to continually put:

Code:
import caurina.transitions.* into the beginning of every nested mc timeline.

View 2 Replies

Actionscript 3.0 :: Importing Caurina For Nested Mc?

Jan 22, 2009

I was wondering if someone could give me another clue.I am building my short flash as3 tweener driven movie.

I have some mcs that have their own animation and they are placed on the stage.

I am finding that flash is requiring me to continually put:
Code: Select allimport caurina.transitions.*into the beginning of every nested mc timeline.

Am I doing everything right? Seems like this shouldnt be necessary since it is imported on the main timeline already..

View 3 Replies

ActionScript 3 :: Anonymous Function As Click Handler Is Called Multiple Times Per Click

Aug 16, 2010

I have a button labeled 'blueButton' and I'd like to use an anonymous function to handle the click, like so:

blueButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
trace( "-----click detected-----" );
// now do other stuff
});

Problem is, the click handler is called multiple times per click. The number of times called seems to be random (sometimes 2, sometimes 4, sometimes 3 etc). could I be missing something in my code, or maybe I set up the button wrong?

also I noticed that it seems to always get called once on the first click. After the first click is when it starts getting called additional times, maybe that has something to do with it?

View 3 Replies

Flash :: Call Anonymous Function From ExternalInterface.call() Method?

Nov 4, 2010

I need to get a javascript var in my Flash application. I like to be able to just set a variable in the javascript (client constraints) rather than define a function.

Can this be done? I am trying to use the ExternalInterface.call()

AS:

ExternalInterface.call("function(){return window.someVar}", null);

JS:

var someVar = "Test";

This does not work and I suspect it is because the ExternalInterface.call() does not like the anonymous function.

View 2 Replies

Importing A Graphic File Causes The File To Stop On Frame 1 (CS4)

Aug 4, 2009

I am having an issue where if I import a graphic to the library or directly to the stage, it causes my movie to stop on frame #1, even though the graphic is on frame #40. I have tried a .png, .jpg, and .psd and they all cause this behavior. I have put other graphics in and never had this issue.

View 4 Replies

ActionScript 1/2 :: Importing A SWF Within Flash File From An External File

Nov 16, 2009

basically i imported a SWF within my flash file from an external file and only the randomize button works on the file none of the rest from the imported flash can anyone let me know why, if you need me to let me know and i will upload files

View 1 Replies

ActionScript 3.0 :: Importing Video And Stop Function?

Jan 13, 2010

Great book but I'm finding stuff that's not working as it's supposed to  The first item I came across was adding a stop(); on a separate layer at the end to stop my swf from looping. I followed the directions to a T but no matter what, the .swf would loop. I came across another forum where it mentioned to change the publish settings to Player 8 which automatically changed the ActionScript to 2.0 instead of 3.0. Well the movie didn't loop anymore but why shouldn't it work with Player 10 ActionScript 3.0? I have the most up to date player that I can get.

The next item I came across was on the Import Video function. The tutorial was to use the video encoder to make a usable movie for my file. When I tried to import it I got nothing, no errors, nothing appeared on my layer as it was supposed to. Same thing here - I changed my publish settings to Player 8 which, again, changed it automatically to Actionscript 2.0 and then the movie imported fine and played and did everything it was supposed to do.

View 2 Replies

ActionScript 2.0 :: Function For Nested Button?

Dec 7, 2011

I have kept 12 buttons inside a Movie Clip. When I refer this with dot and when clicked it works fine. But the same is not working with function. This works

ActionScript Code:
scroll_mc.Feb.onRelease = function() {
var month:String;
month=this._name;

[code]...

Button and Label name of Scene is same i.e., Feb.

View 9 Replies

ActionScript 3.0 :: RemoveEventListener From A Nested Function?

Mar 24, 2010

Example:

Code:
var btn:Sprite = new Sprite();
btn.graphics.beginFill(0x000);

[Code].....

Problem: Since I used a blank function(){} inside of the Listener, I don't know how to later delete that function from that object (btn);

Is it possible? Or is there another way to pass variables while defining Listeners on objects?

View 1 Replies

Importing Swf. Into A Fla. File?

Apr 8, 2009

Is it possible to import a swf file into a Flash file with a transparent background so you can still see the main movie underneath? Also, I would only want the swf file to play on a certian number of frames. By the way I have the original flash file of the swf I want to import.

View 6 Replies

Importing A .mp4 File?

Oct 17, 2009

I have been searching on this and from what I have read in some posts I found through google it seems that it is possible to import an .mp4 file to flash.... I am unable to do this so far and wondering if it is in fact possible to do this.. if so, does anyone know of any decent .avi to .mp4 conversion software that will allow the mp4 to be imported to flash as the ones I have tried so far are not allowing the mp4 to be imported.

View 1 Replies

ActionScript 3.0 :: Importing External AS Files / Running Function Inside Application

Jul 5, 2010

I'm new at AS3. I'm pretty good when it comes to PHP, MySQL or HTML but I'm totally lost in AS.I have a project in Flash Builder 4 that I'm trying to add something to that was built in Flash Professional. It's supposed to loas a couple of external AS files, then execute functions from them at a certain point in the application. I know where I want the functions to execute in the application, and I have linked the AS files to "test.as" which is the main AS file for "testapp.mxml". The problem is calling the "Detector" function from inside "FaceDetector.as" which is one of the external AS files. What is the best way to do the following.[code]I want to start the script and let it do what it's supposed to do inside the application at that given time.

View 8 Replies

ActionScript 3.0 :: Nested MovieClips And GotoAndStop Function?

Feb 26, 2010

I have a movieclip "squareA" -- inside of squareA, on frame 2 is a movieclip called "squareB". I tried the following code:
Actionscript Code:
squareA.x = 10squareA.y = 10squareA.gotoAndStop(2)squareA.squareB.x = 10squareA.squareB.y = 10

But I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at problem_fla::MainTimeline/problem_fla::frame1()
If I put SquareB in frame 1 of SquareA -- it works.

View 3 Replies

ActionScript 3.0 :: Call A Nested Function From Another MovieClip?

Jun 4, 2010

If I have function_2 nested inside function_1, how would you call function_2 from another movieclip on the same timeline?MovieClip(parent).function_1().function_2()-I know that's incorrect, but just to illustrate.

View 2 Replies

ActionScript 2.0 :: Nested Function - Name Of Variable To Call?

Dec 23, 2008

I need a way to call a function from a function. It's not that hard, I know, but the name of the nested function is a variable passed into the first function. Like in setTimer() and other functions in flash, where you have the name of a variable to call. I'm going to have a lot, so doing some cheap if(funcname == blabla){blabla();} won't work.

View 1 Replies

ActionScript 2.0 :: Calling A Nested Function With SetInterval?

Jul 4, 2011

As entitled in this post, suppose we have wrote in timeline

[code]...

The problem emerges because I want to use local variables (i.e. a and b) to perform tasks of myF2 on several clips at the same time but started, say, a half of second one after the another. I don't want to use timeline variables because all clips must start with the same initial variable values.If it's impossible to use setInterval like this, how is it possible to fix the problem I described here? .This code is for Flash Professional 8.0

View 1 Replies

ActionScript 3.0 :: Importing .swf File To .fla File?

Oct 22, 2009

I`ve created a website in AS2.0. Now i want to intregrate a AS3.0 .swf file in this site. It contains google maps.

I tried this using the Import to Stage/Library option. The problem is that it just doesn`t show up anywhere, i don`t get an error, nothing happens.

How can i best intregrate a swf as3.0 in my fla?

I`m using Flash cs4 prof v10.0.

View 4 Replies

ActionScript 3.0 :: Importing Svg File?

Jul 9, 2010

I do not see anything in my stage while I import my svg file.

var loader:Loader=new Loader();
loader.load(new URLRequest("one.svg"));
var a:Sprite=new Sprite();

[code].....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved