ActionScript 2.0 :: How To Make Code From A String
Sep 2, 2004
i think u can do it via XML and the CustomFunctions methods in flash... but id rather do it all in flash if possible.what i want to do is to treat a string as a line of code. eg.
i think u can do it via XML and the CustomFunctions methods in flash... but id rather do it all in flash if possible. what i want to do is to treat a string as a line of code.
I am making a pretty basic flash game using AS3, its a 'fill in the blank' type. I think I basically have this code figured out, but I think I need a string variable for the 'word' part, but I've never coded that before, so I was looking for some guidance on that topic. Here is the code I have right now[code]...
I have a for loop generating a string that needed to be executed as code.
var new_content_string:String = content_string.slice( 0, -1 ); // After generating my string, I slice the last letter.content_txt.htmlText = HERE // Here is the place I want to execute my string
Basically, I would like to expose the interface of some Flash code via a textField. I can easily tokenize the string and get the method name and use eval to call the method. I am having trouble collecting the parameters and handing them to the method.[code]...
Since Action Script is an interpreted language, and it is clear by decompiling animations that the code is still in there, is there any function that lists the code of a function or class as a string?asically, I want to create a suite of components for developers that lets them make modifications to or at least view the code behind a component while the animation is running, and that way make it easier to find bugs, instead of having to stop the animation, dig up the code for that class, and recompile it. It would be even handier if it was possible to edit code while the code was running, so the next time Flash encounters that code, it will instead run the new code. Yes, if used unwisely, that could cause a lot of problems, but the benefit outweighs the risk, and that feature is used in such development environments such as Visual Studio.
Likely, the only solution to that would be to give each class a "code" variable, likely a String. Then when the users click the button to view that certain source, it checks for the "code" variable and displays the contents. The problem is that you have to remember to update the variable each and every time Perhaps I can write an extension for FlashDevelop that does that automatically? It could just update that variable at compile time.
I'm trying to create a series of scripts that will create some custom event listeners. I have three movie clips on my stage. One is a movieclip who's sole function is to hold array's and the event listeners. A second which moves around the screen. And a third that is motionless.
The problem is that the argument I want to test (which activates the custom event) is held within a string.
What I want to know is, how do you test to see if the string argument is true?
Is it something similar to this:
[Code]...
I think I'm going about this in the wrong manner, however this is the only way I can think of this working (since I need to be able to dynamically create these events)
i've read a tutorial about passing variables to HTML. But this tutorial isnt clear for me.. [URL] EXAMPLE 1 Using Query String to Maximize Code Reuse I really dont have an idea what to do inside flash, bec the author only said: Quote: Assuming the image filename is image1.jpg, located at a folder named images. And assuming that the Flash movie will use a variable named imageFilename to refer to the file, then we can do this
How do I do that? Like having a empty movie clip and giving an instance name of imageFilename?
Say I recorded and imported sound files of my voice saying "Two", "Four", "Equals", and "Plus"Would it be possible to have Flash on click string together those sound files like a string so that the user would hear:
I have converted Actionscript to Javascript. There are 5 functions with the same code.Everything must become a string in order to replace the code from the function1().
In Actioncript, we can use this[my_string] to convert string back to byteArray or something like that Javascript must surely have a method to convert string back to code right.
I have swf that loads xml from a folder. I want to copy that XML string and hard code it into flash as an entire string. Then dim my xml object equal to that string. Is this possible? Reasoning is because I don't want people duplicating the swf and chaning the xml to create a whole new object. I don't want to have to manualy enter each question and answer and value into the arrays. That's to time consuming.
AS2 code to load the XML: xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = "<myxml>My XML STRING HARD CODED HERE?</myxml>"; var questionXML:Array = new Array(); function loadXML(loaded) { [Code] .....
[URL]Using Query String to Maximize Code Reuse Assuming the image filename is image1.jpg, located at a folder named images. And assuming that the Flash movie will use a variable named imageFilename to refer to the file, then we can do this How do I do that? Like having a empty movie clip and giving an instance name of imageFilename?
give me the Regular Expression that can check if a given string has any HTML code in it, and coming to think of it I would be bothered with <a href="something">something</a> exactly.
of course i could hardcode that - but if I then change something about the as file, the linenumbers won't be correct anymore, or maybe i rename the as file and so on. It'd be great to be able to create that string somehow using compiler directives. Is this Possible in an AIR application created with ActionScript 3.0?
I am trying to find out how to make one .as file code interact with another .as file's code.like, if I had one .as file that specified options of movies and then when the user clicks on a movie (loaded through xml) it uses code from another .as file to load the correct movie.
trying to make something in Flash and i need a var String to = a quotation mark... but i don't know how to do it...
eg: var whatEver:String = """ obviously that doesn't work... coz it just changes all the following coding to text...I tried searching Google and couldn't find anyone with the same problem.
I have a movieClip on the stage called "home_btn" and another called "home". When moving over the home_btn movieClip I want the timeline inside of home to play. I used the slice command to get rid of the _btn which works fine, which is proven by the trace command, but it doesn't seem to be able to enter the timeline of home.
home_btn.addEventListener(MouseEvent.MOUSE_OVER, onOver); function onOver(event:MouseEvent) { var selectedButton:Object;
I have a map of states state when a particular state is clicked on, the fla centers on and zooms to that state. When you click on a state a unique ID is pulled from an xml. Using this ID, I can then call all the counties that are part of this state through the county's xml which is also loaded on my stage.or example if I click on Arizona, it zooms and I get a trace of all the instance names of the counties within Arizona.
//call all instance names of Arizona counties cldcnfips=(cntXml.Records.Record.(STATE_FIPS==cldstfips).afips.children()); trace(cldcnfips);
package { import flash.display.Sprite; import flash.events.*; import flash.net.FileReference; import flash.net.FileReferenceList; public class FileReferenceListExample extends Sprite { [Code] .....
Code like the above will get executed as soon as loaded, how can I make it run under certain condition? Pretty much this in this answer: function keyEvent(code:String):void { // do something with the "code" parameter, that looks like "alt+ctrl+D", may use .split('+'), etc }
i have many actionscript classes. i will give the codes to some other programmer but i don't want to let him to see all of the code. how can i make code unreadable but make project run? is creating swc or library make this?
I've build a simple twitter feed flash application that uses php script to read the latest tweet from xml and returns the string to flash to be displayed in a text box. However, I was wondering if there is some easy way to make the url in the tweet an active link? [URL]
Trying to recognize urls from an xml text (as1) I have not access to edit the xml.The url is loaded as string, ex: "lorem ipsum dolor sThe url is not always at the end of the stringI'm loading it and showing as htmlText, but the url is not likeable (coz have no tags T.T )using split and join i got:
Code: function sar(holder, searchfor, replacement) { tarray = holder.split(searchfor);
for (var i = 0 ; i < 10000000; i++) ;stop();I've placed this code in frame 1 of a flash app. As you can see it does nothing but count to 10,000,000. This takes about 20 seconds to execute.
In C#.NET, this one line runs over 400 times faster. It can count to one billion in less time. Why? I could see it being faster in C#, but what could possibly be going on under the hood that could make it 400 times slower in AS, given that the one line should reduce to just a few machine instructions?
(If you're wondering, I've been tasked with porting some C# code to ActionScript. The code has some scientific calculations in it. But in AS they run so slow that it is unusable. This is the most basic example of the problem.)