Incrementing Counter on Stage through Class
Hello everyone, I have a thread similar to this one about saving and loading a counter. However, I can't get the counter to increment when colliding with an object. When colliding with the object, it makes it not visible so you can't see it anymore.
My counter that saves and loads looks like this:
var so:SharedObject = SharedObject.getLocal("myStuff","/");
var JumpCounter: int = 0;
if(so.data.JumpCounter)
JumpCounter = so.data.JumpCounter;
And when you jump:
JumpCounter++;
so.data.JumpCounter = JumpCounter;
so.flush();
It ouputs here to a text box:
JumpBox.text = JumpCounter.toString();
This all works fine, I just can't get it to increment when colliding with my MovieClip.
I have a class that looks like this attached to my MovieClip that I want to increment that looks like this:
package {
import flash.display.*;
import flash.events.*;
public class AddJumps extends MovieClip{
//construct function
public function AddJumps():void
addEventListener(Event.ENTER_FRAME, collision);
private function collision(e:Event):void{
if(this.hitTestObject(MovieClip(root).Player)){
MovieClip(root).JumpIcon.visible = false;
I'm unsure as how to access or increment my counter from within a class. I can't seem to remember how to access the stage.
Thanks in advance!
on your main timeline you should use:
var so:SharedObject = SharedObject.getLocal("myStuff","/");
var JumpCounter: int = 0;
if(so.data.JumpCounter)
JumpCounter = so.data.JumpCounter;
function incrementJumpCounterF():void{
JumpCounter++;
so.data.JumpCounter = JumpCounter;
so.flush();
//And when you jump (or otherwise want to increment JumpCounter from the main timeline or a class like AddJumps):
MovieClip(root).incrementJumpCounterF();
Similar Messages
-
Increment Counter in Parent / Child
I am generating classes from an existing schema.
I have two tables that are Parent / Child with the parent containing an
incrementing counter that is part of the Child primary key.
Is there a way to describe this relationship so that the generated code has
the rationship properly described?I have a parent table, 'CARD_HOLDER' that has a key of ID_CARDHOLDER
(integer) and a row of CURRENT_SEQ_NO (integer).
The child table, 'CARD' has a key of ID_CARDHOLDER (integer) and SEQ_NO
(integer) [both colums are the key value].
When a new card is added to the 'CARD' table, the CARDHOLDER.CURRENT_SEQ_NO
is incremented and the CARD.CURRENT_SEQ_NO is set equal to it.
Can I emulate this behavior in KODO?
When a new 'card'
"Abe White" <[email protected]> wrote in message
news:[email protected]..
Sorry, could you describe the table structure in more detail? I'm not
sure I follow. -
Increment counter in XSLT mapping
Hi Experts,
I am creating xslt mapping by using mapforce tool. I am trying to get increment counter variable in xslt mapping. can you please tell me what would be the code for getting sequence number.
Thanks for your help.
Thanks,
Hariyes, there is a global variable concept in XI which u can use for your Sequence Number concept.
If you are on SP14 and above, just take a lookat this blog and the GLOBAL Variables Section
XI: New features in SP14
check this thread
Re: Need Help in XSLT Mapping
Re: Sequence Number in XI Mapping -
MAPPING: Increment counter while creating destination structures
Hello,
i have the following source and destination structure:
<src_struct> (0-n)
<qualifier>
<value>
</src_struct>
<dest_struct> (0-n)
<counter>
<qualifier>
<value>
</src_struct>
only those dest structures have to be created where <qualifier="XX">.
Thus my mapping on structure level looks like:
if <qualifier> equalS "XX" createIf --> <dest_struct>
This works fine.
But additionally i need to increment <counter> in the dest_struct. I.e., when i have 10 src_struct where 5 of them has <qualifier="XX"> i need 5 dest_struct with counter 1 to 5.
I tried this with a UDF which has just a constant as input:
"MY_COUNTER" --> UDF:getNextCounter --> <counter>
This argument is the name under which the last counter was saved in the global container. My expectation was that for each time the field <counter> will be created, my UDF reads the las counter, increments it, saves it back to the container and returns the result.
but the bahavior is different:
For example:
if src_structures 6-10 have <qualifier>="XX" my UFD returns 6-10 in sequnce instead
of 1-5. The shows me, that my UDF runs 10 times even though just 5 dest_struct are created.
What do i wrong?
Her my UDF:
GlobalContainer gc = container.getGlobalContainer();
String counter = new String();
counter = (String) gc.getParameter(MY_COUNTER);
if(counter==null) {
counter = "1";
gc.setParameter(MY_COUNTER,counter);
return(counter);
Integer i_counter = new Integer(counter);
int i = i_counter.intValue() + 1;
Integer I = new Integer(i);
counter = I.toString();
gc.setParameter(ID_TYPE,counter);
return(counter);Hi,
Why dont you take qualifier as another argument (say b) for the same UDF.
so that you can check the value of the qualifier and run the logic as you needed.
as below,
if (b.equals("XX"))
GlobalContainer gc = container.getGlobalContainer();
String counter = new String();
counter = (String) gc.getParameter(MY_COUNTER);
if(counter==null) {
counter = "1";
gc.setParameter(MY_COUNTER,counter);
return(counter);
Integer i_counter = new Integer(counter);
int i = i_counter.intValue() + 1;
Integer I = new Integer(i);
counter = I.toString();
gc.setParameter(ID_TYPE,counter);
return(counter);
Let me know if its not working.
Hope this helps.
Prasad Babu. -
NI-6602 - Encoder capture - resetting the counter to 0 through software - DAQmx
Hello. A simple one. I'm using DAQmx to set up a task to set channel 0 on an NI-6602 as an angular encoder capture port. This is working fine and I can grab the position in degrees. The simple question is - How do I reset the counter to 0 through software. I can set up ZIndex to do it but how do I either reset the counter or set it with an arbritrary number? I can see a method to set it on startup but not during capture.
Thanks.
WillIf working in LabVIEW, there are DAQmx property nodes that will allow you to set the "initial count" value, but ONLY while the task is stopped.
If you can't count on a hardware z-index reset, another software technique I've used to avoid stopping the DAQmx task. I make a wrapper function for all my encoder task access (see the Action Engine nugget for ideas...). Inside this "Action Engine" wrapper, I use an uninitialized shift register to store my encoder's "virtual 0". I add a simple function to the action engine for setting the "virtual 0" to be the current encoder position value. Every time I read from the encoder, I first subtract off the virtual zero before returning the data. As far ast the rest of the app is concerned, the encoder data it gets is just as if I were able to make a software call to DAQmx to set the raw count to zero.
-Kevin P. -
Is it possible to get a count of all the class files in a Flash Builder project?
Is it possible to get a count of all the class files in a Flash Builder project?
Thanks!Resultsets are one per connection unless you have copied them. Do you have lots of connections are you properly reusing them or at least closing and discarding all references?
See tutorial and Javadoc of API too -
IMPORT/EXPORT through classes
Hi,
I have to export dynamic internal tables to another program, but client has asked not to use import/export.
Searched on google and SDN, got to know that it may be acheived through classes.
Please help me if someone has worked on that, also if some has sample code for that, please let me know.
Thanks and Regards
ManuYou can use the Shared Objects instead of the IMPORT/EXPORT to shared buffer. But, the Shared Objects is not the ultimate solution to replace the IMPORT/EXPORT to memory ID.
Check this WIKI on Shared Objects: http://wiki.sdn.sap.com/wiki/display/ABAP/ABAPObjectsShareMemoryEnable+%28SHMA%29
Regards,
Naimesh Patel -
Hi ALL ,
I want to do Incremental Count Grouped By Location Below is the 2 tables in first one is the Data and Second one is the Output Required . Kindly Help
Query i used for the first table :
Select
V.NAME as Product,
DatePart(MM,V.[ImportDate]) as Month,
DatePart(YY,V.[ImportDate]) as Year,
XD.Description as Area
From [dbo].[Product] V
Left Outer Join [dbo].[Area] XD
On V.AreaID = XD.AreaID
Order By Year ,Month
Month No
Year
Product
Area
10
2013
AC
Dal
10
2013
AC
Dal
10
2013
AC
CAL
10
2013
AC
CAL
10
2013
AC
CAL
10
2013
dafad
CAL
10
2013
efeq
CAL
11
2013
fewfew
Dal
11
2013
ccdsc
CAL
11
2013
fewfew
San
11
2013
ewew
San
11
2013
cscds
San
11
2013
csdvcds
San
11
2013
vdvsd
San
11
2013
rewfrew
San
12
2013
rwer
San
12
2013
rrtgx
San
12
2013
twtw
San
12
2013
wqw
San
1
2014
csfdaf
San
1
2014
eewfvvzzqe
San
1
2014
sfsdf
San
Month
Year
Area
ProductCount
10
2013
Dal
2
10
2013
CAL
5
11
2013
Dal
3
11
2013
CAL
6
11
2013
San
6
12
2013
San
10
1
2014
San
13
Kindly Provide the aggregated query for the Second tableHi
Latheesh NK ;
Its working fine for the same year like 2013 all counts are incrementing fine but for the new year here in our case 2014 its starting the count fresh not carry forwarding the previous years data .
Thanks
Priya
Hello Priya, I dont understand your issue here. If the test script is working fine for all the years (you can test it), there should be some differences in your actual code or its datatype.
If test script is not working, please do add more data to explain your scenario, we would be able to help you better.
Drop table T122
create table T122(month int, year int, Product varchar(10), Area varchar(5))
Insert into T122 values
(10,2010,'asd','DSAL'),
(09,2013,'asd','DAL'),
(10,2013,'asd','DAL'),
(10,2013,'asd','DAL'),
(10,2013,'asd1','CAL'),
(10,2013,'asd1','CAL'),
(10,2013,'asd1','CAL'),
(10,2014,'asd1','DAL'),
(10,2014,'asd1','DSAL')
Select * From (Select distinct A2.MONTH,A2.YEAR, A2.Area From T122 A2)A
CROSS APPLY(Select COUNT(1) cnt From T122 A1 Where A.month >=A1.month and A.year >= A1.year and A.Area = A1.Area)B -
Incremental counter & log file?
Is it possible to script an incremental counter in Applescript, similar to the one used in a Print dialog box?
ie: "How many copies do you want to print?" (drop down box offers numerical selection, and a log file is created from this input)
Thanks for any help with this.Is this along the lines of what you're looking for? I'm confused by the "drop down box retains" statement. You can get the users selection from a list (like the 1st script below) or you can have the user input the number by typing it (as in the 2nd script below).
Example #1:
<pre style="margin: 0px; padding: 5px; border: 2px dotted green; width: 600px;
height: 250px; color: #ffffff; background-color: #000000; overflow: auto; font-family: Verdana, Monaco, monospace; font-weight: 900; font-size: 12px;"
title="Copy this text and paste it into your Script Editor application.">--START
property numList : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
--SET PATH TO LOG FILE
set counterDir to POSIX path of ((path to application support from user domain) & "MyCounter:" as string)
set counterLog to counterDir & "counter.log"
--CREATE LOG FILE DIRECTORY (IF NECESSARY)
try
(POSIX file counterDir) as alias
on error
do shell script "mkdir " & quoted form of counterDir
end try
--GET NUMBER AND ADD TO LOG FILE
set theChoice to (choose from list numList) as string
if theChoice is not "false" then do shell script "echo " & theChoice & " >> " & quoted form of counterLog
--END</pre>
Example #2:
<pre style="margin: 0px; padding: 5px; border: 2px dotted green; width: 600px;
height: 250px; color: #ffffff; background-color: #000000; overflow: auto; font-family: Verdana, Monaco, monospace; font-weight: 900; font-size: 12px;"
title="Copy this text and paste it into your Script Editor application.">--START
property numList : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
--SET PATH TO LOG FILE
set counterDir to POSIX path of ((path to application support from user domain) & "MyCounter:" as string)
set counterLog to counterDir & "counter.log"
--CREATE LOG FILE DIRECTORY (IF NECESSARY)
try
(POSIX file counterDir) as alias
on error
do shell script "mkdir " & quoted form of counterDir
end try
--GET NUMBER AND ADD TO LOG FILE
set theChoice to text returned of (display dialog "Enter Number:" default answer "2")
if theChoice is not "false" then do shell script "echo " & theChoice & " >> " & quoted form of counterLog
--END</pre>
Both of the above scripts will keep a log file in the following location:
*/Users/You/Library/Application Support/MyCounter/counter.log*
Once we figure out exactly what you want for the first part of your script, we can then move on to helping you upload your results to your server once a week. Hope this helps... -
How do I interact between stage and classes?
Hi,
I have asked this question before, and all I got is "Go back
to reading beginner books", so I'm hoping that someone here is
willing to actually answer my question as opposed to brushing me
off because they were unwilling to help...
And yes, I have read books on the topic and gone through tons
of the documentation and not found the answer to this. I have
ActionScript 1 and JavaScript experience, so this whole business
shouldn't be this hard.
I am using ActionScript 3 in Flash CS3.
My problem is this:
I need to find out how to send commands between stuff on the
stage and stuff that's defined in a class.
I have had this issue for ages and kept trying to find ways
around it since so far I haven't been able to find help for it.
For example:
When using a document class, how can I access the current
frame number of the Stage?
Or using a document class, how can I access any object (like
a MovieClip with instance name) that was put on the stage using the
IDE?
Currently, to be more specific, I am trying to do something
really simple:
Make a button work on my stage that is not always visible.
With AS3 that's not as easy anymore as it used to be.
So what I did now is create the button in the document class,
used addChild and set it to alpha = 0.
Now, when the Stage reaches specific frames (i.e. ones with
labels, and I got this part figured out), it is supposed to make
the button visible. Then I can add event listeners and stuff, and I
can figure that part out myself.
I don't know how to access the stage frame number from the
document class, so I put it into a frame script in frame 1, but now
this script cannot access the button that is defined in the
document class.
It's driving me bananas...
PLEASE, someone here, can someone please explain to me how I
can make this work?
I have seen plenty of diagrams of the Display List and the
Object Hierarchy, but none of that explains how to actually USE any
of it...
Thanks so much in advance to anyone who is willing to spend
some time to answer!Well, first of all, I have to say that AS3 has basically been
designed to be difficult on purpose, in that all this interaction
between objects is purposefully very strict. For this reason, I
still use AS2 for all my basic Flash work. AS3 is just a lot more
involved, a lot more strict, a lot less forgiving... you need a lot
of experience with it before it starts to make sense.
Now, I think I might have a few specific answers to your
questions:
From any DisplayObject (this includes any Document class,
which has to extend MovieClip or in some cases Sprite) you can
access the Stage using the 'stage' property.
However, stage is probably not exactly what you want, you
want the main timeline, which is the child of stage. To access the
main timeline, you can use the 'root' property of any
DisplayObject.
However, unless you have strict mode off, Flash won't let you
just say "root.myMovieClip" because the root property is of the
type DisplayObject, which is not a dynamic class (meaning you can't
add properties to it) and it has no built in property "myMovieClip"
so it thinks you made a mistake. So you have to "cast" the root
property as a MovieClip, which *is* dynamic so it will let you try
to reference anything on it (like AS1/2 did for everything.)
So what all that means is this should work from inside you
document class:
(root as MovieClip).myMovieClip
or
MovieClip(root).myMovieClip
Either will successfully reference a MovieClip you had put on
the main stage in the IDE and named "myMovieClip".
Rather than setting the alpha to 0, try setting visible to
false. I think this will disable all interactive events, where
simply setting alpha to 0 would make it still be interactive.
HTH -
Hi, i have two problems with my code which I need to fix. 1. How can i get the the results of the station to print out until it reaches 40 stations because it carries on printing in the loop to the screen. 2. How can i get the print statement to print the number of stations it is creating the results for?, i.e the station count goes up in fours, so i want it to print the first batch of results as 4 then 8, then 12 etc.......
Please could anyone help me, thanks.
here is a copy of the code, and also where the arrows are is where I the problems are. Feel free to run the code to see what it does, i think that will clear the problems i want fixings, thanks again.
import java.io.*;
import java.util.*;
import java.awt.*;
import java.text.*;
import java.lang.Object.*;
import java.lang.Math.*;
public class TRS {
public static void main(String[] args){
int packets = 400; // number of packets for each station
double dataRate = 16e6; // Data transmission rate in bps
int size = 1600; // Average packet size in bits
int mean;
int stations;
double ring = 100; // Ring circumference in metres
double ring_inc = (ring/2e8); // Ring rotation time in mirco-seconds
double token_time = (24/dataRate); // Token transmission time
Random rn = new Random();
for(int i=4;i<41;i=+4){ <------------------------------------
System.out.println("\nNumber of Stations = " + (stations)); <----------------------
System.out.println(" ");
System.out.println("\tMean\t\tMean_Delay\tThroughput");
System.out.println(" ");
int [] seeds = new int[stations];
double stat_inc = (ring_inc/stations); // Inter-station propogation time
double frame_time = (size/dataRate); // Framet ransmission time
for(i=0;i<stations;i++){
seeds[i] = (int)(Math.ceil(8999 + 1) * rn.nextDouble()) + 999;
double [][] tt = new double[stations][packets];
for(mean=1;mean<10;mean++){ // Mean inter-arrival time in milli-seconds
for(int j=0;j<stations;j++) {
rn.setSeed(seeds[j]);
double [] t = new double[packets];
for(i=0;i<packets;i++){
t[i] = -mean*Math.log(rn.nextDouble())/1000.0;
for(i=1;i<packets;i++){
double z = t;
double y = tt[j][i-1];
tt[j][i] = y + z;
int end = 1;
double elapsed = 0;
int [] next = new int[stations];
for(i=0;i<stations;i++){
next[i] = 1;
int token = 0;
double [] delays = new double[40000];
double sum = 0;
int counter = 0;
double Q = tt[token][next[token]];
while(end < packets){
if(elapsed > Q){
delays[counter] = elapsed - tt[token][next[token]];
next[token] = next[token] + 1;
counter += 1;
if(end < next[token]){
end = next[token];
elapsed += (ring_inc + stat_inc + frame_time + token_time);
else {
elapsed += stat_inc + token_time;
token = (token+1) % stations;
Q = tt[token][next[token]];
for(i=0;i<counter;i++){
sum += delays[i];
double mean_delay = sum/counter;
double throughput = counter * size/elapsed;
NumberFormat formatter = new DecimalFormat("0.000E000");
String m = formatter.format(mean*1e-5);
String md = formatter.format(mean_delay);
String tp = formatter.format(throughput);
System.out.println("\t" + (m) + "\t" + (md) + "\t" + (tp));for(int i=4;i<41;i=+4)I suppose this will compile, but since you ask about
incrementing the count: that doesn't do it. It
assigns +4 to i. From what you say it sounds like you
want to add 4 to i on each iteration of the loop.
That would befor(int i=4;i<41;i=i+4)
Ah.
So presumably he meant i += 4 and transposed the + and the = (and added a space to boot).
Or maybe he just forgot an i. -
How to increment counter for line items.
Hi,
Please see the code below:
LOOP AT T_MAT INTO W_MAT.
perform bdc_dynpro using 'SAPMM07M' '0421'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-ERFMG(i)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MSEG-MATNR(i)'
W_MAT-MATNR.
perform bdc_field using 'MSEG-ERFMG(i)'
W_MAT-ERFMG.
i = i+1.
ENDLOOP.
In the above code I'm updating the line items thru BDC. Here I'm having a counter ' i '. I'm incrementing it for every loop cycle. When I run the BDC I get the error "Field MSEG-ERFMG does not exist in the screen"
Please help.
regards,
SriramHi Sriram,
you code as to be changed slightly:
DATA l_counter(2) TYPE n.
DATA l_fieldname TYPE string.
loop at t_mat into w_mat.
MOVE i TO counter.
CONCATENATE 'MSEG-ERFMG(' counter ')' INTO l_fieldname.
PERFORM bdc_field USING 'BDC_CURSOR'
l_fieldname.
i = i+1.
ENDLOOP.data l_counter(2) type n.
Regards
REA
Edited by: Ramy EL-ARNAOUTY on Jul 28, 2009 10:29 AM -
Access movieclip on stage from class?
Hi all,
Is it possible to access a movieclip which has been dragged onto the main stage in my FLA from an external class that i've written? Can i create a variable that refers to the object on the stage? Or does it have to be added dynamically to be accessible?
Many Thanks
MattHi Ned, i'm not instantiating it as such i'm just using it to store quite a large method which is being called from the document class.
I'm trying to break all my code down into chuncks stored in .as files so that i dont have 2,000 lines of code all in frame one of the main timeline : S
So this is my document class:
package {
import flash.display.MovieClip;
import loadXML;
public class mainClass extends MovieClip {
public function mainClass () {
loadXML.importXML();
then this is the class being called from the mainClass:
package {
import flash.display.Stage;
import flash.net.*;
import flash.events.ProgressEvent
import flash.events.Event;
import flash.text.*;
public class loadXML {
private static var myXML:XML;
private static var myLoader:URLLoader = new URLLoader();
public function loadXML() {
public static function importXML():void{
myLoader.load(new URLRequest("pipeLineData.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
private static function processXML(e:Event):void {
myXML = new XML(e.target.data);
objectOnStage.text = myXML.TEXT[0];
//etc...
//etc...
Many thanks
Matt -
WMI powershell - Get-Counter vs Specific Performance Classes
Hi,
As i see there are more than one way to get the Performance information in windows using Powershell.
I could use the Get-Counter cmdlet to fetch information about Processor,Disk or Memory.
While there are also specific WMI classes for Performance like Win32_Perf,Win32_PerfRawData,Win32_PerfFormattedData.
How does one decide which is the right way or which provides a more accurate value.
Thanks for helping me understand.It all depends on wwhat youo are tring to do.
Get-Counter and WMI do the samme thing. Raw couters are not often useful.
Start here:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa373083(v=vs.85).aspx
¯\_(ツ)_/¯ -
Linking Mc on stage with class Mc
Hello
I am trying to tell mc on stage to react to another one that is called by addchild and has a class name. I am doing this from the main timeline. How can I achieve this?
if
(this.currentFrame == 3) //Mc with class name that is on stage with addchild method. Called Mcl1//
Mcl2.gotoAndPlay(1) //Mc physically on stage with instance name//
Do I have to add enterframe events listener on the main timeline. (There is already one inside Mcl1 class code).
Any help is appreciated. Thanks.if you want to do something when the current timeline reaches frame 3, yes you need to use a loop (like enterframe or a timer loop) to repeatedly check when the current frame is = 3.
Maybe you are looking for
-
2 ipods on one laptop....help
Well I returned my shuffle for another like customer support said. In my second ipod. Almost got it working. Here is my question. My son uses an ipod mini on his laptop. I'm trying to get my shufflr working on it too. Now I get the message can't writ
-
What generation is my iPad?
How do I find out what generation my iPad is?
-
2.2 Update Breaks 802.1x Wifi?
This afternoon I got my OTA update to Android 2.2. It went smoothly, with one glaring exception: I can no longer connect to the 802.1x/PEAP wifi network at my office. I did a little poking around and it looks like I'm not the only one: https://code
-
Is there any way to query who resolved a Service Request in Service Manager?
Hi, I have a query that pulls the last name of the user who resolved an Incident in Service Manager. The name is pulled from a view called "IncidentResolvedByUserFactvw." I need to pull the last name of the person who completed a Service Request. The
-
CSS Designer vs. the CS6 CSS tab
Since designing responsive layouts, I've been using compound selectors like mad. The CS6 panel was pretty straghtforward in letting you choose your complexity (Less specific/more specific) based on a highlighted selction. In CC, the Compound path see