ActionScript 3.0 :: Why To Delegate / When Can Apply

Feb 16, 2007

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.

View 5 Replies


Similar Posts:


ActionScript 2.0 :: Using The Delegate Class?

Oct 30, 2007

I'm having trouble using the delegate.create method (my first time using it!). Here's part of a class I have...

Code:
public function SiteData(xmlFile:String) {
imagesXML = new XML();

[code]....

View 9 Replies

ActionScript 3.0 :: When To Use Delegate/ Dispatcher/ Listener

Jan 29, 2011

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?

View 8 Replies

ActionScript 2.0 :: Using Delegate For Nested Buttons?

Sep 29, 2009

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?

View 0 Replies

ActionScript 2.0 :: Basic Button Example Of Delegate?

Dec 8, 2009

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)

View 1 Replies

ActionScript 2.0 :: Delegate And Class Scoping

Oct 1, 2010

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]

View 1 Replies

ActionScript 2.0 :: Delegate Versus Instance?

Aug 14, 2007

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?

View 6 Replies

ActionScript 3.0 :: Delegate Function Reference?

Sep 16, 2009

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

View 1 Replies

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.

View 2 Replies

ActionScript 2.0 :: Use Delegate With SendAndLoad In A Class File?

Mar 26, 2012

I have a sendAndLoad going on in a separate class file and following guides online I've used a Delegate to handle the onLoad part, like this [code]...

View 0 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 :: Forwarding Undeclared Methods-calls To A Delegate?

Oct 15, 2011

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.

What's the equivalent of PHP's _call()?

View 2 Replies

ActionScript 2.0 :: Delegate Class - Passing Parameters With Function?

Jan 31, 2008

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 ?

View 3 Replies

ActionScript 2.0 :: Referencing Movieclip Event Handler Is Called From When Using Delegate?

Aug 24, 2006

I'm using Delegates in a new project I'm working on to call an event handler in my class with the scope of the class.

I'm having an issue referencing which button is calling this handler. Since all of my buttons are created dynamicly, this is a big problem.

I'm used to using forms and components where I had no problem with this and could reference who was calling the event handler by using - event.target

This doesn't seem to be the case with movieclips though, is there another way to do this?

View 1 Replies

ActionScript 2.0 :: Delegate Event Won't Fire In Multi Swf Load Class

Jan 31, 2008

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
//

[code]....

View 1 Replies

ActionScript 3.0 :: Delegate Heavy Computations To Be Handled Asynchronously (on The User's Machine)?

Aug 20, 2010

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.

View 2 Replies

ActionScript 3.0 :: Flash Player 10.1.85.3 - If The Object Is Not Found In The Dictionary Object, It Will Be Searched For In The Delegate Objects?

Oct 29, 2010

I am encountering a problem in my app only when it is run in flash player 10.1.85.3. Some earlier player versions I have tried are working fine.From what I can tell it seems related to the following:

Quote:

from here: h[url].....

When searching for objects (not strings) in Dictionary objects using the 'in' operator, if the object is not found in the Dictionary object, it will be searched for in the delegate objects. With 10.1, the toString operator will be called on the Object if not found in the Dictionary. This can cause problems with Proxy objects who need to define the callProperty function or it will generate a RTE. ...what it means "it will be searched for in the delegate objects"?

View 1 Replies

Flash :: Delegate Function (Function).toString() Prints Function Function() {}?

Nov 1, 2010

I've got a Vector of ViewToActionMap objects, which have following constructor:

public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,

[code].....

View 1 Replies

Apply Function Between IP Cam And FMS?

Oct 15, 2011

I want to know how can I get the videos from IP Cam and store on the Flash Media Server then clients can see the videos from the browser.

what kind of software and technique I have to use ?

View 4 Replies

ActionScript 3.0 :: Apply The Css To The Text?

Mar 18, 2009

I'm working on a number of pages that load external text files with buttons.That part works fine and I had the text marked up with basic html but would rather use css....I'm trying to figure out how to apply the css to the text:

here is the css

Code:
@charset "UTF-8";
/* CSS Document */
VIDEO, P, STRONG, LENGTH {

[code]...

the text loads but isn't formatted by the CSS

a. is the css code valid?

b. what do I need to do to get it to apply to myTxt?

c. when I load new text does the CSS have to be 'reapplied'?

View 6 Replies

ActionScript 2.0 :: Possible To Apply ForceSmoothing To JPG?

Dec 25, 2009

Can forcesmoothing be applied to a .jpg that is loaded into a movieclip dynamically (via xml file)?

View 5 Replies

Apply A Certain Tween To Several Objects?

Jun 7, 2009

I'm working on a little flash project to show a card game being played out. Its just playing out a set of moves - no actual logic for actually playing the game.Anyhow, what i would like to be able to do is create a tween (hope thats the right term) where a card will appear in the center of the table, and then slide over to the players hands and at the same time shrink down so i can fit a few hands on the screen. So basically i need a tween that takes an object (the card), places it on the center of the screen, and then slides over and shrinks down to a specific point. So in whatever action script calls this tween, i guess i would need to feed it two values - which card it starts with, and where the card should end up.

View 7 Replies

Css :: Flex - Apply CSS To Componet?

Jul 26, 2011

I have a Flex ActionScript component. How can I apply CSS to this component? I'm hoping to be able to apply styles from an external CSS file.CSS Selector in file 'global.css':

.myPanel
{
color:#cccccc;
background-color:#333333;
border-color:#ff0000;
border-style:solid;

[Code]...

View 1 Replies

IDE :: How To Apply CSS To XML Text Links

May 11, 2005

I want a xml text loaded in a normal textfield. I want to embedd the font to the textfield (so not in the xml file). I also want to add links to the xml text and change the look of the link with css. I just want a text file with links in it in Flash and want it to be possible to change it outside of flash so in a XML or text or html file i dont care. As long as I can make links in the text file without the ugly link stripe under the text (so it should be changeable with CSS).

View 10 Replies

ActionScript 2.0 :: Apply To All Buttons?

Oct 6, 2007

I am writing this code on a bunch of buttons and was wondering if there was a way I could apply some sort of generic thing like move the button 2spaces away. ? Instead of defining exactly where they go on x and y.

[Code]...

View 2 Replies

ActionScript 3.0 :: How To Apply The Get / Set Statements

Aug 25, 2009

After searching for how to do this i discovered the Get/Set functions of as.3. The only problem is that i am not experienced enough with this kind of statement to get it working, so i have come here to seek from the wise and masterful members Here is some more info:Inside a fla called "Main" i have 2 MovieClips. The first is called Main and has a class linking to the com/Main.as file which has this code:

Code:
package com{
import flash.display.MovieClip

[code]....

View 10 Replies

ActionScript 2.0 :: Can't Seem To Apply Effects

Sep 7, 2004

I have been designing dynamic pages with Flash and I can't seem to apply effects such as simple motion tweens and alpha effects to it.

View 3 Replies

ActionScript 3.0 :: Apply More Than 1 Action To The Same Frame?

Apr 18, 2010

I am using action script 3 and need to know how to apply more than 1 action to a frame label, ie; I have 5 pages of images and have actions coded as follows:

btn1.addEventListener(MouseEvent.CLICK,play1);
function play1(event:MouseEvent):void{
gotoAndStop("1Lrg");

[code].....

View 1 Replies

Apply Ease In And Out Both To A Single Tween?

Apr 22, 2010

I was wondering if theres a way to apply ease in and ease out both to a single tween..as i want the tween to start slowly than gain normal speed and then again stop smoothly.

View 2 Replies

Import Text And Apply Motion?

Sep 16, 2011

i would like to have a dynamic text that loads text from a *.txt file. This i know how is done, but the problem appears when i want the text-field to roll over the screen, as a motion tween. To be more specific it must be used for an infoboard, and people shold be able to change the "guests_today.txt" and then the guest list should roll over the display, over and over again.

View 1 Replies







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