ActionScript 2.0 :: Class > Query Vars To Flash - ASP Style
Oct 18, 2006
I recently had a flash project that required me to get query string variables and found it cumbersome, however i found a query string class here on the forums originally created by MichaelxxOA over at actionscript.org. [URL] I reqrote it and structured it to act like Request.QueryString() familiar to those that have worked with asp and aspx.
I'm working on a movie that needs to get the query string data, but I can't just pass it in, as I don't have access to the embedding page, and can't get the author to edit the embedding options. I need to do it all within the movie.
I've seen examples of as 2 using ExternalInterface.call("window.location.href.toStr ing"); but I can't get it to work. Is there another way in as3?
I'm having to work on some old AS2 stuff and my AS2 brain is sadly atrophied.
ActionScript Code: on (press) { arrivaldate = day.text+" "+month.text; //trace(arrivaldate);
[code]....
Is working fine, passing all the variables into the URL. The question is... why? I can't see any mechanism whereby getURL is given all the variables defined above. Does it pass in all local vars by default?
I've been sorting through the XML docs and i've bumped my head into a bit of a question. So, to preface, I have been able to load the XML successfully, but I want to be able to use my own XML loader class to load the XML and then be able to reference it from the document class. Also, I'd like to be able to send a file path to the loader class when I call it.
i'd like to add all or most of my mouse events to stage, but in order to do that i need to be able to tell what is the type of the sprite being clicked.i've added two sprites to the display list, one of which is from a class called Square, the other from a class called Circle.
var mySquare:Sprite = new Square(); var myCircle:Sprite = new Circle(); addChild(mySquare);[code]...........
so far i know how to do is determine if it IS a sprite display object, but since i'll only be working with sprites i need something more specific.rather than checking "is Sprite", is there a way i can check "is Square" or "is Circle"?
I'm trying to run a sqlite query in flex to count the total number of records I believe its working fine but I just can't figure out how to display the results - all I get back is [object Object].
private function overviewOne():void{ var stmt:SQLStatement = new SQLStatement(); stmt.sqlConnection = sqlConn; stmt.text = "SELECT COUNT(user_id) FROM tbl_user WHERE status_status ='Away'";
[code]....
So how do I make a reference to the COUNT(user_id)?
(flash.data::SQLResult)#0 complete = true data = (Array)#1
how can i call public functions or vars of a sprite class from another class (or frame script)? i keep getting 1061: Call to a possibly undefined method getSide through a reference with static type flash.display:Sprite.
//Framescript var a:Sprite = new customRect(); addChild(a);
if i want from a document class to access some variables in other classes (which are imported into that document class) does these variables need to be public to access them or they can be something else?
I need something like 100 movieClip with custom class...How can I avoid repeating them like that:[code]And I check the array in the class.... am I wrong or is there a better way to do it ?
I'm creating a flash project and would like to pilot the most variables (eg: colors, texts, sizes, ...) from a single XML file and then spread them in my document class.
Code: public var yourName:String; public var myXMLLoader:URLLoader = new URLLoader(); public function intro():void {
[Code]....
Right now I got no errors but I got nothing when tracing the "yourName" var.
Lately I changed Flash CS3 for CS4. In older version classes written by me worked fine. However, in CS4 I have serious problem with them. Compiler states that part of my functions and vars are undefined, which is not true. I tried everything - changing name of class, functions, moving class file to different directory, removing package. I even counted { to check if they have pairs. I'm really out of options what can cause those errors.
Here are error given by compiler:
1120: Access of undefined property mnChangeMan. 1120: Access of undefined property ChangeManSliders. 1120: Access of undefined property ChangeManInput.
For the example, there's a single FLA with a document class "main.as." In the public class main.as package, there is a public variable: "var example:String='example';." Inside of the FLA, there is one movie clip in the library and it is assigned a custom base class "sub.as." The movie clip is then placed on the first frame of the stage so its constructor is run at runtime and reads the value of example.
What is the proper way to get the value of "example" in the root document class? Using "root.example" in the sub.as class to target the document class returns an error and when I trace "root", I get "null." Main.example naturally throws an error because that's looking at the actual class and not the movie / stage its attached to.The round-about way I've done it before is to dynamically add the object in the library and pass in the root path when I create a new instance of it (example: submc:sub = new sub(this); ).Is there anyway to get back to the document class with a built-in method like root, etc?
I am trying to set the value of some static vars but I need to reference the class with a string rather than a proper constructor. In AS3 I can do this with:
var ref:Class = getDefinitionByName(classDefinitionAsString) as Class; ref[varNameAsString] = newValue;
I can't find an equivelant approach that will work in AS2 though. I have tried:
var ref:Object = new [classDefinitionAsString]; ref[varNameAsString] = newValue;
This seems to just create an Object and as the vars that I am trying to access are static I don't really want to be using 'new' I just want to reference the vars.
Lately I changed Flash CS3 for CS4. In older version classes written by me worked fine.However, in CS4 I have serious problem with them. Compiler states that part of my functions and vars are undefined, which is not true. I tried everything - changing name of class, functions, moving class file to different directory, removing package. I even counted { to check if they have pairs. I'm really out of options what can cause those errors.Here are error given by compiler:
Quote: 1120: Access of undefined property mnChangeMan. 1120: Access of undefined property ChangeManSliders.
I am a bit puzzled why this does not work when placed in my document class, but works when directly added a key frame in the Flash IDE. ActionScript Code: this['myVar1'] = new Object(); When within the document class I get this error when compiled, ReferenceError: Error #1056: Cannot create property myVar1
I have tried the following but I still get an error. ActionScript Code: public static var root_Ref:Object; root_Ref = root; root_Ref['myVar1'] = new Object();
Lately I changed Flash CS3 for CS4. In older version classes written by me worked fine. However, in CS4 I have serious problem with them. Compiler states that part of my functions and vars are undefined, which is not true. I tried everything - changing name of class, functions, moving class file to different directory, removing package. I even counted { to check if they have pairs. I'm really out of options what can cause those errors.
Here are error given by compiler:
Quote:
1120: Access of undefined property mnChangeMan. 1120: Access of undefined property ChangeManSliders. 1120: Access of undefined property ChangeManInput.
I've made a Horizontal Bar Class which controls an element in library.So I have:Library: HorizontalBar MC - Using class HorizontalBarThis class has some public vars.Library: ContainerGame MC - Using class ContainerGameWhen I add this element to stage (HorizontalBar) inside ContainerGame MC I want to be able to trace public vars from its class inside ContainerGame.
Is there any advantage to deleting vars instantiated within public or private functions in a class, or are they removed from memory after the function has been invoked/run? The function below is completely arbitrary for example:
ActionScript Code: private function someFunctionHere(_ar:Array):Void { var _swf:String = _ar[0];
Is there any advantage to deleting vars instantiated within public or private functions in a class, or are they removed from memory after the function has been invoked/run? The function below is completely arbitrary for example:
Code: private function someFunctionHere(_ar:Array):Void { var _swf:String = _ar[0]; var _nm:String = _ar[1];
If I only instantiate a class once should I make its vars static? I understand how this is of benefit if I make multiple classes, clearly you use less memory as it creates a reference to the same place for each class. Are there any other benefits for creating static vars or functions ?
For example I have my class 'MainMenu' which I create once (might even be my document class). In it I create a Code: private var someHolderForStuff:Sprite = new Sprite();
Should I rather create Code: private static var someHolderForStuff:Sprite = new Sprite();
I'm trying to write a class that will have 3 parameters in a function call to specify: the dynamic textfield, an external HTML file, and an external CSS file. My attempts haven't worked, but I'm not getting many compiler errors. Here's my class file:
Code: // loadText // Loads external HTML file and styles it with an external CSS file // Created by Al Lemieux on 2010-04-19. // Copyright (c) 2010 Lemieux Design. All rights reserved.
I've got a comboBox component on the stage, instance name 'combo'. I want to style the text. I followed the adobe instructions, but they seem not work, and I get no errors.
Code: import fl.data.DataProvider; import flash.text.TextFormat; var tf:TextFormat = new TextFormat();
I've looked up quite a few tutorials, how-to's, etc. on how to pass a query string into my SWF, but it isn't working. The page where the SWF resides is an ASPX page, and this is the code I used:
As you can see, it pulls the "ProjID" querystring and is supposed to pass it into Flash. I have executed the page and viewed the source to make sure it is pulling the querystring appropriately, as shown below: Code: Select all<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL]" width="756" height="433" id="gallery" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="false" /> <param name="movie" value="gallery.swf?ProjID=1" /> [Code] .....
I used "1" for the value, and "1" was what is in the page source, so I know it's at least getting that far. As for what is in the ActionScript, here it is: Code: Select allvar myProj = root.loaderInfo.parameters.ProjID; var myGalleryXML2 = new XML(); myGalleryXML2.ignoreWhite = true; myGalleryXML2.load("[URL]"+myProj); myGalleryXML2.onLoad = function(success) { if(success){ _root.myImages = myGalleryXML2.firstChild.childNodes; _root.myImagesTotal = myImages.length;
It is supposed to load XML from an ASPX page that builds the XML from a database depending on the project ID (ProjID). If I hardcode the variable to "1" (or whatever other ProjID), it works and the correct images are shown for the respective ID. However, I can not get it to pass the ID from the URL to the Flash file. I've even tried "_root.ProjID", and a QueryString class I found through Google, as well as passing the ProjID through Param tags as FlashVars with no luck.