Skip navigation
~AMH~
Currently Being Moderated

TypeError: Error #1010: A term is undefined and has no properties.

May 4, 2010 11:40 AM

Hello,

 

Having a bit of trouble with some AS3.  Any help you can provide would be very appreciated.

 

Error:

TypeError: Error #1010: A term is undefined and has no properties.

 

Code:

var soundReq:URLRequest = new URLRequest("audio05.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);

sound.addEventListener(Event.COMPLETE, onComplete);

function onComplete(event:Event):void
{
sound.play();
}

var mySoundChannel:SoundChannel;
var isPlaying:Boolean = false;
var pos:Number = 0;

play_btn.addEventListener(MouseEvent.CLICK, play_);
function play_(event:Event):void
{
if (!isPlaying)
{
mySoundChannel = sound.play(pos);
isPlaying = true;
}
}

pause_btn.addEventListener(MouseEvent.CLICK, pause_);
function pause_(event:Event):void
{
if (isPlaying)
{
pos = mySoundChannel.position;
mySoundChannel.stop();
isPlaying = false;
}
}

stop_btn.addEventListener(MouseEvent.CLICK, stop_);
function stop_(event:Event):void
{
if (mySoundChannel != null)
{
mySoundChannel.stop();
pos = 0;
isPlaying = false;
}
}

var rectangle:Rectangle = new Rectangle(0,0,48,0);
var dragging:Boolean = false;

volume_mc.mySlider_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
function startDragging(event:Event):void

{
volume_mc.mySlider_mc.startDrag(false,rectangle);
dragging = true;
volume_mc.mySlider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
}

function adjustVolume(event:Event):void
{
var myVol:Number = volume_mc.mySlider_mc.x / 48;
var mySoundTransform:SoundTransform = new SoundTransform(myVol);
if (mySoundChannel != null)
{
mySoundChannel.soundTransform = mySoundTransform;
}
}

stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
function stopDragging(event:Event):void
{
if (dragging)
{
dragging = false;
volume_mc.mySlider_mc.stopDrag();
}
}

 

Thank you,

 

~AMH~

 
Replies
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    May 4, 2010 11:48 AM   in reply to ~AMH~

    click file/publish settings/flash/ and tick "permit debugging".  retest.

     

    copy and paste the error message and highlight or otherwise indicate the line of code mentioned in the error message.

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    May 4, 2010 1:39 PM   in reply to ~AMH~

    then volume_mc.mySlider_mc doesn't exist when that line of code executes.

     

    check for typos first.  if you see none, just above that line 51 use:

     

     

    trace(volume_mc.name);


    for(var i:uint=0;i<volume_mc.numChildren;i++){

    trace(volume_mc.getChildAt(i).name);

    }

     
    |
    Mark as:
  • kglad
    63,069 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 8, 2010 2:06 PM   in reply to ~AMH~

    1 month later is not much of a priority.

     

    anyway, something on line 79 of frame 1 doesn't exist when your code executes.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 4, 2012 11:22 AM   in reply to ~AMH~

    At this line,

    volume_mc.mySlider_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragging)

     

    add the line:


    trace("Volume MC Slider: " + volume_mc.mySlider_mc);

     

    If I'm correct this will come up as "null". Odds are, your slider is not named mySlider_mc or it is perhaps nested in another MovieClip.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points