ActionScript 3.0 :: Correct Way Of Calling DispatchEvent?
Dec 17, 2009I have 2 swfs.Swf A loads Swf B.I want Swf A to listen to an event from Swf B.So, in Swf A:
Code:
function myFunction():void{
//do stuff
[code].....
I have 2 swfs.Swf A loads Swf B.I want Swf A to listen to an event from Swf B.So, in Swf A:
Code:
function myFunction():void{
//do stuff
[code].....
I need to use the unload and stop method.But my actionscript code calls individual swf files which contain 1 video player each. How would I add the unloadandstop methods into the existing actionscript?First question, add this code to the main.swf that is calling the swfs with thre players correct?So far I would I add a second set of event listeners for this function, like this?[code]
View 3 RepliesI'm trying to get the depths of all the blocks to be at the correct levels at the correct times so that the 3d effect is maintained. I've tried many things, but have had little success. All the instances of the blocks are stored in an array, but since it's adding them in accordance with when they're added to the stage, it doesn't help me locate them to swap depths. Is there a way to arrange them by location on the board?
View 4 Replieswhere can i get a nice tutorials that is easy to understand? how to use dispatchEvent.
View 2 RepliesI have a movieclip on my stage that I am using as a button toincrement an index number. I have declared a custom event class andI am passing the index to the custom event as a property.I have initialized the clips on the stage to listen for thecustom event and I am dispatching the event from the instance ofthe button being pressedEverything seems to be ok except my clips listening for theevent don't seem to be getting it. Can you not dispatch an eventdirectly from a movieclip instance on the stage? Do you have to doit from a .AS file class?
View 8 RepliesOne single swf, imgdesc.swf is being loaded into the emptymcholder, by the moviecliploader instance.My order isfolioholdermc ---holds--> emptymcholder --holds--> imgdesc.swfWithin folioholdermc, I disabled buttons and lowered opacity, once imgdesc.swf was loaded, using onloadInit()Now in the button inside imgdesc.swf. I called, this.unloadMovie(), which successfully unloads the file, but I am still inside emptymcholder, though I actually want to go back into folioholdermc.tener to check for unloadMovie. But my problem is can I place this within folioholdermc, within the onloadInit() or maybe within the on(press) function which actually calls the loader in the first place?? I need to enable the buttons within folioholdermc, and increase opacity, once the imgdesc.swf is unloaded.
Within the onLoadInit() in folioholdermc I added
_mc.addEventListener("end",endClip);
function endClip() { trace("end"); //plan to insert code to
[code]........
i want to know what is dispatchEvent in AS3.
[Code]...
I am making a class that is used to load levels, and while making the skeleton I thought I'd make some events for things like if there is an error while loading, or for when the loading finishes. So I did that and decided to test the event, via a test function that dispatches the event...but it just wont get picked up.
Here is the main class (a part of it anyway) where I'm adding the event listener.
ActionScript Code:
public function Game() {
this.addEventListener(Event.ADDED_TO_STAGE, Start);
this.addEventListener(LoadEvent.LOAD_COMPLETE, Bam);
[Code]....
why the dispatchEvent in the Load class and it's internal dispatcher class, is not getting to the eventListener in the Game class.
why my dispatchEvent is not triggering. All I'm trying to accomplish is passing a variable from the document class to a sub class.
View 2 RepliesI am trying dispatchEvent in a class (aClass extends MovieClip) that is instantiated by another class (mainClass extends movieclip),but I am not able to dispatch the custom event in the mainClass unless the aClass is added to the display list (using stage.addChild()).Is there another way to do such a thing?
View 7 RepliesI'm working on a ROLL_OVER event class and I'm stuck on an Error. Not sure what it is that I'm missing.
Code:
Error:
TypeError: Error #1034: Type Coercion failed: cannot convert
[code].....
I'm getting stack overflow errors when I'm trying to publish() a NetStream after close()ing it. Pasted below is the error stack:[code]
View 1 Repliesif 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 have movie A which loads in movie B.I then add movie C to movie B
PHP Code:
//from my movie B when a button is clicked I say
this.dispatchEvent(new Event("Home_Off"));
//in movie C I have
[code]....
I know the function with the dispatch is triggered, other things in that function happen.why would my hideHome function not get run?
What is the effective way to dispatch an event to a child movieClip? Bubbles go the wrong way! The parent is dispatching, but the child never hears the event (hmm, seems like real life). [code]...
View 4 RepliesI'm struggling to get the bytesLoaded in a class back to the main timeline. This is my class:
Code:
package com {
import flash.events.*;
import flash.display.*;
[Code].....
I've written an imageLoader class. I want to dispatch an event after the completion of image loading to the document class from which imageLoader has been initialized.
[Code]...
onLoaderComplete is the image loading complete event and onLoaderProgress is the image loading progress event. Here i have dispatched an event in inLoaderComplete event. I want to send parameters along with the dispatchEvent. How it can be done?
I'm trying to manually dispatch events on a textfield so I can manipulate it indirectly via code (e.g. place cursor at a given set of x/y coordinates). However, my events seem to have no effect.
I've written a test to experiment with this phenomenon:
package sandbox {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
[Code].....
As we can see, the events are being captured and replayed successfully. However, no change occurs in tf2 - the mouse cursor does not appear in tf2 as we would expect. In fact, the cursor remains in tf even after the tf2 events are dispatched.
I have two frames with as3 code:
// frame1:
gotoAndPlay("show controls");
// frame2 - have movieclip with name slide0
[Code]....
And I get 2 messages "slide0 show begin". But when I click on menu_item0 I have one message.
i'd like to send a dispatchEvent to a loaded swf, put into a movieclip. I found a good topic about it : as3 - dispatchEvent from a parent swf to a child swfi have a main.as
another class : submenu.as, that i import in main.aswhen i click on the "main" menu in "main.as", i would like to send a dispatchEvent to submenu.as (because i'd like the submenu to change one of its item, when i click on the "main menu" in "main.as", so i need to send a dispatchEvent to submenu.as) so i put a dispatchEvent in the method "clickButton" in my main.as : "Event.CHANGE"and in the submenu.as, i'd like to listen to this event.CHANGE, and that's what i wrote below ;-)
[Code]...
I can't use dispatchEvent in my static class, I was wondering if anyone knew how I can achieve similar functionality or if it's possible at all to call dispatchEvent from my static class? I basically want to inform my action script code in my flash file when functionality in my static class is complete.
View 4 RepliesIs it possible to dispatch an event from a public static var in Flex? I'm doing this, and Flex throws me an error:
File board.mxml: public static var actionBar:ActionBar;
<mx:VBox>
<ActionBar:ActionBar id="actionBar"/>
</mx:VBox>
File layerMng.as:
board.actionBar.dispatchEvent(...)
Error -> 1119: Access of possibly undefined property actionBar through a reference with static type Class.
I created a class which extends the displayObject3D, inside the class I tried to do two things that I usually do when I extend the Sprite class. In the constructor I created an EventListener which listens for when the displayObject3D is added to the stage and an Event dispatcher
[Code]...
How should I dispatch Events in my objects without having to extend the EventDispatcher?
View 6 RepliesI'm trying to manually dispatch events on a textfield so I can manipulate it indirectly via code (e.g. place cursor at a given set of x/y coordinates). However, my events seem to have no effect.I've written a test to experiment with this phenomenon:[code]Essentially, all this test does is to use setTimeout to effectively 'record' events on TextField tf and replay them five seconds later on TextField tf2. When an event is dispatched on tf2, it is traced to the console output.The console output upon running this program and clicking on tf is:[code]As we can see, the events are being captured and replayed successfully.However, no change occurs in tf2 - the mouse cursor does not appear in tf2 as we would expect. In fact, the cursor remains in tf even after the tf2 events are dispatched.
View 2 RepliesI'm working in this website so to avoid getting an error for adding event listeners to the buttons when they are not on stage i dispatch and event in the last frame of the animation, event that is going to be listened by the document class. Until there everything works great but when I try to dispatch an event from the document class to the sound class, it doesn't work.
FLA file
stop();
dispatchEvent(new Event(BUTTONS_DOWN));
Being a geek and spending my weekends squatting up on design patterns and have hit a problem.I'm using the MVC from AS3 design paterns book and trying to adapt it to my needs. I'm following the examples set by the book and VirtualPet and I'm just getting the error: 1119: Access of possibly undefined property STAGE_CHANGE through a reference with static type IModel.Site/srcView.asline 38 I think I have a feeling where the problem is super simple - but it is still beyond my IQ!
Also I dont understand fully what is the purpose/point of the inferface class - please could somebody explain!
[Code]...
As I'm working on a simple XML photo gallery, I am having a bit of trouble making my Slide class successfully dispatch an MOUSE_OVER and MOUSE_OUT event to the Main class.
Main.as
Code:
// add a new slide
var slide:Slide = new Slide(_slideHolder, "slide_" + no, _xml.img[no], x, no);
slide.addEventListener(Event.COMPLETE, imageLoaded);
[Code]....
When I hover over my sprites, the functions inside Slide.as gets triggered - but they don't pass the event to Main.as as I would have expected.
Strange thing is that the Event.COMPLETE gets triggered inside Main.as.
I'm trying to manually dispatch events on a textfield so I can manipulate it indirectly via code (e.g. place cursor at a given set of x/y coordinates). However, my events seem to have no effect.
I've written a test to experiment with this phenomenon:
Code:
package sandbox {
import flash.display.Sprite;
import flash.events.MouseEvent;
[Code].....
My question is more like "How dispatching custom event effects performance, if there is no listeners for these events?"
For example i have the following function:
PHP Code:
[code]...
So my question is how dispatching this events will effect performance, and should i refrain from dispatching more then 1 event. The question is relevant for both cases of the dispatched event been listened to or not.