PDA

View Full Version : Adobe's code only, still not compiling


saumya
04-06-2006, 12:43 PM
Hi,
I have the code below, downloade from Adobe labs, but it its not compiling.Can you tell me whats wrong

/*
Macromedia(r) Source Code License Agreement
Copyright(c) 2005 Macromedia, Inc. All rights reserved.

Please read this Source Code License Agreement carefully before using
the source code.

Macromedia, Inc. grants to you a perpetual, worldwide, non-exclusive,
no-charge, royalty-free, irrevocable copyright license, to reproduce,
prepare derivative works of, publicly display, publicly perform, and
distribute this source code and such derivative works in source or
object code form without any attribution requirements.

The name "Macromedia" must not be used to endorse or promote products
derived from the source code without prior written permission.

You agree to indemnify, hold harmless and defend Macromedia from and
against any loss, damage, claims or lawsuits, including attorney's
fees that arise or result from your use or distribution of the source
code.

THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package {

import flash.display.Sprite;
import flash.events.TimerEventType;
import flash.events.TimerEvent;
import flash.util.Timer;

import flash.util.trace;

public class TimerExample extends Sprite
{
private var ticks:uint;

public function TimerExample()
{
ticks = 0;
var timer:Timer = new Timer( 1000, 10 ); // delay, repeat
timer.addEventListener( TimerEventType.TIMER, onTick );

timer.start(); // returns immediately
trace("START ---");
}

private function onTick( event:TimerEvent )
{
ticks++;
trace( "Tick " + ticks + "!" );
if( ticks == 10 )
trace("END ---");
}
}
}

max_dev
04-26-2006, 03:05 PM
flash.events.TimerEventType is bad:
only flash.events.Timer exist.

package {

import flash.display.Sprite;
//import flash.events.TimerEventType;
import flash.events.TimerEvent;
import flash.util.Timer;

import flash.util.trace;

public class TimerExample extends Sprite
{
private var ticks:uint;

public function TimerExample()
{
ticks = 0;
var timer:Timer = new Timer( 1000, 10 ); // delay, repeat
//timer.addEventListener( TimerEventType.TIMER, onTick );
timer.addEventListener( TimerEvent.TIMER, onTick );

...
}

private function onTick( event:TimerEvent )
{
...
}
}
}
Now, it work

saumya
04-26-2006, 03:20 PM
That was the old code, which was built for beta1.Now with your code,max_dev, everything works fine.But there is some minor misout, the return type in "onTick" method.Thank you verymuch for the reply.

package {

import flash.display.Sprite;
//import flash.events.TimerEventType;
import flash.events.TimerEvent;
import flash.util.Timer;

import flash.util.trace;

public class TimerExample extends Sprite
{
private var ticks:uint;

public function TimerExample()
{
ticks = 0;
var timer:Timer = new Timer( 1000, 10 ); // delay, repeat
//timer.addEventListener( TimerEventType.TIMER, onTick );
timer.addEventListener( TimerEvent.TIMER, onTick );

timer.start(); // returns immediately
trace("START ---");
}

private function onTick( event:TimerEvent ):void
{
ticks++;
trace( "Tick " + ticks + "!" );
if( ticks == 10 )
trace("END ---");
}
}
}

max_dev
04-26-2006, 03:54 PM
Sorry, return type dismiss from the mind :)