"Lazy"/Delayed initialization of objects?
Good day!
I have a Text control just for easy debugging during development, it was setup as follows:
<!--some previous forms here not shown-->
</mx:Form>
<mx:Form id="DebugResults" label="Debug Output" hideEffect="{fadeOut}" showEffect="{fadeIn}" >
<mx:Text x="128" y="500" enabled="true" id="DebugResultsTXT" width="570"
text="debugging output here" />
</mx:Form>
</mx:TabNavigator>
And an event handler that outputs the debugging info:
public function debug_handleReply(event:ResultEvent):void
// writes to the Text Control for easy debugging
if(DebugResultsTXT){
DebugResultsTXT.text = event.result.toString();
My problem is that when the webpage loads, DebugResultsTXT is always NULL. (I set breakpoint and watched DebugResultsTXT) I found out that I need to manually navigate to the tab "DebugResults" and the DebugResultsTXT text control will be instantiated.
My Questions:
(1) is this because flash performs "lazy" or delayed initialization/instantiation of objects?
(2) any way to "force" the instantiation of DebugResultsTXT without having to manually navigate to that tab (can't expect that from the end-user right?)
Many thanks!
Thanks msakrejda. Right on!
Similar Messages
-
I performed a software reboot on the MSE3310. After the reboot the MSE was no longer visible on the network. I went and consoled into the device and it was operational. I ran the msed stop and msed start commands. I got this message when it tried to load eth0
Bringing up interface eth0: e1000 device eth0 does not seem to be present, delaying initialization.
[FAILED]
Earlier in the day I had updgraded the firmware from 6.0 to 7.0.230.0.
Can I recover the eth0? Is this related to the firmware upgrade?
Thanks.
JasonTarik,
This procedure worked great! After adding the HWADDR parameter to the eth0 config file and rebooting the server, we are now able to access the server on the network again. Thank you very much for the quick reply!
Here is the procedure if others need this.
ifconfig -a showed the eth0 interface was renamed to _tmp462132856
[root@MSE-CPW-01 ~]# ifconfig -a
__tmp462132856 Link encap:Ethernet HWaddr 00:15:17:F1:4D:C7
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:169 Memory:e8180000-e81a0000
eth1 Link encap:Ethernet HWaddr 00:15:17:F1:4D:C8
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Then issued
vi /etc/sysconfig/network-scripts/ifcfg-eth0
to edit the file and add the HWADDR=xx:xx:xx:xx:xx:xx
Then issued a 'shutdown -r now' to reboot the server
After a reboot, network connectivity was restored!
Thanks!
Brian -
How to initialize the object type in pl/sql
Hi,
I am looking for an easy way to initialize the object type in pl/sql.
I have created a object type with around 2 attributes.
when ever i need to initialize the object ..need to pass:
declare
v_obj emp_obj;
begin
v_obj := emp_obj(null,null);
then i can assign the values to object.
Since I am having more than 50 attributes.. need to pass null to all the object attributes.
is there any other way to initialize the object.
thanking you in advance!!!RTFM [url http://oraclesvca2.oracle.com/docs/cd/B10501_01/appdev.920/a96594/adobjadv.htm#1008810]Advantages of User-Defined Constructors
-
How efficiently initialize Calendar object
How can we efficiently initialize a Calendar object to a specific date, using a java.util.Date object?
If I use:
// assume dMyDate is a java.util.Date object.
cal = Calendar.getInstance();
cal.setTime(dMyDate);
it seems inefficient, because the getInstance() method does unnecessary work initializing the calendar to the current date-time. The same happens with:
cal = new GregorianCalendar();
What we need is:
cal = new GregorianCalendar(dMyDate); // not legal!!!
or a raw constructor that does no initialization at all.
I thought maybe initializing the calendar with integers would be more efficient, assuming simple assignments were done:
cal = new GregorianCalendar(0, 0, 0);
but it is hard to tell. I believe the Calendar object does some arithmetic and logic checks to validate the date and adjust it for epoch, etc.
What is the most efficient way to initialize a Calendar object from a Date object?No measurements. It is not a critical problem, but
it seems like a constructor option is missing for the
Calendar object. Maybe there is a practical reason,
but it just seems inefficient to initialize the
object twice.Experience has shown again and again that these kind of speculations are usually worthless. As long as you don't have a performance problem and you've profiled your code to find out where the problem lies, you should not try to optimize anything, but rather make your code readable and understandable. Most of the times those two qualities are much more important than performance. -
Hypothetically, say I was to create an NSString object in a program. I could use
NSString *string = @"This is a string.";
or
NSString *string = [[NSString alloc] initWithString: @"This is a string."];
or
[NSString stringWithString: @"This is a string."];
and I'm sure there are other methods. Which one would be "best?" Why would I choose one method over another in a specific circumstance?MacHamster wrote:
I'm rather new to this and so what I'm about to say might actually be highly erroneous, in which case I hope someone will tell me if it is!
No, you are absolutely correct. It is just that there are some funky things going on with immutable classes (such as NSString, as opposed to the mutable NSMutableString) that are initialized with constants. All that funkiness is happening internally, behind the scenes. You should still call "release" on anything you "allocate".
But if you are building objects from constants, you don't have to worry so much about which method is best. You can just pick the one you like to type the best. They are all identical in terms of efficiency. This may only be true for NSString as well, but that is a popular class.
Try the following code:
NSString * s1 = [NSString stringWithString: @"Testing"];
NSString * s2 = [NSString stringWithString: @"Testing"];
NSString * s3 = [NSString stringWithString: @"Testing"];
NSLog(@"s1 value %p", s1);
NSLog(@"s2 value %p", s2);
NSLog(@"s3 value %p", s3);
using any number of different ways to create the strings. Even call "copy" if you like. As long as you use NSString and initialize from a constant, your end result is always the same constant. -
Delayed visibility of objects not working
I am trying to delay the visibility of an image on one of my projects. The image is the top layer on my time line. I have made sure no objects in the projects has a pause applied to it. When I simply play the project on my time line, the image appears when it is supposed to, but as soon as i preview in a browser, it just never shows.
Can someone help?
See screenshot attached. The image I want to see after a afew seconds is the one titled "Goggles-magnified 420".Thanks Lilybri, yes, I had checked that the visibility was ticked.
I have now solved the problem just by trying random things, and I must say, my solution does not seem to make sense, but it works: I unticked the "show/hide item" (see red crosses on the timeline, next to each item's description), and this made the whole animation work in web browser preview..... :-)
i now hope this will work when i upload my course in my LMS ....fingers crossed
Thanks for your help anyway
JDKD -
HI, I'm having problems initializi​ng object for CNiFgen class.
Hello, I'm having problems initializing object for CNiFgen class, I declare a pointer *m_pFgen to the CNiFgen class, then m_pFgen = new CNiFgen(m_driver, true, true) and then it gives me an error message Primary Error: (Hex 0xBFFA000C) Invalid attribute.
Here is how to make a call to initialize a session to niFgen:
//Create a new session on the device
_session = new CNiFgen(m_resourcename);
Also. I'm attaching an example on how to generate standard waveforms with the class interface for Fgen.
Let me know if you have any other questions,
Jack Arnold
Applcation Engineer
National Instruments
Attachments:
niFgen_Function_Generator_Ex.zip 5569 KB -
Preloading Delays with exported objects
I am having some trouble with a game I am creating. When debuging the preloader does not show until about 75% of the movie is loaded. Before this the movie is just a blank white stage. I have several objects that need to be exported and they have all been changed to not export in frame 1 but this did not help. I unlinked the original class (the stage's custom definition) which acted as the bridge between external classes and the main stage and turned that into a variable. After all this I still can't get it to start before 55%. Anyone know why it is doing this? Any help would be greatly appreciated.
fonts embedded in the authoring environment will be exported in frame 1 and you need to change the frame in which classes are exported, not only by unticking the export in frame one box for library objects, but you also need to change the flash settings: file/publish settings/flash/settings and change the frame number from 1.
-
10g: Initialize State object?
I like the idea of using the State object on the Page to manage State. I've coded the EventHandler to read the parameters and store them on the state, and I see how to read them back from the state when re-rendering the page. My object model also knows what the default selections should be when the user first opens the page, but I don't know how to get these into the State before the user makes their first set of selections and submits those to the EventHandler.
This seems to be related to the suggestion in the documentation that one "should always gracefully handle the absence of a State object." I'd rather not have to code the equivalent of "selectedValue = (uix:pageState == null ? getDefault : uix:pageState.selectedValue)" throughout the forms. What would be the most elegant way to put "if uix:pageState == null then pageState = getDefaultState" in the page? I was thinking about just creating a defaultState property on my dataSource and using that.
Am I barking up the wrong tree? Are there recommended patterns to "gracefully handle the absence of a State object"?I'll ask around tomorrow.
-
Can we initialize the object of color class??
actually i have to store value of colors in the array of Color class ,i want to initialize the array with white color is it possible ?
There are two ways to do it:
1) You have a varying number of colors
Color[] colorArray = new Color[numberOfColors];
for(int i = 0; i < colorArray.length; i++)
colorArray[i] = Color.white;
}2)You have a fixed number of colors (for example three colors).
Color[] array = {Color.white, Color.white, Color.white};If you have a large number of colors to initialize method 1) may be better. -
How to initialize Graphics object without using paint method??
This is a code to make sierpinski triangle using IFS.
I am using a button called "Iterate" which calls funtion paint() .
paint1() gets called from paint on pressing the button.
I want to convert a square into Sierpinski triangle by iterations.
I want to make a square first .If I put that code in paint() then it gets called everytime.
so problem lines are: Graphics g;
g.drawLine(0,0,99,0);
g.drawLine(0,0,0,99);
g.drawLine(0,99,99,99);
g.drawLine(99,0,99,99);
it gives error as object not initialised.
rest of the working code is as follows.
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class mys31 extends Applet implements ActionListener{
String msg ="";
Button iterate;
int i,j;
double [][]t;
double [][]s;
double []a;
double []b;
double []c;
double []d;
double []e;
double []f;
public void init() {
t=new double[100][100];
s=new double[100][100];
a=new double[]{0.5,0.5,0.5};
b=new double[]{0.0,0.0,0.0};
c=new double[]{0.0,0.0,0.0};
d=new double[]{0.5,0.5,0.5};
e=new double[]{1.0,1.0,50.0};
f=new double[]{1.0,50.0,50.0};
for(i=0;i<100;i++)
t[0]=1.0;
t[0][i]=1.0;
t[99][i]=1.0;
t[i][99]=1.0;
for(i=0;i<100;i++)
for(j=0;j<100;j++)
s[i][j]=0.0;
iterate = new Button("Iterate");
add(iterate);
iterate.addActionListener(this);
} // end init
public void actionPerformed(ActionEvent ae){
String str = ae.getActionCommand();
if(str.equals("Iterate"))
msg=" working";
repaint();
} //end of action Performed
public void paint (Graphics g) {
g.drawString(msg,200,200);
paint1(g);
} // end paint
public void paint1(Graphics g)
int j=0,i;
for(i=0;i<100;i++)
for(j=0;j<100;j++)
if(t[i][j]==1)
s[(int)(a[0]*i b[0]*j e[0])][(int)(c[0]*i + d[0]*j + f [0])]=1;
s[(int)(a[1]*i b[1]*j e[1])][(int)(c[1]*i + d[1]*j + f [1])]=1;
s[(int)(a[2]*i b[2]*j e[2])][(int)(c[2]*i + d[2]*j + f [2])]=1;
g.setColor(Color.red);
for(i=0;i<100;i++)
for(j=0;j<100;j++)
t[i][j]=s[i][j];
s[i][j]=0.0;
if(t[i][j]==1.0)
g.drawLine(i,j,i,j);
}//end paint1
} // end classI don't see a question here.
Anyway I would suggest using double buffering - drawing on a BufferedImage and drawing the BufferedImage inside paint.
You will have to call repaint every iteration. -
Hi,
I have an advanced action that is showing a caption and playing triggered audio. I also have that action triggering the display of a Forward button. However, I want the Forward button to be delayed so that it doesn't display until the triggered audio is complete. Right now, I have the Forward button delayed on the timeline, but if a learner waits to click on those buttons, the Forward button will display immediately. If they click the buttons immediately, then the Forward button displays when I want it to.
What would be the best way to accomplish this without having it show up immediately?Thanks, Lieve. I just tried that. I had my two buttons display 3.5 seconds after the slide started...that button triggers the advanced action. I set the pause on those buttons to 0.5 seconds. My Forward button is set to display at 17 seconds.
As before, if I wait to click the first or second button, it's still bringing my Forward button in too early. But if I click these two buttons right away, it's bringing it on time.
What did I do wrong here? -
Lazy Initialization Exceptions
Our Java naturally classes contain properties which are
relationships to other classes - either one to many or many to one.
Due to the fact that these relationships are so intertwined, many
given objects end up referencing a large portion of the database if
one were to recursively follow all of the nested relationships. As
such, we desire to have the option of not loading certain
relationships when the data is not needed.
We use EJB 3.0 (JBoss implementation using Hibernate) for
object persistence. It allows the option of uninitialized
collections and other referenced objects.
The Flex process of serialization to AMF causes serious
problems for this design. It tries to touch all of these properties
while building the binary representation for sending over the wire.
This triggers an immediate attempt to initialize the objects which
are still in the uninitialized state.
This causes the LazyInitializationException to be thrown by
the O/R framework - because the transaction is already closed
(which effectively means the call to the DAO has returned).
The community only offers two suggestions, both which do not
work with Flex (or Flash Remoting for that matter). T
he first is simply initializing everything ahead of time.
This does not work because eventually you have to draw the line
somewhere, and the Flex serialization routines will find that line
and try to cross it.
The second is the open session in view pattern, meaning that
we open the transaction as soon as the Flex client makes a request,
and close it only when the last response has been made. This does
not work either, because Flex would end up initializing everything
during serialization.
I have gone to the extent to writing a custom aspect to
intercept returning calls from my DAO and null out the Hibernate
proxies. This worked until I tried to use it for uninitialized many
to one relationships. Nulling them out actually deletes my
relationship in the database!
The only solution I see is to add intelligence to the Flex
serialization techniques which watch for this scenario, and avoid
triggering the lazy initialization.
Any suggestions would be appreciated.quote:
Originally posted by:
busitech
Our Java naturally classes contain properties which are
relationships to other classes - either one to many or many to one.
Due to the fact that these relationships are so intertwined, many
given objects end up referencing a large portion of the database if
one were to recursively follow all of the nested relationships. As
such, we desire to have the option of not loading certain
relationships when the data is not needed.
We use EJB 3.0 (JBoss implementation using Hibernate) for
object persistence. It allows the option of uninitialized
collections and other referenced objects.
The Flex process of serialization to AMF causes serious
problems for this design. It tries to touch all of these properties
while building the binary representation for sending over the wire.
This triggers an immediate attempt to initialize the objects which
are still in the uninitialized state.
This causes the LazyInitializationException to be thrown by
the O/R framework - because the transaction is already closed
(which effectively means the call to the DAO has returned).
The community only offers two suggestions, both which do not
work with Flex (or Flash Remoting for that matter). T
he first is simply initializing everything ahead of time.
This does not work because eventually you have to draw the line
somewhere, and the Flex serialization routines will find that line
and try to cross it.
The second is the open session in view pattern, meaning that
we open the transaction as soon as the Flex client makes a request,
and close it only when the last response has been made. This does
not work either, because Flex would end up initializing everything
during serialization.
I have gone to the extent to writing a custom aspect to
intercept returning calls from my DAO and null out the Hibernate
proxies. This worked until I tried to use it for uninitialized many
to one relationships. Nulling them out actually deletes my
relationship in the database!
The only solution I see is to add intelligence to the Flex
serialization techniques which watch for this scenario, and avoid
triggering the lazy initialization.
Any suggestions would be appreciated. -
Abstract object array initialization
Hi everybody!
I have a question, I know you can help me.
I created an abstract class called publication, and two other clases called Tape and Book that derive from the publication class. Now, in the application I have :
Publication BookTape[];
when I compile my program I have one error which is that I haven't initialize the BookTape[] object array. My question is How I can initialize an object that comes from an abstract class? could you help me?
Thank you !!!Publication bookTapes[] = new Publication[10];That will create your array (note, this has nothing to do with instantiating abstract classes).
If you actually want to have something in your array, you need to fill it with subclasses of Publication since it's an abstract class.
So.
for(int i = 0;i < bookTapes.length;i++)
bookTapes[i] = new SubclassOfPublication(); -
Object initializer syntax for strongly typed objects
Hi All,
In C#, you can initialize an object like this:
StudentName student = new StudentName {FirstName = "John", LastName = "Smith"};
I know that in ActionScript, I can create an object without an explicit type declaration using a similar syntax, like this:
var student:Object = {FirstName:"John", LastName:"Smith" };
But what if I wanted to strongly type the object I'm creating, like this:
var student:Student = {FirstName:"John", LastName:"Smith" };
That will fail with a compile error because I'm trying to convert a standard Object instance to a Student object instance.
Does ActionScript have a C#-like initializer syntax? Essentially, it gives you initialization constructors without you having to do the busy-work writing them. And, as an added bonus, you can initialize only the properties you want to, and you don't have to explicitly pass null for the properties you don't want to initialize.
-JoshNo such thing in AS. You could write a factory function if you want but it
won't be as efficient as constructors.
Maybe you are looking for
-
Interview questions - TCS - anyone please reply
Hi Gurus, 1)How will we upload vendor open items and transaction data 2)Explain GR/IR automatic clearing during month end activities 3)Explain about automatic account determination 4)Explain about account assignment model 5)What is the use of sub ban
-
How do I delete my iCloud bookmarks and upload a new bookmark file
While managing my bookmarks, I deleted a bookmarks folder in my bookmarks bar. Just then the infamous beachball started and a dialog popped up saying my bookmarks were syncing with iCloud. Then Safari crashed. After opening it, all my bookmarks bar b
-
Hello everyone, I have just bought one of the new Imacs, and am about to install Logic, Omnisphere, Garageband Expansion Packs etc. I have 640G of disk space, so I have room for all of these on the internal drive, but what I was wondering is, should
-
When I open 2 windows in PSE9 how do I drag one out of the way in order to move an image ?
when I open two images in PSE9 how do I move the windows in order to transfer one figure to another?
-
LG L246WHX calibration profile?
Hi all, does anybody has a calibration profile for LG L246WHX 24" monitor? Thanks!