ActionScript 3.0 :: Code Structure Questions For Delegate And Others?
Dec 4, 2009
i instantiate a sprite-class "panel" from my main class. then i call a function "show chooser" inside "panel" which instatiates a sprite class "chooser" with some buttons. now when one of the buttons is pressed i need to call a function inside "panel" which removes the "chooser" sprite/class and which calls a function "onChosen" in the main class.
what is the correct/best way to reference these functions so that they can be called from within the panel and/or chooser classes. i am still too much in the old thinking that a function belongs to a movieclip and can functions with _parent. i need to learn the proper way now.
I don't know if it exists some code generation method for Flex based on XML or Database Structure. For example, we want to manipulate a table in the DB, the most common task is (View/Insert/Update/Delete). And when we have more than 100 fields on the interface, it's rather boring to type them manually in Flex. Is there some ways to generate the Flex Code and the ActionScript functions for managing that.
I seem to run into compile issues in Flash Builder when I import 3rd-party libraries at the wrong level in the directory structure. For example, sometimes I'll import a library one level too deep into its directory tree, and the package explorer ends up excluding the prefix root-level package, usually "com." or "net.". Even though the content of the source itself doesn't change, this will cause compile errors.
Thus: Is it a 1) convention or 2) language requirement that a class's package structure (e.g., "foo.bar.Class") must match its path location (e.g., foo/bar/Class.as)? If it's a language requirement, why is it a requirement? Wouldn't that overdetermine the package structure, since it is already specified in the source code and quite happily consuming the first three to eight columns of each line? If it's not a language requirement, are my compile errors just a result of Flash Builder enforcing the convention?
What is the advantage of using a Delegate class in as2? I realize that it's old news for as3 guys. But Ive got a medium sized as2 project and Im going through my code and wondering why Im using Delegate.create sometimes. What's wrong with "apply"?I admit that I must have jumped on the Delegate bandwagon without thinking anything more than "dhuu...thats what the pros must be using".Am I right in saying that there is nothing at all wrong with simply saying "function_name.apply( this, args )"? Or am I missing something? Is it a matter of memory management? I've done a lot of research on delegation and read all kinds of blogs and scripts from little tweeks to the official.. to >200 lines. Yikes! At the end of the day I wrote my own little delegate class that worked for me (just a rewrite of Proxy without loops). But now that I go though my code I see that I might as well have just used apply because that's all Im doing with it!
Id like to be a better programmer. What am I missing and why shouldn't I do a find and replace here. Why is it better to wrap up "apply"? Will I be better readied to learn other languages?I just don't understand why I was so convinced that I needed the delegate class when I had "apply" out of the box.
I have a ColorPicker Component and I want to (on its CHANGE EVENT) have the LISTENER OBJECT ( known as A) change ANOTHER OBJECT's (known as B) color, based on the ColorPicker's.selectedColor. I do this because i need OBJECT A to keep track of the colors used. Also OBJECT B is dynamic and its instance is based on USER INTERACTION thus B can equal B1 or B2 or C based on mouse click at any given time but must only be 1 at any given time. SO I'm trying to "chain" the events together using listeners/ or delegation but I'm not sure at the logic.how do i reference the objects in the event? should I just try to chain B to listen directly to the event? How can I do this without having to attach listers to the colorpicker every time?
I'm having a hard time understanding to use the Delegate class. I don't seem to understand what it does from what I read online.
Will it work for this situation? I want to rollover a menu that expands onRollover. You can then click on buttons within the rolled over portion. Is delegate for me?
I've got records being populated into our database from paypal's Instant payment notification methods...great. now i turn to our flash cs3 app to populate a component datagrid with the stored database data and to my surprise I'm unable to identify any examples on how this might even be done.
How do you connect to an mssql database from within flash cs3 to retrieve data for displaying within a flash datagrid?
I can write a cfc from coldfusion to return a dataset, but overall i'm not sure if i 'have' to learn Flex, or AIR or what to get the records 'read'.
My ActionScript 3.0 bible is vague at best and resorts to php. (which i dont know)
i have a situation like that, and my goal is to access from onRelease either to the class representation and to the onRelease callee (the caller of the release function,that is the movieclip that catch the onRelease event):[code]
when i'm coding directly on the timeline, i usually create a var like this:
Code: var home:MovieClip = this;
so i always have something to reference the main timeline's scope. how could i do this in a class? delegate.create gets a little confusing.
i tried a few things like the following:
Code: class com.myClass { public var className:String = "myClass"; public static var version:String = "0.0.1";
[code]...
of course this is redundant because it'll scope just fine as parseNews();, but i'm just wondering why it's letting me scope it like this here and not in the onLoad declaration?
I am using a delegate sub-class to perform helper functions for the main app.I have passed all references to it that it needs and it works well apart from the following problem:I also want it to remove an event listener from the main pp.eg:thisStage.removeEventListener(MouseEvent.MOUSE_UP,preOutsideBoundsDragRelease);The compiler tells me I need a reference to "preOutsideBoundsDragRelease" within the removeEventListener statement.eg: "access of undefined property preOutsideBoundsDragRelease
I need to separate the visual part of a component from the functional part of a component, so that I'm able to replace the visual one with a new one for another platform.
Declaring an instance variable _delegate with the delegate's interface isn't a problem. But how Do I forward non-implemented method calls of the visual part to those of the delegate.
I am wanted to know how can i pass a parameter to the function which I'm calling using Delegate class. I know to pass params having static values such as true / false or a static string "hello".
Code: var myFunc:Function = btn.onRelease = Delegate.create(tihs, releaseHandler); myFunc.str = "hello"; function releaseHandler()
[code]....
Here str can be retrieved as 'arguments.caller.str' inside the function.But in case i want to pass the reference of the 'btn' button. Then how can i do this ?
I've written a class that will load multiple SWFs and then call a passed function when complete. My problem is that when all the movies have downloaded the passed function won't fire.
[AS] // LoadChecker // this class is passed am array and calls a function when all of the objects in the array are loaded //
Is it possible to delegate heavy computations to be handled asynchronously (on the user's machine)? When it's done, I could just fire an event, catch the new data, and update. I have played with this for lesser operations, by just setting up a que and only handle a few operations per frame; but is there another method? That feels like a heavy handed workaround, and it won't scale with faster/slower machines. IE: 12 operations per frame works fine on the test machine, but my machine can handle more, but won't do it because it's hard coded.
I need too create quiz app using xml for database for questions and xul or flax for interface, quiz should have 3 types of questions : single answer (radio), multianswer (checkbox) and open (textfield). I really don't know how to import questions from xml, to xul/flex Also i need to save the answers to txt/xml file The xml database is something like this
I'm really new at flash and I'm having some trouble with a textbook assignment. Before I explain my problem here is the code:
Code: stop(); var defValue:Number = 1; stage.addEventListener(Event.ENTER_FRAME, vetIkke); function vetIkke(e:Event [Code] .....
I was doing some assignments in my as3 textbook when I ran into a bit of trouble. I'm trying to make a flash that picks 3 random questions out of a total of 10 and displays them on screen. I made each of the questions movieclips and assigned them all a class (question1 - 10) through Linkage. So the variable "randomQ" is the name of the class of a random question, but how do I get flash to understand that? And how do I spawn that question as a movieclip on stage?
Code: var Question:MovieClip = new randomQ(); I've tried various alterations but can't seem to find the right one. It's possible I've yet to learn the necessary knowledge in order to make this flash.
I'm making a sort of Quiz in Flash with AS3. I know its possible to import the questions + answers with Notepad, XML or even PHP. But I dont know where to start. Can somebody help me out? I allready searched for good tutorials that can help me out but I cant find something usefull.
I'm trying to create a simple quiz that picks questions from an XML file, then checks the answer the user enters against the answers stored in the same XML file. Every time you press blue_btn it should bring up a new question. Right now I'm stuck -- it shows only the last question in the XML file, when I enter the right answer it tells me it's wrong, and when I press blue_btn again nothing happens.
I wanted to randomise my quiz questions and to allow all questions to appear but no similar questions should appear twice. I tried to use arrays to do it but I kept having errors.
I have made a quiz which has 20 questions. 15 questions are asked at random. However, being at random some questions are repeated. How do I shuffle questions rather than use random?
I have a project that i want to make which is a Multiple choice game containing questions and the answers is four pictures when you click on the right answer you move to next question when your are wrong a wrong sign appears i have zero knowladge about flash but i thought this is similar to Geo Challenge in facebook ,,Right ?? what software to download ? any tutorials online ?
I have an application which pulls in data (questions) via XML and randomizes them. Right now if there is 50 questions in the XML file, 50 questions are displayed and randomized in the application. I am trying to figure out how to limit the randomizing pool so that only 35 questions display(even when the XML file has 50 questions) or something like that. My current code which brings in the file and randomizes is below.
Loads the XML data Code: package exam { import flash.net.* //to create URLRequest and load XML file import flash.events.* //for Load events //import flash.display.* //for testing purposes - remove when testing complete //This class downloads the XML document, and then inserts info into arrays and variables. [Code] .....
I was trying to produce an output of an array mixed up and limit the number. how that is done. Now need to incorporate into a quiz application which pulls in data via, XML, displays that, and shows the number of questions. So if 50 questions are in the XML file 50 questions will be displayed in the quiz. What I am trying to do is use the XML file as a question pool and randomly select say 30 questions out of the file to display. no luck so far, but I am making progress!
Im building an activity whereby I want random math questions to appear and for them to be addition, subtraction, division and multiplication with just two integers where the answer is never more than 50
so far I have
ActionScript Code: genQuestion.addEventListener(MouseEvent.CLICK, onGenerate); function onGenerate(e:Event = null):void
[code]....
which randomly generate addition questions whereby each integer couldn't be more than 25. But this isn't right because I could also have 40 +5 and it still be under 50.
I have 4 mc's that are acting as btns inside an mc on the main timeline
code is below newolivefour_mc.buttonMode=truenewolivefour_mc.addEventListener(MouseEvent.ROLL_OVER,buttonOverfour);newolivefour_mc.addEventListener(MouseEvent.ROLL_OUT,buttonOutfour);function
Acatully I have to face an interview on flashlite. I am not at all getting how get prepare on that. Can anyone give guidlines, questions pattern, interview questions for that.