Target movieclip from an AS3 class file - remove/add Child
Halo.
I have a very simple question (for those who use external class files).
Assuming that I have a MovieClip manually added to Stage and I want to access it from inside my class definiton.
So the code would be:
MovieClip(root).MyMovieClip
But I can't figure out how to use remove/add Child in that kind of situation.
I will appreciate any advice.
Thanks
if you can reference using that, you can remove using:
MovieClip(root).MyMovieClip.parent.removeChild(MovieClip(root).MyMovieClip);
and you can add to any displayobjectcontainer.
Similar Messages
-
Web dynpro dc compoent controller method call from Java dc class file
Hi All,
Is it possible to call a wd java component controller method from a java dc class file?
I have declared wd java dc as used dc in java dc.Any poiters for the same would be really helpful.
Thanks in Advance.
regards
Radhika KuthialaHi,
short answer: No.
1. using WD references outside of WD DCs is unsupported and will at least show a warning when you try to deploy. Correct usage of runtime dependencies is not predictable.
2. WebDynpro Controllers have a lifecycle that is controlled by the Framework. Even if you manage to initialize a Controller via "new" and use a method, the Controller will never have all the state-information it contains when started regualary. (think of mapped context, context attributes in general, code called in wdInit ...) I would suppose it is possible to implement a runnable low-profile example that still works, but as soon as you try to use "higher" concepts of WD (which would be the only reason to use a WD Component Controller at all), you will definitely fail.
3. Think of it as calling EJBs Session Beans via "new", but more complex.
hope that helps
Jan -
How do I alter the bytes of a Class file to add calls to the methods?
If i had the bytes of a class file, and I wanted to alter the bytes that constitute each method for the class so that it included a call to the security manager, how would i do it?
1. How would I know which bytes were the opening of a method?
2. how would I know what the name of the method is?
3. How would I create bytes for something like:
SecurityManager sm = System.getSecurityManager().checkPermission(thismeth, subject);
4. I assume that if by some miracle I can do the above, then all I have to do is call defineClass(...) in ClassLoader and send it the new bytes, right?
Thanks to all!OK, if it will help anyone get me the answers here, I found a class on the internet that can read a class file and tell you where in the bytes a method occurs and what its name is, and how long it is. What I need now is how to convert a call into the correct manner of bytes.
For example, so I could add the bytes that would do:
System.out.println("Added!");
The class that reads a class file:
/* Inspector.java by Mark D. LaDue */
/* June 24, 1997 */
/* Copyright (c) 1997 Mark D. LaDue
You may study, use, modify, and distribute this example for any purpose.
This example is provided WITHOUT WARRANTY either expressed or implied. */
/* This Java application analyzes the entries in the constant pool and locates
the code arrays in a Java class file. Each entry in the constant pool
yields the following information:
Index Tag Reference(s)/Value(s)
where "Index" is its position within the class file's constant pool,
"Tag" is the official tag number for that type of entry, and
"Reference(s)/Value(s)" contains the constant pool information
according to the entry's type. (See Lindholm and Yellin's "The Java
Virtual Machine Specification" for details.) For each code array in
the class file, its starting byte, its total length, and the name of
the method in which it occurs are given. Combining this information
with the information yielded by the humble "javap" utility gives one
sufficient information to hack the code arrays in Java class files. */
import java.io.*;
class Inspector {
public static void main(String[] argv) {
int fpointer = 8; // Where are we in the class file?
int cp_entries = 1; // How big is the constant pool?
int Code_entry = 1; // Where is the entry that denotes "Code"?
int num_interfaces = 0; // How many interfaces does it use?
int num_fields = 0; // How many fields are there?
int num_f_attributes = 0; // How many attributes does a field have?
int num_methods = 0; // How many methods are there?
int num_m_attributes = 0; // How many attributes does a method have?
int[] tags; // Tags for the constant pool entries
int[] read_ints1; // References for some constant pool entries
int[] read_ints2; // References for some constant pool entries
long[] read_longs; // Values for some constant pool entries
float[] read_floats; // Values for some constant pool entries
double[] read_doubles; // Values for some constant pool entries
StringBuffer[] read_strings; // Strings in some constant pool entries
int[] method_index;
long[] code_start;
long[] code_length;
// How on earth do I use this thing?
if (argv.length != 1) {
System.out.println("Try \"java Inspector class_file.class\"");
System.exit(1);
// Start by opening the file for reading
try {
RandomAccessFile victim = new RandomAccessFile(argv[0], "r");
// Skip the magic number and versions and start looking at the class file
victim.seek(fpointer);
// Determine how many entries there are in the constant pool
cp_entries = victim.readUnsignedShort();
fpointer += 2;
// Set up the arrays of useful information about the constant pool entries
tags = new int[cp_entries];
read_ints1 = new int[cp_entries];
read_ints2 = new int[cp_entries];
read_longs = new long[cp_entries];
read_floats = new float[cp_entries];
read_doubles = new double[cp_entries];
read_strings = new StringBuffer[cp_entries];
//Initialize these arrays
for (int cnt = 0; cnt < cp_entries; cnt++) {
tags[cnt] = -1;
read_ints1[cnt] = -1;
read_ints2[cnt] = -1;
read_longs[cnt] = -1;
read_floats[cnt] = -1;
read_doubles[cnt] = -1;
read_strings[cnt] = new StringBuffer();
// Look at each entry in the constant pool and save the information in it
for (int i = 1; i < cp_entries; i++) {
tags[i] = victim.readUnsignedByte();
fpointer++;
int skipper = 0;
int start = 0;
int test_int = 0;
switch (tags) {
case 3: read_ints1[i] = victim.readInt();
fpointer += 4;
break;
case 4: read_floats[i] = victim.readFloat();
fpointer += 4;
break;
case 5: read_longs[i] = victim.readLong();
fpointer += 8;
i++;
break;
case 6: read_doubles[i] = victim.readDouble();
fpointer += 8;
i++;
break;
case 7:
case 8: read_ints1[i] = victim.readUnsignedShort();
fpointer += 2;
break;
case 9:
case 10:
case 11:
case 12: read_ints1[i] = victim.readUnsignedShort();
fpointer += 2;
victim.seek(fpointer);
read_ints2[i] = victim.readUnsignedShort();
fpointer += 2;
break;
// This is the critical case - determine an entry in the constant pool where
// the string "Code" is found so we can later identify the code attributes
// for the class's methods
case 1: skipper = victim.readUnsignedShort();
start = fpointer;
fpointer += 2;
victim.seek(fpointer);
for (int cnt = 0; cnt < skipper; cnt++) {
int next = victim.readUnsignedByte();
switch (next) {
case 9: read_strings[i].append("\\" + "t");
break;
case 10: read_strings[i].append("\\" + "n");
break;
case 11: read_strings[i].append("\\" + "v");
break;
case 13: read_strings[i].append("\\" + "r");
break;
default: read_strings[i].append((char)next);
break;
victim.seek(++fpointer);
victim.seek(start);
if (skipper == 4) {
fpointer = start + 2;
victim.seek(fpointer);
test_int = victim.readInt();
if (test_int == 1131373669) {Code_entry = i;}
fpointer = fpointer + skipper;
else {fpointer = start + skipper + 2;}
break;
victim.seek(fpointer);
// Skip ahead and see how many interfaces the class implements
fpointer += 6;
victim.seek(fpointer);
num_interfaces = victim.readUnsignedShort();
// Bypass the interface information
fpointer = fpointer + 2*(num_interfaces) + 2;
victim.seek(fpointer);
// Determine the number of fields
num_fields = victim.readUnsignedShort();
// Bypass the field information
fpointer += 2;
victim.seek(fpointer);
for (int j=0; j<num_fields; j++) {
fpointer += 6;
victim.seek(fpointer);
num_f_attributes = victim.readUnsignedShort();
fpointer = fpointer + 8*(num_f_attributes) + 2;
victim.seek(fpointer);
// Determine the number of methods
num_methods = victim.readUnsignedShort();
fpointer += 2;
// Set up the arrays of information about the class's methods
method_index = new int[num_methods];
code_start = new long[num_methods];
code_length = new long[num_methods];
//Initialize these arrays
for (int cnt = 0; cnt < num_methods; cnt++) {
method_index[cnt] = -1;
code_start[cnt] = -1;
code_length[cnt] = -1;
// For each method determine the index of its name and locate its code array
for (int k=0; k<num_methods; k++) {
fpointer += 2;
victim.seek(fpointer);
method_index[k] = victim.readUnsignedShort();
fpointer += 4;
victim.seek(fpointer);
// Determine the number of attributes for the method
num_m_attributes = victim.readUnsignedShort();
fpointer += 2;
// Test each attribute to see if it's code
for (int m=0; m<num_m_attributes; m++) {
int Code_test = victim.readUnsignedShort();
fpointer += 2;
// If it is, record the location and length of the code array
if (Code_test == Code_entry){
int att_length = victim.readInt();
int next_method = fpointer + att_length + 4;
fpointer += 8;
victim.seek(fpointer);
code_length[k] = victim.readInt();
code_start[k] = fpointer + 5;
fpointer = next_method;
victim.seek(fpointer);
// Otherwise just skip it and go on to the next method
else {
fpointer = fpointer + victim.readInt() + 4;
victim.seek(fpointer);
// Print the information about the Constant Pool
System.out.println("There are " + (cp_entries - 1) + " + 1 entries in the Constant Pool:\n");
System.out.println("Index\t" + "Tag\t" + "Reference(s)/Value(s)\t");
System.out.println("-----\t" + "---\t" + "---------------------\t");
for (int i = 0; i < cp_entries; i++) {
switch (tags[i]) {
case 1: System.out.println(i + "\t" + tags[i] + "\t" + read_strings[i].toString());
break;
case 3: System.out.println(i + "\t" + tags[i] + "\t" + read_ints1[i]);
break;
case 4: System.out.println(i + "\t" + tags[i] + "\t" + read_floats[i]);
break;
case 5: System.out.println(i + "\t" + tags[i] + "\t" + read_longs[i]);
break;
case 6: System.out.println(i + "\t" + tags[i] + "\t" + read_doubles[i]);
break;
case 7:
case 8: System.out.println(i + "\t" + tags[i] + "\t" + read_ints1[i]);
break;
case 9:
case 10:
case 11:
case 12: System.out.println(i + "\t" + tags[i] + "\t" + read_ints1[i] + " " + read_ints2[i]);
break;
System.out.println();
// Print the information about the methods
System.out.println("There are " + num_methods + " methods:\n");
for (int j = 0; j < num_methods; j++) {
System.out.println("Code array in method " + read_strings[method_index[j]].toString() + " of length " + code_length[j] + " starting at byte " + code_start[j] + ".");
System.out.println();
// All the changes are made, so close the file and move along
victim.close();
} catch (IOException ioe) {} -
Getting file from directory where class files are
hi i want to load a properties file from the directory where my java program is (the class/jar files)
somebody told me that i could use System.getProperty("user.dir"); but it would only work under windows; under linux it points elsewhere.
how can i determine the directory where my program lies? sounds easy but i failed :(why to hell put it in the classpath? Because that way you don't have to ask the user where the hell he put the file.
and if i would do so the next question: how can my
program modify the classpath?It can't. And it doesn't need to.
isn't there another way to determine the directory
where the app is started from???If you mean the current, or working, directory, then yes there are several ways to determine that. But that directory need not be where the classes are actually stored. In fact the current directory doesn't even have to be in the classpath.
Now, here's the best way to deal with properties files. (IMHO of course.) Put them in the classpath, in the same directory or jar file as your classes. Then to create a Properties object and load it from your properties file named e.g. "default.properties" you do this:Properties props = new Properties();
props.load(this.getClass().getResourceAsStream("/default.properties")); -
How to dispatch events from custom AS3 classes to MXML
Hello,
I introduce some custom classes inside my SCRIPT tag in MXML.
These classes should dispatch custom Events (or any events for that
matter) and the listeners should be defined inside the SCRIPT tag.
In the custom class I have:
quote:
dispatchEvent(new Event("customEvent"));
And inside the script tag:
quote:
addEventListener("customEvent", testListener);
quote:
public function testListener(evt:Event):void{
Alert("Event fired successfully.");
However, this event is not handled in the listener (the alert
is not shown). What could be wrong?<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void
addEventListener("customEvent", testListener);
dispatchEvent(new Event("customEvent"));
private function testListener(evt:Event):void{
Alert.show("Event fired successfully.");
Do like this
Alert is the Class Object. This is not the Function. -
How to make an exe file from a java class file
i know one of the java's most powerfull properties is plataform independent, but if i have done one application (with GUI) that i want to run on Win32 for example, if anyone knows how to make it please send me a message to [email protected], how i know that can be make it? because HotJava is made in Java and in Win32 is a executable
Do a search on these forums for any of the thousands of times this question has been asked and any of the thousands of times it's been answered.
-
AS3.0: Can't add child and access subchildren timelines?
I have the following code:
var myParent:Parent = new Parent();
var mySymbol_01:Symbol01 = new Symbol01();
var mySymbol_02:Symbol02 = new Symbol02();
myParent.x=100;
myParent.y=100;
addChild(myParent);
myParent.gotoAndStop(1);
button.addEventListener(MouseEvent.CLICK, buttonPressed);
function buttonPressed(e:Event):void{
removeChild(myParent);
playCopy();
function playCopy():void{
addChild(myParent);
myParent.gotoAndPlay(2);
myParent.x=100;
myParent.y=100;
//myParent.rects.width=200;
//myParent.circ.width=300;
If I take
//myParent.rects.width=200;
//myParent.circ.width=300;
and remove the comments, the file breaks and no Movie Clips appear on the stage. Does this have to do with casting the Children as Movie Clips, which I may not have done here?No error codes Ned, it just adds the Child at the last frame in the timeline which happens to be frame 60 (I have a
n animation in the y direction just for kicks to see if I can get the animation to play and have the object move down
ward vertically but it just "pops" into place without any animation.
And no, it's not a sound animation. -
How to read the java class file to convert it in java.
hello all,
i m developing the java application which generated the java code from the java 'class file' .
Can anybody please help me, Is any java support for reading the class file? or how to know the class file format?
I know the application javad, jad, javap which is doing the same thing.
thanks for reply,
- Jayddo you mean decompiling? there are tons of java decompilers available out there, what exactly are you trying to do here?
-
How to create empty text file on target system for empty source text file
Hi All,
I have an issue in handling empty file in the Text (FCC) to Text (FCC) file scenario. Interface picks text file and delivers on target system as text file. I have used FCC in both sender and receiver CCs.
Interface is working fine if the source file is not empty. If the source text file is empty (zero Bytes), interface has to delivery an empty text file on target system. I have setup empty file handling options correctly on both CCs.
But when I tried with an empty file I am getting the error message 'Parsing an empty source. Root element expected!'.
Could you please suggest me what I need to do to create an empty text file on target system from empty source text file?
Thanks in Advance....
Regards
Sreeni>
Sreenivasulu Reddy jonnavarapu wrote:
> Hi All,
>
> I have an issue in handling empty file in the Text (FCC) to Text (FCC) file scenario. Interface picks text file and delivers on target system as text file. I have used FCC in both sender and receiver CCs.
> Interface is working fine if the source file is not empty. If the source text file is empty (zero Bytes), interface has to delivery an empty text file on target system. I have setup empty file handling options correctly on both CCs.
>
> But when I tried with an empty file I am getting the error message 'Parsing an empty source. Root element expected!'.
>
> Could you please suggest me what I need to do to create an empty text file on target system from empty source text file?
>
> Thanks in Advance....
>
> Regards
> Sreeni
the problem is that when there is an empty file there is no XML for parsing available. Hence in case you are using a mapping it will fail.
What ideally you should do is to have a module that will check if the file is empty and if so write out an XML as you want with no values in the content/fields.
Or the next choice would be to have a java mapping to handle this requirement. I guess that on an empty file the java mapping will go to an exception which you can handle to write out your logic/processing -
How to run several class files at the same time
I have four class files, there's: cvnt1.class,cvnt2.class,cvnt3.class and cvnt4.class.
I want to know how to write application for running all of those files together. thanks!Your question is still unclear - do you want to access code from those class files (just add all of them to classpath) or do you want to create number of threads or number of processes (one per class) and start code from each class simultaneously or something else?
-
Tomcat can't detect the class file of the JApplet.
Hi,
I am relatively new in the applet field. I am trying to invoke an JApplet through JSP.
Problem is that i have to package the JApplet class files as it has to access other packages. also the JSP with the embedded JApplet exists in a different folder from the JApplet class files.
I am getting the class not found exception.
Context Path: http://localhost:8080/sncdatagate
folder structure as follows.
sncdatagate\jsp\myApplet.jsp
sncdatagate\WEB-INF\classes\datagate\ui\myApplet.class
package for myApplet.java : datagate.ui
The JSP code is as follows :-
<jsp:plugin
type="applet"
code="datagate.ui.myApplet"
codebase="/sncdatagate/"
width ="700"
height="400"
iepluginurl="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_01a-win.cab#version=1,3,1,1"
nspluginurl="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_01a-win.cab#version=1,3,1,1"
jreversion="1.3.1_01">
<jsp:params>
<jsp:param name = "encodedString" value="<%=encodedString%>"/>
</jsp:params>
</jsp:plugin>
The error on Java console is as follows:-
load: class datagate.ui.myApplet not found.
java.lang.ClassNotFoundException: java.io.FileNotFoundException: File not found: http://localhost:8080/sncdatagate/datagate/ui/myApplet.class
at sun.plugin.protocol.jdk12.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Kind help!
Would greatly appreciate any suggestions.
Thank You.
regards,
PriyaThe WEB-INF\classes\ folder is meant for servlets and the files insides are accessed thru the "servlet/" folder. To run applets, place them outside of the web-inf folder together with your jsp files.
If your applet has a package, remember to create appropriate folders for it. Eg.
sncdatagate\jsp\myApplet.jsp
sncdatagate\datagate\ui\myApplet.class
<applet
code="datagate.ui.myApplet"
codebase="/sncdatagate/" ... -
Where to place an xml file that is read by java class file dir structure
Hello all,
I have an xml file that I am using in lieu of a database to track conference rooms . This is a small file. I need to read this file from my java class file which is used by a jsp. Currently I have an absolute path C://logger/conference.xml. All works fine but I need to deploy to a different machine soon and so I need to place this file somewhere in the project directory structure (created by netbeans) so that it will be included in the war file and can be read by the java class file.
Also what would be the relative path to this suggested directory.
TIA!!!public class DOMconference {
/** Creates a new instance of DOMconference */
public DOMconference() { }
//private final static String XML_FILE_NAME = "/opt/conference.xml";//set the output file and location
public String XML_FILE_NAME = "";
private final static String FIRST_CONF_ID = "8200";//set the initial conference number
static Document document;
public void getFilePath(String path)
XML_FILE_NAME = path.replaceAll("\\\\","/");
System.out.println("XML==============="+XML_FILE_NAME);
File file = new File(XML_FILE_NAME);
*generic method that returns a Document object
public Document getDocument() throws SAXException, ParserConfigurationException,
IOException
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
factory.setCoalescing(true);
factory.setNamespaceAware(false);
factory.setValidating(false);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(file); //HERE IS WHERE THE ERROR POINT S TO
return document;
}Here is the complete error:
INFO: Server startup in 1282 ms
XML===============C:/Documents and Settings/gforte/agi/build/web/WEB-INF/conference.xml
[Fatal Error] bin:1:1: Content is not allowed in prolog.
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
at agi.DOMconference.getDocument(DOMconference.java:91)
at agi.DOMconference.getLdapConferences(DOMconference.java:466)
at agi.Ldap.getConferences(Ldap.java:243)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:111)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
[Fatal Error] bin:1:1: Content is not allowed in prolog.
NotifyUtil::java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:606)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:554)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:571)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:936)
at org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:248)
So if I change my code to this (note that all I change is how the constant XML_FILE_NAME is set and I copy and paste the path that is derived from getFilePath after the String.replaceAll call.):
public class DOMconference {
/** Creates a new instance of DOMconference */
public DOMconference() { }
private final static String XML_FILE_NAME = "C:/Documents and Settings/gforte/agi/build/web/WEB-INF/conference.xml";//set the output file and location
//public String XML_FILE_NAME = "";
private final static String FIRST_CONF_ID = "8200";//set the initial conference number
static Document document;
public void getFilePath(String path)
//XML_FILE_NAME = path;//.replaceAll("\\\\","/");
System.out.println("XML==============="+XML_FILE_NAME);
File file = new File(XML_FILE_NAME);
*generic method that returns a Document object
public Document getDocument() throws SAXException, ParserConfigurationException,
IOException
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringComments(true);
factory.setCoalescing(true);
factory.setNamespaceAware(false);
factory.setValidating(false);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(file);
return document;
}All is fine..
Just in case, here is my xml file contents copy and paste from notepad.
<?xml version="1.0"?><conf_rooms><conf_room><conf_id>8200</conf_id><conf_name>Conference room 1</conf_name></conf_room><conf_room><conf_id>8201</conf_id><conf_name>Conference Room 2</conf_name></conf_room><conf_room><conf_id>8202</conf_id><conf_name>dufus</conf_name></conf_room></conf_rooms>Thanks for hanging in there with me on this.
Graham -
TypeError: Error #1006 - Removing MovieClip from the stage
I have a movie clip that is called to the stage and once the movieclip is finished it calls a function that removes it from the stage. The code works but I get an error message about 4 seconds after the movie clip ends.
Here’s the error message:
TypeError: Error #1006: exitWordMicroscopic is not a function.
at ASvocabulary_microscopic/frame110()[ASvocabulary_microscopic::frame110:1]
Here’s the stage code:
//************************Removes the movieclip from the stage and enables the button.*************************
function exitWordMicroscopic():void
bnt_vocab_microscopic.mouseEnabled = true;
removeChild(word_Microscopic);
//******************************Stage buttons**************************************
stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
function goButtonsHomeRead_1(event:MouseEvent):void
//Vocabulary buttons
if (event.target == bnt_vocab_microscopic)
bnt_vocab_microscopic.mouseEnabled = false;
SoundMixer.stopAll();
addChild(word_Microscopic);
word_Microscopic.x = 47;
word_Microscopic.y = 120;
Here’s the code inside the movie clip. This is what the error message is referring to:
//****************** Calls function to remove itself from the stage****************************
Object(parent).exitWordMicroscopic();
What am I doing wrong?Here' how the code looks now:
Objective: To remove the current movieclip while it's playing so that it does not show on the next (or previous) frame.
Here’s the stage code:
var word_Microscopic:ASvocabulary_microscopic = new ASvocabulary_microscopic();
//Removes the movieclip from the stage and enables the button.
function exitWordMicroscopic():void
bnt_vocab_microscopic.mouseEnabled = true;
removeChild(word_Microscopic);
//******************************Stage buttons**************************************
stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
function goButtonsHomeRead_1(event:MouseEvent):void
//Vocabulary buttons
if (event.target == bnt_vocab_microscopic)
SoundMixer.stopAll();
bnt_vocab_microscopic.mouseEnabled = false;
addChild(word_Microscopic);
word_Microscopic.x = 47;
word_Microscopic.y = 120;
word_Microscopic.play();
//This button takes the user to the Main Screen
if (event.target == bnt_ReadGoHome_1)
// exitWordMicroscopic(); [If I use this function I get this error ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.]
SoundMixer.stopAll();
gotoAndPlay("1","Main");
stage.removeEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
//This takes the user to the next frame.
if (event.target == GoNext_1)
SoundMixer.stopAll();
gotoAndPlay("2");
stage.removeEventListener(MouseEvent.MOUSE_DOWN, goButtonsHomeRead_1);
Here’s the code inside the movie clip.
//****************** Calls function to remove itself from the stage****************************
Object(parent).exitWordMicroscopic(); -
I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
This is the error message(s) I am receiving: "TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at index_fla::MainTimeline/Down3()"
import nl.demonsters.debugger.MonsterDebugger;
var d:MonsterDebugger=new MonsterDebugger(this);
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.align=StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
// loader is the loader for portfolio page swf
var loader:Loader;
var loader2:Loader;
var loader3:Loader;
var loader1:Loader;
// resize content
function resizeHandler(event:Event):void {
// resizes portfolio page to center
loader.x = (stage.stageWidth - loader.width) * .5;
loader.y = (stage.stageHeight - loader.height) * .5;
// resizes about page to center
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
/*loader2.x = (stage.stageWidth - 658.65) * .5;
loader2.y = (stage.stageHeight - 551.45) * .5;*/
addEventListener(Event.ENTER_FRAME, onEnterFrame,false, 0, true);
function onEnterFrame(ev:Event):void {
var requesterb:URLRequest=new URLRequest("carouselLoader.swf");
loader = null;
loader = new Loader();
loader.name ="carousel1"
//adds gallery.swf to stage at begining of movie
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader.load(requesterb);
} catch (error:SecurityError) {
trace(error);
addChild(loader);
loader.x = (stage.stageWidth - 739) * .5;
loader.y = (stage.stageHeight - 500) * .5;
// stop gallery.swf from duplication over and over again on enter frame
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
//PORTFOLIO BUTTON
//adds eventlistner so that gallery.swf can be loaded
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
function Down(event:MouseEvent):void {
// re adds listener for contact.swf and about.swf
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
//unloads gallery.swf from enter frame if users presses portfolio button in nav
var requester:URLRequest=new URLRequest("carouselLoader.swf");
loader = null;
loader = new Loader();
loader.name ="carousel"
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader);
loader.x = (stage.stageWidth - 739) * .5;
loader.y = (stage.stageHeight - 500) * .5;
removeChild( getChildByName("about") );
removeChild( getChildByName("carousel1") );
// remove eventlistner and prevents duplication of gallery.swf
MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
//INFORMATION BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
function Down1(event:MouseEvent):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
var requester:URLRequest=new URLRequest("contactLoader.swf");
loader2 = null;
loader2 = new Loader();
loader2.name ="contact"
loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader2.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader2);
loader2.x = (stage.stageWidth - 658.65) * .5;
loader2.y = (stage.stageHeight - 551.45) * .5;
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
//ABOUT BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
function Down3(event:MouseEvent):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
var requester:URLRequest=new URLRequest("aboutLoader.swf");
loader3 = null;
loader3 = new Loader();
loader3.name ="about"
loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader3.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader3);
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
removeChild( getChildByName("carousel") );
removeChild( getChildByName("carousel1") );
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
stop();Andrei1,
Thank you for the helpful advice. I made the changes as you suggested but I am receiving a #1009 error message even though my site is working the way I wan it to work. I would still like to fix the errors so that my site runs and error free. This is the error I am receiving:
"TypeError: Error #1009: Cannot access a property or method of a null object reference."
I'm sure this is not the best method to unload loaders and I am guessing this is why I am receiving the following error message.
loader.unload();
loader2.unload();
loader3.unload();
I also tried creating a function to unload the loader but received the same error message and my portfolio swf was not showing at all.
function killLoad():void{
try { loader.close(); loader2.close; loader3.close;} catch (e:*) {}
loader.unload(); loader2.unload(); loader3.unload();
I have a question regarding suggestion you made to set Mouse Event to "null". What does this do setting the MouseEvent do exactly? Also, since I've set the MouseEvent to null do I also have to set the loader to null? e.g.
---- Here is my updated code ----
// variable for external loaders
var loader:Loader;
var loader1:Loader;
var loader2:Loader;
var loader3:Loader;
// makes borders resize with browser size
function resizeHandler(event:Event):void {
// resizes portfolio page to center
loader.x = (stage.stageWidth - loader.width) * .5;
loader.y = (stage.stageHeight - loader.height) * .5;
// resizes about page to center
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
//adds gallery.swf to stage at begining of moviie
Down();
//PORTFOLIO BUTTON
//adds eventlistner so that gallery.swf can be loaded
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
function Down(event:MouseEvent = null):void {
// re adds listener for contact.swf and about.swf
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
//unloads gallery.swf from enter frame if users presses portfolio button in nav
var requester:URLRequest=new URLRequest("carouselLoader.swf");
loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader.load(requester);
} catch (error:SecurityError) {
trace(error);
this.addChild(loader);
loader.x = (stage.stageWidth - 739) * .5;
loader.y = (stage.stageHeight - 500) * .5;
// sure this is not the best way to do this - but it is unload external swfs
loader.unload();
loader2.unload();
loader3.unload();
// remove eventlistner and prevents duplication of gallery.swf
MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
//INFORMATION BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
function Down1(event:MouseEvent = null):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
var requester:URLRequest=new URLRequest("contactLoader.swf");
loader2 = null;
loader2 = new Loader();
loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader2.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader2);
loader2.x = (stage.stageWidth - 658.65) * .5;
loader2.y = (stage.stageHeight - 551.45) * .5;
loader.unload();
loader2.unload();
loader3.unload();
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
//ABOUT BUTTON
//adds eventlistner so that info.swf can be loaded
MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
function Down3(event:MouseEvent = null):void {
//this re-adds the EventListener for portfolio so that end user can view again if they wish.
MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
var requester:URLRequest=new URLRequest("aboutLoader.swf");
loader3 = null;
loader3 = new Loader();
loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:IOErrorEvent):void {
trace(event);
try {
loader3.load(requester);
} catch (error:SecurityError) {
trace(error);
addChild(loader3);
loader3.x = (stage.stageWidth - 482) * .5 - 260;
loader3.y = (stage.stageHeight - 492) * .5 - 140;
loader.unload();
loader2.unload();
loader3.unload();
// remove eventlistner and prevents duplication of info.swf
MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
stop(); -
Call function in main timeline from class file
Hi all, How can a function in main timeline be called from class file?
Hi all, How can a function in main timeline be called from class file?
You can, but you really shouldn't.
Classes shouldn't "talk" to the outside directly.
Use Event dispatching to get things done.
"root" (i just threw up by just typing that word) should be avoided at all cost, especially in AS3.
Maybe you are looking for
-
How do I access my Photo Stream to delete pictures?
How do I access my Photo Stream to delete pictures?
-
Hi everybody, In a stored procedure, I a trying to use the cursor in a string. My purpose in adding the where clause. For example: CREATE OR REPLACE PROCEDURE AirportAppendixReport(whereClause varchar2) IS cursor cFac IS select tblArpt.fkObjectI
-
What happens when I hit update on the carrier setting pop up but it doesn't do anything?
I Have an iphone 4 the speaker for FaceTime no longer works and i need to do a carrier update but it won't work someone help!!
-
IPhone App Update - big Problems installing ITunes again
Hello! Yesterday I tried to Update to 4.02. ITunes loaded the big Update file with my small bandwidth within 1 hour. After that ITunes told me that the firmware-file was damaged. So I tried it again 3 times. The same. I uninstalled ITunes, Quicktime,
-
2 usb drives and an AEBS...
It just keeps getting worse, if its not one thing, its another! I have 2 usb external drives hooked up to the AEBS with a usb hub, worked fine since Monday (other than being slow as molasses) both drives always showed up under SHARED in Finder. Now t