instance

AS3 dynamically attach MovieClip from a library to the Stage

若如初见. 提交于 2020-01-05 19:36:31
问题 I really have searched high and wide and i'm starting to think it may be my terminology that is preventing me from finding the answer. I have a MovieClip in my library set to Export to ActionScript 3.0 with a Class called 'Info_Win' (its basically going to be a pop-up window, the contents of which depends on it's instance name). I will be adding a given number of these MovieClips to the main stage and each one has to be given a custom instance name that will allow me to access it once it's on

In Python, how do I check if an instance of my class exists?

泄露秘密 提交于 2020-01-05 17:13:12
问题 I'm making a program that asks the user to login, and I'm wondering how I can make it so it checks if an instance of my Username class exists. Oh and please excuse my sloppy and disorganized coding, I'm not very good at it. quit_login = 1 class Usernames: def __init__(self, password): self.password = password testlogin = Usernames("foo") def login_e(): a = raw_input("Please enter a username: ") new_pass = "" if isinstance(a, Usernames): a = Usernames(new_pass) print Usernames else: login_pass

How to access “self” inside the scope of a class?

喜夏-厌秋 提交于 2020-01-05 12:12:19
问题 I've crossed an interesting problem. Suppose we have a class, and in its constructor we take a boolean as an argument. How can I define methods inside the class based on the instance's condition/boolean? For example: class X(): def __init__(self, x): self.x = x if self.x == true: # self is unreachable outside a method. def trueMethod(): print "The true method was defined." if self.x == false: # self is unreachable outside a method. def falseMethod(): print "The false method was defined." 回答1:

Store an instance in Express js session

不想你离开。 提交于 2020-01-05 10:26:09
问题 I'm using the expressjs session, and I have a instance need to store: function a(){this.name="";} var ins = new a(); req.session['user'] = ins; and when I get res.session['user'] next time, the object is not instanceof a, and it cannot access any prototype methods in a, how can i store the ref of the object in session, looks the session will convert it to json object 回答1: You can't store instances like that in JSON unless: You provide your own custom serializer (implementing a toJSON()

I get StackOverflow error when I create new instance in external class

孤者浪人 提交于 2020-01-05 09:36:08
问题 I have my main class CalculatorGUI.java and my second class KeyHandler.java. If I create instance of my main class in external class (e.g. CalculatorGUI one = new CalculatorGUI();), I get: Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError Why is that? I have to make this instance to use variables from y main GUI class. Here is my CalculatorGUI class: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools

Why are parenthesis used in the middle of a method call in Java?

徘徊边缘 提交于 2020-01-04 04:13:09
问题 I came across some code and cannot understand a certain aspect of it although I have done some extensive searching! My question is: Why are parenthesis used in the middle of a method call? package com.zetcode; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class QuitButtonExample extends JFrame { public QuitButtonExample() { initUI(); } private

Get attributes for class and instance in python

ぐ巨炮叔叔 提交于 2020-01-04 03:12:23
问题 In python work next code: class MyClass(object): field = 1 >>> MyClass.field 1 >>> MyClass().field 1 When I want return value for custom fields I use next code: class MyClass(object): def __getattr__(self, name): if name.startswith('fake'): return name raise AttributeError("%r object has no attribute %r" % (type(self).__name__, name)) >>> MyClass().fake fake But: >>> MyClass.fake Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: class MyClass has no

Where is the MySql 5.6 equivalent of `MySQLInstanceConfig.exe` to edit configuration files?

孤街醉人 提交于 2020-01-03 13:14:05
问题 I installed MYSQL 5.6, This works fine. On another server I have MYSQL 5.1 The 5.1 version includes MySQLInstanceConfig.exe in the bin folder But version 5.6 does not include this file. So my question is, how can I configure the instance on MySql version 5.6? 回答1: It has been replaced by MySQL Installer, which is available as both a GUI and console application. 来源: https://stackoverflow.com/questions/19607925/where-is-the-mysql-5-6-equivalent-of-mysqlinstanceconfig-exe-to-edit-configura

“New” Excel.Application vs Excel.Application

风格不统一 提交于 2020-01-03 12:23:34
问题 I am seeking clarification on the impact of "New" on the objects and the script. My understanding is that if I need to perform actions on an excel document and the application is closed then I should use New Excel.Application. If I keep this application active (through an object such as a Workbook for example) and later in the script I decide to open another workbook, should I still use New Excel.Application or would it be better to use Excel.Application then? My concern lies in the fact that

SQLite database in separate class vs. in same class, which is better? Android

妖精的绣舞 提交于 2020-01-03 05:37:49
问题 I have an SQLite database that is in a separate class from the main class that extends Activity. I noticed that there are two ways of setting up the database. one way is to put it inside the main Activity class, either in the class or as a nested sub class. the second way is to put it in the separate class. the separate class looks better, however there is one disadvantage. You have to create an instance of it in the main activity class every time you want to do something. I read that