Flash :: Difference Between Function Call And DispatchEvent
Nov 25, 2011If i keep aside the loose coupling advantage of Events, what is the difference in the way of working of
1) Simple function call
2) Dispatching an event
If i keep aside the loose coupling advantage of Events, what is the difference in the way of working of
1) Simple function call
2) Dispatching an event
Does anyone know if there is a way to call a dispatchEvent call from inside of a static function?
View 2 RepliesI'm still wondering which method is the best use:
Event Dispatcher:
PHP Code:
package
{
import flash.events.EventDispatcher;
public class Test
[code]....
How can I get the instance of the class to call the dispatchEvent for the postTrace function.
1180: Call to a possibly undefined method dispatchEvent.
Code:
package {
import flash.display.*;
import flash.events.*;
[Code].....
if I have a class I load, import com.pixelator;//import explosion class In my movie I want to run a function when it finishes and dispatches the event below. How do I do that? here is the code from the class
PHP Code:
function completeHandler() {
dispatchEvent(new Event("PIXELS_DONE"));
}
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.
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?
I working on a game project in Flash AS3. I need to pass data from one class (Game) to other class objects (Ships) on EnterFrame and performance is starting to be a issue. I was wondering is there a difference in performance between calling to the Ship a direct function or dispatching an event which the Ship can listen.
another question is where should I put the enterframe function. Is it better to use only one enterframe function and call the methods dispatch events from there, or it will be wiser to put the enterframe in the different objects (Ships)? note: some Ships are inactive most of the time.
I am trying to adapt to AS3, and I am new to writing packages. I have my external .as file, and in there I have a bunch of functions. I need to call a function written on the timeline.I realize I need to use dispatchEvent, but I'm not exactly sure how. In the package, I currently have:
Code:
public function autoNextPict(e:TimerEvent):void
{
[code].....
I've got a class where I'm using:
o.type = "focus";
o.target = "this";
dispatchEvent(o);
and then focus is a function of an object in the FLA.
I want focus to be in the AS External Class file but it won't trigger.
What is the difference between calling exampleFunction() and exampleFunction.call() ?
There is a feature on Actionscript that allows you to use functions through the 'call' method. For example, to use the 'test' function below, I could write test() and test.call()
function test():void {
trace('function was called')
}
What is the difference?
I'm using this code to call a actionscript 3 function through javascript
[URL}
and I want to call the acrionscript 3 function from a javascript function, but not on a button action.
actionscript code:
//call to javascript
ExternalInterface.call("sendToJavaScript");
//call from javascript
[Code]....
just wondering if theres a difference between using
function x() {
}
and
x = function(){
}
i find sometimes,but rarely function x() will not run while the other will??
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.
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();
}
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.
So I have a Movieclip with a Listener listening for MOUSE_OVER, and on mouse over it triggers a function ToolTip.
[Code]...
which triggers the tooltip function but the problem is that... when the mouse is clicked on MC2 showToolTip works fine.. but when I mouse_out of MC2 it runs exitToolTip function from MC shouldnt it run exitToolTip only when you mouse out of MC? how do I make exitToolTip run only when we mouse out of MC rather than MC2 ...
What is the difference between set and get function?
View 2 Replieshave 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 RepliesI'm wondering what the difference is between creating a new object with a class or function? For example:
Code:
class snake{
this.id = index++;
this._x = 0;
this._y = 0;
}
or
Code:
function snake(){
var snake = new Object();
snake.id = index++;
snake._x = 0;
snake._y = 0;
}
Whats the difference between a variable and a function? Ive started reading an actionscript book.....and to me it seems there the same.
View 4 RepliesI have been cosuming webservices using alducente.services.WSDL classes with old ASP.NET services from Flash.
Trying the same as3 calls with the new WCF services I get the error that the method I am calling does not exist.
[Code]...
but that fixed nothing. Also I tried putting on web.config the tag but is not recognized.
What is the difference between the following two function definitions in ActionScript 3?
f = function(arg) {
// body
}
and
function f(arg) {
// body
}
Is it possible to call a PHP function from flash and have it execute right away?
If so how could I go about doing that, because I am trying to call a PHP function that will update a users facebook status, but thus far I have been unsuccessful, so I am kind of at the end f my rope.
I have this piece of code that has a problem.
[Code]...
Below is a MXML code built from Flash Builder 4.5 with AIR SDK 3.0. Using Starling framework to create 2D animation and wonder how do I call a addText function without create a new instance of Game?
main.mxml is a main application:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" [code].....
I'm trying to call a function from a AS3 container which should call old AS2 SWF that cannot be edited bacause we are talking about 1000 swf files, does exist some way to call a function inside the AS2 SWF from the AS3 container? I know a possible way by adding a LocalConnection as written here but as I said I can't edit all the swf files, so I just wonder to know if does exist some alternative.
View 3 RepliesI have a function in Flex which has three function in it.
public function update():void
{
A(); \Dispatches a event with Remote Call
[code].......
I've researched over that a way to call a javascript function for actionscript 2.0 and 3.0 is via ExternalInterface?But I'm trying to call a javascript function from my flash during an image click.
This is properly place in the html and my swf file is properly embedded in the html.. but it's not working.. Or maybe i don't understant the function? this is just a simple try to call a javascript function but it's not working..
I have load html text from an xml file, like below [code]...
in above code I want call a flash funtion when roll over on "on roll over in this text" text.