Accessing display object on the stage from another class
I've googled this to no avail, I've only found how to manipulate the stage itself and not a display object on it, and I'm noob enough to not be able to figure it out from there. :/
I have a movie clip on the main timeline with instance name displayName. I created a button that should change what frame displayName goes to (in order to...did you guess it?! diplay the Name of the button. Awesome. )
So I am trying to write the code in a reusable fashion and have the buttons all linked to a class called GeoPuzzle. Inside GeoPuzzle I instantiate a touch event and run the code. However, the function has to be able to change displayName in the main part of the timeline and, of course, the compiler says displayName doesn't exist because I'm in a class and I'm talking about the stage.
Here is the simplified code in the class:
package com.freerangeeggheads.puzzleography {
import flash.display.MovieClip;
import flash.events.TouchEvent;
public class GeoPuzzle extends MovieClip {
//declare variables
public function setInitial (abbrev:String, fullName:String, isLocked:Boolean):void {
//set parameters
this.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
public function GeoPuzzle (): void {
public function geoTouchBeginHandler (e:TouchEvent): void {
e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
//some other methods
nameDisplay.gotoAndStop(e.target.abbrev);
public function geoTouchEndHandler (e:TouchEvent): void {
//some other methods
nameDisplay.gotoAndStop("USA");
The lines in bold are my problem. Now this code doesn't actually execute as is so if you see an error in it, yeah, I have no idea what the problem is, but it DID execute before and these lines still gave me trouble so I'm trying to troubleshoot on multiple fronts.
How can I tell displayName to change it's current frame from within display object class?
Thanks!
if displayName is a GeoPuzzle instance, use:
package com.freerangeeggheads.puzzleography {
import flash.display.MovieClip;
import flash.events.TouchEvent;
public class GeoPuzzle extends MovieClip {
//declare variables
public function setInitial (abbrev:String, fullName:String, isLocked:Boolean):void {
//set parameters
this.addEventListener(TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
public function GeoPuzzle (): void {
public function geoTouchBeginHandler (e:TouchEvent): void {
e.target.addEventListener(TouchEvent.TOUCH_END, geoTouchEndHandler);
//some other methods
this.gotoAndStop(this.abbrev);
public function geoTouchEndHandler (e:TouchEvent): void {
//some other methods
this.gotoAndStop("USA");
Similar Messages
-
Accessing display objects via the stage var
I'm passing a stage reference to my class, but when I try to
access a movieclip on the stage I get an error.
this gives me an error:
var mc = targetStage.myMovieClip;
Thanks!var myClass = new MyClass (this.stage);
That would be the same thing, this.stage would refer to the
Stage instance. Each .swf has one Stage instance. In a Flash
project, the stage has one child, the MainTimeline instance.
MainTimeline is basically a big MovieClip, and it contains all your
objects, scenes and timelines you create in Flash.
So, if you instantiate from the main timeline itself (either
on a frame script or Document class) you are already inside
MainTimeline, which is what you want to pass along a reference to,
so you would pass in "this" as Colin said, or "root".
Colin mentioned that MovieClip(root) would work anyway; if I
understand he is referring to the fact that every DisplayObject
(such as MovieClips and SimpleButtons created in Flash) already
have a "root" property that usually refers to the MainTimeline
instance. However, your class "MyClass" does not extend
DisplayObject so there is no root property available, which is why
you need to manually pass in a reference to the root
timeline. -
.How to instantiate the innerclass from another class with coded eg.
How to instantiate the innerclass from another class(both for static & non static) please give me an eg with coding.
It's just a preference, but I like writing factory methods:
public class Outer {
public class Inner {}
public static class StaticInner {}
public Inner innerInstance() {
return new Inner();
public static StaticInner staticInnerInstance() {
return new StaticInner();
public static void main(String[] args) {
Outer.StaticInner si = Outer.staticInnerInstance();
Outer outer = new Outer();
Outer.Inner i = outer.innerInstance();
}Often, for me, the inner class implements an interface, and the factory method
lets you hide the implementation class:
public class Outer {
private class Inner implements Runnable {
public void run() {}
public Runnable runnerInstance() {
return new Inner();
public static void main(String[] args) {
Outer outer = new Outer();
Runnable r = outer.runnerInstance();
} -
ABAP Objects : calling one method from another class
Hi,
Can you please tell me how to call method from one class or interfce to another class.The scenario is
I have one class CL_WORKFLOW_TASK, this class have interface IF_WORKFLOW_TASK & this interface have method IF_WORKFLOW_TASK~CLOSE. Now my requirement is ,
There is another class CL_WORKFLOW_CHAIN ,this class have interface IF_WORKFLOW_CHAIN & this interface have method IF_WORKFLOW_CHAINCLOSE_ALL_PREDECESSORS. Now i have to write my code in this method but i have to use IF_WORKFLOW_TASKCLOSE method for closing the task.
Can you please give me the code for the above .
Please waiting for reply.Hi,
You can use the concept of INHERITANCE in this scenario.By using this concept, you can call all the public and protected methods of class CL_WORKFLOW_TASK in the required calss CL_WORKFLOW_CHAIN as per your requirement.
Go through the Introdctory(INHERITANCE) programming from this SAPHELP link.
http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
I hope, it will help in you inresolving your problem.
by
Prasad GVK. -
How to display values in textfields obtained from another class
Hi,
Why, oh why, doesn't this work:
When I select a row in my tableClass (consist of a JTable) I want to display these values (strings) in my TextFieldGUI class (consist of just JTextFields). My code looks like this:
TableClass:
public void mouseClicked(java.awt.event.MouseEvent mouseEvent) {
textFieldGUI = new TextFieldGUI() ;//reference to my textfield class
gui = new mainGUI() ; //reference to my GUI class
int tabbedIndex = gui.getSelectedIndex() ;
int col = tableModel.getColumnCount() ;
Vector string = new Vector() ;
String empty = "" ;
for(int index = 0; index < col ; index++){
if(table.getValueAt(row, index) == null)
string.addElement(empty) ;
else
string.addElement(table.getValueAt(row, index).toString()) ;
if(tabbedIndex == 0){
System.out.println(string) ; //works fine
textFieldGUI.setTextFieldValues(string) ;
}TextField class:
public void setTextFieldValues(Vector s){
Vector string = new Vector() ;
string = s ;
System.out.println("TextFieldVector: " + string) ; //works fine as well
String name = "" ;
String dob = "" ;
String web = "" ;
name = string.elementAt(0).toString() ;
dob = string.elementAt(1).toString() ;
web = string.elementAt(2).toString() ;
System.out.println("NAME: " + name +
", BIRTH: " + dob +
", WEB: " + web) ; //values are correctly printed
txtName.setText(name) ; //writes nothing (empty)
txtDob.setText(dob) ; //writes nothing (empty)
txtWeb.setText(web) ; //writes nothing (empty)
}Anyone got a hint on how I should svolve this one?
thanks
gmtongarHi
my problem is, for each job_id there is many users. Oh that's something completlty different...
I Strongly Recommand to_
1.*create 2 tables Jobs & users*
2.*create a relation between them* 1 to many to get for each job more than a user that's the way that Must be -- execuse me the bad design of the db pulled u into this trap -
3.then u can deal with it normally no need to a sample code but just a form with Jobs as (Master) and Users as (detail) with a relation and with a simple query u can display each job_id is for many users.
no null values no commas r needed.
Hope this helps...
Regards,
Amatu Allah. -
How do I refer to the stage from a class?
I have a class that places objects on stage with addChild(obj) it allowes me to position objects using pixels( say obj.x = 10; obj.y= 50; ) just fine but if
I try this: obj.x = stage.stageWidth / 2; I get a message that I Cannot access a property or method of a null object referenceThe stage property is only available to objects that are currently on the display list. Your best bet is probably to pass a stage reference to the class when you instantiate it.
-
XML reader and get the value from another class
Hello to all, I have stupid question.
I have main.java and ConfigXML.java(read my config xml file).
Code from ConfigXML.java
NodeList flnamelist = flcon.getElementsByTagName("filename");
Element flnameEL= (Element)flnamelist.item(0);
NodeList flnameTEXT = flnameEL.getChildNodes();
String alsl = ((Node)flnameTEXT.item(0)).getNodeValue().trim();How I can get String alsl = ((Node)flnameTEXT.item(0)).getNodeValue().trim(); from my ConfigXML.java to main.java.
Sorry for my bad englishpublic class ConfigXML {
private String alsl;
// constructor goes here if necessary
public void parse() {
// something
NodeList flnamelist = flcon.getElementsByTagName("filename");
Element flnameEL= (Element)flnamelist.item(0);
NodeList flnameTEXT = flnameEL.getChildNodes();
alsl = ((Node)flnameTEXT.item(0)).getNodeValue().trim();
// Notice that we assigned the data to an instance variable
public String getAlsl() {
return alsl;
public class Main {
// That's a really terrible name but at least let's capitalize it so it's standard
public static void main(String[] args) {
ConfigXML config = new ConfigXML();
config.parse();
String answer = config.getAlsl();
} -
Adding objects to the stage & acceessing stage properties - I'm a bit confused..
Hi,
I'm a little confused on two fronts regarding display
programming:
A. What the best way to add objects to the stage?
B. How to access stage properties.
I can do both of these when the project is an 'Action Script
Project', but I'm having trouble when it is a 'Flex Project' (e.g.
an MXML file). See the two attached files with questions included
in the comment to see exactly what I mean.
A. What the best way to add objects to the stage?
=====================================
In an action script project that extends Sprite I can just
call addChild()
In an MXML project I can add objects to the stage by first
adding them to a UIComponent, then adding that to the stage.
1. Is that the best way to do it?
In this doc:
http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html
it says that
quote:
Each SWF file has an associated ActionScript class, known as
the main class of the SWF file. When Flash Player opens a SWF file
in an HTML page, Flash Player calls the constructor function for
that class and the instance that is created (which is always a type
of display object) is added as a child of the Stage object. The
main class of a SWF file always extends the Sprite class
2. why cant I just add a sprite object direct to the stage
without the UIComponent?
3. What is the 'main class', and how can i get access to it?
B. How to access stage properties.
=========================
In an action script project that extends Sprite I can just
call trace(stage.framerate)
But in an MXML file I cannot figure out how to access the
stage properties.
See the attached code for the things that I tried, but which
didnt work.
In the page:
http://www.actionscript.org/forums/showthread.php3?t=140655
It says
quote:
For stage access you have a couple of rules:
* natively, only display objects have inherent access to
stage
* display objects only have a valid reference to stage if
they're within the stage's display list (on the screen, after added
to it with addChild)
* The only display objects which immediately have access to
the stage before the use of addChild (in their constructor) are the
document/application class instance (root) and any instance from
the library placed on the timeline (not created with AS).
* Non-display object classes have to be passed or assigned a
reference to the stage from another object which already has access
to it - they cannot access it otherwise.
4. How do I access the stage properties in the MXML project?
5. I suspect this is related to the "main class", which I
dont yet understand - is it?
Sorry for the long post.
cheers
tom"tom saffell" <[email protected]> wrote in
message
news:gd7cm9$d1v$[email protected]..
> Thanks Luigi - that helps a lot.
> I hadnt seen the Flex 3 Developer Guide before - it's
very useful.
>
> I now see that I can access properties of the
application object directly
> with
> this.<property>.
> However, the framerate property cannot be set by
actionscript, only in
> MXML (I
> can set it in the <mx:application> tag). But I
need to be able to set it
> programatically, dependent on user input.
>
> 5. Is there a way around this?
> 6. Can I set the stage's framerate to achieve the same
outcome?
>
> I still dont understand why I cannot access the stage
object. When I call
> either
this.stage or
uic.stage * then I get
quote:
Cannot access
> a
> property or method of a null object reference.
My understanding is
> that I
> can access the stage object via any display object on
the display list.
> I'm
> confused about this bit..
>
> * - uic is a UIComponent that has been added to the
display list (i think)
> by
> calling addChild(uic) from the AS3 within the
application
>
> 7. How do I access stage properties in AS3 in an MXML
project?
http://www.adobe.com/livedocs/flex/3/html/help.html?content=05_Display_Programming_10.html
It seems like possibly your real problem is that you're
having trouble
searching the Help effectively:
http://flexdiary.blogspot.com/2008/07/getting-help-in-flex-builder.html -
Accessing an Array List from another class
Hi, I was a member on here before, but I forgot my password and my security question is wrong.
My question is how do I access a private arraylist from a different class in the same package?
What I am trying to do is the following (hard to explain).
Make a picking client for a shop, so that when an order is recieved, the picker can click on the orders button, and view all of the current orders that have not been completed. This Pick client has its own user interface, in a seperate class from where the BoughtList array is created, in the cashier client. The boughtlist is created when the cashier puts in the product number into the cashier client and clicks buy. I seem to be having trouble accessing the list from another class. Once the order is completed the cashier clicks bought and the list is reset. There is another class in a different pagage that processes some of the functions of the order, eg newOrder().
Yes it is for Uni so I dont need / want the full answers, jist something to get started. Also please dont flame me, I have done many other parts of this project, just having trouble getting started on this one.
Here is the code for the cashier client. The code for the Pick client is almost the same, I just need to make the code that displays the orders.
package Clients;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.NumberFormat;
import java.util.Locale;
import Catalogue.*;
import DBAccess.*;
import Processing.*;
import Middle.*;
class CashierGUI
class STATE // Cashier states
public static final int PROCESS = 0;
public static final int CHECKED = 1;
class NAME // Names of buttons
public static final String CHECK = "Check";
public static final String BUY = "Buy";
public static final String CANCEL = "Cancel";
public static final String BOUGHT = "Bought";
private static final int H = 300; // Height of window pixels
private static final int W = 400; // Width of window pixels
private JLabel theAction = new JLabel();
private JTextField theInput = new JTextField();
private JTextArea theOutput = new JTextArea();
private JScrollPane theSP = new JScrollPane();
private JButton theBtCheck = new JButton( NAME.CHECK );
private JButton theBtBuy = new JButton( NAME.BUY );
private JButton theBtCancel= new JButton( NAME.CANCEL );
private JButton theBtBought= new JButton( NAME.BOUGHT );
private int theState = STATE.PROCESS; // Current state
private Product theProduct = null; // Current product
private BoughtList theBought = null; // Bought items
private Transaction theCB = new Transaction();
private StockReadWriter theStock = null;
private OrderProcessing theOrder = null;
private NumberFormat theMoney =
NumberFormat.getCurrencyInstance( Locale.UK );
public CashierGUI( RootPaneContainer rpc, MiddleFactory mf )
try //
theStock = mf.getNewStockReadWriter(); // DataBase access
theOrder = mf.getNewOrderProcessing(); // Process order
} catch ( Exception e )
System.out.println("Exception: " + e.getMessage() );
Container cp = rpc.getContentPane(); // Content Pane
Container rootWindow = (Container) rpc; // Root Window
cp.setLayout(null); // No layout manager
rootWindow.setSize( W, H ); // Size of Window
Font f = new Font("Monospaced",Font.PLAIN,12); // Font f is
theBtCheck.setBounds( 16, 25+60*0, 80, 40 ); // Check Button
theBtCheck.addActionListener( theCB ); // Listener
cp.add( theBtCheck ); // Add to canvas
theBtBuy.setBounds( 16, 25+60*1, 80, 40 ); // Buy button
theBtBuy.addActionListener( theCB ); // Listener
cp.add( theBtBuy ); // Add to canvas
theBtCancel.setBounds( 16, 25+60*2, 80, 40 ); // Cancel Button
theBtCancel.addActionListener( theCB ); // Listener
cp.add( theBtCancel ); // Add to canvas
theBtBought.setBounds( 16, 25+60*3, 80, 40 ); // Clear Button
theBtBought.addActionListener( theCB ); // Listener
cp.add( theBtBought ); // Add to canvas
theAction.setBounds( 110, 25 , 270, 20 ); // Message area
theAction.setText( "" ); // Blank
cp.add( theAction ); // Add to canvas
theInput.setBounds( 110, 50, 270, 40 ); // Input Area
theInput.setText(""); // Blank
cp.add( theInput ); // Add to canvas
theSP.setBounds( 110, 100, 270, 160 ); // Scrolling pane
theOutput.setText( "" ); // Blank
theOutput.setFont( f ); // Uses font
cp.add( theSP ); // Add to canvas
theSP.getViewport().add( theOutput ); // In TextArea
rootWindow.setVisible( true ); // Make visible
class Transaction implements ActionListener // Listener
public void actionPerformed( ActionEvent ae ) // Interaction
if ( theStock == null )
theAction.setText("No conection");
return; // No connection
String actionIs = ae.getActionCommand(); // Button
try
if ( theBought == null )
int on = theOrder.uniqueNumber(); // Unique order no.
theBought = new BoughtList( on ); // Bought list
if ( actionIs.equals( NAME.CHECK ) ) // Button CHECK
theState = STATE.PROCESS; // State process
String pn = theInput.getText().trim(); // Product no.
int amount = 1; // & quantity
if ( theStock.exists( pn ) ) // Stock Exists?
{ // T
Product pr = theStock.getDetails(pn); // Get details
if ( pr.getQuantity() >= amount ) // In stock?
{ // T
theAction.setText( // Display
pr.getDescription() + " : " + // description
theMoney.format(pr.getPrice()) + // price
" (" + pr.getQuantity() + ")" // quantity
); // of product
theProduct = pr; // Remember prod.
theProduct.setQuantity( amount ); // & quantity
theState = STATE.CHECKED; // OK await BUY
} else { // F
theAction.setText( // Not in Stock
pr.getDescription() +" not in stock"
} else { // F Stock exists
theAction.setText( // Unknown
"Unknown product number " + pn // product no.
if ( actionIs.equals( NAME.BUY ) ) // Button BUY
if ( theState != STATE.CHECKED ) // Not checked
{ // with customer
theAction.setText("Check if OK with customer first");
return;
boolean stockBought = // Buy
theStock.buyStock( // however
theProduct.getProductNo(), // may fail
theProduct.getQuantity() ); //
if ( stockBought ) // Stock bought
{ // T
theBought.add( theProduct ); // Add to bought
theOutput.setText( "" ); // clear
theOutput.append( theBought.details()); // Display
theAction.setText("Purchased " + // details
theProduct.getDescription()); //
// theInput.setText( "" );
} else { // F
theAction.setText("!!! Not in stock"); // Now no stock
theState = STATE.PROCESS; // All Done
if ( actionIs.equals( NAME.CANCEL ) ) // Button CANCEL
if ( theBought.number() >= 1 ) // item to cancel
{ // T
Product dt = theBought.remove(); // Remove from list
theStock.addStock( dt.getProductNo(), // Re-stock
dt.getQuantity() ); // as not sold
theAction.setText(""); //
theOutput.setText(theBought.details()); // display sales
} else { // F
theOutput.setText( "" ); // Clear
theState = STATE.PROCESS;
if ( actionIs.equals( NAME.BOUGHT ) ) // Button Bought
if ( theBought.number() >= 1 ) // items > 1
{ // T
theOrder.newOrder( theBought ); // Process order
theBought = null; // reset
theOutput.setText( "" ); // Clear
theInput.setText( "" ); //
theAction.setText( "Next customer" ); // New Customer
theState = STATE.PROCESS; // All Done
theInput.requestFocus(); // theInput has Focus
catch ( StockException e ) // Error
{ // Of course
theOutput.append( "Fail Stock access:" + // Should not
e.getMessage() + "\n" ); // happen
catch ( OrderException e ) // Error
{ // Of course
theOutput.append( "Fail Order process:" + // Should not
e.getMessage() + "\n" ); // happen
}(disclaimer: I did not read through your Swing code, as I find that painful)
My question is how do I access a private arraylist from a different class in the same
package?Provide a public accessor method (getMyPrivateArrayList()) -
HT4061 How do I access the songs I have uploaded to the cloud from another computer?
How do I access the songs I have uploaded to the cloud from another computer?
oliversdaniel wrote:
How do I access the songs I have uploaded to the cloud from another computer?
So you purchased iTunes Match? Enable iTunes Match on your other device.
This is the only way to upload. -
Accessing a variable defined in one class from another class..
Greetings,
I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.
Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem to be working for me. Any ideas would be appreciated. Thanks,
- Jeremy
package jab.enemy
import flash.display.MovieClip;
import flash.events.Event;
import jab.enemy.MissleDisappear;
public class DieLikeThePhishes
private var _clip2:MovieClip; // player
private var _clip3:MovieClip; //phish1
private var _clip4:MovieClip; //phish2
private var _clip5:MovieClip; //phish3
private var _clip6:MovieClip; //phish4
private var _clip10:MovieClip; // background
private var _clip11:MovieClip // missle1
private var _clip12:MovieClip // missle2
private var _clip13:MovieClip // missle3
private var _clip14:MovieClip // missle4
private var _clip15:MovieClip // missle5
private var _clip16:MovieClip // missle6
private var _clip17:MovieClip // missle7
private var _clip18:MovieClip // missle8
private var _clip19:MovieClip // missle9
private var _clip20:MovieClip // missle10
private var _clip21:MovieClip // missle11
private var _clip22:MovieClip // missle12
var ay1 = 0;var ay2 = 0;var ay3 = 0;var ay4 = 0;
var vy1 = 0;var vy2 = 0;var vy3 = 0;var vy4 = 0;
var phish1BeenHit:Boolean = false;var phish2BeenHit:Boolean = false;
var phish3BeenHit:Boolean = false;var phish4BeenHit:Boolean = false;
public function DieLikeThePhishes(clip2:MovieClip,clip3:MovieClip,clip4:MovieClip,clip5:MovieClip,clip6:M ovieClip,clip10:MovieClip,clip11:MovieClip,clip12:MovieClip,clip13:MovieClip,clip14:MovieC lip,clip15:MovieClip,clip16:MovieClip,clip17:MovieClip,clip18:MovieClip,clip19:MovieClip,c lip20:MovieClip,clip21:MovieClip,clip22:MovieClip)
_clip2 = clip2;_clip3 = clip3;_clip4 = clip4;_clip5 = clip5;_clip6 = clip6;
_clip10 = clip10;_clip11 = clip11;_clip12 = clip12;_clip13 = clip13;_clip14 = clip14;
_clip15 = clip15;_clip16 = clip16;_clip17 = clip17;_clip18 = clip18;_clip19 = clip19;
_clip20 = clip20;_clip21 = clip21;_clip22= clip22;
_clip3.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame)
function onEnterFrame(event:Event):void
vy1+= ay1;_clip3.y += vy1; vy2+= ay2;_clip4.y += vy2;
vy3+= ay3;_clip5.y += vy3; vy4+= ay4;_clip6.y += vy4;
if (phish1BeenHit ==false)
if(_clip3.y >620)
{_clip3.y = 620;}
if (phish2BeenHit ==false)
if(_clip4.y >620)
{_clip4.y = 620;}
if (phish3BeenHit ==false)
if(_clip5.y >620)
{_clip5.y = 620;}
if (phish4BeenHit ==false)
if(_clip6.y >620)
{_clip6.y = 620;}
if (_clip11.hitTestObject(_clip3) ||_clip12.hitTestObject(_clip3)||_clip13.hitTestObject(_clip3)||_clip14.hitTestObject(_cl ip3)||_clip15.hitTestObject(_clip3)||_clip16.hitTestObject(_clip3)||_clip17.hitTestObject( _clip3)||_clip18.hitTestObject(_clip3)||_clip19.hitTestObject(_clip3)||_clip20.hitTestObje ct(_clip3)||_clip21.hitTestObject(_clip3)||_clip22.hitTestObject(_clip3))
_clip3.scaleY = -Math.abs(_clip3.scaleY);
_clip3.alpha = 0.4;
ay1 = 3
vy1= -2;
phish1BeenHit = true;
if (_clip11.hitTestObject(_clip4) ||_clip12.hitTestObject(_clip4)||_clip13.hitTestObject(_clip4)||_clip14.hitTestObject(_cl ip4)||_clip15.hitTestObject(_clip4)||_clip16.hitTestObject(_clip4)||_clip17.hitTestObject( _clip4)||_clip18.hitTestObject(_clip4)||_clip19.hitTestObject(_clip4)||_clip20.hitTestObje ct(_clip4)||_clip21.hitTestObject(_clip4)||_clip22.hitTestObject(_clip4))
_clip4.scaleY = -Math.abs(_clip4.scaleY);
_clip4.alpha = 0.4;
ay2 = 3
vy2= -2;
phish2BeenHit = true;
if (_clip11.hitTestObject(_clip5) ||_clip12.hitTestObject(_clip5)||_clip13.hitTestObject(_clip5)||_clip14.hitTestObject(_cl ip5)||_clip15.hitTestObject(_clip5)||_clip16.hitTestObject(_clip5)||_clip17.hitTestObject( _clip5)||_clip18.hitTestObject(_clip5)||_clip19.hitTestObject(_clip5)||_clip20.hitTestObje ct(_clip5)||_clip21.hitTestObject(_clip5)||_clip22.hitTestObject(_clip5))
_clip5.scaleY = -Math.abs(_clip5.scaleY);
_clip5.alpha = 0.4;
ay3 = 3
vy3= -2;
phish3BeenHit = true;
if (_clip11.hitTestObject(_clip6) ||_clip12.hitTestObject(_clip6)||_clip13.hitTestObject(_clip6)||_clip14.hitTestObject(_cl ip6)||_clip15.hitTestObject(_clip6)||_clip16.hitTestObject(_clip6)||_clip17.hitTestObject( _clip6)||_clip18.hitTestObject(_clip6)||_clip19.hitTestObject(_clip6)||_clip20.hitTestObje ct(_clip6)||_clip21.hitTestObject(_clip6)||_clip22.hitTestObject(_clip6))
_clip6.scaleY = -Math.abs(_clip6.scaleY);
_clip6.alpha = 0.4;
ay4 = 3
vy4= -2;
phish4BeenHit = true;
if (_clip3.y > 10000)
_clip3.x = 1000 +3000*Math.random()-_clip10.x;
_clip3.y = 300;
_clip3.alpha = 1;
_clip3.scaleY = Math.abs(_clip3.scaleY);
ay1 = vy1 = 0;
phish1BeenHit = false;
if (_clip4.y > 10000)
_clip4.x = 1000 +3000*Math.random()-_clip10.x;
_clip4.y = 300;
_clip4.alpha = 1;
_clip4.scaleY = Math.abs(_clip4.scaleY);
ay2 = vy2 = 0;
phish2BeenHit = false;
if (_clip5.y > 10000)
_clip5.x = 1000 +3000*Math.random()-_clip10.x;
_clip5.y = 300;
_clip5.alpha = 1;
_clip5.scaleY = Math.abs(_clip5.scaleY);
ay3 = vy3 = 0;
phish3BeenHit = false;
if (_clip6.y > 10000)
_clip6.x = 1000 +3000*Math.random()-_clip10.x;
_clip6.y = 300;
_clip6.alpha = 1;
_clip6.scaleY = Math.abs(_clip6.scaleY);
ay4 = vy4 = 0;
phish4BeenHit = false;
var missleDisappear1 = new MissleDisappear(_clip11,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear2 = new MissleDisappear(_clip12,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear3 = new MissleDisappear(_clip13,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear4 = new MissleDisappear(_clip14,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear5 = new MissleDisappear(_clip15,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear6 = new MissleDisappear(_clip16,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear7 = new MissleDisappear(_clip17,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear8 = new MissleDisappear(_clip18,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear9 = new MissleDisappear(_clip19,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear10 = new MissleDisappear(_clip20,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear11 = new MissleDisappear(_clip21,_clip3,_clip4,_clip5,_clip6,_clip10);
var missleDisappear12 = new MissleDisappear(_clip22,_clip3,_clip4,_clip5,_clip6,_clip10);I would approach it in much the same way as you would in java, by making getters and setters for all of your class variables.
Getters being for returning the values, Setters being for setting them.
So you would make a get function for the variable you want to access ala:
function get1PhishBeenHit():boolean {
return this.phish1BeenHit;
Then to access the value of that variable from outwith the class:
var result:boolean = ClassInstanceName.get1PhishBeenHit(); -
Referring to functions on the stage from a movieclip.
First of all, I'd like to thank you to anyone who takes their time to read this. I registered to this forum for the sole purpose of getting help to this one issue of mine, as I found most issues were solved in here. By reading my problem (and hopefully responding) you're doing me a huge favour. Thanks in advance.
I just started "coding" in AS3. By "coding", I actually mean trying around with features and generally trying to grasp the vast amount stuff you can do with this software of. I have some coding experience, however the way Flash likes to hide code snippets all over my project does tend to confuse me. Not knowing where I tried putting the code and/or rewrote some other stuff keeps me sorta busy.
I'd also like to apologize for the title, if it in any way confuses you. Shortening down my problem to a single sentence was hard, please keep that in mind.
Anyway, my issue is this:
Messing around with movieclips inside movieclips, I've keep encountering the error "1120: Access of undefined property onTimerComplete." I do realize that this error generally is caused by not having defined an instance correctly or not having it defined at all - an error beginners tend to make.
Nonetheless, I'm not trying to refer to an instance/symbol, I am trying to call a function defined on the stage from within a movieclip that also is placed on the stage.
I've been reading huge amounts of text/articles and how-to 's, but they all seem to only touch the subject lightly or simply going in head-first - becoming far too complicated for me (a beginner) to grasp.
So, trying to sum my questions up into something that looks like a tl;dr:
- What's up with levels, "_root" and referring to functions like in the older versions of flash?
Flash tells me to use some display-package instead of _root, when I use that... (I do realize the article is from Flash 5.0)
- How do you refer to a function defined on the stage, from inside a movieclip? (The function is a timer, that is supposed to make the mother-movieclip continue to the next child-movieclip.)
Please, I really don't know how to define my problem any further than this. Ask as many questions as you would like, I really appreciate any help I can get.
- Mattimussiclick file/publish settings/flash and tick "permit debugging". highlight the line number referenced in the error message. (and, use:
Calling:
stop();
MovieClip(root).startTimer();
Defining:
var myTimer:Timer = new Timer(2000, 1);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
myTimer.start();
function onTimerComplete(event:TimerEvent):void{
play();
//myTimer.stop();
function startTimer():void{
trace("startTimer function was executed");
myTimer.start(); -
DropTarget check against all objects on the stage
Hey all,
Not sure the best way to do this. I have a class we will call DropActivity, here is the code
package com.activitycontrol
import com.activitycontrol.DropCheck;
public class DropActivity
// Constants:
// Public Properties:
// Private Properties:
private var _selectedClip:Object;
// Initialization:
public function DropActivity(/*selectedClip:Object*/)
// Public Methods:
public function set selectedClip(selectedClip:Object):void
_selectedClip = selectedClip;
public function stopDraggingMe():void
var dropCheck:DropCheck = new DropCheck();
//dropCheck.checkAgainst = dropTarget.name; ///***********
if (dropCheck.canBeDropped == true)
_selectedClip.stopDrag();
// Protected Methods:
when the stopDraggingMe() method is called from another object (code shown below) I need to see all the objects on the stage to see what objects on the stage my currently selected movie clip is over and assign it to the dropCheck.checkAgainst method (that will be checked against an array to see if it can in fact be dropped, if so set the canBeDropped value to true and therefor run the .stopDrag() ). I have read using root is not a good coding practice in AS 3.
call to the stopDraggingme() mehod.
private function setDown(event:MouseEvent):void
var droppedItem:DropActivity = new DropActivity();
droppedItem.selectedClip = this;
droppedItem.stopDraggingMe();No, I think I can use drop target, I just need to use it from the DropActivity class and not a document class. I just don't know how to use it from a non-document class.
"and you need to loop through all displayobjects to see which have a positive hitTest with your dropped object, correct?"
I am trying to say..... ok, what movie clip is currently under the one I have selected, the drop activity class knows what object I have selcted as it is in the selectedClip variable. so I need to find out what clip is under it ......... the light just came on!
answer duh......dropCheck.checkAgainst = _selectedClip.dropTarget.parent.name;
thanks a bunch kglad you have helped me out once again, you are the man. I might just have to buy you a beer one of these days. -
Accessing a JTextField from another class
I 've got 2 classes I am trying to get the value of a JTextField that located in a second class see the code
class1 myClass = new class1();
String text = myClass.jTextField1.getText();
System.out.print(text);What happens is when i run the program and enter some text in the jTextFild1 and then click on my Jbutton it does not print anything
the JButton is in the caller class
Could anyone explains to me what is wrongan example would help maybe....
if you want to access your jtextfield from another class then:
import javax.swing.*;
public class FieldHolderClass {
public JTextField jtf = null;
public FieldHolder() {
JFrame jf = new JFrame();
jtf = new JTextField();
jtf.setText("this is the text that is here when other callerclass seeks for text");
jf.getContentPane().add(jtf);
jf.setVisible(true);
public class CallerClass {
public static void main(String args[]) {
FieldHolderClass fHolder = new FieldHolderClass();
System.out.println((fHolder.jtf.getText());
}of course i have not written any swing app for a long time, so i might have forgotten everything... so, don't flame me when that code does not compile.
the thing that it's supposed to show, is that you make a <b>public</b> variabel (jtf) and you simply ask for it from another class by typing holderclass instances name dot and that variable name (in this case jtf) and dot and then call the method on that variable (or object...)
it might also be that you want your code to work the way that when you enter a text into jtextfield, then after pressing enter it would get printed on terminal...
in that case you should also register some Listeners... i remember that back when i was just getin' to know java then i had problems with it as well... but then again, i didn't read any manuals...
i hope i was somewhat help... -
How to view and access files on my iBook G3 from another iMac
**Hello, everybody on this excelent forum. I need to know how to use my Firewire conection, to view and access files in my iBook G3, from another iMac G3, both are OK in working good condition. I put this question because some days ago a Mac expert fix to me the access in my recent SwapMeet second hand aqcired iMac G3, without the original last owner password.
this person are egoistic, and DoNot show me how he use the Firewire do this job.
Thank You: Eduardo from NorthWest Mexico.Hello, Niel, Thank You very Much for your fast and kindly responce.
the next monday I'll buy a new FireWire cable to test the metod you tell me.
Again thanks and best regards from NW-Mexico.
Eduardo
Maybe you are looking for
-
Slow motion is gone on Yosemite?
Just That. Is it gone? or I'm doing something wrong? Steve used to love this feature...
-
Hi : I am developing a applicaition in apex i have a reqirement like this i have created a check box, Check box will normally have check and uncheck values which is like 0 and 1 now i need to create a table to hold these values if i check it must hol
-
17 inch macbook pro not getting anything close to 8 or even 7 hours?
hello its been over a week now and i have not gotten anything close to the advertised 7 hour battery life. i dont have the other graphics card on and im only doing web browsing. on a full charge i wont get more then 3 in a half maybe 4 hours... is so
-
So much good info on these pages! Having decided to purchase FCE v.4, I copied all my iMovie-imported files to an external hard-drive as a back-up. Instead of DV-stream clips, however, I now have Quicktime.mov files in all their HD beauty. Admittedly
-
How to know when there will be something new.
I have a Powermac G4...and it's ok but kinda slow...not updated. In otherwords I would like a new computer (and an iPod). I'm thinking about a refurbished 20" imac intel core duo. But I don't want to get it and then realize something new just came ou