events not caught... loadMovie movieClip onRollOver

View: New views
1 Messages — Rating Filter:   Alert me  

events not caught... loadMovie movieClip onRollOver

by Marcello James :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello :)

when you use a loadMovie your movieclip is delete by the FlashPlayer ...

1 - use a movieclip in your container and apply the onRollOver event on the
container

2 - use MovieClipLoader class (existe in MX2004 & Flash8)

var loader:MovieClipLoader = new MovieClipLoader() ;

var url_up:String = "final-fond.jpg" ;
var url_down:String = "final-fond-down.jpg" ;

var bt:MovieClip = _target.createEmptyMovieClip("container", 1);
var picture:MovieClip = bt.createEmptyMovieClip("picture", 1) ;

loader.loadClip( picture , url_up ) ;

bt.onRollOver = function () {
   loader.loadClip( this.picture, url_down ) ;
}

.... but it's more easy use flash.display.BitmapData class to keep the
bitmaps (2 jpg) in memory and use it with draw's API -> use attachBitmap
method :
import flash.display.BitmapData ;
import flash.geom.Rectangle ;

var bmp:BitmapData = new BitmapData(100, 139) ;


var onLoadInit:Function = function ( target:MovieClip ) {

    trace("> onLoadInit : " + target) ;
    bmp.draw(target) ;

    target.removeMovieClip() ; // remove the container

}

var loadBitmap:Function = function ( url ):Void {
    var mc:MovieClip = createEmptyMovieClip("container", 10000) ;
    var loader:MovieClipLoader = new MovieClipLoader() ;
    loader.addListener(this) ;
    loader.loadClip(url, mc) ;
}


var url:String = "picture/picture.jpg" ;
loadBitmap(url) ;

var picture:MovieClip = createEmptyMovieClip("picture", 1) ;
picture._x = 100 ;
picture._y = 100 ;

Key.addListener(this) ;
onKeyDown = function () {

    picture.attachBitmap(bmp, 1) ;

}

You can load at the begining of you animation the bt views.... and use this
method to implement your visual in onRollOver etc... :)

PS : sorry for my english

EKA+ :)


2006/7/23, Raphaël ARBUZ <raphaelarbuz at netcourrier.com>:

>
>  Hi to all of you,
>
>I'm a very beginner in ActionScript and MTASC especially and here is my
>prob:
>
>I have following code below, but the "onRollOver" method is never
>called.... I tried with other events with no more success: looks like no
>events are handled.
>
>Any clue?
>
>Thanks very much,
>
>Raph
>
>My code:
>
>class FameMain{
>
>  static function main():Void
>  {
>   var recorder:Recorder = new Recorder();
>  }
>
>}
>
>class Recorder {
>
>  public var _target:MovieClip = _root;
>  public var vSkin:MovieClip;
>  public function Recorder() {
>       this.vSkin= this._target.createEmptyMovieClip("skin_mc",
>this._target.getNextHighestDepth());
>       this.vSkin.loadMovie("final-fond.jpg");
>       this.vSkin.onRollOver = function() {
>              this.loadMovie("final-fond-down.jpg");
>       }
>  }
>}
>
>--
>MTASC : no more coffee break while compiling
>
>


#####################################
#####################################

I found that the 'loadClip version' of the above code did not work [Flash
Pro 8].  I don't have time to investigate the all of the real reasons.  Code
below is what worked for me.


var holder = _root.createEmptyMovieClip("_holder", 10);  //determine which
levels you want to load
var mc = holder.createmptyMovieClip("mc", 15);             //into

loader.loadClip("your_image.gif", mc);  //per se actionscript reference
method definition

mc._x = 100;  //your movieclip positions
mc._y = 100;

Hope this helps others.

"The being that has not satisfied its needs dies." --E. Levinas

_________________________________________________________________
PC Magazine’s 2007 editors’ choice for best Web mail—award-winning Windows
Live Hotmail.
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_pcmag_0507


--
MTASC : no more coffee break while compiling