Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








Event Handlers And Screens


OK, I've tried this a dozen ways and I hope one of you guru's out there can tell me where I'm going wrong:

I have a form application and I'm using a MenuBar component to try to navigate between forms - I'm able to capture the events for selected menu items but I can't seem to get the screens I want to become visible:

I went back to the basics and wrote one handler exactly like the documentation:

var listen = new Object();
listen.change = function(evt) {
var menu = evt.menu;
var item = evt.menuItem;
if (item == menu.searchMenu) {
this._parent.CDBscreen.setVisible(true);
}
}

Nothing happens - tracing the if() works - but the setVisible doesn't.
I've also tried "this._parent.CDBscreen.visible = true;" and even wrote a global function to take the event data in frame 1 screen 1 and do the reveal using the generated "Show Screen" code created from a behavior; all with the same result... nada...

Any ideas would be appreciated!

-Thanks
-DM




FlashKit > Flash Help > Flash ActionScript
Posted on: 06-25-2005, 08:51 PM


View Complete Forum Thread with Replies

Sponsored Links:

Custom Event Handlers - Triggering Event Listeners On Other Objects
I'm trying to update an object whenever something happens in another object. At the moment, I have the second object explicitly calling an update function on the first object, but this seems a little sloppy and it strikes me that this is the sort of scenario where I should be using custom event handlers.

I'm not quite sure how they work though. My first assumption is that if I built two objects, one like this which fires off an event:


Code:
public class eventFirer extends Sprite
{

public function eventFirer():void
{
dispatchEvent(new Event("customEvent"));
}
}
...and one like this which updates whenever the custom event happens:


Code:
public class eventListener extends Sprite
{

public function eventListener():void
{
trace ("main");
addEventListener("customEvent", eventFired);
}

private function eventFired(e:Event):void
{
trace ("ok");
}
}
...then eventListener.eventFired would automatically be set off whenever a new eventFirer is created. This seems not to be the case though.

Can anybody enlighten me as to how custom events bubble between otherwise unrelated objects?

View Replies !    View Related
Event Handlers Vs. Event Listeners
I'm having trouble understanding why listeners are necessary, beyond tying events to objects "conceptually." Are listeners used that often? What am I missing?

View Replies !    View Related
Event Handlers
Hi all,

I am trying to create a movie clip symbol and write some code for its rollOver event, then take this movie clip and add it to another movie clip where I want to write another rollOver event handler for it. Right now Flash uses the second event handler only. I would like to execute both.
The reasoning behind this is to create a base symbol to which i can add extra functionality based on the nesting level.

Any thanks would be greatly appreciated.
Michael

View Replies !    View Related
Event Handlers
One more question:

Do you think event handler-methods for MC's 'owned' by objects
should be declared inside the constructor (1) or outside the constructor(2)?

//(1)
funTest = function() {
this.reply = "Yeehaw fun klik";
this.mc = createEmptyMovieClip("FunMC", ++mcdepth);
this.mc.onRelease = function() {
trace(this.reply);
}
}
joy = new funTest();
//end

or maybe this way?

//(2)
hapyTest = function() {
this.reply = "Whee happy klikin";
this.mc = createEmptyMovieClip("HapyMC", ++mcdepth);

}
hapyTest.prototype.onRelease = function() {
trace(this.reply);
}
glad = new hapyTest();
//end

Not that I can get either example to actually to work, but you
understand the concept from these simplified examples
(sorry I am in a bit of rush)

y~

View Replies !    View Related
Event Handlers
OK , instead of troubling you with my code I'll try to simplify the problem:

someMC.onPress = function ()
{
trace (someVariable);
}

This will trace the variable's value at the time of pressing the button. But I want it to trace the value of the variable at the time the function was created . How can I do that?

View Replies !    View Related
Event Handlers
Hi,

When I want to ease a movieclip on the stage in x or y I would attach something like the following code to the movieclip:

onClipEvent(enterFrame)
{
_y+=(ygoal-_y)/2
}

giving ygoal the value of my final y position.

What I can't work out is if I am attaching the movieclip using attachMovie, how would I attach the above code so I can control so I can still ease the clip to whatever position I want?
Thanks

View Replies !    View Related
[F8] Event Handlers
Still new to the ActionScript scene, and working with a video program called CartoonSmart. Very good tutorials.

I have attached the file I am working on to help me understand event handlers and function references. However, this does not appear to want to work. I would like "engine" to disappear when clicked on, but instead, it just loops through the timeline. How would I fix this problem?

David

View Replies !    View Related
Event Handlers
Hi I hope someone can explain this to me so I can get the following to work. I have 2 questions about event handlers.

Ok so I have the code below...


Code:
var tween_handler:Object = new Tween(tabContent.photoHolder, "_alpha", Strong.easeIn, 100, 0, 1, true);
tween_handler.onMotionFinished = function() {
trace("onMotionFinished triggered");
mclPG.loadClip("event"+lastChar+"/"+this.myNumber+".jpg", tabContent.photoHolder);
};
My first question is how do I pass a variable (in this example lastChar) into the tween_handler.onMotionFinished function? For a regular function I would do the following callFunction(variable_to_pass) but I can't see how i do it in this case.

Second question is if I have the following part of the code in one movie and load into this movie a second swf which I want to use the onMotionFinished handler how do I refer to it? I can't seem to get the scope right (I am assuming this is possible)

So I have this code in main.swf


Code:
var tween_handler:Object = new Tween(tabContent.photoHolder, "_alpha", Strong.easeIn, 100, 0, 1, true);
I load child.swf into a mc called loader_mc which is on the root timeline of main.swf. I want to say, when the motion tween in main.swf has finished do something in child.swf

I tried putting the following on the first frame of child.swf but nothing happened.

Code:
_root.tween_handler.onMotionFinished = function() {
trace("onMotionFinished triggered");
};

Any help with either of these would be most appreciated.
Thanks

View Replies !    View Related
Event Handlers
I'm trying to run a calculation on some input fields. I want it to run one calculation if a certain radioButton is selected; I want it to run a different calculation if the other radioButton is selected. Would this be the correct way to create the eventhandler to determine which one should run?

public function change(event:Object):Void
{
if (event.target == increase, subtotal, percentRadio1); {
calculate();
}
if (event.target == increase, subtotal, percentRadio24); {
calculatesemi();
}
}

Thanks!

View Replies !    View Related
CS3 Event Handlers
I have a MovieClip that I am using as a button (which was previously possible in Flash 8). I created the up, over, and down frames in the button and am writing the AS3 code for the button. It looks like this:

import flash.events.MouseEvent;

function playMovie(event:MouseEvent):void
{
clip1.play();
}
function overState(event:MouseEvent):void {
playButton.gotoAndStop(5);
}
function downState(event:MouseEvent):void {
playButton.gotoAndStop(10);
}
function outState(event:MouseEvent):void {
playButton.gotoAndStop(1);
}

playButton.addEventListener(MouseEvent.CLICK, playMovie);
playButton.addEventListener(MouseEvent.MOUSE_OVER, overState);
playButton.addEventListener(MouseEvent.MOUSE_DOWN, downState);
playButton.addEventListener(MouseEvent.MOUSE_OUT, outState);

That's an awful lot of code for 1 button. If I had 5 or 6 buttons, that's a lot to edit. Is there an easier way to do this?

View Replies !    View Related
Mc Event Handlers In MX
hi-
i'm trying to make the paradigm shift to MX's movie clip event handers--here's where i'm stuck:
first, i'm dynamically attaching MCs for my menu:

menuArray = ["current", "play", "mfa", "resume", "contact"];

this.onLoad = function () {
mLen =menuArray.length;
//add menuMCs to stage ////
for (i=0; i<mLen; i++){
level=i+10;
myName=menuArray[i];
attachMovie("MENU_MC",myName,level);
//set init properties for each loaded MC
setProperty(myName, _x, markerX);
myW=getProperty(myName, _width);
myX=markerX+(i*myW);
setProperty(myName, _x, myX);
setProperty(myName, _y, 200);
setProperty(myName, _alpha, 80);
}
}

second, inside each mc is this code:

myName=this._name;

this.onMouseUp = function () {
trace(myName);
//_root.loadMenuMC(myName);
}

when i mouse up, each Name is traced, so it seems that this function is being activated in every menu MC that is loaded, and each is calling loadMenuMC with its name as the variable. i also tried this syntax:

myName.onMouseUp=
and _parent.myName.onMouseUp

so how do i differentiate the 'generic' MC function calls?

also, bonus points for telling me how variables can be passed from onLoad to onEnterFrame, etc. it seems when i tried it that the onEnterFrame didn't pick up any vars from onLoad.

any help in figuring this problem out and info on mc event handlers in general is much appreciated--
regards,
-mojo

View Replies !    View Related
For...in Event Handlers
I'm currently just testing a few items in Flash. While I'm in this early stage, it'd be quite handy for this particular project if there were a way to assign events to every item in a certain MC (or on _root).

Here's what I've done thus far:

ActionScript Code:
for (movieClip in _root) {    movieClip.onRollOver = function() {        this.gotoAndStop(2);    };    movieClip.onRollOut = function() {        this.gotoAndStop(1);    };    movieClip.onPress = function() {        this.gotoAndStop(3);    };    movieClip.onRelease = movieClip.onReleaseOutside=function () {        this.gotoAndStop(1);    };}


If I trace I can clearly see the instance names of the MCs (which means it works -- sort of), but no matter what I've tried I can't get the events to bind to the on-stage MCs.

Any / all help would be wonderful, though I'm not holding my breath on this even being possible at this point.

View Replies !    View Related
Event Handlers In MX
is event handlers make our life easier or not?

let say i have a MC named "A1"
now i apply AS to A1


ActionScript Code:
A1.onPress = function() {    function that make MC move from A to B};


now i need 10 more copies of A1
when i duplicate (copy Paste) this MC,
only i will follow the actionscript, the other will not.

do i need to make each one of the movieclip their own actionscript? can it just be one to control all 10 identical things?

View Replies !    View Related
For...in Event Handlers
I'm currently just testing a few items in Flash. While I'm in this early stage, it'd be quite handy for this particular project if there were a way to assign events to every item in a certain MC (or on _root).

Here's what I've done thus far:

ActionScript Code:
for (movieClip in _root) {    movieClip.onRollOver = function() {        this.gotoAndStop(2);    };    movieClip.onRollOut = function() {        this.gotoAndStop(1);    };    movieClip.onPress = function() {        this.gotoAndStop(3);    };    movieClip.onRelease = movieClip.onReleaseOutside=function () {        this.gotoAndStop(1);    };}


If I trace I can clearly see the instance names of the MCs (which means it works -- sort of), but no matter what I've tried I can't get the events to bind to the on-stage MCs.

Any / all help would be wonderful, though I'm not holding my breath on this even being possible at this point.

View Replies !    View Related
Event Handlers, More Than One
How to add more event handlers to one MC

if i have this

SKROLL.onRelease = function() {
this.dugme = false;
};

SKROLL.onDragOut = function() {
this.dugme = false;
};

how to put it in one line, to add both EH to SKROLL MC?

View Replies !    View Related
Event Handlers With Functions
Ok I am trying to get the hang of the new way of writing event handlers with functions and I can't seem to get the hang of it scope is the hardest thing here I have set up something I have done in flash 5 but in MX its a different story I simplified it so you can see where my problem is

Code:
init();
function init() {
//depth=0;
holder = createEmptyMovieClip("circleHolder", -1);
holder.xspd = 1.32;
holder.yspd = .56;
holder.xradius = 100;
holder.yradius = 100;
holder.onEnterFrame = dupCir;
}
function dupCir() {
cir = this.attachMovie("circle", "circle"+this.depth, this.depth++);
cir.angx += this.xspd;
trace(cir.angx);
//this.onEnterFrame = moveCir;
}
the trace comes out as 1.32 which is what this.xspd is but I am adding xspd all the time so it should be increasing but it is not what is wrong with this layout everything I seem to do in function and scope is going wrong.Pleas someone explain

View Replies !    View Related
Event Handlers On Dynamic MCs
Hello,

I need to create event handlers for movie clips that have been created dynamically. The structure that I have is something like this: I have a MC called project1 and inside I am dynamically creating the MC for which I need the event handlers. Could you please make any suggestions as to how to write them? I want to treat the MCs as buttons.

Thanks a lot for your help,
Fabocp

View Replies !    View Related
Event Handlers In Functions
I know how to use event handlers in function literals, as:

code: mc.onMouseDown = function(args) {
statements;
}

How would I define the event handler inside a normal function (for more flexibility)? I can't seem to find a good example anywhere.

TIA,
aaroneousmonk

View Replies !    View Related
Event Handlers Problem
Hi..

I'm using the Flash MX dynamic event handlers to do smooth motion and alpha fading, ie:


content.welcome.onEnterFrame=function(){
if(moveFlag==true){
floatTo(this,2,0,Ypos);
}
}

content.welcome.more.onRelease = function(){
moveFlag=true;
Ypos=-251;
}





this all works fine, apart from whne I navigat the MC content to a frame that does not contain the MC welcome, and back again.. the event handlers do not seem to re-register, and putting a trace in both the onRelease and onEnterFrame handlers brings up nothing..

I guess there must be a way round this.. any takers?

View Replies !    View Related
Array Event Handlers
i have a set of 14 buttons and i want all of them to call the same function onRelease. i know that i can code it as follows:

button1.onRelease = button2.onRelease = button3.onRelease = function() {
//do function thing here
}

my question is, can i create an array of all the buttons and their events and then use that in place of the list as shown above. i.e.

buttoncalls[] = function() {
do function thing here
}

if this is possible, what's the proper syntax. Thanks for your help .

View Replies !    View Related
Event Handlers Mixup
I have this attached to a MC

Code:
onClipEvent(load)
{
this.ucitano=10;
this.trenutno=10;
djelitelj=(_root.brojKarti+1)/2;
_parent.attachMovie("DMC","DM",1);
_parent.DM.loadMovie('znakovi\'+_parent._parent.poljeGlavno[0].broj+'.swf');
_parent.DM._alpha=0;
}


but when i turn this code to

nameOfClip.onLoad = function () {same as code that is up}

it doens't work at all? why is that? what is differnce between this 2? i know the other one is in fact method of MC, so should i refernence variables and MC's on some other way?

View Replies !    View Related
AS 2.0: Problem With Event Handlers
I've been making classes with AS 2.0 for a short while now and i've run into my first problem. I happens when i create an instance and call a method of a class, all inside an onMouseDown() handler.

This works:
code:
var colTween:ColourTween7 = new ColourTween7(box, "ff00ff");

_root.onMouseDown = function(){

colTween.beginHex("0099cc", 30, 300);
}

but this doesn't and i can't figure it out:
code:
_root.onMouseDown = function(){
var colTween:ColourTween7 = new ColourTween7(box, "ff00ff");
colTween.beginHex("0099cc", 30, 300);
}


i don't understand!

Dene

View Replies !    View Related
Event Handlers & Func & Arg.
I have made a function "pLoader"
and i want to attach it to MC with event handler
like this

_root.loader.progress.onEnterFrame = pLoader;

and this works.
But what i realls need is to make function with variable like this
function pLoader(nesto) {}
and then use it like this

_root.loader.progress.onEnterFrame = pLoader(_root);

but when i use () then this event handling does not work, why? and can i fix that somehow?

View Replies !    View Related
Using Event Handlers Within Classes (AS 2.0)
I am having a problem getting event handlers to work in my classes.

The problem is, if I specify code like

this.someobject.onLoad = myfunction;

Nothing happens when it loads.

But if I specify the following;

this.someobject.onLoad = myfunction();

The myfunction will actually run, however it runs before the onLoad event actually should be occuring. I am aware that the proper way to execute an event handler via a function is without the "()" but it just wont run.

Here is my code specifically;


PHP Code:



    private function logon() : Void
    {
        //----------------------------------------------------------------------
        /*
            Description: Called when user presses the submit button for logon
            Purpose: Sends and loads user provided authentication to server
        */
        //----------------------------------------------------------------------
        
        if (_level0.debug)iaDebuggo.sendMessage("Logon executed");
        if (_level0.debug)iaDebuggo.sendMessage("Attempting to load logon response from assets/phpinc/inc_logonProcess.php");
        if (_level0.debug)iaDebuggo.sendMessage("Email Address: " + this.emailAddress);
        if (_level0.debug)iaDebuggo.sendMessage("Password: " + this.passwd);
        
        this.logonStatus = 1;
        
        this.logonTimer = setInterval(this.logonTimerTick, 100);
        
        var xmlString : String = "<iaLogonClass email_address="" + this.emailAddress + "" passwd="" + this.passwd + "" rPassword="" + this.rPassword + ""></iaLogonClass>";
        this.authObj = new XML(xmlString);
        this.authObjReply = new XML();
        this.authObj.contentType = "application/x-www-fla-urlencoded";
        this.authObjReply.onLoad = this.validateResponse;
        this.authObj.sendAndLoad("assets/rpc/iaLogonClassHandler.php", this.authObjReply);
    }
    
    private function validateResponse (success : Boolean) : Void
    {
        //----------------------------------------------------------------------
        /*
            Description: Called from function logon() after Flash has finished the
                         sendAndLoad for XML.
                        
            Purpose: Parses server response to determine if user has authenticated
        */
        //----------------------------------------------------------------------
        // Handle the XML data returned from the server
        var srvRetData : Array = new Array();
        srvRetData['authResult'] = this.authObjReply.firstChild.attributes.authResult;
        srvRetData['debuggo'] = this.authObjReply.firstChild.attributes.debuggo;
        srvRetData['setUser'] = this.authObjReply.firstChild.attributes.setUser;
        srvRetData['setpasswd'] = this.authObjReply.firstChild.attributes.setpasswd;
        srvRetData['testCookieU'] = this.authObjReply.firstChild.attributes.testCookieU;
        srvRetData['testCookieP'] = this.authObjReply.firstChild.attributes.testCookieP;
        
        if (_level0.debug)iaDebuggo.sendMessage("XML Return = " + srvRetData['debuggo']);
        
        if (srvRetData['authResult'] == null)
        {
            if (_level0.debug)iaDebuggo.sendMessage("No data found from server response");
            this.logonStatus = 4;
            clearInterval(this.logonTimer);
        }
        else
        {
            if (srvRetData['authResult'] == "1")
            {
                this.logonStatus = 2;
                clearInterval(this.logonTimer);
            }
            else if (srvRetData['authResult'] == "2")
            {                
                this.logonStatus = 3;
                clearInterval(this.logonTimer);
                this.launchGUI();
            }
        }                
    }




The two functions above are both from my class. I omitted the rest of the code that is not essential to trying to troubleshoot the problem.

The function "logon()" is called from an internal function within the class. Then, after the xml is loaded, the function "validateResponse" is supposed to be called. However, the function "validateResponse" never loads.

Any guidance would be appreciated

View Replies !    View Related
Event Handlers Being Overridden
Hi folks, I searched through old posts and didn't find a clear and definitive answer on how this issue is overcome.

To describe my problem, I have a movie clip object, that uses on(press) and on(release) to pan/drag the image around or place a dot (it's a map).

I need to be able to place these points on this map, and be able to drag the points around too. Now, the on(rollOver)/on(press)/on(release) event handlers on the Point movie clip are overridden by the parent map movie clip.

I've tried using functions but I highly doubt that I am not using them correctly. Could someone please clarify for me on what I need to do? Thank you.

aixagent

View Replies !    View Related
List Of ALL Event Handlers
hi there,

does anyone know where i can find a complete list of all flash event handlers (maybe on the mm dev site ?)
it's kind of tedious to look through the help files...

thanks

View Replies !    View Related
[F8] Assigning Event Handlers
In the book Actionscript for FlashMX - the definitive guide by Colin Moock, chapter 10 (page 223) about events and event handlers. He describes how to defind an event handler for an object:

ball.onEnterFrame = moveDown;
function moveDown ( ) {
// Move the ball down 5 pixels with each frame.
this._y += 5;
}

Then he says:

To be more succinct when assigning an event handler,we can specify the callback function with a function literal, as follows:
ball.onEnterFrame = function ( ) {
this._y += 5;
};

OK - now exaclty what does this mean? What is a "callback function" and what is a "function literal"?

View Replies !    View Related
Scope Of Event Handlers
OK, if I have an event handler defined on frame 1 of my main movie and there is a stop() function on the last frame (for arguments sake we'll say the last frame is frame 5), then my understanding is that as long as the event takes place after the event handler has been defined, it should carry out the event handler function....like in frame 5 for this example! What if I defined the event handler on frame 5 instead of frame 1 though? Would the event handler function still be executed if the movie has reached frame 5? I realize that the function can't be executed if it hasn't been defined yet, but if I tried to utilize it at frame 5 or beyond it should work, correct?

One last caveat....what if the event handler is defined on a MC that has been externally loaded via another swf file...what complications will this cause, or what considerations do I need to take into account to utilize this event handler?

Thanks for your help, much appreciated!

View Replies !    View Related
Understanding Event Handlers
I get the whole event listener / event handler thing for a button. What I'm not sure about is why I have to write "event:MouseEvent" when setting a function. If functionName is specified in the listener, shouldn't the handler know when to do it's thing?

Example:

buttonName.addEventListener(MouseEvent.CLICK, functionName);

function functionName(event:MouseEvent){

instanceName.x += 10;
}

Thanks!

View Replies !    View Related
[F8] Event Handlers Thing ?
hi,
I am not clear about the difference between onEnterframe() and onclipEvent
when to use which of these ?
**Does "enter frame mean that we must click the frame in timeline and paste/write code...
***Does "on movieClipEvent() mean that we should click the MC itself and paste code ?
which method and where ?
thanks.

View Replies !    View Related
Defining Event Handlers
I'm learning ActionScript now and I'm having a hard time defining Event Handlers. I know what to write, I understand it but I cannot define it. A Function is a block of code, a Method is a Function applied to an Object but how is an Event Handler defined ?

And..
for example:
Is all of that called an Event Handler or only part of it ?

Code:
mc_Square.onPress = function():Void {
this.startDrag();
}

View Replies !    View Related
Event Handlers On Inner Objects
Hello,
I have a component and it loads movies images etc. My component definition is like this.


Code:
function BannerLoader()
{
trace("Creating BannerLoader");
this.movie_x = 0;
this.movie_y = 0;
this.movie_is_paused = false;
this.current_frame = 0;

this.movie_mcl = new MovieClipLoader();
this.loader_handler = new Object();
this.movie_mcl.addListener(loader_handler);
}

BannerLoader.prototype = new MovieClip();

BannerLoader.prototype.loader_handler.onLoadInit = function(target_mc:MovieClip )
{
trace("MCL Loaded");
this.banner_mc._x = this.movie_x;
this.banner_mc._y = this.movie_y;
this.banner_mc.play();
this.banner_mc.Initialize( );
}
My problem is onLoadInit never invokes..Is there any problem on syntax or I miss something?

View Replies !    View Related
Event Handlers In Conflict
Hi!

i have a problem concerning event Handlers which are in conflict with each other.

what i would like to do:
i would like to assign a MOUSE_OVER on object a, which puts object b on visible.
object is assigned a drag handler. so when i move the mouse over a, b is supposed to
become visible so that i can drag it.
because a lies over b though, i get a strange flickering when moving over b. i guess
because the to events are in conflict with each other.

does anybody have an idea how to solve that problem. would be great if the mouse over handler
for a would also trigger, when i move over b. to me it sounds logical, because when the mouse
is over b it is also over a.

well, would be very glad for an advice.

thanks!

code:
--------------------------------
var rect_A:Sprite = new Sprite();
rect_A.graphics.beginFill(0xeeeeee);
rect_A.graphics.drawRect(0, 0, 200, 200);
rect_A.graphics.endFill();
addChild(rect_A);

var rect_B:Sprite = new Sprite();
rect_B.graphics.beginFill(0x000000);
rect_B.graphics.drawRect(100, 100, 60, 60);
rect_B.graphics.endFill();
rect_B.visible = false;
addChild(rect_B);


// Event Handler für rect_A
rect_A.addEventListener(MouseEvent.MOUSE_OVER, handler_mouseOver);
rect_A.addEventListener(MouseEvent.MOUSE_OUT, handler_mouseOut);

function handler_mouseOver(event:MouseEvent):void {
rect_B.visible = true;
}
function handler_mouseOut(event:MouseEvent):void {
rect_B.visible = false;
}

// Event Handler für rect_B
rect_B.addEventListener(MouseEvent.MOUSE_DOWN, handler_mouseDown);
rect_B.addEventListener(MouseEvent.MOUSE_UP, handler_mouseUp);

function handler_mouseDown(event:MouseEvent):void {
rect_B.startDrag()
}
function handler_mouseUp(event:MouseEvent):void {
rect_B.stopDrag()
}

View Replies !    View Related
Dynamic Event Handlers
I´ve been taking a look a this tutorial

http://www.kirupa.com/developer/acti...namicevent.htm

And there is a piece of code that confuses me:


PHP Code:



goRight=function()
{
    if (this._x<300) this._x+=5;
    else this.onEnterFrame=goUp;
}
goUp=function()
{
    if (this._y>300) this._y-=5;
    else this.onEnterFrame=goLeft;
}
goLeft=function()
{
    if (this._x>100) this._x-=5;
    else this.onEnterFrame=null;
}

myClip.onEnterFrame=goRight; 




The clip executes goRight, when _x = 300 executes goUp and when _y = 300 executes goLeft. After the first execution of goLeft the value of _x is <300 so in the next onEnterFrame the clip should execute goRight, not goLeft.

Can anyone tell me why it continues with goLeft????

Thanks.

View Replies !    View Related
Overridden Event Handlers
Hello all,

I've been attaching a movieclip to my stage via AS and assigning it an .onPress event handler and this works, however, when I do so, the other events that are part of the attached movie clip cease to work (they work prior to assigning the .onPress handler). I can get the same effect if I assign the others as well (.onRollover and .onRollout) but I'm curious if by attaching an even handler in AS do I override any handlers that were part of the MC that I attached?

Hope that made sense and thanks!

Matt.

View Replies !    View Related
Debugging Event Handlers
Hey guys,

I'm looking for some tips and tricks whilst debugging Event Handlers... Because of the asynch nature of Flash, debugging never picks up on that stuff :-(

For the record, I'm creating some classes that are listening for other classes to finish up loading data and creating objects before it continues along...

View Replies !    View Related
Buttons And Event Handlers
In Flash 8, I could script a button this way:

button1.onRelease = function() {
img_mc.gotoAndPlay(1);
}

How would I do something similar in CS3?

View Replies !    View Related
Event Handlers: Flash MX
I'm having trouble wrapping my head around Event Handling in Flash MX. How has it improved from previous versions?


Cheers!
- wickedWays

View Replies !    View Related
More Butten Event Handlers?
when you roll over a button, is there an event handler with an equivelant to hold or something? i want to move a MC's _x value left or right depending on the button being hovered over (left or right). it only works when the user PRESSES or RELEASES.... and the picture in the MC is 4000 pixels wide lol.

any ideas? or will i have to create some sort of while loop?

View Replies !    View Related
Please, Help On Dynamic Event Handlers
Hi thr!

This is what I have:

1 movieclip with the following script on it:

onClipEvent (load) {
divalpha = 5;
_alpha = 0
}
onClipEvent (enterFrame) {

if (this._parent.barra_nav1._x <=350) {
_alpha += (endalpha-_alpha)/divalpha;
endalpha = 100
}

}

Which means that my mc wait till other movie (barra) reaches a certain point and then fades in.

What I need to accomplish:

I need that after this "marvelous" fading in, if the user rollover the mc it fades back to 20% alpha using the same formula and fades back to 100% when the user rollout.

As I´ve declared in the enterFrame that the alpha is equal to 100% I´m not getting the results I need.

Ive been searching for tutorials on Dynamic Event handlers with no results but I'm sure there most be a way to overwrite the first enterFrame...

HELP PLEASE!!!!!!!

Thx in adcvance

View Replies !    View Related
Dynamic Event Handlers Help?
I'm making a piece of flash used for a website banner, previously i've had very little experience with action scipt as i've made various animations only having to use simple functions such as "stop()" and i've made a never ending scrolling menu also, but now i want to have an event that "onPress" a small animation is played where the mouse clicked the banner. What would be the appropriate script to link the .swf i make to the "onPress" command? or what is the right command in general assuming it is that command

View Replies !    View Related
Nested Event Handlers - Help
I have a very large movie clip 2000px by 2000px that I allow to be dragged around the frame.

It contains within it a child movie clip that contains about 100 smaller clips, 8px by 8px, which are distributed around the parent. I need the child clips to have rollover funtions, and they should move with the parent when the parent is dragged.

It appears that these functions conflict. That is, I can do one or the other, but if I try to do both, the drag stops working.

Any ideas?

View Replies !    View Related
Dynamic Event Handlers
So I found this really great snow effect (on this site actually), but its coded for flash 5. Because of the onClipEvent (enterFrame) code, I can't make it stop after 15 seconds. Well, I don't know HOW to make it stop after 15 seconds. does anyone? if not, can someone help me throw this code into a function so that I can apply a getTimer(); to it and stop it after 15 seconds?

Heres the code:

onClipEvent (load) {
//variables
width = 305;
height = 250;
//random x,y, and alpha
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 20+Math.random()*50;
//random x and y for flakes
this._x = -width+Math.random()*(3*width);
this._y = -10+Math.random()*height;
//speed and trigonometric value
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
rad = 0;
}
onClipEvent (enterFrame) {
// horizontal movement
rad += (k/180)*Math.PI;
xmovement = _root._xmouse;
this._x -= Math.cos(rad)+(xmovement-(width/2))/50;
// vertical movement
this._y += i;
// remove clips when they misbehave (overstep boundaries)
if (this._x>(width+50)) {
this._x = -45;
this._y = Math.random()*height*2;
}
if (this._x<-50) {
this._x = width+45;
this._y = Math.random()*height*2;
}
if (this._y>=height) {
this._y = -50;
this._x = -width+Math.random()*(3*width);
}
}

View Replies !    View Related
Event Handlers: Flash MX
I'm having trouble wrapping my head around Event Handling in Flash MX. How has it improved from previous versions?


Cheers!
- wickedWays

View Replies !    View Related
More Butten Event Handlers?
when you roll over a button, is there an event handler with an equivelant to hold or something? i want to move a MC's _x value left or right depending on the button being hovered over (left or right). it only works when the user PRESSES or RELEASES.... and the picture in the MC is 4000 pixels wide lol.

any ideas? or will i have to create some sort of while loop?

View Replies !    View Related
Please, Help On Dynamic Event Handlers
Hi thr!

This is what I have:

1 movieclip with the following script on it:

onClipEvent (load) {
divalpha = 5;
_alpha = 0
}
onClipEvent (enterFrame) {

if (this._parent.barra_nav1._x <=350) {
_alpha += (endalpha-_alpha)/divalpha;
endalpha = 100
}

}

Which means that my mc wait till other movie (barra) reaches a certain point and then fades in.

What I need to accomplish:

I need that after this "marvelous" fading in, if the user rollover the mc it fades back to 20% alpha using the same formula and fades back to 100% when the user rollout.

As I´ve declared in the enterFrame that the alpha is equal to 100% I´m not getting the results I need.

Ive been searching for tutorials on Dynamic Event handlers with no results but I'm sure there most be a way to overwrite the first enterFrame...

HELP PLEASE!!!!!!!

Thx in adcvance

View Replies !    View Related
Dynamic Event Handlers Help?
I'm making a piece of flash used for a website banner, previously i've had very little experience with action scipt as i've made various animations only having to use simple functions such as "stop()" and i've made a never ending scrolling menu also, but now i want to have an event that "onPress" a small animation is played where the mouse clicked the banner. What would be the appropriate script to link the .swf i make to the "onPress" command? or what is the right command in general assuming it is that command

View Replies !    View Related
Nested Event Handlers - Help
I have a very large movie clip 2000px by 2000px that I allow to be dragged around the frame.

It contains within it a child movie clip that contains about 100 smaller clips, 8px by 8px, which are distributed around the parent. I need the child clips to have rollover funtions, and they should move with the parent when the parent is dragged.

It appears that these functions conflict. That is, I can do one or the other, but if I try to do both, the drag stops working.

Any ideas?

View Replies !    View Related
Defining Event Handlers
I'm learning ActionScript now and I'm having a hard time defining Event Handlers. I know what to write, I understand them but I cannot define them. A Function is a block of code, a Method is a Function applied to an Object but how is an Event Handler defined ?

And..
for example:
Is all of that called an Event Handler or only part of it ?

Code:
mc_Square.onPress = function():Void {
this.startDrag();
}

View Replies !    View Related
Various Event Handlers In Same Instance
How can I invoke various event handlers for the same instance in the timeline?

For example you can use:

ActionScript Code:
on (releaseOutside, release, dragOut) {
    trace("button");
}

But this only works if the AS is in the instance as a mouse event and not in the timeline.

What I have now is this:

ActionScript Code:
button.onReleaseOutside = function() {
    trace("button");
};
button.onRelease = function() {
    trace("button");
};
button.onDragOut = function() {
    trace("button");
};

But surelly there is a better way of doing this. Right?

View Replies !    View Related
Please HELP On Dynamic Event Handlers
Hi thr!

This is what I have:

1 movieclip with the following script on it:

onClipEvent (load) {
divalpha = 5;
_alpha = 0
}
onClipEvent (enterFrame) {

if (this._parent.barra_nav1._x <=350) {
_alpha += (endalpha-_alpha)/divalpha;
endalpha = 100
}

}

Which means that my mc wait till other movie (barra) reaches a certain point and then fades in.

What I need to accomplish:

I need that after this "marvelous" fading in, if the user rollover the mc it fades back to 20% alpha using the same formula and fades back to 100% when the user rollout.

As I´ve declared in the enterFrame that the alpha is equal to 100% I´m not getting the results I need.

Ive been searching for tutorials on Dynamic Event handlers with no results but I'm sure there most be a way to overwrite the first enterFrame...

HELP PLEASE!!!!!!!

Thx in adcvance

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved