ActionScript 2.0 :: Arbitrary Expressions In Function Calls?
Nov 25, 2009
I have several custom functions that I import as .as files, but I frequently have to modify them to suit projects, which makes standardization and version tracking harder.Is there a way to pass arbitrary expressions to a function when it's called? For example, if I write the function,
Code:
function foo(){
for(i=1; i<=1; i++){
trace(i);
}
}
would there be some way to attach an additional expression after the trace function during the function call? As in,
Code:
foo(do_stuff_here);
where the function would act as if it had said,
Code:
function foo(){
for(i=1; i<=1; i++){
trace(i);
[code]....
but without modifying the original function?I realize I could add an expression to the original function within a conditional, and toggle it via an argument within the call, but since I don't know what I'll add next, or whether I'll need it next time, this would become impractical quickly.
im using a function that iterates through all nodes in an XML tree, and then calls itself again if any of the nodes it is looking at has a set of child nodes, so in other words it multi-dimensionally loops through the entire XML tree.[code]one question i have is - am i correct in my assumption that while variables declared within a function are not accessible anywhere but within that function, if a function calls itself, any loops within that function that use a variable such as "i" will be affected seeing as "i" is accessible within the function?if so, how do i get around that? currently my function loops through all the way down to last child node it can find along the first branch of the XML tree, but then doesnt continue looping through the other branches.
I have this button: <s:Button includeIn="MeniuPrincipal" label="Descarcare Date" click="downloadLmData(event)"/> And this click event handler: protected function downloadLmData(event:MouseEvent):void { downloadData('competenta', 'competente'); downloadData('localitate', 'localitati'); }
The downloadData function looks like this: private function downloadData(item:String, items:String):void { try { var colVar:String = 'col' + cappitalize(items); this.status = "Descarcare date in curs..."; this[colVar] = null; [Code].....
The problem is, all calls are ignored, except for the first one. Is there any "queuing" mechanism which would allow all calls to be made?
I have a gallery, which has a document class and all classes below.When I load gallery.swf into main timeline currently, how do I call some functions in that document class?
I'm trying to call an function in flash from xml. so I used <a> tag and asfunction. But how come when it calls a built-in function in flash, it works. and when it calls a custom function, it just won't work???
If I create a function which calls someLoader.loadClip(...) many different times for different clips and files that I have created, does the system create a seperate thread for each call or does it load one by one ?
I'm making a function to be called by different buttons, and I want the function also alter the appearance of the button itself. But I don't know how to refer to the button from within the generic function.
At work we have a lot of AS3 code that conditionally performs logging or assertions like so:
[Code]...
Is there any way to do something similar in AS3, or do we have to do the conditional compilation blocks around everything? I have been looking around manuals but have found nothing useful yet.
I'm implementing AMF service methods for an flash front-end. Normally things work fine, but we've found that if two methods are called one right after the other, the second call returns null to the flash front-end even though the method actually completes successfully on the PHP end (to verify this, I dump the return data to a file right before I return it).
I have a button in an AS 2.0 fla that calls a javascript function like an anchor so the html goes to a set y position of 750button actions are in a frame
jobsLink_mc.onPress = function () { //ExternalInterface.call("scrollPageY"); ///getURL("javascript:scrollPageY();") getURL("javascript: scrolling()") }
Now the javascript in the html of the page is
<script language="javascript"> function scrolling(){ document.body.scrollTop = 750; } </script>
I originally copied the code from a page a designer never finished but the function works. [URL]click the blue button JOBS / INTERNSHIPS you will see the flash button calls the java function and the page is viewed at Y 750 Now I have the same page elements in a different fla that calls the same function and it doesn't work.
I am developing a game project, in which I have many functions on it. I have all the major functions on the frame 50. And I don't want these functions on the next frame. Indeed I didn't have these functions on the 51st frame, the 51st frame only contains a stop action. But flash calls all the major function on the 51st frame also, I don't want these function to call on the 51st frame. Is there any way to stop this? Or else my program contains error?
Here is the program... = The 50th Frame = stop(); fscommand("allowscale",false); fscommand("fullscreen",false); var die:Boolean = false; var currGun:String="hd_gun"; [Code] .....
I do not want to use external .as files because I will have about 100 swfs to manage in this project, 100 swf is a lot of file management alone without adding 100 .as files on top of it.This is the code in the parent swf file to call the child swf and place it in the page_mc movieclip (note in my final project "child.swf" is replaced with the loading array variable but we're going to keep it simple):
ActionScript Code: var pageLoader:Loader = new Loader(); page_mc.addChild(pageLoader); var loadedpage:URLRequest=new URLRequest("child.swf"); pageLoader.load(loadedpage);
Now just for a simple function to call, we'll say we have a box_mc on the stage in the child swf, and when we click the button in the parent swf I want to call a simple function like this to hide it:
ActionScript Code: function hideBox(event:Event):void { box_mc.visible=false; }
how do I call that function in the child swf from a button in the parent swf?
I have 4 invisible buttons that all do basically the same thing. I am learning how to consolidate my code using functions and I'm stuck on this one. I am using onRollover, on Rollout and onReleases in a frame actionscript. The code is below for 2 of the buttons.
I have a video playback system that runs in a loop as it traverses the playlist of videos, doing something like this:On playback start:
-check for pre-roll ad, play ad if set to true; otherwise: -check for branding video bumper, play bumper if set to true; otherwise: -play video
On playback end: -check for post-roll ad, play ad if true; otherwise: -reset video
The way I have it coded/hacked works fine, but is less than ideal, especially as I plan to build on it. It looks something like this:[code]So, what's a better way to handle this? For an interactive timeline/map I've made in the past, there were a number events that were triggered at certain times during audio narration. Each event was unique (some were animations, others were text labels that appeared, etc), but I unified them as classes with a common 'time' property and common public go() function, and threw them into an array. As the narration played back I would check the 'time' property of the next object in the array, and once it matched I would call the go() function for that event, increment the phase position (so I know which array index to check next), and continue.
I don't know if this is possible with Actionscript 3. What I want to do is have a loseAll(); function that calls other function that in turn close sections of an application. I would be easier to have all the close functions in the closeAll() function and then pass a reference to the once that i don't want to be called. something like this.
I'm trying to optimize my project and eliminate unnecessary function calls, and the one I use the most is Math.abs. I ran a quick test and I use it 200-300 times each frame; checking for collision between the character and monsters, determining if objects are close enough to be in view, and some other misc calculations of that sort.
I've loaded text from database and I make links for each title, works good, until I try to add a item counter to have a next and previous button, allowing user to load 12 records.when inserting the next code, my links fire n times, not just once as expected, making browser to unespectly quit.what can be the reason?
some explanation
init is the number I need to increase or decrease to make database query
total is the number of received records by query
total_geral is the number of all records in database, so I can know if I must or not have a next button
t is the name of the mysql table where query should happen
code: Contadores function contagem(init:Number, total:Number, total_geral:Number, t:String):void { var contador;[code]...
Basically I have created a custom sort function to use with sort(); inside an Array object and I have traced the amount of times each sort() has called customSortFunction. Apparently it keeps changing the amount of times it is called which has seemed to cause problems for me.I am using this to sort Sprite obects on the stage. I am working with an isometric grid and need to make sure everything is sorted based on y and if two objects are on the same tile (tile hover and avatar etc) then it sorts them as well.
However it seems that when I have some objects in a certain position, the customSortFunction isn't called to sort every single item. The case I am facing just now is it sorts every item, but leaves 2 unsorted. I have traced and debugged and it is definitely not calling customSortFunction enough times.
Assuming the nextSound() function looks the same as playSound, typewise... The button click works fine, but the event listener won't call the function because its sending an argument the function isn't expecting. I can change the nextTrack function to be evt:Event, but then the button is sending not enough arguments, and I can't find anything to type it to that will work. I can make a typed function to call the un-typed nextTrack function from the event listener
public function callnextsong(evt:Event):void{ nextTrack(); }
I have an interface that contains audio controls in the Library (class: AudioControls)When a movie is loaded into the interface, and it happens to contain a sound (class: Audio_1), this loaded movie calls an interface function to show the audio controls:
Code: if (Interface._ui != null) { Interface._ui.playCurrentAudio(); }
The problem is, the playCurrentAudio() func in the interface contains some code that refers to nested MCs:
Code: public function showAudioControls():void { audioControls.x = 710; audioControls.y = 583; //
[code]....
That would be the speaker, rewind_btn, playPause_btn, etc. Referring to the parent clip, "audioControls", is no problem of course. But I get an error when I publish the loaded movie:
1119: Access of possibly undefined property speaker through a reference with static type AudioControls. 1119: Access of possibly undefined property rewind_btn through a reference with static type AudioControls. 1119: Access of possibly undefined property playPause_btn through a reference with static type AudioControls.
is it possible to determining what object calls a function based on an event listener? for example, i have 2 buttons on stage that call the same function when they are clicked. i'd like the function to determine which button was the sender.
I`m building a photo slide projector that calls a function using setInterval. But after the tenth call (about after 50 sec) the flash player stops working and crashes.On the first frame of the main timeline I set the following code:
Code: // comando para fullscreen fscommand("fullscreen", "true"); fscommand("allowscale", "false");
is possible to draw a border around an arbitrary Shape (or Sprite) dynamically with ActionScript? From the IDE is really easy, just select the line color and click the Shape with the paint tool (S).How can we the same with Actionscript?
Is it possible to draw a border around an arbitrary Shape (or Sprite) dynamically with ActionScript? From the IDE is really easy, just select the line color and click the Shape with the paint tool (S).
I'm trying to figure out how to tile a rectangle (the stage) with an arbitrary number of rectangles. Simple tiling where all the tiles are the same size and simply stacked in a grid.I'm doing this with a resizable layout and a number of tiles that is arbitrary and will change over time.
Given a more or less 4:3 or 16:9 monitor I would like a solution that tends toward minimizing the perimeter of the tile and being similar in aspect ratio to the screen. I realize that if I have a prime number of tiles that I won't be able to make a nice grid, but other than that it seems there should be some way to do this.Lets say I have 231 tiles I need to arrange. The factors are 1, 3, 7, 11, 21, 33, 77 and 231.If the screen is really, really wide 1 x 231. Wide but not not as crazy wide as before 3 x 77. And most likely 11 x 21 is what I would need.So is there an easy way to do this on the fly? Is there a pre-calculated way to make it easy?