On Wed, 28 Mar 2007 18:14:50 -0400, Dennis Asher <[EMAIL PROTECTED]>
wrote:
I've managed to avoid OOP till now but AS3 is here and no choice now.
What's wrong in the class below? The code in the mouseover/mouseout
functions do not reference the textfield correctly. I've tried adding:
event.hello.visible = true;
and
event.target.hello.visible = true;
Hi Dennis,
Made a small change to your code by moving the variable hello outside of
the function and into
the level of the class so that all functions in the class can access this
variable
When you build you project I am assuming that you created a movie clip in
the library then in the properties you set the class to be Location. Then
dragged an instance of the Movieclip onto the stage and named it. The
thing you have to be aware of is that the mouseevents you are setting up
are associated with the movieclip and not the text field. It is the
rolling into and out of the movieclip that will change the visibility.
With this in mind you will have to have something occuping space in your
movie clip, create a filled square for example. If you don't have any
objects in your movieclip then the clip will not have any dimensions so a
mouseover will never be registered and you will never see the text appear.
You can also try adding the movieclip dynamically via actionscript by
having this in a frame script:
var my_mc:Location = new Location();
this.addChild(my_mc);
and you rollover effect will work as well.
hth,
Rob
---------
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.DisplayObjectContainer;
import flash.text.TextField;
public class Location extends MovieClip {
var hello:TextField = new TextField();
public function Location() {
addEventListener(MouseEvent.MOUSE_OVER,
mouseOverListener);
addEventListener(MouseEvent.ROLL_OUT, mouseOutListener);
addChild(hello);
hello.text = this.name;
hello.visible = false;
}
private function mouseOverListener(event:MouseEvent):void {
hello.visible = true;
}
private function mouseOutListener(event:MouseEvent):void {
hello.visible = false;
}
}
}
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com