ActionScript 3.0 :: Papervision And Event Dispatcher?
Sep 9, 2009
I created a class that extends the displayObject3d and added an Event dispatcher like bellow:
Code:
package {
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
[code]....
but unfortunately the event never dispatches.
View 1 Replies
Similar Posts:
Jun 20, 2010
I'm programming a little tank game (Check the attachment). The main class for tank is game.serovkonstantin.tanks.Tank.as and there are also 2 subclasses for now: Abrams and T90 which extend Tank. In my game.serovkonstantin folder I have a custom event (TankEvent), and the only event type inside of it which is TANK_INACTIVE.
I've added an event listener for MouseEvent.CLICK to each of the tank instances (inside Tank.as) which works just fine. When I add any of the tank instance onto the stage and click it, it traces the tank's name just like I wanted whether it's Abrams or T-90 depending on what tank I clicked. But the problem is that when I click a tank I also want it to dispatch my TankEvent.TANK_INACTIVE. The main stage has a listener for this event, so I expected it to catch the event and trace some phrase, but nothing happens I don't know whether it doesn't dispatch my event or doesn't catch it.
========
if you're interested why I need to dispatch this event, well,I suppose it will help my game know what tank to move when I click somewhere on the stage, and what tank(s) should be inactive,event it they all of the same type. I mean if I click one of the tanks it accepts all the controls while the other should be inactive
View 21 Replies
Mar 26, 2006
So I have two classes talking to each other with EventDispatcher. One is a thumbnail of an image, and when it's clicked, it sends an event to the other class to display the full size version. I'm using a MovieClipLoader instance to load the full version (and the thumbnail).
Here's how it's sending the event from the thumbnail class:
Code:
private function initButton () {
this.loadMe.onPress = function () {
this._parent.sendEvent();
}
[Code]....
The problem I'm having is it loads the full size version ONCE. After that, it no longer receives the event. The ("event received") trace no longer comes through. But the ("send event") trace continues to work.
The other weird part is if I comment out the loadClip, then the events come through just fine on both sides. But it's like after it loads an image once, it quits responding to that event ('onPhotoSelected'). Is there some kind of mis-communication between the events of the MovieClipLoader and my custom event or something?
View 1 Replies
Jan 13, 2010
I have two movieclips: MovieClip X and MovieClip Y.
MovieClip Y is nested inside of MovieClip X. MovieClip Y contains buttons with listeners attached to them. These listeners call a method
Code:
buttonClickedHandler();
inside of buttonClickedHandler();... dispatchEvent() is called to dispatch a custom event that bubbles up to MovieClip X. This chain of events works as intended, I can set up a listener in MovieClip X for the custom event and everything is fine...
The problem comes when I try to invoke a dispatch on a button in MovieClip Y without actually physically clicking it. If i call
Code:
ButtonA.dispatchEvent(new MouseEvent(MouseEvent.click));
the listener for the button click event will fire properly, and if i trace the dispatchEvent of the custom event, it returns true meaning the event was dispatched successfully. But in MovieClip X... the listener for that custom event is never fired, its as if the custom even is not bubbling.
View 1 Replies
Jul 10, 2009
How do i create a trace that can detect if an event dispatcher is dispatching an event?....my problem is i've created a custom event that is not being dispatched i use this custom event in other applications and have verified that the code is correct I'm not getting any errors neither it just dies silently
View 1 Replies
Jan 3, 2011
there are 2 functions in my code that dispatch a TweenEvent. each function dispatches the same tween and adds the same TweenEvent.MOTION_FINISH event listener. however, the event listening function must act according to which function dispatched the event. is it possible to get the function of the event dispatcher from the event listener? i could use a flag to make this work if there are no other elegant solutions.
[Code]....
View 1 Replies
Nov 5, 2011
If I have an event listener which picks up an event, how can I remove the event dispatcher? I would be looking for something like this.
Code:
addEventListener(MouseEvent.CLICK, onClick, true);
function onClick(event:MouseEvent):void
{
event.target = null;
}
View 3 Replies
May 14, 2010
I've a parent (Canvas) with many children (LinkButtons)The linkButtons trigger an event to communicate between them:[code]Now, the issue is that the event is only listened by the dispatcher child. In other words, only the child triggering the event, is receiving it. I was wondering what's wrong with it, and if I should add a listener to the parent (Canvas)I basically need the children (LinkButton) communicate between them
View 1 Replies
Dec 14, 2009
I'm still getting confused with the whole event dispatching feature...all I need to do is fire a single event from a child swf to it's parent in as2..
View 0 Replies
Jul 30, 2011
I have a loaded swf (CustomClass) and I want to listen a dispatch event from the swf, but it doesn't seems to work. The relation of the dynamic class are:
Code:
tablet(DocClass of the swf) ---> mainmenuC
I'm trying to pass a event to a function in tablet, and have the codes listen to the dispatchEvent from the function in tablet.
ActionScript Code:
CustomClass.addEventListener("profile_home", currentPage)
private function currentPage(event:CustomEvent):void {
trace("profile home clicked")
} tablet.as
[Code] .....
It doesn't return any error, but why does it not pass the data?
View 2 Replies
Aug 22, 2011
I'm building a flash app (just AS3 with FlashDevelop) and I'm having some trouble keeping things loosely coupled around the event system. I've done a lot of reading about central event systems and static eventdispatchers but they don't quite fit the bill for me. What I'm building is similar to a video player.I have a Player class which is the parent of all the other little parts of the app.The Player class extends Sprite and I've currently designed it so that you could instantiate multiple Player's and put them on the stage.I also have a Controller class which extends EventDispatcher and I dispatch all my events through this class. It's a central event class.
The problem is that I need to pass around a reference to this class so that all the other classes can dispatch and listen through it. Passing around the reference works but it's the exact opposite of loose coupling. I know I could make a static EventDispatcher that all the classes could see but then if I had two or three Player's on the stage they would all hear each others events.How can I create a type of sandbox that will allow all the child classes of a Player instance to be aware of the central dispatcher without passing a reference or making it static?
View 1 Replies
Jul 29, 2009
I'm having an issue with an event dispatcher and an event listener. Here is the application code...
Code:
Select allpackage {
import flash.display.MovieClip;
import flash.events.*;
import flash.net.URLVariables;
import SendAndLoad;
public class Test extends MovieClip {
[Code] .....
It will trace the loader.data variables but doesn't dispatch the event to the main application (Test). I'm listening for the event on the stage of the main but it doesn't trigger the event to display that the login has been successful even though it traces from the sendAndLoad class...
View 3 Replies
Feb 4, 2009
I've built a custom event dispatcher:
Code: Select allpackage com.tests{
import flash.events.EventDispatcher;
import flash.events.Event;
[Code].....
The event traces out that it successfully fired, but the listener doesn't catch it...
View 2 Replies
Aug 25, 2009
So I have a small game where I have implemented a* path finding. I have a spot where a player moves around the screen along the path found. I have a section where i know the user is at the end of the path and I am looking to dispatch an event at this moment so I can do things at the end of the path.
i have imported the aStar_path_dispatcher file into the move class then i do,
[code]...
then in my main document class i import the aStar_path_dispatcher again, and set up an instance of it: then add a listener:
[code]...
however this "move finished" doesn't seem to want to work. I have never used custom events before
View 2 Replies
Mar 4, 2010
If I create an object like so:
class Foo {
[Bindable] public var property: String;
}
The class Foo has an implicit event dispatcher to handle property change events. How can I access that without making Foo explicitly extend EventDispatcher?
View 1 Replies
Mar 24, 2011
I am trying to build a portfolio application similar to the used by Whitevoid. I am using Flex 4 and Papervision3D 2. I have everything working except for one issue. When I try to load an external SWF as a material on one of the planes, I can see any native Flex or Flash components in their correct positions, but the papervision objects are not being rendered properly. It looks like the viewport is not being set in the nested swf. I have posted my code for loading the swf below.
private function loadMovie(path:String=""):void
{
loader = new Loader();
request = new URLRequest(path);
[Code]....
Below I have posted two pictures. The first is a shot of the application running by itself. The second is the application as a MovieMaterial on a Plane. You can see how the button created as a spark object in the mxml stays in the correct position, but papervision sphere (which is rotating) is in the wrong location.
View 1 Replies
Jan 22, 2009
Ok I have 3 classes as an example. Main.as
AutoSlide.as
ControlPac
Main looks like this.
Code:
package com {
import flash.display.Sprite;
import flash.events.Event;[code]....
But I also though other objects could be setup to listen for an event that has been dispatched. This is why I put a listener on ControlPac
Code:
controlPac.addEventListener(AutoSlide.CALL_SLIDE, callNextSlide);
But its not hearing the dispatched event. I tried to extend ControlPac as an evnt and also as a Sprite but its still not able to receive dispatched events from another object
View 5 Replies
Apr 11, 2010
I was studying about EventDispatcher and tried to make my own class and interface IEventDispatcher.Then later i was wondering, what use does the interface have anyway when you still have to declare the functions that are in the interface to the class that implements the interface? The dispatcher will still work without the interface. Like addEventListener, removeEventListener, these functions are within EventDispatcher so why do i need an IEventDispatcher?
View 3 Replies
Jan 29, 2011
I have a ColorPicker Component and I want to (on its CHANGE EVENT) have the LISTENER OBJECT ( known as A) change ANOTHER OBJECT's (known as B) color, based on the ColorPicker's.selectedColor. I do this because i need OBJECT A to keep track of the colors used. Also OBJECT B is dynamic and its instance is based on USER INTERACTION thus B can equal B1 or B2 or C based on mouse click at any given time but must only be 1 at any given time. SO I'm trying to "chain" the events together using listeners/ or delegation but I'm not sure at the logic.how do i reference the objects in the event? should I just try to chain B to listen directly to the event? How can I do this without having to attach listers to the colorpicker every time?
View 8 Replies
Dec 7, 2009
I need to pass a variable in dispatcher tag... for instance
[Code]....
Now how can i pass the user in the mate dispatcher tag.
View 1 Replies
Dec 1, 2010
I have been having an issue that I can't seem to solve, I have been fumbling with it most of the day. I am tying to dispatch a custom event in one class and listen for it in another. Here is how my app is built. I have a main swf that loads another swf called LoadingDoors into it. In my LoadingDoors Document class I dispatch a listener:
private function timerListener(event:TimerEvent):void
{
if(doorsMC.currentFrameLabel == "Closed")
[code].....
View 6 Replies
Apr 25, 2006
I've tried to make an XML parser class using ASBroadcaster, that would act as a listener, and then have methods like getNode(n), which when called, would return the value of that node as a string to the dispatcher/caller.
This doesn't really work all that well, since I'm unsure of how to adress the dispatcher/caller in an economic way.
Do I have to supply the caller object as an argument when broadcasting from it, then do another broadcast for setNode inside the XMLParser.getNode method, supplying it as an argument again, and then check with an if statement in the setNode of the caller, whether it is the right one or not. Seems a bit over the top.
I'd want XMLParser to be a centralised class, that all other objects would refer to via some listener or get/set thing, instead of having an instance of it in each of the objects that would use it.
View 1 Replies
Jun 22, 2011
I have a GlobalDispatcher Singleton class extending EventDispatcher that can be accessed through a static getInstance () method by any class after the constructor has been called. i have a host movie that calls the GlobalDispatcher constructor and sets up a listener for a custom event. This host movie then dynamically loads in a different external movie (in the same domain as the host). This movie calls the getInstance method to get the instance of the GlobalDispatcher. Then after an animation it has the GlobalDispatcher dispatch the same custom event the host is set to listen to. The host then captures the event dispatched by the dynamically loaded movie.
View 1 Replies
Oct 19, 2009
I asked this question in papervision 3d forums, but nobody replied. So. I am writing a 3D application with actionscript 3 and papervision 3D. But I have stuck on one problem, I can't figure out, how to place skidmarks (decals?) on an object. The only method I can think of is drawing directly to BitmapData (texture). What would you suggest to draw a textured skidmark on ground (plane primitive)?
View 1 Replies
Jul 2, 2009
I have done globe in papervision - basically sphere + material (image of political map) over it.Now, I need to make every country on my globe interactive, what means, I need somehow create event listeners for lots (at least 15) of small areas on my globe, and if I click those areas, something will happen (say, additional info windowwill come out)I googled a lot and found a lot of things describing some realted stuff (hotspots?), but since I am quite new in flash/actionscript/papervision, could I, please, get some introductory idea how my problem might be solved?
View 1 Replies
Jul 27, 2009
i was trying to put text in papervision but am having touble.
View 4 Replies
Aug 21, 2009
Is there any development tool that has the papervision3d classes buit-it, so i can get hints when i'm writing th code as i get hints for as3 code?
View 2 Replies
Feb 12, 2009
I am new to Papervision, and am experimenting on importing animated 3ds max models into my project.I can export a model (with no animations) into Collada format, and import it using Papervision, with no problems. But when I try to import a model with animations, i get this error:[code]I am using Flash CS 4 / Papervision3D Public Beta 2.0 - Great White / 3D Studio Max 2009 (with the New Collada Plugin).
View 7 Replies
Jan 4, 2011
I am trying to develop a game based on papervision and flash.the very basic idea of the game is that some 3D objects are falling from the sky and you have to catch them .. At a time there can be as many as 20 of such 3D objects on the stage.Now the problem is that these 3D objects are causing too much CPU usage .. I was hoping if there was another way to do the same thing and which causes less of performance issues ...
1.I have two classes suppose A and B
2.the class A calls class B
3.class B initiates a 3D sphere whenever it is called .. the Sphere has a bitmap image material .. and it rotates along the X axis on every enter frame event
4.class A has a timer function which moves the 3D object in the Y direction and also destroys it when the object reaches a specified Y position ..here are the code snippets ...
Class A :Code:
public function onTick(e:TimerEvent)
{
if(Math.random() < spawnrate)[code]......
View 2 Replies
Apr 11, 2011
trying a simple papervision tutorial and swf stops rendering by mat = new MovieMaterial(rec);
[Code]...
View 2 Replies