ActionScript 2.0 :: Syntax For SetInterval Inside Class?
Apr 30, 2008class actionscript.Time extends MovieClip
{
private var dateTimer:Number;
[code]....
class actionscript.Time extends MovieClip
{
private var dateTimer:Number;
[code]....
I was wondering why my current code for calling a setInterval on a function doesn't work inside my class.I have this code inside one function, calling a second function.
intID = setInterval(selfReferential, dupe, 30, 0x000000);
The selfReferential keyword refers to the current class,but was defined previously (selfReferential = this; ).I get no errors, but the dupe() function is never called.and I had the selfReferential variable replaced with the this keyword at one point as well.
I would like to focus my question on the setInterval and clearInterval use inside a class.
isn't bellow the right way to use it ?
[Code]...
I have put all button inside movieClip called "container" and I have added "container." inside for loop and now I am getting errors.
for (i=8; i<15; i++){
container.this["button" + btns[i].name.replace("btn","")].mouseEnabled = false;
}
If i have a setInterval inside a function, will it execute at the desired interval, even if i only call the containing function once?
View 5 Replieshow to call a function via setInterval a limited number of times (e.g. 20 times).
Code:
function CallMe(Me){
trace(Me);
}
for(var i:Number = 0; i<=20;i++){
setInterval(CallMe(i),3000);
}
My intention for the above simple code would be to have 'i' get traced every 3 seconds. But it doesn't. 'i' just gets dopped out into the output pane all in one go. Do steady release!
I'm making a project where slices of faces are randomized at different times. Each MovieClip contains 24 frames.
Here's what I have:
Code:
#include "mc_tween2.as"
stop();
//Total number of faces.
[code]....
If I place some working setInterval code within a function and then call the function, it fails:
Code:
function RevealLinks():Void {
menu_mc._visible = true;
[code].....
One (dumb) question: Is it possible to use flex 4 syntax declaration inside of a actionscript method? For example, something like that:
[Code]....
function onLoad(){
trace("Calling SetInterval");
setInterval(this,"resizeImage",1000);
[code].....
public function showImageAt(num:Number):Void
{
var interval:Number = setInterval(
function():Void {
[Code]......
so the test function never gets called...
I'm having a problem that has been really getting to me for the last 12 hours or so and I can't seem to find the answer anywhere. I know it's something simple, but I just don't know the correct syntax.
I've got a Flex Application in Flash Builder 4 with a file called "Test.mxml" which looks like this (simplified):
[Code]...
I have a custom class called SpeedCheck, in this class I have a function called Activate(), I am trying to call this function using setInterval from another class but I am not sure how to format it.
This is how I would normally call the function:
ActionScript Code:
SpeedCheck.Activate()
I tried this:
ActionScript Code:
setInterval(SpeedCheck ,"Activate",100);
but it doesn't work, what am I doing wrong?
I try to use setInterval and Tween Class // Flash 8.One time I move the circle on certain position and second time (what I dont know how to do it) I need to move the circle back on original position.
View 1 RepliesHow do I fix this? With this code in my class:
function moveDelay():Void {
myInterval = setInterval(this.movePoints, delay);
}
I lose scope when it calls the function. "this" becomes undefined.
I am trying to write a class that will take a string (provided by a different class) and display it gradually, character by character, as if it were being written by a typewriter. To do this I am making use of the setInterval method in flash.utils, but I'm having difficulties... whenever I test the movie there is no text displayed, but flash isn't reporting any errors.
Here is the code:
package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.utils.*;
public class TypeWriter extends MovieClip {
[Code] .....
I have this issue where I have a function that when it gets called via a setInterval (or setTimeout as I have tried both), it somehow makes my class vars undefined. I have traced it right before I call the timer, right after and then inside the following function that gets called. See below:
Code:
private function onFrontTireSuccess (evt:Object):Void {
_allowTorqueChange = false;
[code].....
I have this issue where I have a function that when it gets called via a setInterval (or setTimeout as I have tried both), it somehow makes my class vars undefined. I have traced it right before I call the timer, right after and then inside the following function that gets called. See below:
Code:
private function onRearTireSuccess (evt:Object):Void {
allowRandomCars = true;
_scoreboardTimer.reset();
[Code].....
using action script...
stop();btn001_btn.addEventListener(MouseEvent.CLICK,showimage1);function showimage1(event:MouseEvent):void { gotoAndPlay(10);}btn002_btn.addEventListener(MouseEvent.CLICK,showimage2);function showimage2(event:MouseEvent):void { gotoAndPlay(20);}
however movie is playing without stopping to "Listen" for a Mouse CLICK. Images placed at frame 10 and 20 should appear only when CLICK'd.
This code is straight out of Classroom in a Book CS4.
I'm working through actionscript 2.0 tutorials using Flash 8, and I'm getting apparent false syntax alerts from script files containing classes with static properties. The .as files seem to work okay when I run them with corresponding .fla files with the Test Movie option, and the code is copied straight from a Macromedia tutorial pdf manual. [code]...
View 0 RepliesI'm having an issue with setInterval/clearInterval when it comes to dealing with objects. Take this example:
[Code]...
Why does clearInterval not stop the interval? Does clearInterval not work when called inside a setInterval? Am I doing something wrong? How do I get it to delete the interval when it reaches a certain count?
im looking for how to remove a setInterval. i searched but the answer which was supposed to work dident for me.
[Code]...
package{
public class Character{
protected var _hp:uint = 50; //Character Health Points
protected var _power:uint = 5; //Damage dealt
[Code].....
I`m instancing a Character and a Player in the Main Timeline, all in frame 1.
When I use: ""player.attack(character)"" it works fine by itself.
So I added the if (defender._hp <= 0) this.win() which gives me the following error:
1061: Call to a possibly undefined method win through a reference with static type Character.
"defender" is a Character instance, "this" is a Player instance and "win()" is a Player method. I try to call the Player method inside a Character method using the Player instance adding the "." and his method name
Do I really need to define the win() function in the Character class? Is there a bypass to use a subclass method in a parent class method if it`s called from an instance of the subclass?
Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.
I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().
I hate to be defiant, but what if I don't want to?
Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?
It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.
That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.
HERE ARE THE STEPS I'M TRYING:
- Create new flash document
- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage
- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()
- Set a name for that box using box.name = "test" let's say
- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great
- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";
That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?
i have a BasicMap.as that takes an Array and populates itself with the MC objects passed to it by a String reference.it inherits from Sprite, and so it just places the objects on its self.then i have a class that inherits from that class, and gives a little more functionality to it, but in order for it to do that, it needs to place the objects not on itself, but instead inside a holder Sprite, so here is my problem:
code:
package Mushroom{
import flash.display.Sprite;
[code]......
I want to know how to make class instances into listeners and broadcasters, from inside each class. Here is what I am trying specifically... part of the Proj class... (projectiles, as a matter of fact)
Code:
private function listen():Void {
u.register(this);
onUpdate = function(){
step(); // a function I have which makes the projectile move (not shown)
}
}
where "u" is another class, the Updater class with this code...
Code:
class Updater {
// const. --- make this a broadcaster
public function Updater(){
[code]....
PS: What is the syntax for using AS2 code tags instead of just "[CODE|"?
I am having a problem instantiating a Character class inside of a game class.I am working on converting URL...l these tutorials to A.S. 2.0.[code]
View 2 RepliesThis is what i'm trying to do :
I have 1 class that extends movieclip, let's call it Class0. I have 1 class that extends movieclip, let's call it Class1.
I create an instance of Class0 on stage like : var myClip0:Class0 = new Class0(this, "Class1");
The class Class0 when initializing, will create a new movieclip (myClip1) and add it as child, as an instance of Class1, like myClip0.myClip1. But it's when i create that clip, i want to tell it, it's an instance of Class1, like :
private var myClip1:Class1 = new Class1(this);
Where Class1 could be any class.
How do i pass Class1 to Class0 so it can create it dynamically?? Do i have to use the apply function??
inside Class0, i have a function that does :
Code:
if(subClass){
initSubclass(subClass);
}
[Code].....
Performance wise, is it better to instantiate inside or outside the constructor?
Code:
public class example {
private var _mc:MovieClip = new Movieclip();
[code]......
I am very new to flash and on the net I've found a class that allows me to use a nice scroll bar for the content. My problem is that I can't get a preloader working with the class. When I want to add scrips to the frames it bugs the class if I try to implement the preloader inside the class I can't get it working. Here's the class I am using for the scroll bar. - if you want to test it, it will require additional data. You can get it all here: [URL].
package{
import flash.display.*;
import flash.text.*;
import flash.events.*;
import gs.TweenLite;
import com.warmforestflash.ui.FullScreenScrollBar;
public class Main extends Sprite{
[Code] .....
If I try to insert the preloader script inside the class it has problems with the stop(); & play(); commands. Any way to get a preferably simple preloader working with the class I am using?