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








What Event Handler Can I Use For Hover?


I made a little scrolling textarea in Flash MX and I'm attempting to create an effect.

I made two UP and DOWN buttons. Currently I have to press them UP and DOWN to get the text to scroll. How can I get so that I only have to HOVER over the button and it will keep on scrolling?

EXAMPLE: http://www.sohh.com/dev/Flash_Text_A...06-06-2002.swf
http://www.sohh.com/dev/Flash_Text_A...06-06-2002.fla - SOURCE CODE
[Edited by ibeblunt on 06-08-2002 at 12:16 AM]




FlashKit > Flash Help > Flash Newbies
Posted on: 06-07-2002, 11:39 PM


View Complete Forum Thread with Replies

Sponsored Links:

Event Handler Inside An Event Handler
i have a movie clip that is essentially a box when clicked can be dragged around and so forth.


ActionScript Code:
//AS for the box movie clip
on (press) {
    startDrag(this);
}
on (release) {
    stopDrag();
}


however inside the box i want a small button that should be able to close the box by turning it invisible (unless there is a better way to do this)


ActionScript Code:
//AS for the close button
on (press) {
    setProperty("_root.box", _visible, false);
}


the box can be dragged but clicking the close buttons does nothing (just continues to drag the box). i think the problem here is since im using the press function to drag the box then the press function inside the clip never actually gets executed. is there a way around this or maybe a better way to create this effect? thanks.

View Replies !    View Related
Passing Parameters From Event Listener To Event Handler
Hi Chaps,

First of all, apologies as I know this question has been asked before, but I have spent the last twenty minutes reading this thread and still can't seem to figure out how to apply it to my situation - probably because I'm thick!

I have a number of objects which need to be rotated according to different parameters. I have a function which takes those parameters, then uses the tween class to handle the rotation. I'm then using the tweenEvent class to check for when the motion is complete. Then, I need access to those same parameters in the complete handler to do further operations. The problem I have is that the tween event class doesn't allow me to pass the parameters along to the cpmpleteHandler, so I'm stuck getting my parameters from the first function to the second function:


Code:
function rotate(parameters){

rotationTween = new Tween(object,parameter1,parameter2,........);

rotationTween.addEventListener(TweenEvent.MOTION_FINISH,completeHandler);

}

function completeHandler(e:TweenEvent){

//need access to the paremeters passed into the first function here!!

}
From reading the thread mentioned above, I have a feeling I may need a custom class to do this - please don't laugh but I've never written (or had the need to) write my own class before, so I really wouldn't know what to do. Any help greatly appreciated, but an actual code snippet which demonstrates this would be even better!

Ric.

View Replies !    View Related
Custom Event Handler For A Timer Event?
I understand how to create custom events in order to pass parameters to a function being called by an event listener. I can get this to work fine if the event is being dispatched within my own code. However, I don't get how to do this if the event is a built-in event being dispatched by a Flash object.

Specifically, I need to call a function and pass it parameters when a timer ends. I don't know how to change the information being sent by the Timer because it is a native Flash class rather than something I'm writing. Can someone please clarify how to do this?

View Replies !    View Related
Using Event.target With An Event Handler
Hi folks,

I'm looking for a more efficient way of doing the following:


Code:
function selectLevel():void{
levelSelect.level1.addEventListener(MouseEvent.MOUSE_DOWN,gotoLevel1);
levelSelect.level2.addEventListener(MouseEvent.MOUSE_DOWN,gotoLevel2);
levelSelect.level3.addEventListener(MouseEvent.MOUSE_DOWN,gotoLevel3);

}


function gotoLevel1(e:MouseEvent):void {

currentLevel = 1;
//load up level 1
}

function gotoLevel2(e:MouseEvent):void {

currentLevel = 2;
//load up level 2
}

function gotoLevel3(e:MouseEvent):void {

currentLevel = 3;
//load up level 3
}
As you can probably see, I have a movie clip called 'levelSelect' which contains three buttons - level1, level2 and level3. What I'm doing so far, is adding an event listener to each button, and then if any of them are clicked, it activates a different event handler function for each button.

However, as the only difference in the handler functions is the number of the level, and then assume I have 100 levels, this doesn't seem like very efficient coding!

So, how can I make it so that I have just a single event handler function which all the buttons use, and get it to recognise which level button was clicked? Effectively, I'm trying to do this:


Code:
function selectLevel():void{
levelSelect.level1.addEventListener(MouseEvent.MOUSE_DOWN,clickHandler);
levelSelect.level2.addEventListener(MouseEvent.MOUSE_DOWN,clickHandler);
levelSelect.level3.addEventListener(MouseEvent.MOUSE_DOWN,clickHandler);

}


function clickHandler(e:MouseEvent):void {

//somehow detect the level number 'n' from the instance name of the button, or the child number of the parent movieclip
currentLevel = 'n';
//load up level 'n'
}
I'm sure it has something to do with e.target, or e.currentTarget, but I can't get further than that!

Cheers,

Ric.

View Replies !    View Related
Event Handler, Please Help :o)
Hey,

I'm desinging a website and I created the menu in a movie clip. The rest of the site, ex: home, pics, ect.. is on the main timeline. I used labels for home, pics, ect.. but I need an event handler that will let the buttons in the movie clip menu go to the labels on the main timeline. If anyone knows the event handler for this or has any ideas that could possibly help me. Please let me know. Thanks so much for you help.

- John

View Replies !    View Related
Event Handler
How can I add actions to a movieClip that is dynamically created?

I need my script to create a movieClip, load a picture into the movieClip, and add an onRelease event handler to this movieClip.

Can this be done??

View Replies !    View Related
Event Handler
I have a button on the right side of my layout that on(release) text should appear in an area on the left. How do I accomplish this?

Thanks.

View Replies !    View Related
Event Handler
I have a component placed on a movie clip that is its _targetInstanceName. In my component I want to catch an event of the _targetInstanceName. How can I do it?

View Replies !    View Related
Event Handler Help
I need some help with event handlers

you have a movie clip named "ball"

Code:
ball.onEnterFrame = function () {
this._y+=3;
}
This code goes on the timeline.
When the code is placed on the clip here is the error


Code:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1:
Statement must appear within on/onClipEvent handler
ball.onEnterFrame = function() {

Total ActionScript Errors: 1 Reported Errors: 1
What would have to change in the code to place it on a clip?

Thanks

Ponyack

View Replies !    View Related
Event Handler
Hello,
I have a simple question,

I'm making a movie quiz and at the end i have an animation inside a movie clip and when the person gets to the last frame I want that animation to play but only one time instead of playing it 12 times per second so I would like to know if there is an event handler that does this, for example:

ActionScript Code:
onClipEvent(enterFrame){ //<--- this is the event handler want to replaceif(_root.Score ==100){_root.ball.gotoAndPlay("AdvancedM");}}

thanks

View Replies !    View Related
Terminate Event Handler
I'm using Colin Moock's event handler driven preloader (see below), but need to incorporate the ability to stop preloading (skip intro button) and load a new page in the browser. A simple goto action attached to a button doesn't work while the loader is chugging away. The command "break;" doesn't seem to work with event handlers, and a simple skip intro button with a getURL(~, _self) action doesn't jump until the preloader finishes.

I've tried (unsuccessfully) to pass a variable into the named movieclip ("_root.preloader.skip = 1;") to which this script is attached, but it seems to ignore it, e.g., if (skip > 0){gotoAndStop("end");}

Any suggestions?


//The Preloader

onClipEvent (enterFrame) {
loaded = _parent._framesloaded;
if (loaded>0 && loaded == _parent._totalframes && loading != "done") {
_parent.gotoAndPlay("start");
loading = "done";
}
percentDone = Math.floor((_parent.getBytesLoaded()/_parent.getBytesTotal())*100);
loadStatus = percentDone+"% complete";
bytesLeft = Math.floor((_parent.getBytesTotal() - _parent.getBytesLoaded())/1000);
displayBytes = bytesLeft + "k remaining";
loadBar._xscale = percentDone;
}

View Replies !    View Related
Movie End Event Handler
I have six sound files (all separate .swfs). Each file lives in its own frame with a stop (); script attached to each frame.

I want to give the user the option of listening to a single sound file, or listening to them all in succession. Does anyone of a suggestion for a script to handle this?

Is there an event handler that addresses the end of a sound or a movie clip? I'm sure there is, and if I knew that I could figure out the rest on my own.

Thanks in advance!

View Replies !    View Related
'onmousemove' Event Handler
I have attached the 'onmousemove' event handler onto a movie clip (I want the movie to goto the next scene if the mouse is moved). However it does not seem to work...do I have to work out the mouse coordinates first or something? If anyone could provide me with the script I would be very greatful!

Many Thanks

Elliot

View Replies !    View Related
'onmousemove' Event Handler
I have attached the 'onmousemove' event handler onto a movie clip (I want the movie to goto the next scene if the mouse is moved). However it does not seem to work...do I have to work out the mouse coordinates first or something? If anyone could provide me with the script I would be very greatful!

Many Thanks

Elliot

View Replies !    View Related
Onquit Event Handler?
hi, is there any way in flash to use an on_quit event? i would like to have short movie clip (e.g. a company logo) displayed when the user quits the flash player (standalone). just like seen with the macromedia director stuff.

thanks

hyper

View Replies !    View Related
OnRelease Event Handler
I'm dynamically creating thumbnail images, by using createEmptyMovieClip(), and then loading the jpg's into those empty clips. I want these to be clickable buttons, so after they are created and loaded, I'm using this code to attempt to attach an action:

(inside a for loop, so i is being incremented...)
...
{
clip = "clip" + i;
loader[clip].loadMovie(imgList[i]);
loader[clip].onRelease = function()
{
trace("test action");
};
}
...

each movie clip is getting a different image loaded, so the targeting of the movie clips (loader[clip]) works, but for some reason, no tracing occurs when i click on any of them.

Has anyone else had problems using onRelease = function() on movie clips? I think I'm missing something simple here, but can't figure it out...

View Replies !    View Related
OnRelease Event Handler
I'm dynamically creating thumbnail images, by using createEmptyMovieClip(), and then loading the jpg's into those empty clips. I want these to be clickable buttons, so after they are created and loaded, I'm using this code to attempt to attach an action:

(inside a for loop, so i is being incremented...)
...
{
clip = "clip" + i;
loader[clip].loadMovie(imgList[i]);
loader[clip].onRelease = function()
{
trace("test action");
};
}
...

each movie clip is getting a different image loaded, so the targeting of the movie clips (loader[clip]) works, but for some reason, no tracing occurs when i click on any of them.

Has anyone else had problems using onRelease = function() on movie clips? I think I'm missing something simple here, but can't figure it out...

View Replies !    View Related
Setinterval - Event Handler Help
Help. I need help with code to have this read in as I start my program. I have heard about setinterval, but need help with the code to make it work. Also is this the way on should go?

on (release) {
_root.SQLSelect = "SELECT * from trade WHERE FieldID = 2";
fscommand("flashstudio.selectfromdb", "SQLSelect");
fscommand("flashstudio.getfieldfromdb", ""tradedesc","1",desc2");
fscommand("flashstudio.getfieldfromdb", ""discount","1",discountb");

View Replies !    View Related
Combine Var With Event Handler
How do I use the variable path correctly with my .onPress ...

function drag()
{
path = ("_root.hold3.global_mv");

path.onPress = function()
{
startDrag(path);
}

path.onRelease = function()
{
stopDrag();
}
}
drag();

I just tried Eval(path) and it works but is this correct? I don't want to use my Flash4 syntax.

View Replies !    View Related
Combo Box With Event Handler
I am trying to get a dynamic text box to update its contents when a selection is made in my combo box (Drop down menu). My fla is attached. Please HELP!!!

View Replies !    View Related
PLEASE HELP - Event Handler And Combo Box
I am trying to get a dynamic text box to update its contents when a selection is made in my combo box (Drop down menu). My fla is attached. Please HELP!!!

View Replies !    View Related
...please Help Problems With An Event Handler
Hi buddies!
I'll try to explain as easy as possible this problem:

Ive got a movie where fireflies are flying in the night. The idea is that when I touch 3 fireflies, they go into a bottle (we say... when I catch them). When the 3 fireflies are into the bottle, I need to start an animation (it's basically an image of a dawn that represents that the day has come).

First, I created a variable that contains the info about how many fireflies are into the bottle. Everytime that one of the bugs gets into the bottle, I increase the value +1.
So I create an event handler (onEnterFrame) that evaluates when the variable reaches the value of 3. If the variable = 3, then the animation begins...

The problems is that I cannot make the animation start... I dont know if it related to the eventhandler code, or something else... I spent an afternoon trying to solve it but I couldn't.
Ive attached the file (MX format) so you can see the whole thing...

Take a look buddies!!!
I need some opinions please!!!

View Replies !    View Related
Loadmovie Using An Event Handler? Or What?
Hello and thank you all in advance.
Dumb question. Can you load an external swf or jpeg file into a target by having a button on the main timeline with on(press)? I've noticed that in the forum several answers regarding loading the movie were answered but I would like to trigger the file by using an event handler (eg on(press)).
Thanks again!

View Replies !    View Related
Remove Event Handler
Hi! I have the next code:

mc.onPress=function()
{
//some code
}

How do I remove the event handler onPress ??

View Replies !    View Related
Creating New Event Handler For MC
In a kiosk application (with NO mouse action) I try to mimic the action of buttons...with movie clips.
I was wondering if that would be possible to create new event handler for MC?

So that, by script, I could tell something like:

my_mc.selected = true
my_mc.focused = true

then have an event handler function like:

my_mc.onSelected = function () {
trace ("button is pressed");
}
my_mc.onFocused = function () {
trace ("button is on focus");
}


So:
1) a way to give a state to a movieclip (like "focused", "pressed"...)
2) then an event handler...to handle corresponding function


Would you please have an idea on how I could achieve this?
Thanks a lot!

View Replies !    View Related
Custom Event Handler
hi:

i was wondering if it was posible to make a custom event handler, i have a scene and i duplicate a MC a lot of times and each duplicated MC has its own code, so the scene is getting a little slow, so i was wondering instead of using the enterFrame event handler i could use something like this

onClipEvent(this._x<100){
do this
}
or instead of the this._x<100 some other condition
thanks i have flash 8 and i am using actionscript 2

View Replies !    View Related
XML Event Handler Problem
I'm working with AS 2.0.

Well I have the xml load in my constructor so I know I make the call to load the xml before I call the getTeam function but I've read that the xml won't necessarily load right away or something like that. I've put an if statement that takes the success parameter from the xml.onLoad function so I thought that guarenteed that all the data would load before moving on to other functions but maybe that isn't the case. Is there anyway to make sure that the xml has loaded completely before anything else is done? When I trace the teams array inside the event handler it outputs the Objects in the array but when I try tracing the teams array anywhere else but in the event handler it gives me undefined.

Here's the code for my class and the test code follows it:


Code:
class League{
private static var numberOfTeams:Number=32;
private var teams:Array;
private var games:Array;
private var numberOfGamesPlayed:Number;

public function League()
{
teams=new Array();
games=new Array();
var parent=this;
var xmlInput:XML=new XML();
xmlInput.ignoreWhite=true;
xmlInput.onLoad=function(success)
{
if(success)
{
for(var i=0; i<xmlInput.firstChild.childNodes.length; i++)
{
var t:Team=new Team(xmlInput.firstChild.childNodes[i].attributes.name,
xmlInput.firstChild.childNodes[i].attributes.totalGames,
xmlInput.firstChild.childNodes[i].attributes.wins,
xmlInput.firstChild.childNodes[i].attributes.losses,
xmlInput.firstChild.childNodes[i].attributes.pointsForPerGame,
xmlInput.firstChild.childNodes[i].attributes.yardsForPerGame,
xmlInput.firstChild.childNodes[i].attributes.thirdDownPercentage,
xmlInput.firstChild.childNodes[i].attributes.penaltyYards,
xmlInput.firstChild.childNodes[i].attributes.pointsAllowedPerGame,
xmlInput.firstChild.childNodes[i].attributes.yardsAllowedPerGame,
xmlInput.firstChild.childNodes[i].attributes.interceptions,
xmlInput.firstChild.childNodes[i].attributes.forcedFumbles,
xmlInput.firstChild.childNodes[i].attributes.puntReturnAvg,
xmlInput.firstChild.childNodes[i].attributes.kickReturnAvg);

parent.teams.push(t);
}
}
}
xmlInput.load("NFLTeamStats.xml");

var xmlInput2:XML=new XML();
xmlInput2.ignoreWhite=true;
xmlInput2.onLoad=function(success)
{
if(success)
{
for(var j=0; j<xmlInput2.firstChild.childNodes.length;j++)
{
for(var k=0; k<xmlInput2.firstChild.childNodes[j].childNodes.length; k++)
{
var g:Game=new Game(xmlInput2.firstChild.childNodes[j].attributes.id,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.id,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.winner,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.loser,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.margin,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.total);

games.push(g);
}
}
}
}
xmlInput2.load("NFLGames.xml");
}

public function getGamesPlayed()
{
numberOfGamesPlayed=0;
var xmlInput3:XML=new XML();
xmlInput3.ignoreWhite=true;
xmlInput3.load("NFLGames.xml");
trace(xmlInput3.firstChild.childNodes[0].attributes.id);
xmlInput3.onLoad=function()
{
for(var i=0; i<xmlInput3.firstChild.childNodes.length; i++)
{
trace("outer loop");
for(var j=0; j<xmlInput3.firstChild.childNodes[i].childNodes.length; j++)
{
trace("inner loop");
numberOfGamesPlayed++;
trace(numberOfGamesPlayed);
}
}
}
return numberOfGamesPlayed;
}

public function getTeams():Array
{
trace(teams.length);
var teamsArray:Array=new Array();
teamsArray=teams.slice();
trace(teamsArray.length);
return teamsArray;
}

public function getGames():Array
{
var gamesArray:Array=new Array();
gamesArray=games.slice();
return gamesArray;
}
}

Code:
var l:League=new League();

trace(l.getTeams());

View Replies !    View Related
Event Handler In Nested Swf
I have a combo box component that works fine when tested alone. It breaks, however, when a parent swf loads it. The code (shortened for brevity) of the child swf containing the combo box is:


Code:
// Create listener object.
var cbListener:Object = new Object();

// Create event handler function.
cbListener.change = function (evt_obj:Object) {
switch (evt_obj.target.selectedItem.label) {
case "Donor Recruitment":
gotoAndStop("recruiting"); break;
case "Donor Screening":
gotoAndStop("screening"); break;
case "Introduction":
gotoAndStop("intro"); break;
default:
gotoAndStop("intro"); break;
}
}

// Add event listener.
quickLinks.addEventListener("change", cbListener);
quickLinks.dropdownWidth = 150;
quickLinks.setStyle("backgroundColor", "0xDDDDDD");
quickLinks.setStyle("fontSize", 11);

// Add Items to List.
quickLinks.addItem({data:1, label:"Introduction"});
quickLinks.addItem({data:2, label:"Donor Recruitment"});
quickLinks.addItem({data:3, label:"Donor Screening"});


Any help would be greatly appreciated!

View Replies !    View Related
Event Handler Misery
Hey guys,

I am having trouble with event handlers. I have the following code:

var object:Object=event.target;
var dropTween=new Tween(object, "x", None.easeNone, object.x, myTarget.x, 0.7, true);
var dropTween2=new Tween(object, "y", None.easeNone, object.y, myTarget.y, 0.7, true);
dropTween.addEventListener(TweenEvent.MOTION_FINIS H, bounce(object));

Then:

function bounce(event:TweenEvent, dO:Object):void
{
trace("funtion: bounce");
if (currentTotal>targetTotal)
{
var bounceTween=new Tween(dO, "x", None.easeNone, dO.x, startX, 0.7, true);
var bounceTween2=new Tween(dO, "y", None.easeNone, dO.y, startY, 0.7, true);
}
}

But it won't let me pass the value to the event handler... How can I get around this? Do I need to use a global variable, or is there a better way?

View Replies !    View Related
Creating New Event Handler For MC
In a kiosk application (with NO mouse action) I try to mimic the action of buttons...with movie clips.
I was wondering if that would be possible to create new event handler for MC?

So that, by script, I could tell something like:

my_mc.selected = true
my_mc.focused = true

then have an event handler function like:

my_mc.onSelected = function () {
trace ("button is pressed");
}
my_mc.onFocused = function () {
trace ("button is on focus");
}


So:
1) a way to give a state to a movieclip (like "focused", "pressed"...)
2) then an event handler...to handle corresponding function


Would you please have an idea on how I could achieve this?
Thanks a lot!

View Replies !    View Related
Help Adding Event Handler
Hi,
I have in the first frame of a flash document the following code:

attachMovie("mcImage","image1",1);
image1._y=0;
image1._x=400;
image1.onEnterFrame = function() {
this._x-= 1;
trace("moved");
}

I have the linkage for mcImage set to Export fir ActionScript and Export in first frame.
When I test it, the instance moves to the right location, but the onEnterFrame function only runs once (it says "moved" once in the output window). I'm trying to get the instance to scroll across the screen.
Shouldn't the onEnterFrame function run as often as my frame rate?

Thank you.

View Replies !    View Related
Dynamic Event Handler Help
So I found this really great snow effect, 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
Problem With Event Handler
Hi, I am new to programming in Flash.

My problem is that whenever I try to write an event handler for a simple button class, it always says that the statement (which is actually an event handler that I wrote) needs to be within an event handler. My code is not being read as an event handler.

I've attached the .fla file for the button class I am trying to create and I put it in a zip file.

Whatever help anyone can provide would be greatly appreciated.

Sam

View Replies !    View Related
Event Handler Problem
folks,

i'm trying to return some xml data assigned to a local private variable via an event handler function, and then have that value returned via a getter but i seem to be losing the data upon exiting the event handler function:


Code:
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("data.xml"));

private function onComplete(e:Event):void {
_data = loader.data; // or e.target.data, doesn't make a diff
}

// however...
public function get Data():XMLList {
return _data; // returns null
}
why am i losing the information stored in _data upon exiting onComplete(), if i'm storing it as a local private variable? this is what i want to do:


Code:
// object that contains code above
var xmlData:XMLData = new XMLData();
trace (xmlData.Data); // should return xml data
thanks,
n.

View Replies !    View Related
Timer Event Handler..
I have a function that runs on a timer event something like the following:


Code:
playTimer=new Timer(100,0);
playTimer.addEventListener(TimerEvent.TIMER, mousePlayer);
playTimer.start();

function mousePlayer(evt:Event):void {
if (stage.mouseX>stageMid) {
if (currentHFrame<(hSkidArray.length-1)) {
currentHFrame++;
removeChild(hSkidArray[prevHFrame]);
addChild(hSkidArray[currentHFrame]);
prevHFrame=currentHFrame;
}
} else if (stage.mouseX<=stageMid) {
if (currentHFrame>0) {
currentHFrame--;
removeChild(hSkidArray[prevHFrame]);
addChild(hSkidArray[currentHFrame]);
prevHFrame=currentHFrame;
}
}
}
Theres an array of 30 display objects, and what its doing is checking for the mouse position and incrementing through the list based on mouseX > or < stageWidth/2. Fairly straight forward.

The problem is it seems to be really quickly running through all the increments based on mouseX every time the timer event fires. Seems obvious but it should test once each time, whereas it seems to be running looping the function continuously whenever the event is fired - is this making sense?

Any clues would be appreciated.

[edit] Just to add, it runs fine on an EnterFrame event but i needed more control so i used Timer.

View Replies !    View Related
Removing Event Handler
I've added an event handler to a MC.


ActionScript Code:
_root.frame.photo_frame.onPress = function(){...

Now I want to remove it - not just clear out the function. I don't want there to be an event handler (onPress) for this MC at all.

Any ideas? Thanks in advance!

View Replies !    View Related
Help On Dynamic Event Handler
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 advance

View Replies !    View Related
Event Handler Detection?
How can I test the existence (or lack thereof) of a movieclip's Event Handler, such as onLoad, onPress, etc?

View Replies !    View Related
Mc Out Of Scope Event Handler
TIA,

I have two event handlers on the Main Timeline.(attached at the bottom)
Also on the Main Timeline, there is an outerMC(2frames), which contains, a innerMC1(frame1) and an innerMC2(frame2).

With the event handler on the Main Timeline, when the nested movieclip is no longer under the playhead, the event handler goes out of scope and stays out of scope, even if the playhead is returned to the firstframe, via the simple on() {prevFrame();} button.

This seems to be very odd, a parent function, does not go out of scope, when the playhead moves within a nested movieclip.

How can I have centralized event handler code on the Main Timeline and be able to address nested movieclips regardless if that movieclip exists on the first frame or not.

code:







Attach Code

outerMC.innerMC1 = function (){ this._parent.nextFrame();}
outerMC.innerMC2 = function (){ this._parent.prevFrame();}

View Replies !    View Related
Custom Event Handler
I am trying to make a custom event handler to check to see when the XML data is loaded into an object in my class so it can be accessed by the instance in an FLA. I made the class below to extend Events. I am planning on using a timer to keep checking to see when it is loaded. I can't put the checking logic into the base class because when the class runs, the XML object is there. It is a question of when it is available to the instance of the class. So, do I have to put the timer code in the FLA? Can I somehow put the timing logic into the handler as? Any help on the best way to do it....I've gotten it to work in the FLA but I hate having that code out there in the FLA if I can do it elsewhere in a class...

Thanks in advance!








Attach Code

// Can I put handler logic - timer checking logic - in here somehow and have it check for the instance?

package handlers{

import flash.events.Event;

public class xmlObjectEvent extends Event{

public static const XMLOBJECTLOAD:String = "XML Object Load";

public function xmlObjectEvent(type:String):void{
super(type);
}

public override function clone():Event{
return new xmlObjectEvent(type);
}
}
}

View Replies !    View Related
Custom Event Handler
Just curious. I made a custom event handler that is dispatched from within a class when an XML document is loaded. The listener is attached to the instance of that class in the FLA. The attached code to this thread is what is for the class instance. Does that have to be out there? Is there a cleaner way to do it so that the code would be away in a class? Just wondering....

Thanks!







Attach Code

import mps.uiprototype.main.xmlLoader;
import mps.uiprototype.events.xmlObjectEvent;

var myXML:XML = new XML();

var appMenubar:xmlLoader = new xmlLoader("xml/menubar.xml");
appMenubar.addEventListener(xmlObjectEvent.XMLOBJECTLOAD, handleXMLObject);

function handleXMLObject(e:xmlObjectEvent):void{

// Load the XML Object passed from the load event into the local Object
myXML = e.xmlData;
trace("Here: " + myXML.mainitem[0].@name);

// Remove the listener as it is no longer required
appMenubar.removeEventListener(xmlObjectEvent.XMLOBJECTLOAD, handleXMLObject);

}

View Replies !    View Related
Get Name Of Function / Event Handler
Does anyone know if there is a way to get the name of the function that my code is running inside?

Code:
_btn.onPress = function () {
trace(something);
}
this would then output "onPress" or something like it... hope you all understand what i'm searching for.

Thanks!

View Replies !    View Related
How To Play An Event Handler?
I'm creating a button to play an movie clip using onClipEvent() but I couldn't get it works. It contains a button (text) and a cube (movie clip). On that movie clip I have a button.

I want the animation of movie clip play while my mouse is rollOver on my text. Does anyone know how to make that works??

here my example:

code in cube instance name "cubemc" :

onClipEvent (load)
{
elas = 1.200000;
speed = 5;
temps = 0;
}

onClipEvent (enterFrame)
{
if (this.hitTest(_root._xmouse, _root._ymouse))
{
this.ts = 160;
}
else
{
this.ts = 110;
} // end if

this.ds = this.ts - this._xscale;
this.temps = this.temps / elas + this.ds / speed;
this._xscale = this._xscale + this.temps;
this._yscale = this._xscale;
}

in this movie clip, it contains a button with that code:

onPress()
{
getURL("http://www.yahoo.com","_self");
}


code in my text which is a button instance name "bt" :

bt.onRollOver
{
cubemc.play();
};

View Replies !    View Related
Creating New Event Handler For MC
In a kiosk application (with NO mouse action) I try to mimic the action of buttons...with movie clips.
I was wondering if that would be possible to create new event handler for MC?
So that, by script, I could tell something like:
my_mc.selected = true
my_mc.focused = true
then have an event handler function like:
my_mc.onSelected = function () {
trace ("button is pressed");
}
my_mc.onFocused = function () {
trace ("button is on focus");
}

So:
1) a way to give a state to a movieclip (like "focused", "pressed"...)
2) then an event handler...to handle corresponding function

Would you please have an idea on how I could achieve this?
Thanks a lot!

View Replies !    View Related
Button Event Handler?
ok, i'm having some trouble setting up the links in my flash file.

this works:

Code:
// profile
profile.btn.onRollOver = function() {
profile.gotoAndPlay(1);
}
this doesn't:

Code:
function rollUp(item) {
item.gotoAndPlay(1);
}
profile.btn.onRollOver = rollUp(profile);
i'm not really sure what's up. i've taught myself actionscript just by messing around with different ideas, but the function is so simple i'm thinking it has to do with how i'm trying to trigger it?

i want to use the rollUp function because all the buttons have the same rollover effect and if i ever change the frame count, i'll only have to update the rollUp/rollDown numbers once instead of each button's onRollOver and onRollOut.

View Replies !    View Related
AddListeners, Event Handler And All
May someone tell me how is it possible (if it is) to pass variables along when we addEventListeners to a component button.
And by the way, what's the main differences between addEventListeners and addListener?

I have a FLVPlayback component from which i wanna play 4 different flv clips referenced in a xml file.

The xml part works fine.

So I have my 4 buttons (components) here. When i click the button 1, i want to either send the variable 1 to a function that is build to load the desired flv in the player. The variable would determine which of the flv to play.

either that or when i click a button, i want to set directly the .contentPath of my flv player, load it and play it via a simple function that would be referenced to in the addEventListener call

I hope everything is clear enough.

I'm having trouble just making the buttons send different variables to a particular function, according to which of my 4 buttons are pressed.
button 1 sends 0
button 2 sends 1
button 3 sends 2
button 4 sends 3

that looks pretty simple but seems like i cant even do that by myself.

Thanks for the help again

View Replies !    View Related
Custom Event Handler
hi, I want to create some custom event handler, so here is my code at stage

ActionScript Code:
import getInfo;var hhh:getInfo = new getInfo();



my class getInfo;

ActionScript Code:
package {    import flash.display.MovieClip;    import flash.events.Event;    import phpInfo;    import getInfoEvent;    public class getInfo extends MovieClip {        public function getInfo() {            var url:String = "http://localhost:81/www.theflashblog-bg.com/fcp_v2/bin/php/showPosts.php";            var php:phpInfo = new phpInfo();            php.getAllPosts(url);            addEventListener(getInfoEvent.getXML, heh);        }        public function heh(info:getInfoEvent):void {            trace(">> "+info.xmlArrayData);        }    }}


get form php ifrmation class: class phpInfo

ActionScript Code:
package {    import flash.events.Event;    import flash.net.URLLoader;    import flash.net.URLLoaderDataFormat;    import flash.net.URLRequest;    import flash.net.URLRequestMethod;    import flash.net.URLVariables    import flash.xml.XMLDocument;    import flash.display.Stage;    import flash.display.MovieClip;        import getInfoEvent;    import getInfo;    public class phpInfo extends MovieClip{        public static const readyXML:String = "readyXML";        public var query:String;        public var id:String;        public var ArrayOfInfo:Array = new Array();        private var phpLoader:URLLoader = new URLLoader();        private var request_:URLRequest = new URLRequest();        private var varsToSend:URLVariables = new URLVariables();                                public function phpInfo():void {            request_.method = URLRequestMethod.POST;            phpLoader.dataFormat = URLLoaderDataFormat.TEXT;        }        public function getAllPosts(url:String):void {            request_.url = url;            //set needed info            varsToSend.hostnam = "localhost";            varsToSend.database = "theblog";            varsToSend.username = "tAdmin";            varsToSend.password = "tpass";            //            request_.data = varsToSend;            phpLoader.addEventListener(Event.COMPLETE, getAllPosts_COMPLETED);            phpLoader.load(request_);        }        private function getAllPosts_COMPLETED(info:Event):void {            var gallery_xml:XMLDocument = new XMLDocument();            gallery_xml.ignoreWhite = true;            gallery_xml.parseXML(phpLoader.data);            var i:uint;            var al:Number = gallery_xml.firstChild.childNodes.length;            for (i=0;i<al;i++) {                ArrayOfInfo.push(new Array(gallery_xml.firstChild.childNodes[i].attributes["id"], gallery_xml.firstChild.childNodes[i].attributes["date"], gallery_xml.firstChild.childNodes[i].attributes["title"], gallery_xml.firstChild.childNodes[i].attributes["author"], gallery_xml.firstChild.childNodes[i].attributes["view"], gallery_xml.firstChild.childNodes[i].attributes["categry"], gallery_xml.firstChild.childNodes[i].attributes["attach"], gallery_xml.firstChild.childNodes[i].attributes["image"], gallery_xml.firstChild.childNodes[i].attributes["comments"]));            }            this.dispatchEvent(new getInfoEvent(getInfoEvent.getXML, ArrayOfInfo));                    }    }}



event class:class getInfoEvent

ActionScript Code:
package {    import flash.events.Event;        public class getInfoEvent extends Event{        public static const getXML:String = "getXML";        public var xmlArray:Array = new Array();                public function get xmlArrayData():Array {            return xmlArray;        }        public function getInfoEvent(type:String, gotData:Array):void {            xmlArray = gotData;            super(type, true);            trace(xmlArray);        }        public override function clone():Event {            trace("<<>>");            return new getInfoEvent(type, xmlArray);                    }    }    }



So, what is the problem. The problem is that in function getInfoEvent(), it trace me the array correctly, but this clone(), don't trace "<<>>", and I don't have function heh() trace too. What is wrong?

View Replies !    View Related
Event Handler Target
Is it possible to target an mc for animation with your event handler other then the event.target?


this is my handler:


Code:
function btnHandler(event:MouseEvent):void {
Tweener.addTween(event.currentTarget, {scaleX:20, time:1, transition:"easeout"});
}
But if i change that target to a specific MC in my array, like: btnsArray[3], then i get a weird error in my output panel.

Any ideas?

View Replies !    View Related
F8 AS Xml Event Handler Problem
I'm working with AS 2.0.
Well I have the xml load in my constructor so I know I make the call to load the xml before I call the getTeam function but I've read that the xml won't necessarily load right away or something like that. I've put an if statement that takes the success parameter from the xml.onLoad function so I thought that guarenteed that all the data would load before moving on to other functions but maybe that isn't the case. Is there anyway to make sure that the xml has loaded completely before anything else is done? When I trace the teams array inside the event handler it outputs the Objects in the array but when I try tracing the teams array anywhere else but in the event handler it gives me undefined.
Here's the code for my class and the test code follows it:

Code:
class League{
private static var numberOfTeams:Number=32;
private var teams:Array;
private var games:Array;
private var numberOfGamesPlayed:Number;

public function League()
{
teams=new Array();
games=new Array();
var parent=this;
var xmlInput:XML=new XML();
xmlInput.ignoreWhite=true;
xmlInput.onLoad=function(success)
{
if(success)
{
for(var i=0; i<xmlInput.firstChild.childNodes.length; i++)
{
var t:Team=new Team(xmlInput.firstChild.childNodes[i].attributes.name,
xmlInput.firstChild.childNodes[i].attributes.totalGames,
xmlInput.firstChild.childNodes[i].attributes.wins,
xmlInput.firstChild.childNodes[i].attributes.losses,
xmlInput.firstChild.childNodes[i].attributes.pointsForPerGame,
xmlInput.firstChild.childNodes[i].attributes.yardsForPerGame,
xmlInput.firstChild.childNodes[i].attributes.thirdDownPercentage,
xmlInput.firstChild.childNodes[i].attributes.penaltyYards,
xmlInput.firstChild.childNodes[i].attributes.pointsAllowedPerGame,
xmlInput.firstChild.childNodes[i].attributes.yardsAllowedPerGame,
xmlInput.firstChild.childNodes[i].attributes.interceptions,
xmlInput.firstChild.childNodes[i].attributes.forcedFumbles,
xmlInput.firstChild.childNodes[i].attributes.puntReturnAvg,
xmlInput.firstChild.childNodes[i].attributes.kickReturnAvg);

parent.teams.push(t);
}
}
}
xmlInput.load("NFLTeamStats.xml");

var xmlInput2:XML=new XML();
xmlInput2.ignoreWhite=true;
xmlInput2.onLoad=function(success)
{
if(success)
{
for(var j=0; j<xmlInput2.firstChild.childNodes.length;j++)
{
for(var k=0; k<xmlInput2.firstChild.childNodes[j].childNodes.length; k++)
{
var g:Game=new Game(xmlInput2.firstChild.childNodes[j].attributes.id,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.id,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.winner,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.loser,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.margin,
xmlInput2.firstChild.childNodes[j].childNodes[k].attributes.total);

games.push(g);
}
}
}
}
xmlInput2.load("NFLGames.xml");
}

public function getGamesPlayed()
{
numberOfGamesPlayed=0;
var xmlInput3:XML=new XML();
xmlInput3.ignoreWhite=true;
xmlInput3.load("NFLGames.xml");
trace(xmlInput3.firstChild.childNodes[0].attributes.id);
xmlInput3.onLoad=function()
{
for(var i=0; i<xmlInput3.firstChild.childNodes.length; i++)
{
trace("outer loop");
for(var j=0; j<xmlInput3.firstChild.childNodes[i].childNodes.length; j++)
{
trace("inner loop");
numberOfGamesPlayed++;
trace(numberOfGamesPlayed);
}
}
}
return numberOfGamesPlayed;
}

public function getTeams():Array
{
trace(teams.length);
var teamsArray:Array=new Array();
teamsArray=teams.slice();
trace(teamsArray.length);
return teamsArray;
}

public function getGames():Array
{
var gamesArray:Array=new Array();
gamesArray=games.slice();
return gamesArray;
}
}

Code:
var l:League=new League();
trace(l.getTeams());

View Replies !    View Related
Event Handler For XML Text.
Hey guys.

I am developing a Flash magazine and i am a little stuck. I have my magazine component and can use the API to easily navigate with a goToPage function. However, i have also developed a tab menu which creates an index from the XML of the magazine. What i need to do now is tie these together so that when a page is clicked in the Index, the magazine flicks to the appropriate page. Can anyone suggest how i might go about doing this please?!

Thank you in advance for your help.

View Replies !    View Related
Problem With Event Handler
I've used Kirupa's code for making a movie clip behave like a button:

stop();

this.onEnterFrame = function(){
if(rewind == true){
prevFrame();
}
}
this.onRollOver = function(){
rewind = false;
play();
}
this.onRollOut = function(){
rewind = true;
}
this.onRelease = function(){
gotoAndPlay("Scene 1","start");
}

The code allows a tweened animation to play backwards as well as forwards. In my case when you rollover a movie clip it starts off with a dark tint and then becomes brighter. Once you roll out of the movie clip it goes back to a dark tint. This is all good...

but..

The problem I am having is that the last line of code does not actually work. I cannot get the movie clip to take me to a new scene, but it will divert me to a URL if I want it to.

Any ideas anyone?

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