ActionScript 3.0 :: Not Use Weak References By Default?

Dec 12, 2009

The default value for weakReference in the call to addEventListener() is false. Many memory issues can be resolved by using weakReferences; in fact, some industry experts "strongly recommend always using weak references with listeners".If this is the case, can someone provide me with a good reason why weakReference defaults to true? (Note that I'm not asking why someone would ever want a listener that is not a weakReference, but rather why weakReference=false is the default)

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Why Does Not Use Weak References By Default

Dec 11, 2009

The default value for weakReference in the call to addEventListener() is false. Many memory issues can be resolved by using weakReferences; in fact, some industry experts "strongly recommend always using weak references with listeners".If this is the case, can someone provide me with a good reason why weakReference defaults to true? (Note that I'm not asking why someone would ever want a listener that is not a weakReference, but rather why weakReference=false is the default)

View 4 Replies

ActionScript 3.0 :: Weak References On Loader On Mac?

Jan 12, 2010

I was having a weird problem on my Mac when creating a loader.

PHP Code:
var myUrlRequestURLRequest URLRequest(imageurl);myImageLoader Loader();myImageLoader.contentLoaderInfo.addEventListener(Event.INIT, imageInitHandler, false, 

[code].....

View 0 Replies

ActionScript 3 :: Weak Listener References Not Appropriate During Initialization?

Apr 19, 2010

As I currently understand, if an event listener is added to an object with useWeakReference set to true, then it is eligible for garbage collection and will be removed if and when the garbage collection does a sweep.

public function myCustomSpriteClass() //constructor {
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener, false, 0, true);
}

In this case, is it not appropriate to initialize an object with weak references event listeners, incase the garbage collector does activate a sweep removing the objects event listeners since they were added during initialization of the object? In this case, would it only be appropriate to create a type of deallocate() method which removes the event listeners before the object is nullified?

View 1 Replies

Flash - Clarifications Regarding Weak References In Listeners?

Aug 29, 2011

I understand how weak references work, but I am bit confused regarding it's use in actionscript event listeners. Consider the example below:

public class Rectangle extends MovieClip {
public function Rectangle() {
var screen:Shape=new Shape();

[code]...

If the Rectangle object has no other references, then it is a candidate for garbage collection, but since there is an event listener within the object, the event dispatcher holds a reference to the object, even though there are no other references to the object(other than the one held by the event listener). Hence it is prevented from being garbage collected. Is this the reason why weak event listeners are prescribed? Is the flash player so naive that, it cannot figure out that the event listener is defined within the same object?

View 1 Replies

ActionScript 3.0 :: Weak References Can Be Used For Memory Optimization?

Mar 5, 2010

i heard that weak references can be used for memory optimization, but i really don't understand what it is. does anyone around here know a good tutorial, blog or something that covers this issue?

View 2 Replies

Actionscript 3 :: Advantage / Disadvantage Of Using Weak References In EventListeners?

Aug 5, 2009

I've been teaching myself actionscript 3 over the past month or so and recently ran into an issue where an object kept doing things after I thought it had been removed. I figured out that the problem was caused by an event listener using the default of useWeakReference = false and I'm wondering why that's the default. what is the advantage to not using a weak reference? and why is that the default? it seems to me that in general you'd want to use weak references, so I must be missing something.

View 4 Replies

ActionScript 3.0 :: Proper Use Of Weak Reference?

Jun 8, 2010

As I understand it if I set the weak reference param to true in my event listeners I don't need to worry about removing the listeners. I'm not really clear what would cause the listener to be set for garbage collection. I would hate to have a situation where the listener was removed before I wanted it to.

View 2 Replies

Flex :: Swiz Mandates Weak Encapsulation?

Feb 4, 2010

I just started using Swiz, and, it seems like Swiz forces you to create classes with weak encapsulation. Swiz requires all event handlers to be public in order to mediate events.

Assume that component 'A' dispatches a few events, which I want to listen to in component 'B'. Traditionally, I'll just add event listeners on 'A' in 'B' and all the event handlers in 'B' can be kept private. However, if, I am using Swiz, I need to make all the handlers, mediating events, public.

View 4 Replies

ActionScript 3.0 :: FileReference Type Method ... Weak

Dec 18, 2009

So there I was, creating a small app that allowed user to upload custom images. Everything went smooth, until......<insert horror music here> So you want to validate that its an image, and not something else. Well you restrict it with the File filter...but there are ways around that. So as a double check, you check the file type after a file is selected. <drum roll>

Awesome, the type method returns null if the image doesnt have the proper headers....what the hell....So most images are compressed for smaller file size, thus the headers are stripped out. So...Type method appears to be useless....There was a simple way around this using the name method..but what the hell...type method is weak!!

View 4 Replies

Actionscript 3 :: Event Listener Added By A Weak Reference

Aug 29, 2011

My problem is basically as follows. There is an instance of a class extending EventDispatcher. Everything goes well when I add event listener to the object like this:

[Code]...

Now someFunction is not called even though the line containing dispatchEvent('eventName') is being executed just like before (and there is an external reference to myObject as well). The application I'm developing is quite complex so, unfortunately, I can't post the exact code.

View 2 Replies

Flex :: Create Weak Reference And Strong Reference?

May 6, 2010

package uk.co.bigroom.utils
{
import flash.utils.Dictionary;
/**
* Class to create a weak reference to an object. A weak reference

[code]....

In this Class, how they denote one as Weak Reference and one as Strong reference.

View 1 Replies

Actionscript 3 :: Way To Map Object ID References?

Nov 4, 2010

I'm writing an application where I have many objects (data models) that are identified by a unique String ID that every such object possesses and these objects can refer to each other by their IDs.So far so good but now I need to keep track of which object keeps a reference to another object and of course there are cases where an object references (or is referenced by) more than one other object and I was wondering what would be the best method to store these references? In a simple map data structure I could just map one object's ID to another but as mentioned there are cases where an object can hold a ref to an arbitrary amount of other objects

View 1 Replies

C++ :: Why Some 'Types' Are References While Some Are 'Primitives'

Mar 19, 2012

Types like Movieclip , String, Object act as references when declared and defined, while types like int, Number are primitives. Why such difference has been made. Why not all of them can be primitives ?

View 1 Replies

ActionScript 2.0 :: Multiple CSS References In One Tag?

Aug 15, 2009

I'm using the CSS object (TextField.StyleSheet) to format my dynamic text, which is loaded from an XML doc. I tried referencing more than one class, like <span class="body bluetext">. However, it doesn't seem to work because it ignores the first syle(s) and only applies the last one in the list. I'm guessing Flash doesn't support this (since they're CSS support is already very weak). Just want to make sure I'm not doing something wrong.

View 0 Replies

ActionScript 3.0 :: References And Event Listeners?

May 17, 2010

Lately I've been twitching in the back of my head wondering just how many references to objects that I'm making, and whether or not they are getting GC'd or not.My question in this sense refers to event listeners and whether or not they are removed in certain cases where you get rid of an object. Two examples:

First, and I think this one is an easy one... when you create an object that adds an event listener to itself INSIDE it's own methods (e.g. this.addEventListener(e:Event, function)), when you REMOVE that object (this), do it's event listeners disappear too? I can only say yes, because they are referencing THAT object and are INSIDE that object.

So I think that question answers itself (but I'd love to know if the truth says otherwise).

But secondly, if you add an event listener to an object from a sibling or parent object, and then remove the object, does that event listener stick around, therefore maintaining a reference to that object and keeping it in memory? And is that the concept that people keep referring to of 'weak' event listeners? E.g. someChildObject.addEventListener(e:Event, function)Also, are event listeners by default strong or weak?

And I am assuming that 'yes', it DOES keep the reference. Which, if you are a n00b programmer like me, you probably are all like, 'aww sh*t damn, how am I supposed to make sure that my objects are getting thrown in the garbage collector's mouth of goodness every once in a while?

View 1 Replies

ActionScript 3.0 :: MovieClip References From A Class?

Jul 15, 2009

I have a files that has movie clips and nested movie clips on the stage. I am now writing a class and want to give the MCs event handlers and other properties.
 
When I do something like the following: myMC_mc.MyOtherMC_mc.mouseEnabled = false;
 
I get the error: 1120: Access of undefined property myMC_mc.
 
I added this to the top of my class and it seems to take away the error, but I thought this was not needed in AS3 anymore.

private var myMC_mc:MovieClip;
private var myMC_mc.MyOtherMC_mc:MovieClip;
 
What do I have to do to not get the error? How is this done right?

View 3 Replies

ActionScript 3.0 :: Trace References The Buttons?

Nov 10, 2009

I have this bit of code I am trying to understand how the trace references the buttons.
 
private function PX(e:Event):void {
 xd=new XML(e.target.data);
xl.removeEventListener(Event.COMPLETE,PX);[code]....

View 3 Replies

ActionScript 1/2 :: Variable References To Objects?

Aug 30, 2010

I've got a 15x3 grid of dynamic text fields in an object called "textbox" that I want to reference through a for loop, so I don't have to have 45 lines of code for assigning stuff to those fields.I have each dynamic field named by their placement in the grid, so, c0a, c0b, c0c, c1a, c1b, c1c, etc.I can also name them c00, c01, c02, if necessary.
 
I tried:
 
for (i=0; i<15; i++) {
textbox.c[i]a.text = "Cell " + i + " A";
textbox.c[i]b.text = "Cell " + i + " B";
textbox.c[i]c.text = "Cell " + i + " C";
}
 
but that gives me a syntax error.I also tried naming them c00, c01, c02, c10, c11, c12, etc., so I could do a double nested loop:
 
for (i=0; i<15; i++) {
for (n=0; n<3; n++) {
textbox.c[i][n].text = "Cell " + i + n;
}
}
 
but that gives me a syntax error too.So, is there a way to access all of these with a for loop, or am I going to have to do it the long way?

View 3 Replies

ActionScript 3.0 :: Movieclip References In An Array

Feb 27, 2011

I have a movie clip in which I have a number of sub movieclips. The number of sub movieclips can vary, so I would like to keep track of them in an array. I am doing that like so:[code]The trace seems fine, showing the names of the correct sub movieclips, but when I try to change the alpha I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 3 Replies

See All External File References In Flash?

Sep 12, 2010

I need to update the dynamic text in this flash file I have and export it to SWF. I've looked at the actionscript in all the frames and symbols but the only thing I've found so far are "stop();" 's

I tried exporting this to SWF to see if the file size was the same as the current working version on the site, and it was about 15kb smaller, and does not work at all.

How can I see all external file references in flash? I need to be able to tell my boss which files are needed or at least what is missing.

View 5 Replies

Embed Youtube Video Without Any References?

Nov 1, 2011

I need i way to embed youtube videos, without any reference. I need something like this [url]... Here the only thing is the youtube logo, no external click, and no title.

View 1 Replies

Actionscript 3 :: Listing References Of An Object?

Mar 8, 2012

Does anyone know if it's possible to list the references an object currently has in ActionScript3 (e.g. listeners, children etc)?

I'm trying to clear an object from memory ready for garbage collection but for some reason it's hanging around.

View 2 Replies

ActionScript 2.0 :: Object References In Events?

Sep 22, 2009

I am trying to create an object that is handling the events of different objects. The object is created in the 1st frame of a code layer:

ActionScript Code:
var gImageEdit:ImageEdit = new ImageEdit( imgAction, movImageFront,
 movToolbar.btnZoomInImage, movToolbar.btnZoomOutImage, gZoomSound );

[code].......

View 1 Replies

ActionScript 3.0 :: Return All References To An Object?

Jun 3, 2010

I'm just getting to grips now with how the Garbage Collector works.

Is there a way (like a function or a custom class available somewhere) to check an object for all its references and return them so that you can see what it's connected to?

View 2 Replies

ActionScript 3.0 :: Pulling Data From XML Through Var References

Sep 8, 2010

I am trying to pull a text from within xml tags and place them in a text box when certain mc's are clicked. I am using the e.target to find the name of the mc clicked and grab info from tags with the same name as the target mc. The XML link is good as i can get data when doing tests with out using mentioned technique.

ActionScript Code:
package {
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
[Code] .....

And the xml file
Code:
<statsIcons>
<pollutionIcon_mc> some text </pollutionIcon_mc>
</statsIcons>

View 1 Replies

ActionScript 3.0 :: Loaded Swf Loses Its References?

Nov 6, 2010

I'm trying to get some things done but run once in a while, well at least, into some issues.Here is one:

I have an swf that is an image viewer/browser that has references on same level, an ImageProperties.xml and some folders full of small jpeg tiles.I actually have a few of these, each in its own folder.Above these folders I have another swf that is the main one, and I am loading from there the other ones with the code pasted at end of this post.

This works if I replace the URLRequest by just the name of the swf to load and I put the main swf with the loader function and the loaded one at same level. But if I leave URLRequest going one level deep "16/xxx.swf" and have the loader swf one level up then it loads the viewer but doesn't show the image.

[Code]...

View 6 Replies

ActionScript 3.0 :: Embede A Class That Is Only References From Xml?

Jan 24, 2011

I have some classes that I want to be able to target them in xml.[code]...

the two ways I know of to embed the class is to associate it with an exported symbol or just reference the class name somewhere in the code (like just sticking the reference in the document class constructor)[code]...

View 2 Replies

ActionScript 3.0 :: References Variables Across Classes?

Jan 12, 2012

I'm building a simple Pong-esque game and I've 'hit' a problem. I'm having an issue with referencing one variable from one class into another. Sounds confusing to me, even harder to understand.

Basically I've got this in my "game.as" class:

ActionScript Code:
public var pongBall:ball;

and in my "player1.as" class I am trying to get said ball to bounce off the player's bat on contact. I think I have the coding right for it apart from trying to link it to the ball from game.as! So far I have this:

ActionScript Code:
public function bounceTest (event:Event) {
if (this.hitTestObject("game.as".startGame.pongBall)) {

[Code]....

View 7 Replies

ActionScript 3.0 :: Finding All References To An Object?

Aug 12, 2009

* Is it possible to create weak references to objects (like theventListener/EventDispatcher is able to do) so that if they are removed, you won't be stuck keeping a reference and taking up space to something that should be garbage collected?* Is there any way to find out how many active variables are referencing a certain object? This would be handy to actually create weak references, since, if you for example, have a static array containing all objects created in that class, you can do a regular check to see if there is only one remaining reference, and if so, you can safely remove it.

* Also, might there be any way to list the entire space (one big chunk of binary data, most likely) of every variable currently running in the program, all references, basically, what Flash is currently storing in RAM?I'm pretty sure that Flash (as crappy and lacking as it is in so many areas) does not have anything like any of these built in, but hopefully there is at least something.

View 3 Replies







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