• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Compiling error from var isPlaying:Boolean = true;

New Here ,
Oct 18, 2012 Oct 18, 2012

Copy link to clipboard

Copied

I need help with correcting a compiling error from the code listed below. The  error reads as follows:

Scene 1, Layer 'actions', Frame 1, Line 101152: A conflict exists with inherited definition flash.display:MovieClip.isPlaying in namespace public.

Thanks in advance. Here's my code:

import flash.events.MouseEvent;

import flash.geom.Rectangle;

import flash.events.Event;

//define constraints to keep thumb inside of bar

var constraint:Rectangle = new Rectangle (bar.x, bar.y, bar.width-thumb.width, 0);

var ratio:Number = animatedBug.totalFrames / (bar.width - thumb.width);

var isPlaying:Boolean = true;

//make the movie clip behave like a button

thumb.buttonMode = true;

durr.text = String(animatedBug.totalFrames);

animatedBug.stop();

thumb.addEventListener(MouseEvent.MOUSE_DOWN, handleDown);

stage.addEventListener(MouseEvent.MOUSE_UP, handleUp);

addEventListener(Event.ENTER_FRAME, trackPlayback);

function handleDown(e:MouseEvent):void {

    //pass in the constrain to contain thumb within bar

    e.target.startDrag(false, constraint);

    addEventListener(Event.ENTER_FRAME, trackthumbPos);

    removeEventListener(Event.ENTER_FRAME, trackPlayback);

}

function handleUp(e:MouseEvent):void {

    thumb.stopDrag();

    removeEventListener(Event.ENTER_FRAME, trackthumbPos);

    addEventListener(Event.ENTER_FRAME, trackPlayback);

    if (animatedBug.isPlaying == true) {

        animatedBug.play();

    } else {

        animatedBug.stop();

    }

}

function trackthumbPos(e:Event):void {

    var dif:Number = thumb.x - bar.x;

    curr.text = String(animatedBug.currentFrame);

    animatedBug.gotoAndStop(Math.ceil(dif * ratio));

}

function trackPayback(e:Event):void {

    if(isPlaying == true) {

        thumb.x = bar.x + (animatedBug.currentFrame / ratio);

    }

    curr.text = String(animatedBug.currentFrame);

}

TOPICS
ActionScript

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 19, 2012 Oct 19, 2012

Copy link to clipboard

Copied

AS3 accept only unique properties names. You application is an instance (subclass) of flash.display.MovieClip. MovieClip already has this properly, so you cannot declare another one with the same name.

Since MovieClip.isPlaying is read-only - you also cannot override setter. Thus - your only option is to use another name for your isPlaying variable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 19, 2012 Oct 19, 2012

Copy link to clipboard

Copied

Hello Andrei1/Ned,

I followed your recommendations by changing the isPlaying variable to jumpStart as well as cleaning up the code a bit. The code now works. Many Thanks!

import flash.events.MouseEvent;

import flash.geom.Rectangle;

import flash.events.Event;

//define constraints to keep thumb inside of bar

var constraint:Rectangle = new Rectangle (bar.x, bar.y, bar.width-thumb.width, 0);

var ratio:Number = animatedBug.totalFrames / (bar.width - thumb.width);

var jumpStart:Boolean = true;

//make the movie clip behave like a button

thumb.buttonMode = true;

durr.text = String(animatedBug.totalFrames);

animatedBug.stop();

thumb.addEventListener(MouseEvent.MOUSE_DOWN, handleDown);

stage.addEventListener(MouseEvent.MOUSE_UP, handleUp);

addEventListener(Event.ENTER_FRAME, trackPlayback);

function handleDown(e:MouseEvent):void {

    //pass in the constrain to contain thumb within bar

    e.target.startDrag(false, constraint);

    addEventListener(Event.ENTER_FRAME, trackthumbPos);

    removeEventListener(Event.ENTER_FRAME, trackPlayback);

}

function handleUp(e:MouseEvent):void {

    thumb.stopDrag();

    removeEventListener(Event.ENTER_FRAME, trackthumbPos);

    addEventListener(Event.ENTER_FRAME, trackPlayback);

    if (jumpStart) {

        animatedBug.play();

    } else {

        animatedBug.stop();

    }

}

function trackthumbPos(e:Event):void {

    var dif:Number = thumb.x - bar.x;

    curr.text = String(animatedBug.currentFrame);

    animatedBug.gotoAndStop(Math.ceil(dif * ratio));

}

function trackPlayback(e:Event):void {

    if(jumpStart) {

        thumb.x = bar.x + (animatedBug.currentFrame / ratio);

    }

    curr.text = String(animatedBug.currentFrame);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 19, 2012 Oct 19, 2012

Copy link to clipboard

Copied

If I run your code I do not get that error, though I have to repair the code a bit to get there, so it is possible you have different or more code than what you posted.  The typo I found is that your code calls a function named trackPlayback, but it has a function named trackPayback (function trackPayback)

I believe the error you are getting results from possibly declaring the same variable (isPlaying) more than once though for the code you show it does not happen.  One thing I do notice is that you are using "isPlaying" and "animatedBug.isPlaying " and I cannot be sure if that is intended or not.

Just a note, a conditional test evaluates the true/false value of whatever argument is being tested, so in the case of Boolean values such as isPlaying, you do not need to check if it == true... you can simply use:   if(isPlaying)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 19, 2012 Oct 19, 2012

Copy link to clipboard

Copied

Adobe introduced isPlaying property in Flash 11. Code compiled for earlier versions will not throw the error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 05, 2016 Oct 05, 2016

Copy link to clipboard

Copied

LATEST

i cannot play mp3 with this code, when i change target publish from version 9 to version 11.4

But if i publish with target version 9, my sound is mute at all browsers. please help me, thanks

Screenshot_15.png

=============================================================

stop();

// Create the sound object

var snd:Sound = new Sound();

// Assign a var name for the sound channel

var channel:SoundChannel;

// Boolean value for button functions, to switch in the conditionals

var isPlaying:Boolean = false;

// Set the play buffer to 5 seconds, you can adjust this

var context:SoundLoaderContext = new SoundLoaderContext(5000, true);

// Load the requested URL sound into the snd var, along with context

snd.load(req, context);

// Create the play channel using snd

channel = snd.play(pausePosition); // Start playing

// Set "isPalying" to true initially

isPlaying = true;

// make play button show pause symbol

playBtn.gotoAndStop(2);

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

// New track play function

function newTrack():void {

  if (trackPlayNum < tracksInFolder) {

         channel.stop(); 

         trackPlayNum += 1;

      gotoAndPlay(2);

     } else {

         channel.stop(); 

         trackPlayNum = 1;

      gotoAndPlay(2);

     }

  // Always set pausePosition back to 0 here

  pausePosition = 0;

} /// Close newTrack function

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

// Listen for the onPlaybackComplete function directly below

channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);

// This onPlaybackComplete fires off when tracks finish playing

function onPlaybackComplete(event:Event) {

  // Run the newTrack() function above every time a song completes

  newTrack();

}

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

///  Get ID3 info for each track playing ////////////////////

snd.addEventListener(Event.ID3, onID3InfoReceived);

function onID3InfoReceived (event:Event):void {

  var songName:String;

  var artist:String;

  if (snd.id3.songName != null){

  songName = snd.id3.songName;

  } else {

  songName = "Title Unknown";

  }

  if (snd.id3.artist != null){

  artist = snd.id3.artist;

  } else {

  artist = "Unknown Artist";

  }

  // Now here we add the info to the songInfo text on stage

  songInfoClip.scrollingText.songInfo_txt.text = songName + "  -  "  + artist;

}

////// END ID3 Info Gathering

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

// Play & Pause Function //////////////////////////////////////////////////////

function playPause(event:MouseEvent):void {

  

   if (isPlaying == true) {

   

    pausePosition = channel.position;

       channel.stop();

    playBtn.gotoAndStop(1);

       isPlaying = false;

    } else {

  

       channel = snd.play(pausePosition);

    playBtn.gotoAndStop(2);

    isPlaying = true;

  }

}

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////

// Play Next Song Function ////////////////////////////////////

function nextSound(event:MouseEvent):void {

    

  if (trackPlayNum < tracksInFolder) {

           if (snd.bytesLoaded != snd.bytesTotal) {

          channel.stop();

  snd.close();

                     trackPlayNum += 1;

                  gotoAndPlay(2);

           } else {

          channel.stop(); 

                     trackPlayNum += 1;

                  gotoAndPlay(2);

           }

     } else {

           if (snd.bytesLoaded != snd.bytesTotal) {

          channel.stop();

  snd.close();

                     trackPlayNum = 1;

                 gotoAndPlay(2);

           } else {

         channel.stop();

                    trackPlayNum = 1;

                 gotoAndPlay(2);

           }

     }

  pausePosition = 0;

}

////////////////////////////////////////////////////////////////////////////////////

// Play Previous Song Function //////////////////////////////

function previousSound(event:MouseEvent):void {

      

  if (trackPlayNum == 1) {

        

  if (snd.bytesLoaded != snd.bytesTotal) {

          channel.stop();

  snd.close();

                     trackPlayNum += 1;

                  gotoAndPlay(2);

           } else {

                 channel.stop();

                    trackPlayNum = tracksInFolder;

                 gotoAndPlay(2);

           } 

  } else {

  

           if (snd.bytesLoaded != snd.bytesTotal) {

         channel.stop();

  snd.close();

                    trackPlayNum -= 1;

                 gotoAndPlay(2);

           } else {

         channel.stop();

                    trackPlayNum -= 1;

                 gotoAndPlay(2);

           } 

  

  }

  pausePosition = 0;

}

////////////////////////////////////////////////////////////////////////////////////

// Button Listeners ///////////////////////////////////////////////////////////////////////

playBtn.addEventListener(MouseEvent.CLICK, playPause);

previousBtn.addEventListener(MouseEvent.CLICK, previousSound);

nextBtn.addEventListener(MouseEvent.CLICK, nextSound);

//autoPlayIcon.addEventListener(MouseEvent.CLICK, toggleAutoPlay);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////// AutoPlay Function ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*function toggleAutoPlay ():void {

}*/

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  ///////////////   Track Scrubber and Ghost Scrub Knob /////////////////////////////////////////////////////////////////////////////////

// ------------------------------------------------------------------ Along with the follower clip inside the trackScrubber

var isDragging:Boolean;

trackScrubber.ghostKnob.visible = false;

// Set Bounds

var scrubberBounds = new Rectangle(0,trackScrubber.ghostKnob.y,trackScrubber.scrubberRect.width,0);

trackScrubber.addEventListener(MouseEvent.MOUSE_DOWN, dragScrub);

stage.addEventListener(MouseEvent.MOUSE_UP, dropScrub);

         // Drag scrubber

  function dragScrub(evt:Event):void {

  trackScrubber.ghostKnob.startDrag(true,scrubberBounds);

  trackScrubber.ghostKnob.visible = true;

            isDragging = true;

  }

         // Drop scrubber

  function dropScrub (evt:Event):void {

             if (isPlaying == true) {

  if (isDragging == true) {

                     stopDrag();

  // Calculate full time of this track

  var fullTime:int = Math.floor(snd.length / 1000);

  // Claim a var for the position the song is where we release the scrubber after dragging

                  var newPos:Number = fullTime / 100 * Math.floor(trackScrubber.ghostKnob.x * 1000);

  // Important to set new pause position here

                  pausePosition = newPos / 2;

  channel.stop();

  gotoAndPlay(2);

                  //channel = snd.play(newPos);

  isPlaying = true;

  isDragging = false;

   }

  } else { // if not playing

  isDragging = false;

  trackScrubber.ghostKnob.visible = false;

  //pausePosition = fullTime / 100 * Math.floor(trackScrubber.tBarKnob.x * 1000);

  }

  }

///////////////   End Track Scrubber and Seek Bar //////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Add listener to trigger [onEnterFrame] function below

addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(event:Event):void {

  // Set and change volume if they drag

    var volumeLevel = channel.soundTransform;

  var newLevel:Number = (volumeSlider.knob.x) / -100;

  volumeLevel.volume = newLevel;

  channel.soundTransform = volumeLevel;

  volumeSlider.volumeLightBar.width = volumeSlider.knob.x;

  // Set and change pan if they drag

  var panLevel = channel.soundTransform;

  var newPan:Number = (panSlider.knob.x / 100) - 1;

  panLevel.pan = newPan;

  channel.soundTransform = panLevel;

    // SPEAKER 1 BOUNCE (left channel)

    spkr1.width = ( Math.round(channel.leftPeak * 8) ) + 60; // 60 is speaker width

    spkr1.height = ( Math.round(channel.leftPeak * 8) ) + 60; // 60 is speaker height

    // SPEAKER 2 BOUNCE (right channel)

    spkr2.width = ( Math.round(channel.rightPeak * 8) ) + 60; // 60 is speaker width

    spkr2.height = ( Math.round(channel.rightPeak * 8) ) + 60; // 60 is speaker height

  // ANIMATED EQ BARS MASK CODE

    maskEQ1.width = (Math.round(channel.leftPeak * 27) ); // 27 is the width of the EQ masks

    maskEQ2.width = (Math.round(channel.rightPeak * 27) ); // 27 is the width of the EQ masks

  bars1.mask = maskEQ1;

  bars2.mask = maskEQ2;

  // Get full time

  var tallytime = (snd.length/1000);

  var totalmins:Number = Math.floor(tallytime /60);

  var totalsecs = Math.floor (tallytime) % 60;

  if (totalsecs < 10){

  totalsecs = "0" + totalsecs;

  }

  displayFullTime.text = ( " " + totalmins+ ":" + totalsecs);

  // End get Full time

  // Get playing time

  var totalSeconds:Number = channel.position/1000;

  var minutes:Number = Math.floor(totalSeconds /60);

  var seconds = Math.floor (totalSeconds) % 60;

  if (seconds < 10){

  seconds = "0" + seconds;

  }

  displayTime.text = ( " " + minutes+ ":" + seconds);

  // End get playing time

  /// progress bar code...

  var estimatedLength:int = Math.ceil(snd.length / (snd.bytesLoaded / snd.bytesTotal));

  var playbackPercent:uint = 100 * (channel.position / estimatedLength );

  // I want my position bar to be 200 pixels wide on completion so I multiply the percentage x 2

  trackScrubber.positionBar.width = playbackPercent * 2;

  trackScrubber.follower.x = trackScrubber.positionBar.width;

  // make the loaded progress bar that lives under the playhead progress bar grow dynamically

  var loadedPercent:uint = 100 * (snd.bytesLoaded / snd.bytesTotal);

  trackScrubber.loadedProgressBar.width = loadedPercent * 2;

}

// Place track amount and current track # into a text field

songCount_txt.text = "Track " + trackPlayNum + " of " + tracksInFolder;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines