I can't use dispatchEvent in my static class, I was wondering if anyone knew how I can achieve similar functionality or if it's possible at all to call dispatchEvent from my static class? I basically want to inform my action script code in my flash file when functionality in my static class is complete.
Alright, so I have a class that is linked (via the linkage panel) to a scrollbox class. I'll paste the class here:[code]Ignoring the formatting, the commented out functions are the ones causing the issue. Adobe says that it's a static class and I can't use non-static functions. The way I wanted to use it was:
1. Call the page button generating function above.
2. In the main code in my program is this line:scrollbox.setClickFunction(historyContent.generate Page);So when the buttons that are supposed to be generated are clicked, the scrollbox class can call the History pages generatePage function and pass it which page to show. (I did this because there was a lot of text and a limit on how much would display, so small chunks sounded logical).
3. In the onClick function (which I haven't finished yet because the rest wont work), when you click one of the buttons it calls the set function. Its that simple.
I have a SWF called Application.swf that loads another SWF called jeu.swf. My main class (don't know how to call it haha), is called Main.as. Another class is called actionObjets.as. When I call: dispatchEvent(new MicroJeuEvent(MicroJeuEvent.JEU_TERMINE, 8, "")); It works perfectly from Main.as, it works perfectly.
But when I call it from actionObjets, it doesn't work. No error either. I tried putting this line in a static function, doesn't work either. Why can I dispatch an Event from my main class and not from another one? I'm not a programmer and I just don't get a few of the basic principles of as3. Is there a way of doing differently?
I can communicate an event between any of them fine using a dispatchEvent and addEventListener, and I can get values from the card & board actionscript files into main.as using e.target.*
However for some reason I just cannot get a value to send from main.as to the card or board classes using this same method. And I'm literally stumped as to why.
I'm trying to dispatch a custom event. So that my main document class can react when a nav button is clicked.I have a navbutton class which creates the dispatch's the event... and is handled by the onNavigate Method...
This onNavigate method works perfectly.... however when I try to create a listener in my main document class I don't "hear" the event.Here's part of the code from the main doc class...here's where I register the listener
this.addEventListener("NAVIGATE", doSomething);
here's where I should handle it...
private function doSomething(e:Event) { trace(e.target.name); trace(e.target._label.text);
When I type a class name without new before, FlashDevelop does not show autocompleate. Is it a way to enable that feature? (do you have the same issue?)
I'm currently writing a feature for an interactive periodic table which dynamically displays the name of the element and other properties when you hover over the element. I have thought of three ways to do this and I am wondering which is the best, memory-wise and speed-wise, for loading this information.
make a class with an array ( new Array("hydrogen", "helium", "lithium",...etc.)), instantiating it, then accessing the info with object.arr[i] make a class with a static array (otherwise, same as no.1), importing it, then accessing the info with class.arr[i] put the information into an external xml file and accessing it from there. The 3rd method seems excessive as you have to go through the hassle of adding event listeners for URLloader every time. Is there any difference between the 1st and 2nd way? (What is happening in terms of memory when you are importing a class - is the entire array added to memory?)
I'm wondering if anyone has experience with if there is a big difference in performance in ActionScript 3 between keeping a class with only public static functions, and utilizing those functions often (as in a frame event at 30fps), and in turning the class into a "normal" class of which I instead make an instance and call the functions via the instance instead.
I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it
Code: var class:Class = Class(getDefinitionByName("FooClass")); However, when I try to call foo() using the variable, it errors saying the function
But the same error keeps showing up, related to the var t1 and var t2 lines: Access of possible undefined property text through a reference with static type class What should I do? I already tried removing the String indication, trade : by =,
I see where i was going wrong however when i change the instance name like you said i 1120: Access of undefined property snakePart. all of this code btw is at document class level and the movieclips are in the library not on stage
Like most Flex/Flash Builder developers, I have been using the dispatchEvent method to communicate between different classes of an application. And, that works fine, but, I have been toying with a different idea about inter-class communications and would like you to shoot it down, if you can.
Why not have an application "state" class, instantiated as a singleton, which holds the information that is needed by the application's various classes? Examples would be current user and session, currentState of the parent application, selection criteria, data providers, etc. Each class would, of course, have to be aware of this state class. Each class in the application would post its relevant state to this "state" class, and likewise each class could establish listeners for changes to the relevant objects therein.
It just seems to me that, rather than dispatching events, setting up listeners that in turn fire off a listener method, I could instead bind, for example, a datagrid to the state class' relevant data provider, or whatever is needed. In other words, all "listening" and binding is performed against a single state class.
Hi there, i am hoping for some advice on structure/optimisation from some of you experts . I am working on a portfolio system that is modular, each module works in a self contained way and does not require the other modules to function, though they can be 'linked' by having them all reference the same PortfolioData() class.
im happy with how it is working, but i feel there could be a better way to share the datasource between all classes rather than duplicating it and storing a copy in each class.
I am trying to create a class out of some code senocular wrote on another forum. The code controls the changing of a display object from one color to another. It's called InterpolateColor.I have managed to create a class out of the original code but I am trying to make the class static so that I don't have to create an instance of it in my controller class... I just want to access it by importing it at the top and then saying something like ActionScript Code:InterpolateColor.interpolate( _myMC, 0xFFFFFF );The problem, I keep getting errors when I try and change the class initialize line to ActionScript Code:static public class InterpolateColorWhat have I done wrong in my translation to a class that is preventing me from accessing this in a static way Here's the whole class:
I need to created a static AS3 class to pass variables between modules/ views. For some reason I don't see how to do this in my book or on Adobe. I want a class of "get" and "set" functions.
[code]The compiler is throwing 3 errors of the same type 1119(1119: Access of possibly undefined property enemyList through a reference with static type Class.) and pointing to the 3 places where I used enemyList in the Hero class. Why cant I use the static array in the Hero class? Or is there another method to detect collision through the available enemies on screen?
I'm trying to manually dispatch events on a textfield so I can manipulate it indirectly via code (e.g. place cursor at a given set of x/y coordinates). However, my events seem to have no effect.
I've written a test to experiment with this phenomenon:
As we can see, the events are being captured and replayed successfully. However, no change occurs in tf2 - the mouse cursor does not appear in tf2 as we would expect. In fact, the cursor remains in tf even after the tf2 events are dispatched.
I have a static utility class that must have a reference to the stage, and I'm not sure what is the best option for me to get the stage inside my class...
I've thought of these options:Pass in as a parameter of the function Have a static variable I can set to the stage I don't like either of these because they are ugly.
What methods can you suggest for me to get a reference to the stage in my static class?