ActionScript 3 :: DispatchEvent Does Not Work In Secondary Class
Jan 14, 2011
I have a SWF called Application.swf that loads another SWF called jeu.swf. My main class (don't know how to call it haha), is called Main.as. Another class is called actionObjets.as. When I call:
dispatchEvent(new MicroJeuEvent(MicroJeuEvent.JEU_TERMINE, 8, ""));
It works perfectly from Main.as, it works perfectly.
But when I call it from actionObjets, it doesn't work. No error either. I tried putting this line in a static function, doesn't work either. Why can I dispatch an Event from my main class and not from another one? I'm not a programmer and I just don't get a few of the basic principles of as3. Is there a way of doing differently?
i am quite new to Actionscriot although i have lots of programming background. My application displays an image (with glow effects) via FLEX that has a link on it. Since the user would have no idea that this image is clickable, i want to set a tooltip that should come up after the image has been displayed. Here is my code fragment :
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.
I can communicate an event between any of them fine using a dispatchEvent and addEventListener, and I can get values from the card & board actionscript files into main.as using e.target.*
However for some reason I just cannot get a value to send from main.as to the card or board classes using this same method. And I'm literally stumped as to why.
I'm trying to dispatch a custom event. So that my main document class can react when a nav button is clicked.I have a navbutton class which creates the dispatch's the event... and is handled by the onNavigate Method...
This onNavigate method works perfectly.... however when I try to create a listener in my main document class I don't "hear" the event.Here's part of the code from the main doc class...here's where I register the listener
this.addEventListener("NAVIGATE", doSomething);
here's where I should handle it...
private function doSomething(e:Event) { trace(e.target.name); trace(e.target._label.text);
Like most Flex/Flash Builder developers, I have been using the dispatchEvent method to communicate between different classes of an application. And, that works fine, but, I have been toying with a different idea about inter-class communications and would like you to shoot it down, if you can.
Why not have an application "state" class, instantiated as a singleton, which holds the information that is needed by the application's various classes? Examples would be current user and session, currentState of the parent application, selection criteria, data providers, etc. Each class would, of course, have to be aware of this state class. Each class in the application would post its relevant state to this "state" class, and likewise each class could establish listeners for changes to the relevant objects therein.
It just seems to me that, rather than dispatching events, setting up listeners that in turn fire off a listener method, I could instead bind, for example, a datagrid to the state class' relevant data provider, or whatever is needed. In other words, all "listening" and binding is performed against a single state class.
Is there a mechanism by which an AIR application can manually display in whichever monitor I choose? I can look at the display list in Screen.screens, but I'm unclear on how to actually force the drawing of the app into one of those.
Everything was going fine on a website project I've been working on, until yesterday. I'll try to explain the whole scenario first, and I'll put the code in here too so anyone can try to figure out what is wrong. Here's the breakdown of the site:
1) There is a MAIN SWF file that plays an intro and then stops on the last frame with the "Main" Navigation buttons.
2) Inside the Root folder where the MAIN SWF resides, there is another folder called "swfs" which contains six main external navigation pages, as well as another folder called "galleries" which contains additional external swf files for six gallery pages.
3) On one of the layers of the MAIN SWF, there is a movie clip called "mySWFLoadingClip" that the "Main" Navigation buttons load and unload the main swf pages onto. These all work perfectly. The problem start on the next step. This is the code I used for the navigation buttons on the MAIN SWF timeline:
var Xpos:Number = 0.0; var Ypos:Number = 0.0; var swf:MovieClip; var loader:Loader = new Loader(); var defaultSWF:URLRequest = new URLRequest("swfs/home_page_swf.swf"); [Code] .....
4) One of the external navigation SWF pages is called "portfolio_page_swf" and gets loaded into the "mySWFLoadingClip" moveclip on the MAIN SWF. This is where the problem begins. The "portfolio_page_swf" has six buttons that call out to an additional external swf from the galleries folder. Now when I open the "portfolio_page_swf" file to test out if the buttons work, they work perfect. When I click the buttons, the external swf gallery files show up like they should. But the problem is that when I open the "MAIN SWF" file to test out the site, I can click the Main Navigation buttons and they work. I click on the Portfolio button on the Main SWF time line, and it places the "portfolio_page_swf" onto the stage like it should, but when I click the buttons that are within the "portfolio_page_swf" the galleries don't show up. The buttons from the "portfolio_page_swf" page only work if I open the "portfolio_page_swf" file directly.
Here is the code that is used in the "portfolio_page_swf": var Xpos:Number= 0.0; var Ypos:Number = 0.0; var swf:MovieClip; var loader:Loader = new Loader(); var defaultSWF:URLRequest = new URLRequest("galleries/gallery_print_swf.swf"); [Code] .....
How to load an External SWF onto the main time line and then load an additional external swf from within the first external swf.
I'm currently working on a project where I mix animation sequences with short videos. My project also has two scenes and the FLV will be placed on the main time line of the second scene. The problem I am having is, if the movie is previewed from the first scene, or exported, the FLV on scene 2 won't load. the timeline on the playhead will just spin. I'm currently using "Load external video with playback component" as the method for importing the flv file.I have already worked with this video multiple times in other flash files and have never had a problem loading the video. Is there a limitation to FLV playback in multiple scene movies?
Does anyone know of a way to get Flash CS5 for Windows to preview an animation in a secondary browser?
Dreamweaver CS5 lets you specify a browser as a secondary browser -- pressing Ctrl+F12 launches it. In Flash, however, F12 and Ctrl+F12 both launch the primary browser...
I'm having a problem trying to call an specific label or frame in a secondary MC.
-There is a main time line (120 frames) with an Intro animation stop in frame 103.
-There is 2 buttons in frame 103 (b1,b2). On release this buttons play 104 and stop in the last frame of the main time line (120).
-In the frame 120 these 2 buttons fade and an MC called navmenu and an empty mc (to load external flash) appear
-MC navmenu is the main menu with 6 frames, one for each button.
I'm trying that when I click on b1, it play 104 go to the end of the main time line, and call frame 3 on navmenu MC, plus load movie on empty MC.[code]...
I have a line chart with a column chart as a secondary series. When I roll over the line, the datatips appear. However, if I move the mouse to a spot where a column appears while still on the line, the data tip item appears for the line AND the column. How do I get it so that I only show datatips for the line but not the column?
I have a main flash movie, that launches an external swf. Now this works fine, but this external SWF, launches more external mini SWFs. What happens is that after going opening and closing these mini swfs, is that eventually the main swf, will start to to run beneath the the 1st external swf. i.e. I have a small animation that is suppose to stop and remain invisible until the secondary swf is closed.
But this is not the case, and very randomly this will start to happen, and it makes everything look like crap. At first I thought it was the fonts that I was using through out the swfs, because there were some design changes, but after updating the SWFs with the new embedded font I am still running into this issue. Look at it like this. main swf---->2nd swf--->numerous 3rd swfs
I was wondering why my current code for calling a setInterval on a function doesn't work inside my class.I have this code inside one function, calling a second function.
The selfReferential keyword refers to the current class,but was defined previously (selfReferential = this; ).I get no errors, but the dupe() function is never called.and I had the selfReferential variable replaced with the this keyword at one point as well.
I need to make a video page. i used a flash player and implemented the videos on the pages. now my client needs that, the same page have to work with ipads, i know that we have to use html5 video player for that.
My question is in case eventhough html5 video supportable player available that should play the flash content first. in case it will not run the flash player then it should run the html5.
I have an array of three values.focal[x,y,z]these values change based on user input.however when the change occurs, they are logged into a new array to test for valid changed.A simplified psuedo version of my code:[code]However, when the focal[1]++; focal[0]--; ect, ect, code takes place. It also changed the temp array.and since it changes my temp, it never resets me original code back to its previous nature.I have never seen this behavior and its kinda throwin' me off.
I 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?
One 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
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.
I 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?
I'm trying to highlight some text in AS3 (ie, the text's background) and it's proving to be quite hard. I've found a class that is meant to do - search google for "AS3Text Highlighter". However, when I publish the files, I get the errors:
Code: Scene 1, Layer 'Layer 1', Frame 1, Line 11172: Definition com.formatlos.as3.lib.text:highlight could not be found. Scene 1, Layer 'Layer 1', Frame 1, Line 11172: Definition com.formatlos.as3.lib.text:highlight could not be found.