ActionScript 3.0 :: Passing Var Type Name As Parameter?
Sep 3, 2009
I would like to know if is possible to pass a var type as parameter to a function. I have several sounds in library, and I would like to do something like that:
Code:
function PlayMe(soundname:String)
{
var snd:this[soundname] = new this[soundname];
snd.play();
}
I have a function setup that I was hoping to re-use to eliminate a bunch of code, but I can't figure out how to pass a parameter to it. I'm getting the trace output, but the rest of the function is not working.Is there a way to get this to work?From what I can tell the syntax matches the examples in the reference guide.
i have 1 PHP page in which i have a Flash animation. this flash swf file, display 2 fields and 1 button.
this php page is called "test.php".
i'm able to send data from Flash to a PHP page, but i would like to send the content of those 2 fields to the "test.php" and display them. however, i do not know how to do it.
i see that it works but i'm not able to display or refresh the PHp page to display the result.
as walkaround i was thinking to collect the webpage address where is executed the flash and to send it to another PHP page. and this 2nd PHP page, will reload the test.php with parameters...
how to get under flash, the address of the actual executed php page ?
I am new to flex and SAP. I am designing a dashboard in flex. I have retrieved data from SAP query_view_data and I am able to show it in charts. However now I want to pass parameter to SAP web service to retrieve data between two dates. I am trying to this with the following code:
protected function adg1_creationCompleteHandler(event:FlexEvent):void { var IInfoprovider:String="0FIGL_O02";
The problem I am currently having right now is the inability to send variables loaded from the LoaderSWF to the SWF that has been loaded.
Concretely speaking, I have an embed script on an HTML page that contains several variables in the FlashVars line. The embed script loads a file called loader.swf. Loader.swf's main responsibility is basically take those variables from the flashvar, load the game URL and pass along the rest of the necessary parameters to the game that the loader is loading. However, I've been working out several solutions and none of them worked the way I wanted to.
how can I load the game SWF file and send along additional parameters with that request? Is there someway I can punch in variables into the myLoader object?
The code I came up with sends along the authenticity token just fine, however, it is not sending score_url correctly. I'm not sure if that is the correct behavior, but please enlighten me with any insights you may have.
I have also considered trying LocalConnection, but the problem is that I do not have the necessary source code for the games to set up LocalConnection on the receiving end.
Also, the game files are using AS2, while the loader is using AS3. The game files read variables by utilizing _root.score_url, etc.
I have a function that I want to use to change either the _x and _y or the _width and _height. Rather than writing a separate function for each.For example, instead of writing this...
My problem is, when I call the function as I wrote it above, Flash naturally takes the _width and _height Values (ie. 432, or whatever the width and height may be), instead of literally putting '_width' or '_height' where the params are found throughout the function...
I'd like to make a call to a function and send either a string or an integer... function getImage(val:*):void{ if(val == String){ switch(val){ case'next': loadNext(); [Code[ ..... and vary my function accordingly...
Code: <mx:Script> public function dtFunc(hd:HitData):String { return hd.item.Month + ":<B>$" + hd.item.Profit + "</B>"; } </mx:Script>
[Code]...
My dataTipFunction does not define what data type to pass in. How does flex automatically know it's a HitData type? Is there any other possible data type that actionscript accepts?
I'm trying to convert some C# code I have and one problem I can't find a solution for is to have a function take parameters of unknown types.
C# code: PHP Code: public T Maximum<T>(T v1, T v2){ return v1 > v2 != null ? v1 : v2;}
A straight translation to AS3 would look something like this, for making it easier to understand for people that might be confused by C# syntax.
[Code]...
This way you can send in anything as the parameters (notice the <T>), be different classes for example, depending on what situation you want to use it, instead of writing a lot of duplicate functions for every possible parameter type.
Is there a way to do this in AS3? Edit: Seems like I managed to find a solution right after I wrote this. Seems like one can use "*" as parameter type.
I have a flash movie for drop down menus that is called by all flash/movie banner sections of my site. The banner movies use FlashVars to set the heading and an image. The trouble is that the flash menus also were set to use a flashvar to dictate the context of the menus and leave one top level menu highlighted to show the content to the user. I have not been able to get both of them to use the Flashvars functionality. The html page calls the banner movie directly and it can therefore access the Flashvars. The menu swf however - which is not called from the html page but instead is called from within the banner movie - cannot access the flashvars variables. That leaves me with two choices:
1. Either use a different method for passing the context variable to the menu movie. 2. HTML code calls the banner movie. I can continue using flashvars and get the context variable by reading it from within the banner movie - and then somehow pass the value down to the menu movie if that is possible.
I have an asp.net page where I get the user_id from who's logged in. Now I need to pass this user_id to a flex application that runs in an asp.net page as a .swf. How can I get this user_id in a variable in my flex application.Or what is the best way to get the user_id into flex.
i have 1 PHP page in which i have a Flash animation. this flash swf file, display 2 fields and 1 button.
this php page is called "test.php".
i'm able to send data from Flash to a PHP page, but i would like to send the content of those 2 fields to the "test.php" and display them. however, i do not know how to do it.
i see that it works but i'm not able to display or refresh the PHp page to display the result.
as walkaround i was thinking to collect the webpage address where is executed the flash and to send it to another PHP page. and this 2nd PHP page, will reload the test.php with parameters...
but once again, how to get under flash, the address of the actual executed php page ?
I am connecting to a web service that I know has a method named getAddy.However, in order to work properly I need to provide this method with a paramater named sessionToken. I'm having difficulty with this, my code currently looks like this:
ActionScript Code: var WS_URL:String = "http://somedomain?wsdl"; var addy_ws:WebService = new WebService(this.WS_URL);
I am trying to build a static function that will allow me to do any sort of effect I want, however I would like to give it pass certain parameters but I am not quite sure how to do it. I am basically trying to write my own effects package with easing and all sorts of thing. ActionScript Code: public static function easeMC(targetMC:MovieClip, mcProperty, amount:Number, speed:Number){ targetMC.mcProperty = do the easing code; }
Basically, those are the parameters im trying to pass but I don't know how I would go about assigning the property per se, like if I want the x position or the width to be the one animated. The easiest way I can think of is making mcProperty a string and then doing this: ActionScript Code: switch (mcProperty) case "width": targetMC.width = do the easing code; case "x": targetMC.x = do the easing code;
for(var i=1;i<=2;i++) { var mc=attachMovie("mc_name","obj"+i,i) mc._x=200*i;
[code]....
this code places two objects obj1 and obj2 and two buttons button1 and button2
button1 is expected to return _level0.obj1 button2 is expected to return _level0.obj2
Instead they both return _level0.obj2. Obviously, each button is passed the object corresponding to the last "i" in the loop. How shall I sort this out? One of the obvious solution sis to attach each button to its object
mc.mc=mc.attachMovie("button","button"+i,i+10);
but this is not acceptable for some other reason I also have to use this for(var i=1;i<=2;i++) block because in the final application the number of objects will be variable and set by the user at the run time.
Following my tiny project I experienced awkawrd behaviour of the sound object. Likely it is something wrong in my code though. I've got a DocumentClass where the sound loads in, and then starts, and have 2 Sliders, one responsible for actual position of the sound in time, and second VolumeSlider. I pass to both of them current Sound object and SoundChannel to the constructor and when I move my TimeSlider to scrub the sound I hear that second sound plays in the background (which is not scubbable). Moreover my VolumeSlider even if it passes a value to the sound.soundTransform and reapply it I didn't hear any change. My question is: can I have right soundChannel object referenced in other classes to change its parameters? From my point of view it is rhetorical question and any passed object has a reference to the main object, but as always I can be wrong.
Or maybe some of had similar issue in the past. Particularly I can instantiate my sliders in the same class as sound object to pass the value(already sliders are instantiated in mainPanel class which represents what the name suggest - main panel ^^just exactly like i.e. Winamp^^ )this way it should work ( I wouldn't have to pass sound object as a parameter to the sliders objects but retrieve slider's value to change the volume) From one point it is clear method as sliderVolume object shouldn't have an sound object inside, but from the point of my app it would be better to pass it though and manage inside the sliderVolume, timeSlider sliders.
I am using the asfunction to call a function and passing a parameter. The problem is in the parameter. I can give a parameter that is over 104 characters. What ever is after that 104th character doesnt pass into the string of the function.
I'm having troubles activating the HitTest, passing the objects name as a parameter through a global function. Let's say there is the following function on the main timeline:
Code: _global.fallIntoBasket = function (fallingObject) { if (_root[fallingObject].hitTest(_x, _root.basket_mc._y+(_root.basket_mc._height/2)-7, true)) { trace ("teste"); _root[fallingObject]._alpha=0; }}
I then call this function passing the this._name of the object as a parameter in a onClipEvent (EnterFrame) on each of the falling Objects action box. The whole detection thing doesn't work though... but if I place the hitTest code on each of the object, and change the _root[fallingObject] to this it works. Can I not pass hitTest through a function?