Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-13-2009, 12:03 AM   #1
DominusV
n00b
 
Join Date: Sep 2009
Posts: 14
Default 1046: Type was not found or was not a compile-time constant: Timer.

1046: Type was not found or was not a compile-time constant: Timer.
1180: Call to a possibly undefined method Timer.

both referring to line: 14

Code:
package 
{
	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	
	


	public class HelloWorld3 extends MovieClip
	{
		public function HelloWorld3() 
		{
			var timer1:Timer = new Timer(1000);
			timer1.addEventListener(TimerEvent.TIMER, timerfunc);
			function timerfunc(event:TimerEvent)
			{
				this.graphics.beginFill(0x000000);
				this.graphics.drawCircle(event.target.currentCount*10,100,4);
			}
			timer1.start;
				
		}
	}
}
If anyone could help me, that'd be great. I'm new to AS3 and am trying to get the basics down.
DominusV is offline   Reply With Quote
Old 09-13-2009, 12:15 AM   #2
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

you simply need to import the corresponding class exactly like you do for the other classes you already import. I believe this is flash.utils.Timer.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 09-13-2009, 12:27 AM   #3
DominusV
n00b
 
Join Date: Sep 2009
Posts: 14
Default

Quote:
Originally Posted by ASWC View Post
you simply need to import the corresponding class exactly like you do for the other classes you already import. I believe this is flash.utils.Timer.
Alright, this is what I thought but didn't know what exactly I needed to import.

Is there an easy way for me to find out exactly I need to import in the future?
something i can google/reference
DominusV is offline   Reply With Quote
Old 09-13-2009, 12:57 AM   #4
attunedesigns
Helper monkey
 
attunedesigns's Avatar
 
Join Date: May 2009
Posts: 401
Default

Hit F1 in Flash CS3 for context-sensitive help (offline)... or go to adobe livedocs, which CS4 links to.
__________________
flash & design portfolio me.addEventListener(Life.Events.PARTY,partyHandler ,false,984);
attunedesigns is offline   Reply With Quote
Old 09-13-2009, 12:58 AM   #5
UncleNinja
I love noogies.
 
UncleNinja's Avatar
 
Join Date: Mar 2009
Location: Georgia, USA
Posts: 786
Default

Here's an idea.
If you're ever using a method or a class and you don't know where it came from, simply look it up here and click the link and see where it lives so you can import it properly.

Oh noes! The helper monkey beat me to it! Sorry attunedesigns.
__________________
-UncleNinja on Twitter

ActionScript Hints - a revolutionary wiki dedicated to helping Flash developers
UncleNinja is offline   Reply With Quote
Old 09-29-2009, 03:55 PM   #6
geddesburg
Registered User
 
Join Date: Sep 2009
Posts: 1
Default

I've created a simple function that has a move sequence in it. I want it to be available to all my mxmls, so I put in a separate actionscript file. Here's the code:

package com.esri.solutions.flexviewer.widgets.Scripts
{
import mx.effects.Sequence;
import mx.effects.Move;

public class No extends Sequence
{
public function No() {
super();

var moveEffect:mx.effects.Move;

moveEffect = new Move(this.target);
moveEffect.duration = 100;
moveEffect.xBy = -10;
this.addChild(moveEffect);

moveEffect = new Move(this.target);
moveEffect.duration = 200;
moveEffect.xBy = 20;
this.addChild(moveEffect);

moveEffect = new Move(this.target);
moveEffect.duration = 100;
moveEffect.xBy = -10;
this.addChild(moveEffect);
}
}
}

Then, in one of my mxmls I imported my script using:

import com.esri.solutions.flexviewer.widgets.Scripts.No;

Finally, I try and use my sequence:

<Scripts:No id="NoSequence" target="{radioPermitExisting}"/>

I get the following error:

Type was not found or was not a compile-time constant:No.

I find this very confusing, since I was able to point to the No function when importing. Any ideas? Thanks,

Mark
geddesburg is offline   Reply With Quote
Old 02-06-2010, 06:18 AM   #7
stublue
Registered User
 
Join Date: Feb 2010
Posts: 5
Default

Quote:
Originally Posted by DominusV View Post
1046: Type was not found or was not a compile-time constant: Timer.
1180: Call to a possibly undefined method Timer.

both referring to line: 14

Code:
package 
{
	import flash.display.*;
	import flash.text.*;
	import flash.events.*;
	
	


	public class HelloWorld3 extends MovieClip
	{
		public function HelloWorld3() 
		{
			var timer1:Timer = new Timer(1000);
			timer1.addEventListener(TimerEvent.TIMER, timerfunc);
			function timerfunc(event:TimerEvent)
			{
				this.graphics.beginFill(0x000000);
				this.graphics.drawCircle(event.target.currentCount*10,100,4);
			}
			timer1.start;
				
		}
	}
}
If anyone could help me, that'd be great. I'm new to AS3 and am trying to get the basics down.
I get exactly the same error. This is my code, almost identical:

package
{
import flash.display.*;
import flash.text.*;
import flash.events.*;

public class UsingTimers extends MovieClip
{
public function UsingTimers()
{
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, timerFunction);
myTimer.start();
//addChild(myTimer);
function timerFunction(event:TimerEvent)
{
this.graphics.beginFill(0x000000);
this.graphics.drawCircle(event.target.currentCount *10,100,4);
}

}
}
}

and the errors

1046: Type was not found or was not a compile-time constant: Timer.
1180: Call to a possibly undefined method Timer.

I tried adding - import flash.utils.Timer; and got this error

TypeError: Error #1010: A term is undefined and has no properties.
at MethodInfo-1()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

I also tried - import flash.events.TimerEvent; but got same errors as the first time.


I am listening here but it ain't working. I can't see where I've gone wrong?

Last edited by stublue; 02-06-2010 at 06:20 AM.
stublue is offline   Reply With Quote
Old 02-06-2010, 09:24 AM   #8
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,673
Send a message via Skype™ to henke37
Default

The error is due to the currentCount property either being misspelled or not existing to begin with.
__________________
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Old 02-06-2010, 11:05 AM   #9
stublue
Registered User
 
Join Date: Feb 2010
Posts: 5
Default

Quote:
Originally Posted by henke37 View Post
The error is due to the currentCount property either being misspelled or not existing to begin with.
it's definitely not mispelled, it's highlighted in blue and exactly like it is out of the book.

Perhaps then you mean I need to define a variable called "currentCount"?

thanks for being patient I'm quite new to as3 and the book occasionally leaves bits out

also, then do you think I should put "import flash.utils.Timer;" back in to the code?

Last edited by stublue; 02-06-2010 at 11:07 AM.
stublue is offline   Reply With Quote
Old 02-06-2010, 11:45 AM   #10
dhil dhil senthil
Flash+Math=Magic
 
dhil dhil senthil's Avatar
 
Join Date: Jul 2009
Location: Chennai
Posts: 340
Default Inner function does not recongnising "this"

ActionScript Code:
package {     import flash.display.*;     import flash.text.*;     import flash.events.*;     import flash.utils.Timer;     public class UsingTimers extends MovieClip {         public function UsingTimers() {             var THIS=this             var timerFunction=function(event:TimerEvent) {                 THIS.graphics.beginFill(0x000000);                 THIS.graphics.drawCircle(event.target.currentCount *10,100,4);             }             var myTimer:Timer=new Timer(1000);             myTimer.addEventListener(TimerEvent.TIMER, timerFunction);             myTimer.start();         }     } }
Hope it helps. It gives a interesting output. Thanks stublue.

Last edited by dhil dhil senthil; 02-06-2010 at 11:53 AM.
dhil dhil senthil is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:10 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.