Flex :: Design - Static Functions Or Events?

Feb 1, 2011

I'm working with an application which was originally designed to make heavy use of static-variables and functions to impose singleton-style access to objects. I've been utilizing Parsley to break apart some of the coupling in this project, and I'd like to start chiseling away at the use of static functions. I will explain the basic architecture first, and then I'll ask my questions. Within this application exists a static utility which sends/receives HTTP requests. When a component wishes to request data via HTTP, it invokes a static function in this class: Utility.fetchUrl(url, parameters, successHandler, errorHandler); This function calls another static function in a tracking component which monitors how long requests take, how many are sent, etc. The invocation looks very similar in the utility class:

[Code]...

View 1 Replies


Similar Posts:


Flex :: Events - DispatchEvent From An Static Var?

Jan 10, 2012

Is it possible to dispatch an event from a public static var in Flex? I'm doing this, and Flex throws me an error:

File board.mxml: public static var actionBar:ActionBar;

<mx:VBox>
<ActionBar:ActionBar id="actionBar"/>
</mx:VBox>
File layerMng.as:
board.actionBar.dispatchEvent(...)

Error -> 1119: Access of possibly undefined property actionBar through a reference with static type Class.

View 2 Replies

ActionScript 3.0 :: Static Function Can't Find Non-static Functions

Jan 6, 2010

Ok, so I have a bit of a mess here (Which I'm probably not doing right anyway, which could be my problem...). I have a document class, I'll call it as Body.as, that creates an object from another class known as Headgear.as. There are also other objects created from other classes, or will be in the future. Now, amoung all this, Headgear.as and all of the other classes Body.as will use to make objects require the use of dragging functions (starting and stopping dragging). On stopping drags, position checks are then made to compare a particular hidden movieclip with the dragged MC.

To try and save myself some hassle (from making the same functions over and over to ensuring that when the objects are created I don't need to send a complete crapload of variables just to ensure the position checking function would work), I had the functions for the event listeners (Which are set-up on the draggable MCs in Headgear.as) just direct to functions in Body.as

[Code]...

View 6 Replies

ActionScript 1/2 :: Creating Static Logo Fade Design?

Mar 26, 2010

I was looking to hir someone or make this myself but i could really find any tutorials or anything. Does anyone know how i can make an effect like this in Flash:can you make one like it for my website CreationCrave?

View 1 Replies

ActionScript 3.0 :: Static Class Can't Replace Singleton Design Pattern

Jan 1, 2010

I am not able to understand, why a static class cannot replace a Singleton design pattern .

Cannot a static class, can be used to ensure, the class is never/once only, instantiated. Because that is the facility "static" key words provide , however it doesnot allow instantiation, but that is much similar to the limitation of instantiation once only.

View 9 Replies

ActionScript 3.0 :: Design A Class That Uses Functions From Multiple Classes?

Jun 7, 2011

I'm trying to design a class that uses functions from multiple classes, but as Google tells me, you cannot extend multiple classes.

Here's my code:

Code:
package com.levelGenerator {
import flash.display.Sprite;
import flash.events.KeyboardEvent;

[code]...

How do I use the Keyboard functions and nextFrame() without extending multiple classes?

P.S. A language with object-oriented principles that doesn't allow multiple inheritance? Lame...

View 9 Replies

Actionscript 3 :: Design Pattern To Require Multiple Events Before Executing Method?

Aug 23, 2011

There are many times that I've needed to execute some code after a number of events have fired, and I've come up with counters and such but I feel there must be a better way.For example, say five files need to be loaded, after which a UI component will become active.If I set up a counter that increments each time a file is requested, then decrements each time one has loaded, I run the risk that the first two or three files may somehow get completely loaded before my code gets around to requesting the fourth and fifth, which would mean that my counter would be at zero when I still have two files to load, thus allowing the UI component to be prematurely activated.

There are some cases where you could know the number that need to be loaded before the requests go out, but it's possible that the first file contains the paths (and therefore the number of) files.And this file-loading scenario is only an example of the pattern I'm trying to explain.)

View 4 Replies

Actionscript 3 :: Get/set Functions On Static Properties?

Feb 7, 2012

I am using get/set functions to make variables that are (or appear to be) read only. I can get it to work with instance variables, but not static variables. I found this, which seems to indicate that it's possible to use get/set functions on static properties, but the compiler keeps telling me I have duplicate function declarations. This is essentially what I'm using:

package {
public class Foo {
protected static var bar:int = 0;
public static function get bar():int {return bar;}
}
}

View 2 Replies

ActionScript 3.0 :: Interfaces And Static Functions?

Sep 5, 2009

It seems that Actionscript doesnt support defining static functions in interfaces. Whats the reasoning behind this?I think it would be useful to have that ability but I'm sure there must be a reason why its not there.

View 8 Replies

ActionScript 3.0 :: Dispatching Events From Static Class?

Aug 3, 2010

However, it seems to me as I've started building this (or trying, rather) that there's no way this can be done, but I'm sure I'm wrong. Since the static class is never added as an instance to the display list, the stage (or any object for that matter) will never hear any events it dispatches.I've searched and found this, but that doesn't seem to be the right solution since I'm listening for my custom LinkEvent event from the stage, and *not* in the class calling the dispatch function in the static dispatcher class.And to reiterate, the goal is to have a single class I can use throughout my application that dispatches my custom LinkEvent event with two properties: linkURL, and linkTarget.The whole reason for wanting to do this is so I can have some control over what happens (to track, or do some other behavior) when someone clicks on a link created within an htmlText TextField with an <a>

View 1 Replies

Actionscript 3 :: Calling Static Functions That Don't Exist

Nov 16, 2010

I'd like to have a class that will resolve calls to static functions that don't exist.If you have an object that subclasses the Proxy class, you can override the callProperty() method to catch calls to functions, as properties of that object, that don't exist.How can this be done with static function calls in a class? It cannot be done by making the overridden callProperty() method static. Is there another way?

View 1 Replies

Xml :: Structure Classes To Avoid Using Static Functions?

Nov 16, 2011

I have a Flash application that creates a sort of powerpoint presentation. All the 'slides' are stored in an XML files which is read and processed.

I'm trying to build the presentation using this XML file. At the moment, my main class has it's initial function main and a static function processXML main initiates my database class with a function called initDB. One of my issues is that initDB forgoes processing because it's dependant on an event listener. On completion of loading the XML files, the event listener initiates my static function on my main to create objects from this file.

The issue is that because the event listener continues the processing (after an indeterminate amount of time), the functions are no longer controlled by the main class.

[Code]...

View 1 Replies

ActionScript 3.0 :: Static Stop/Play Functions?

Jan 26, 2012

Let's say I would want to use the frameScript method to add some stop and play methods to some frames.

Normally I would declare the stop function:

[Code].....

My question is, how can I create the same $FUN_FrameStop as a static function?

Static functions do not allow the use of this since static members are bound to a class and are not inherited by that class' instances.

So, is there a way to create a function similar to $FUN_FrameStop, but static?

View 3 Replies

ActionScript 2.0 :: Mx.utils.Delegate And Static Functions?

Oct 25, 2005

How can I get around using an instance variable in a static function that must be called by the Delegate method?

View 6 Replies

ActionScript 3.0 :: Are All Functions Included From A Static Class

Feb 7, 2012

To rephrase my question: if you have a class with a bunch of static methods and you use one of them in your code, does the whole class get compiled with your movie? I suspect that it would be and, if that's the case, wouldn't it be better (from a file-size perspective) to use packaged functions instead?

View 3 Replies

ActionScript 3.0 :: Speed Performance Of Static Class Functions

Jul 7, 2010

i am pretty familiar with tweaking as1/as2 performancehowever in as3 i am still a noob concerning optimization.i tend to have a class utils in my projects in which i carry a lot of static vars and functions.[code]

View 3 Replies

Actionscript 3 :: Make Static Stop/Play Functions?

Jan 26, 2012

Let's say I would want to use the frameScript method to add some stop and play methods to some frames.

Normally I would declare the stop function:
private function $FUN_FrameStop():void {
stop();

[code].....

View 3 Replies

ActionScript 3.0 :: Flash :: Static Stop/Play Functions?

Jan 26, 2012

I would want to use the frameScript method to add some stop and play methods to some frames.Normally I would declare the stop function:

HTML Code:

private function $FUN_FrameStop():void { stop(); return; }
and then use it like this:

Code:

addFrameScript(47, $FUN_FrameStop, 122, $FUN_FrameStop);
My question is, how can I create the same $FUN_FrameStop as a static function?

Static functions do not allow the use of this since static members are bound to a class and are not inherited by that class' instances. So, is there a way to create a function similar to $FUN_FrameStop, but static?

View 2 Replies

ActionScript 2.0 :: Override Static Functions Of Flash Top Level Classes?

Jun 6, 2006

Is there any way to override static functions of Flash top level classes? Lets take Stage or Math for example. What if we want to change Stage.addListener functionality, is there any solution to this problem?

View 3 Replies

ActionScript 1/2 :: Events That Delete Functions?

Sep 8, 2009

I have a dragable object with something like
 
on(press){    startDrag("object");}on(release){    stopDrag();
}
 
How do I make it so that when the mouse button is released it makes it so the object can't be picked up any more (basically it removes the on(press) part)?

View 7 Replies

ActionScript 3.0 :: Save Variables To Be Used Out Of Events And Functions?

Feb 23, 2010

I'm working on a project for school which is requiring me to make a game using Flash and ActionScript 3.0. One of the tasks I have to do is load an external XML file that will be displaying questions and answers. I've looked at google to find simple scripts for loading XML, one example being below:

Code:
var myXML:XML;
var myLoader:URLLoader = new URLLoader();

[code].....

View 1 Replies

ActionScript 2.0 :: MovieClip Events As Class Functions?

Aug 1, 2006

I have built a movie which has some nested movies within. I have created a class called ButtonMc in a .as file and used linkage to connect the symbol in the .FLA file with the class code in the ButtonMc.as file . This is the code for ButtonMc class:

Code:
class ButtonMc extends MovieClip
{

[code]....

View 5 Replies

ActionScript 1/2 :: Functions Called By Events Run In The Caller Context?

Sep 16, 2009

Imagine I have Class A that is listening to an Event on Class B. This listener will call Method X in the Class A. Inside Method X, "this" refers to the Instance of Class B, I'm not in the context of Class A. Isn't this a bit awkward, or am I getting everything wrong? Is there a way to make the listener call my method in the context of A?

View 3 Replies

ActionScript 3.0 :: Can't Trigger Functions That Are Mapped On Keyboard Events

Sep 24, 2009

I build a game that is working great on its own.Using keyboard events enter frame.When i load it in another movie, i cant trigger functions that are mapped on keyboard events.The listener is executed, but doesnt listen.On its own fine, loaded into another movie: no keyb events and from time to time enter frame event errors.I can access the keybard functions AFTER clickin on the movieclip that contains my loaded swf.

View 3 Replies

Actionscript 3.0 :: Events Never Seem To Get Fired (since I Traced The OnComplete Functions)?

Jun 19, 2009

I am building a flash site in AS3 using AMFPHP. I could really use some help in the Event department...The structure of the site is as follows:

Documentclass,
adds PageConveyer (which holds all Pages)
- adds addEventListener( Event.COMPLETE, onPageConveyerComplete ), onPageConveyerComplete:
- startAnimation (loop through pages and components in arrays to animate into screen)[code].....

The problem lies in the Event listeners.I want to make sure everything (pages/components) is loaded before I start animating. My guess was that Flash listens to the underlying objects until they are done running, then fires the Event.COMPLETE event to the parent object, which in turn fires it's own COMPLETE event. These events never seem to get fired (since i traced the onComplete functions). Im lost here. How can I best listen to this many objects within objects, to know for sure whether they are finished and ready to be animated in?

View 2 Replies

ActionScript 2.0 :: Dynamically Assigning Functions To Button Events Results?

Jun 25, 2009

I am in the process of writing a scrolling image viewer that dynamically updates from an xml file. I have written the scroll function (with a lot of help from Kirupa and other sources), and the pictures are updating beautifully, but when it comes to adding the function for the buttons I am encountering an unusual error.

Using the following code:

Code:
initButtons=function(){
for (var i in btnArray) {
var btn:MovieClip = btnArray[i];

[code]....

from this site results in the doClick function being called for each of the buttons in the btn array at runtime, and then not working afterwards.

View 4 Replies

Actionscript 3 :: Flash RIA Development - Using Events / Listeners Or Allowing Children To Call Functions In Parents?

Oct 20, 2011

I'm working on a web app built in Flash AS3. At a high level - the app has a main screen, and several "modal dialog"-type screens that pop-up to manage various user interactions. (This is a similar pattern I use in most of the apps I develop...) Typically - when the user clicks a UI control on the dialog screen (e.g., button, text box, slider bar, etc.) - the main screen needs to react, or manage the consequences. It seems like there are two general ways to handle this: Have the dialog screen dispatch events that the main screen listens for Allow the dialog screen to call functions in the main screen when those controls are clicked (which requires that the dialog screen maintain a reference to the main screen, and that the functions in the main screen are public)

In general - I understand that one of the key benefits of the first method is that the dialog screen isn't so tightly coupled; it's only responsibility is to broadcast the event. This would allow me to more easily use the dialog class in other contexts, or applications. But for many RIAs I develop - a particular screen is SO SPECIFIC to the the application that there's no chance I'd ever reuse it in another application. So, the "easy re-use" benefit is minimal. So - if you eliminate that benefit - which method is actually better? (More performant, less resource-intensive?) For example - if I use events, then Flash needs to manage many listeners for events that may never occur. So - it might be more efficient if the dialog window could call a function in the main screen directly, instead of dispatching an event.

View 3 Replies

Actionscript 3 :: Big Performance Difference Between Using Class With Static Functions Vs Instantiated Class?

Mar 22, 2012

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.

View 1 Replies

ActionScript 3.0 :: Accessing A Class's Static Functions From A Variable Of Type Class?

Feb 19, 2010

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

[code].....

View 6 Replies

Flex - Design - Mediators Coupled To Proxies In Flex PureMVC?

Aug 14, 2009

I've just recently learned the PureMVC framework, and am a little confused as to the coupling between Proxy and Mediator objects. The links on this page connect to some documents describing the framework. (Please note, the links on the aforementioned page open PDFs.)

The diagrams and examples of PureMVC I've examined often show a direct coupling between a Mediator and Proxy. When the proxy's state is updated, rather than sending a new Notification, the Mediator (which retrieves a reference to the Proxy from the Facade) has its state updated.

This certainly seems to simplify the logic of the code, but it also directly couples two seemingly disparate components together. To my understanding, a Mediator's purpose is to translate Events from a view into PureMVC Notifications. Proxies are meant to perform some function to gather data and relay it back to the view. These two components seem to exist in different layers of the application, and perhaps shouldn't necessarily be coupled together.

Wouldn't it make more sense to have the Proxy objects send their own Notifications when their state updates, which are forwarded to the interested Mediator by the Facade?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved