ActionScript 3.0 :: Custom Events - Any Way To Call Function?

Jul 29, 2009

The fact is that the "dispatchEvent" method must be placed into the code or timeline where the "event" happens, then it can be trigged and the function associated with the event will be invoked. Ok, it is understood. Nevertheless, my question is: what's the point to create an event to trigger the a function call, if I can simply call the function instead directly???

Code:
package{
import flash.events.Event;
public class CustomEvent extends Event{
public static const ONSOMETHING:String = "onSomething";
public function CustomEvent(type:String){
super(type);
[Code] .....

If I can do simply:
Code:
DoIt();
function DoIt(){
trace ("Done!");
}
What I mean is that custom events doesn't look like as REAL events for me, but more like a delegate way to call a function. Differently from Flash native events that are controlled by an internal engine that keep checking if the event happened, in the custom events they must triggered 'manually', and it seems to lose the event main characteristic.

View 6 Replies


Similar Posts:


ActionScript 2.0 :: Call A Custom Function From Another Custom Function's Parameter?

Apr 1, 2008

I want to call a function from another function's parameter but I don't know how and don't know if it is possible.I've considered this as a solution but it didn't worked.

Code:
function myFunc(target_mc:MovieClip, nX:Number, nY:Number, cFunc:Function) {
target_mc._x += nX;
targen_mc._y += nY;
target_mc.onPress = cFunc;

[code]....

View 2 Replies

ActionScript 2.0 :: Call A Custom Function It Doesn't Call It At All

Oct 13, 2002

have a node that has an asfunction embedded - won't work. if I change the a href to a web page- it works fine. If I try to call a custom function it doesn't call it at all.

View 1 Replies

Actionscript 2.0 :: Call Function With Different Parameters Via Right-click Custom

Apr 7, 2009

I have this custom right-click menu. I need to call the reactOnClick() function with a specific parameter when clicking a specific right-menu item. I want to avoid multiplying the function for each right-click item.

Code: Select all//set up the custom right-click menu
rcnMenu = new ContextMenu();
//the value below is here just for testing purposes,
//the actual value could be anywhere between 3 and 13
var numberOfItemsTakenFromXml:Number = 5;

[Code].....

View 1 Replies

ActionScript 2.0 :: Call A Dynamic Function From Within A Custom Class

May 28, 2008

i have created a class that so far works great. what i need to do is get that class to accept a function as one of its parameters. so for example:

[Code]...

and when the class is finshed to use the passed function name to call a internal function in the flash movie I don't even know where to begin or what its called to even do a search on it.

View 8 Replies

ActionScript 3.0 :: Call A Function From Custom Class On Button Click?

Oct 9, 2009

Let's say I have a Widget class that extends MovieClip:

[Code]...

How would I call doWidget(i:int) from the specific widgetRay[] instance clicked, using onClick from the main?

View 4 Replies

Flex :: Call A Custom Component's Public Function In The Main App?

Oct 6, 2010

How do I call a custom component's public function from the main app. For example, I've got a timer component, MyTimer.In the main app, I want to call startTimer() or stopTimer().In the main app, I've got:

<visualcomponent:MyTimer />
In the component, I've got:
public function startTimer():void {

[code].....

View 1 Replies

Actionscript 3 :: Function - Custom "call - Later" - Pass More Than One Parameter

Feb 15, 2011

I have this class ('Scheduler.as'):

[Code]..

So as you see in your test-run the first two calls work fine, the one that calls a function that takes no parameters and the one that takes one parameter. The problem is when I need to pass more than one parameter! Solving the issue: Well, I know it'd be solved if I could simply retain the ...args as is, and pass it on to the this.m_function.call call. Another way, maybe is to have some sort of a foreach loop which would feed the designated ...args when the time comes, yet again, how would I refer/pass it?

View 1 Replies

Flash - Listener In Main Document Class For Custom Dispatch Event From Another Class Does Not Respond Or Call Function?

Apr 1, 2011

I have a document class called Main.as In the class constructor I have the following listener:

enter code here
var listeningFORModeChangeToStudent:Sprite = new Sprite;
listeningFORModeChangeToStudent.addEventListener(TellAllModeChangeToStudent.STUDENT,exp);
addChild(listeningFORModeChangeToStudent);

[code]....

In a third class I make a call to the despatcher in the previous class:

enter code here
var ThisTellAllModeChangeToStudent:TellAllModeChangeToStudent = new TellAllModeChangeToStudent;
ThisTellAllModeChangeToStudent.tellAllModeChangeToStudent();

I have trace statements in eveything and from this I know the despatcher in TellAllModeChangeToStudent is being called.The problem is that the listener in the main.as is not calling the function exp.I cant see why and I dont know how to check if the listener is actually seeing the dispatch event?

View 1 Replies

ActionScript 3.0 :: Use ExternalInterface.Call To Call A JavaScript Function To Launch A Lightbox Window?

Jun 22, 2009

I'm trying to use ExternalInterface.Call to call a JavaScript function to launch a lightbox window. So far I have this:

AS3:
flash.external.ExternalInterface.call("launchLB", "" + aUrl + "");
JavaScript:
function launchLB(url) {
alert(url);

[Code]....

I get the alert but I can't get the lightbox window to display. When my as code makes the ExternalInterface call I get what looks like a page refresh and a blank browser window.

View 1 Replies

ActionScript 2.0 :: Function Call Does Not Work When Call It Via An Action On A Graphic And EnterFrame

Jan 7, 2008

I have an enterFrame action that I use on a graphic:

[Code]....

Because I want to use the above code more than a few times, I tried to make it a function.

[Code]....

But for some reason the function call does not work when I call it via an action on a graphic where initially the code worked when it was explicitly written and not called as a function.

Code:
onClipEvent (enterFrame) {
fadeOut();
}

View 3 Replies

ActionScript 3.0 :: Function Call Not Working - Getting Error 1180: Call To A Possibly Undefined Method Init? ?

Sep 25, 2009

why this is not working.I have an application with a new class I just created.  The class loads, but will not call it's own internal function. 
 
package com.parkerandkent.components.classic.photogallery {
 import caurina.transitions.Tweener;
     import flash.display.MovieClip;[code]....
 
"Test 2" will not fire here.And I get this error message:
 
CallTag.as , Line 10        1180: Call to a possibly undefined method init.

View 4 Replies

Flash :: Call Anonymous Function From ExternalInterface.call() Method?

Nov 4, 2010

I need to get a javascript var in my Flash application. I like to be able to just set a variable in the javascript (client constraints) rather than define a function.

Can this be done? I am trying to use the ExternalInterface.call()

AS:

ExternalInterface.call("function(){return window.someVar}", null);

JS:

var someVar = "Test";

This does not work and I suspect it is because the ExternalInterface.call() does not like the anonymous function.

View 2 Replies

Flash - Externalinterface.call Won't Call The JavaScript Function - Firefox 3.6

Feb 10, 2011

I have a function defined in JavaScript like so:

function fadeBack() {
alert("fadeBack called");
};

I call that function from my Flash file like so:

import flash.external.*;
flash.external.ExternalInterface.call("fadeBack");

This works in both Safari and Chrome, but for some reason Firefox won't ever call the function. Still, I can't figure this out. How can I fix it?

View 2 Replies

ActionScript 3.0 :: Call A DispatchEvent Call From Inside Of A Static Function?

Feb 3, 2009

Does anyone know if there is a way to call a dispatchEvent call from inside of a static function?

View 2 Replies

ActionScript 2.0 :: Custom Events In It?

Jan 14, 2009

How do i make custom event in as2 similar to as3?

View 5 Replies

Divine What Events A SWF Might Call?

Jun 30, 2011

I have a flash video player in SWF form, no FLA. It plays videos, as you might expect, by passing in a URL as a parameter. This works great.

However, now the customer wants to trigger an action when the video ends. Problem is, I don't have any documentation, sources, or anything else that would help me determine what functions, if any, the SWF calls on video completion.

I have no idea whether this is a canned project or a file developed in house, I have no idea if the source FLA still exists, and the customer really likes it, so unfortunately changing it to something else is not really an option.

So, my question: Is there some debugging technique I can use to determine if it is trying to call a javascript function? I tried decompiling it using this flash decompiler, but it did not yield any meaningful results.

View 2 Replies

ActionScript 3.0 :: Creating Custom Events

Mar 1, 2009

I've been running into a billion problems while creating custom events, so I clearly don't understand some of the basics. All the examples I've found online are unnecessarily complicated, so I've gone ahead and created a super simplified version of how I think it should work. The results are in bold...

[Code]...

View 4 Replies

ActionScript 3.0 :: Using Custom Events And Bubbleing?

Apr 29, 2010

So heres the issue I'm haveing, my event listener is not being triggered from the parent, and not retrieving my string for each button being clicked on.
 
Here is the event listener which listens for the subclass to dispatch an event called MenuEvent.LOAD_PAGE and then passes a string to a variable thats called whatPage thats defined within my custom event.

[Code]...

View 1 Replies

AS3 :: Flash - Custom Broadcast Events ?

Mar 15, 2010

In Actionscript 3, most events use the capture/target/bubble model, which is pretty popular nowadays:

When an event occurs, it moves through the three phases of the event flow: the capture phase, which flows from the top of the display list hierarchy to the node just before the target node; the target phase, which comprises the target node; and the bubbling phase, which flows from the node subsequent to the target node back up the display list hierarchy.

However, some events, such as the Sprite class's enterFrame event, do not capture OR bubble - you must subscribe directly to the target to detect the event. The documentation refers to these as "broadcast events." I assume this is for performance reasons, since these events will be triggered constantly for each sprite on stage and you don't want to have to deal with all that superfluous event propagation.

I want to dispatch my own broadcast events. I know you can prevent an event from bubbling (Event.bubbles = false), but can you get rid of capture as well?

View 2 Replies

Actionscript 3 :: How To Implement Custom Events

May 12, 2011

How do I correctly implement custom events? I thought the following should work, but I never receive CustomEvent.READY in the main Model

[Code]...

View 2 Replies

ActionScript 3.0 :: Dispatch Custom Events?

Mar 14, 2011

I have this Document class:


ActionScript Code:
package  {
import flash.display.MovieClip;[code]....

I just want to dispatch that custom event named "myEvent" but it doesn't work. How can I do? I don't want to use flash events. I want to use mine.

View 8 Replies

ActionScript 3.0 :: Custom Events Not Dispaching?

Oct 3, 2009

I'm making a game where you build supports under a bridge to keep it up. I'm trying to add some custom events to my game but I cant seem to get them to dispatch. What I'm trying to do is get the repair shop support to fire an event and tell the bridge and the surrounding supports its been built so they can generate a movie clip and start repairing them selves.If I trace the event it gives me all the correct data after the support is built but the listener on in the repair shop support and on the bridge does not receive it.

Code:
package com.CustomEvents {
import flash.events.Event;

[code]....

View 4 Replies

ActionScript 3.0 :: How To Dispatch Custom Events

Nov 24, 2009

i have been trying to figure our the dispatchEvent system in as3. But am just not able to wrap my head around it. So can someone please explain and give me an example on how to dispatch custom events?

for eg: Here i just want to disptach event every 100ms and the event should give me the value of "a" .

Code:
package com
{
import flash.utils.Timer;

[Code].....

View 4 Replies

ActionScript 3.0 :: Custom Events Within Package?

Dec 24, 2009

I'm trying to create a custom multi-touch application that consists of a package containing about 6 classes at the moment. I'm trying to find a way to communicate between the various classes when certain custom events happen but am having a hard time making custom events.

I've tried about 5 different tutorials online for creating custom events and none of them have worked. The code is a bit extensive so I won't attach it but the specific situation I'm dealing with goes like this:

There is a drop down menu system that contains file names from an XML file. When the file name is clicked in the menu I want a custom event to be dispatched that I can pick up in another class file that loads the name of that file into a "status bar" textfield element elsewhere in the app, and later a class that will open the file and add it to the stage.

View 2 Replies

ActionScript 3.0 :: Custom Events Not Working?

Aug 12, 2010

Can anyone help with this, I've been working on it for hours straight and I'm still having major issues.

Sometimes it works great, sliding each new status update down as it should. Most of the time it seems to have completely random positions set. I am completely at a loss. [URL]..

I think it's an event issue, specifically with line 127 trying to loop through the children and dispatch a custom event to all children. I'm not sure how to best do that.

View 8 Replies

ActionScript 3.0 :: Custom Events On Video Playback?

Feb 6, 2009

I'm using one of flash's standard FLV skins but want to modify the code and graphics. Not a problem however, I want an animation running around the outside of my player that can also be controlled by the play button of the movie player..... so..animation on outer skin is running or perhaps starts to run when user mouses over that area... video inside is still.... press play button, video starts, animation stops.... press pause, video stops, animation starts...

View 2 Replies

ActionScript 3.0 :: Create Mulitple Custom Events ?

May 14, 2009

I'm using the following code to create events my question is how do i create multiple events? I need each event to contain a diffrent data parameter.

PHP Code:

package NetConnections.Call{
// Import class
import flash.events.Event; [code].........

View 1 Replies

Flex :: Custom Components / Events And Scope

Apr 15, 2012

I'm trapping keyboard events on the stage and dispatching custom events through a framework (Mate, though I don't know that this is an important issue), but I'm pretty confused by the scope. The structure is:application (traps keyboard events and dispatches custom event mainPanel (receives dispatched events but mainCalendar (a child element) is null on debugging. Obviously if I try to call a public method on mainCalendar it errors out, even though it's a child of mainPanel. However, mainCalendar is NOT null IF I use FlexGlobals.topLevelApplication.mainPanel.mainCalendar. Outerdocument and parentDocument do not expose mainCalendar either, BTW mainCalendar (a custom component inside mainPanel with public methods. Creation policy is 'all' and it's visible and exists long before I trap any keystrokes at the top level)Could someone take a minute and explain why the mainCalendar is out of scope when mainPanel receives a custom event, even though mainCalendar is a child of mainPanel. Is there a better way to manage the events so I don't have to always address the component via the topLevelApplication?

View 1 Replies

Flex :: Write Events For A Custom Component In It?

Jan 4, 2010

I have written a custom component for drawing a circle in Flex. But When I try to write a click event or mouseDown event for that component, it doesn't work.[code]...

The "Hello" Alert is displayed only at a particular point and guess is, at the point, (175,150) the x, y co-ordinates of the circle. But shouldn't it be displayed wherever I click on the MyCircle component?? how to enable it in that way?

Also the mouseDown function doesn't work for MyCircle,but if have the event for the VBox, the Alerts are displayed.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved