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

Problem adding tooltip on other frames

Explorer ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

Hi All,

I'm fairly new to AS3 and have been working with some premade code. I am able to get this script and class file attached to my Flash file, and I can add the tooltip to a movie clip on my stage as well as a child movie clip.

The problem I'm seeing now is that the script can't initialize if I put the tooltip on a different frame than the first frame of a child movie clip.

I have tweening and need these tooltips to only be available at certain points in the .swf, not all from the first frame.

/**
Font Notes :

notes, cannot have embedded and non embedded fonts in 1 field.

if using a stylesheet and an embedded font, the font-family:NAME must equal the actual name of the font,
not the linkage class. 

if using textformat create a new instance of the linkage class:
var font:LINKAGE = new LINKAGE();
tf.font = font.fontName;
*/

package {


import assets.com.hybrid.ui.ToolTip;
import flash.display.*;
import flash.events.*;
import flash.utils.*;

import flash.text.*;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.system.*;

import flash.net.URLLoader;
    import flash.net.URLRequest;
import flash.events.IOErrorEvent;


public class Application extends MovieClip {
 
 
  private var _tf:TextField;
   private var _timer:Timer;
  private var _reusableTip:ToolTip;
  private var _sheet:StyleSheet = new StyleSheet();
 
 
  public function Application(){
 
   this.loadStyleSheet();

   _reusableTip = new ToolTip();
   _reusableTip.hook = true;
   _reusableTip.cornerRadius = 20;
   _reusableTip.tipWidth = 400;
   _reusableTip.align = "right";
   _reusableTip.border = 0xadd483;
   _reusableTip.borderSize = 5;
  }
 
  private function loadStyleSheet():void {
   var loader:URLLoader = new URLLoader();
   loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
            loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
   var req:URLRequest = new URLRequest("assets/styles.css");
            loader.load(req);
  }

        public function errorHandler(event:IOErrorEvent):void {
   event.currentTarget.removeEventListener(event.type, arguments.callee);
            //inputField.htmlText = "Couldn't load the style sheet file.";
        }

        public function loaderCompleteHandler(event:Event):void {
   event.currentTarget.removeEventListener(event.type, arguments.callee);
   var loader:URLLoader = URLLoader(event.target);
   this._sheet.parseCSS(loader.data);
   this.initialize();
        }
 
  private function initialize():void {
    //level1.level2.buttonMode = true;
    main_mc.level1.addEventListener( MouseEvent.MOUSE_OVER, this.onMouseOver );
    // level1.level2.addEventListener( MouseEvent.MOUSE_DOWN, this.omd );
    main_mc.test2_mc.addEventListener( MouseEvent.MOUSE_OVER, this.onMouseOver_test2_mc );
    //this.debug();
  }
 
  private function omd( event:MouseEvent ):void {
   _reusableTip.setContent( "Set A New Title", "Set Some New Content, A Little Less Than Before." );
  }
 
  private function onMouseOver( event:MouseEvent ):void {
  
   /*
   _reusableTip = new ToolTip();
   _reusableTip.hook = true;
   _reusableTip.cornerRadius = 20;
   _reusableTip.tipWidth = 260;
   _reusableTip.align = "right";
   _reusableTip.border = 0xFF0000;
   _reusableTip.borderSize = 5;
   */
   _reusableTip.show( main_mc.level1, "Safety", "We often work in harsh conditions and with potentially dangerous equipment. The first, last, and ongoing focus of all PRECorp activities is the safe work ethic employees." );
   //this.traceDisplayList( stage );
  }
  private function onMouseOver_test2_mc( event:MouseEvent ):void {
  
   _reusableTip.show( main_mc.test2_mc, "Hi", "Some Text" );
  } 
   
//  private function debug():void {
//    Memory Testing
//   _tf = new TextField()
//   addChild( _tf );
//   this._timer = new Timer( 25 );
//   this._timer.addEventListener( "timer", onTimer );
//   this._timer.start();
//  }
// 
//  private function onTimer( event:TimerEvent ):void {
//   _tf.text = flash.system.System.totalMemory.toString()
//  }
// 
//  function traceDisplayList(container:DisplayObjectContainer, indentString:String = ""):void{
//   var child:DisplayObject;
//   for (var i:uint=0; i < container.numChildren; i++)
//   {
//    child = container.getChildAt(i);
//    trace(indentString, child, child.name);
//    if (container.getChildAt(i) is DisplayObjectContainer)
//    {
//     traceDisplayList(DisplayObjectContainer(child), indentString + "    ")
//    }
//   }
//  }


}
}

The error I get is:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at Application/initialize()

at Application/loaderCompleteHandler()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at flash.net::URLLoader/onComplete()

thanks for your help,

John

TOPICS
ActionScript

Views

870

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 Expert ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

on line 78 you're trying to reference an object that doesn't exist when that line executes.

if that's not enough info for you to solve the problem, indicate which line is 78.

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
Explorer ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

Hi kglad,

Line 78 is: "main_mc.test2_mc.addEventListener( MouseEvent.MOUSE_OVER, this.onMouseOver_test2_mc );"

This movie clip is throwing the error because it is not on frame 1. So, I need some kind of Enter_Frame event listener maybe?

How would I add that to this?

Thanks,

John

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 Expert ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

which movieclip is not on frame one of which timeline, main_mc on the main timeline or test2_mc on main_mc's timeline?

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
Explorer ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

Hi kglad,

main_mc holds the animation that has multiple frames. test2_mc is the movie clip that I want to initiate the tooltip on that is within main_mc. I'm think the problem is that the AS3 needs an event handler. I'm using this tooltip: http://blog.hy-brid.com/flash/25/simple-as3-tooltip/

Is there a way I can cut the code out of the class and put it only on the frame in the timeline that I need it to be?

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 Expert ,
Jun 06, 2013 Jun 06, 2013

Copy link to clipboard

Copied

LATEST

you can use timeline code but, that's not a good idea.

what causes main_mc to move to a frame where test2_mc exists?

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