Communicating between instances


Can I have an instance of one class call a function in the instance of another class if the first class was instantiated in the second class Essentially this:
Code: //Class 1 public class main { var helper:Helper; var callBack:Function; public function main () { callBack=callbackFunction; helper=new Helper(1,callBack); } public function callbackFunction() { trace("called"); } } //class 2 public class helper { public function helper(input:int,_callback:Function) { if(input==1) { //call the callback function in class 1 } } } I can think of is have both main and Helper extend displayObject, do addChild() and use parent/child to communicate between the two. This seems superfluous though. Or I suppose it could also be possible to call a static function, but that seems too limiting.

side note: this seems like something I would be able to find by searching the immense amount of as3 articles and forums online, and maybe I am using the wrong search terms, but i could not find anything related to this.
Posted On: Thursday 3rd of January 2013 10:20:34 PM Total Views:  233
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




Flash AS3: Scale tween stops in between

, I have created a movie clip loader in my main movie and once I click on the button in main movie it loads external swf files accordingly. I have also added script so that the external swf will be scaled from "0" to "1" on both the X and Y axis. it works sometimes. But sometimes it scales movie not upto 100% it scales it around 20 to 30 %. I am not getting why My code is correct or what Please guide... my code is; Code: btn1.addEventListener(MouseEvent.CLICK, loadExMovie); function loadExMovie(e:MouseEvent):void { myContentLoader.unloadAndStop(); myContentLoader.load(new URLRequest("4.swf")); var myTween1 = new Tween(myContentLoader,"scaleX",Strong.easeOut,0,1,1,true); var myTween2 = new Tween(myContentLoader,"scaleY",Strong.easeOut,0,1,1,true); }
VIEWS ON THIS POST

74

Posted on:

Thursday 25th October 2012
View Replies!

Flash Problem with transition between background images

Hi all, I'm new here and to flash so hopefully what I'm about to ask isn't stupid... I'm making a portfolio website, and I have everything set up and working nicely, with the exception of the background images. I've got 5 different links, each one told to load it's own background image when clicked via a UILoader from the main index file. The problem I'm having is in-between the transitioning of the old and new image, the old image completely disappears while the new one is loading and fades in. Basically, the background image disappears and I'm left with a white screen while the other image is loading and before it shows. What I want it to do it for the old image to remain on the screen and then the new image to fade in on top of it. The script I'm using is as follows: (Relevant code highlighted in red) Code: mainImage.source="images/Bkgd1.jpg"; mainImage.addEventListener(ProgressEvent.PROGRESS, bkgdImagePreloader); function bkgdImagePreloader(event:ProgressEvent):void { var percent:Number = Math.round((event.bytesLoaded*100)/event.bytesTotal); percent_txt.text="Background Loading "+percent+"%"; } //Background 4 = ABOUT //Background 5 = SERVICES //Background 8 = CONTACT //Background 6 - PORTFOLIO //Fade in of image mainImage.addEventListener(Event.COMPLETE,fadeIn); function fadeIn(e:Event):void { var myAlphaTween:Tween=new Tween(mainImage,"alpha",Regular.easeOut,0,1,1,true); } Then after some movement: Code: function moveLogo(theXLPosition:Number, theYLPosition:Number, theLRotation:Number, theSection:String, theBackground:String):void { sectionLoader.source=null; var myxTween:Tween=new Tween(logo_mc,"x",Regular.easeOut,logo_mc.x,theXLPosition,1,true); var myyTween:Tween=new Tween(logo_mc,"y",Regular.easeOut,logo_mc.y,theYLPosition,1,true); var myrotateTween:Tween=new Tween(logo_mc,"rotation",Regular.easeOut,logo_mc.rotation,theLRotation,1,true); myrotateTween.addEventListener(TweenEvent.MOTION_FINISH, donePlaying); function donePlaying(e:TweenEvent):void { sectionLoader.source=theSection; mainImage.source=theBackground; } } Hope someone can help me, it's driving me nuts.
VIEWS ON THIS POST

56

Posted on:

Thursday 25th October 2012
View Replies!

toggling between swf's

Just wondering if there's an easy solution to toggle between swf's on a web page. I have page with a swf embedded on the page and would like to "switch" or load other swf's in that spot based on a link the user clicks. So say when the user lands on home.php, it loads "a.swf"... then they click on a link and it loads "b.swf" and so on. I understand this could be done within the flash file itself (by loading external swf's) but was wondering if this could be done "outside" the flash file.
VIEWS ON THIS POST

72

Posted on:

Thursday 25th October 2012
View Replies!

RegExpressions - Removing everything in between?

Say I have the following string: "Cotton 231 is & great43 for fun: Cotton"; I want to find and delete everything between the words Cotton via RegExp (because I don't know what will be inbetween Cotton, I just know Cotton is the magic word every time). I can .replace, which I intend to do, but I can't figure out what the RegExp would be Anyone know how this can be done
VIEWS ON THIS POST

89

Posted on:

Thursday 25th October 2012
View Replies!

event listener between classes

Hi I have a slider what changing zoom in my main class and I have around 30 instances of another class on screen in different movie clips containers. I want all 30 instances react when in main movie slider change position. From other words. I want to set event listeners in each child class and dispatch event when its appeared in main movie. Code: class main{ private function zoomSldChanged(evt:SliderEvent){ someObject.dispatchEvent(new Event(Event.CHANGE,true,false)); } } class sids{ function sids() someObject.addEventListener(Event.CHANGE,sliderCHANGE); } private function sliderCHANGE(evt:Event){ trace("Hi"); } } I feel like I need someObject Object to listen events but what is someObject should be Is it possible to do so any help appreciate.
VIEWS ON THIS POST

77

Posted on:

Thursday 25th October 2012
View Replies!

AS3,problem communicating with an external SWF file

Hi I have loaded an external SWF file, now I am trying to communicate with a button inside that SWF , BUT FOR SOME REASON IT GIVES ME THIS ERROR TypeError: Error #1010: A term is undefined and has no properties. at galleryMovieTest/onComplete() I don't get it what is undefined here is the code: stop(); var holder:MovieClip = new MovieClip(); stage.addChild( holder ); if(currentFrame == totalFrames) var imageRequest:URLRequest = new URLRequest("bgSlider.swf"); var imageLoader:Loader = new Loader(); imageLoader.load(imageRequest); addChild(imageLoader); var WIDTH:Number = stage.stageWidth; var HEIGHT:Number = stage.stageHeight; imageLoader.x = WIDTH-WIDTH - 250; imageLoader.y = 50; imageLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, onComplete); function onComplete(event:Event):void { event.target.content.figuers_btn.addEventListener( MouseEvent.CLICK, goToFiguresLable); function goToFiguresLable(event:MouseEvent):void { gotoAndStop("figures"); } }
VIEWS ON THIS POST

101

Posted on:

Thursday 25th October 2012
View Replies!

Custom Event conflict between swfs (Error 1034)

I'm using a custom event (HotEvent) to make the communication between a loaded swf and its container, but im getting some strange error if i set the event handler parameter type: Code: TypeError: Error #1034: Type Coercion failed: cannot convert globals::HotEvent@32e5761 to globals.HotEvent. at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at wallpaper.view::Wallpaper/wallpaper.view:Wallpaper::closeBtnHandler() it works fine i dont type the handler function, like this: Code: private function sectionCloseHandler(e:*):void { } any ideas on how to solve this conflict
VIEWS ON THIS POST

68

Posted on:

Thursday 25th October 2012
View Replies!

Variables between AS Files

I have variables declared (I assume) in Main.as and I wish to use them in other AS files such as pg1.as Here's my code: Code: //Main.as package { import fl.controls.*; import flash.text.*; import flash.events.*; import flash.net.*; import flash.display.Sprite; public class Main extends Sprite { public static var tf_CSM_17_l:TextFormat = new TextFormat(); tf_CSM_17_l.font = "Comic Sans MS"; tf_CSM_17_l.bold = false; tf_CSM_17_l.color = 0x000000; tf_CSM_17_l.size = 17; tf_CSM_17_l.align = TextFormatAlign.LEFT; //several more almost identical declarations function Main(){ var Page1:pg1 = new pg1(); Page1.pg_1(); } //lots more coding not relevant to the problem } } //pg1.as package { import fl.controls.*; import flash.text.*; import flash.events.*; import flash.net.*; import flash.display.Sprite; public class pg1 extends Sprite { public function pg_1(){ var pt1:Label = new Label() pt1.setStyle("textFormat", tf_CSM_17_l); pt1.move(102,93); pt1.width = 789; pt1.height = 284; pt1.text="some text"; addChild(pt1); } } } this produces the following error: 1120: Access of undefined property tf_CSM_17_l. I assume its in the wording of the "public static var". What should be used so that this variable is available to all AS files
VIEWS ON THIS POST

49

Posted on:

Thursday 25th October 2012
View Replies!

Custom events vs. "callback hooks" for loosely-coupled messaging between Classes

Given the warm and well-considered responses I got from my recent post, I thought I'd posit another one to the Flash Gods. I'm considering a controller/view model where you have one Class that's handling creating the graphics, the buttons etc, and listening for user input, such as keyboard input, clicks on buttons, rollovers, what have you. A second Class is handling the business logic - for example, what to actually DO when a button is clicked, change the state of the application etc. The project doesn't warrant a full MVC implementation (like PureMVC) but I'm still trying to follow some best practices here. The question is - is there any bias toward setting up communication between these classes using Custom Events, or is a simple callback interface acceptable I tend to invent my own terminology, since I have no formal background, so I need to illustrate my point, at the risk of being once again too verbose: Option 1: Custom Events 1. User clicks Button A 2. Class "View" is listening for a MouseEvent.CLICK event on that button 3. "View" then dispatches a custom event (View.BUTTON_CLICKED) 4. Class "Controller" is registered to listen for View.BUTTON_CLICKED 5. The appropriate function is called within Controller that then goes and does something useful. Option 2: Callback Hook 1. Class "View" has a public setter method onButtonClicked which accepts a Function reference as its only parameter and assigns this to a private variable 2. Class "Controller" which has a reference to Class "View" calls onButtonClicked and passes a reference to a function defined in Controller that will handle the event 3. User clicks Button A 4. "View" is listening for MouseEvent.CLICK on that button 5. "View" does its own (view-related) processing and then calls the callback function (in "Controller") that will then go and do something useful. I hope the distinction is clear. Are there any obvious advantages / disadvantages to one approach over the other
VIEWS ON THIS POST

92

Posted on:

Thursday 25th October 2012
View Replies!

Difference between Flash and Flex generated SWF?

there, please bear with me while I try to explain this clearly... also, if this is posted in the incorrect please, please point me in the right direction. I have a working add-on for an online world called There. It is what's called a compass replacement, and its written in AS2/Flash CS4. It works pretty well, however for a variety of reasons I want to move the project to AS3/Flex. Doing the conversion will require a near-complete rewrite, of course. Before I got started on the rewrite, I wanted to investigate using the Flex framework to make things more visually appealing. However, I can't really get that far with that becaue I hit another roadblock, even when trying to make a pure AS project in Flex. Here's the problem I'm having... I have tried many things and I'll just boil this down to the crux of the issue. I am experiencing a long pause when starting my app in There. It doesn't matter if it's a Flex Project or an ActionScript project in Flex. I tried both to experiment. Either one will give a long pause, freeze the There client, and sometimes crash There. I think the pause itself may be the cause of the There crash, as it doesn't always crash the There client. I can take the same code, bring it over to Flash, compile it, and it starts up with no delay. Of course that means I won't be able to use Flex, but if forced to thats what I'm going to have to do. So basically, my question is... how does the SWF file generated by a ACTIONSCRIPT PROJECT's SWF file made in Flex differ from the one compiled in Flash Is there anything I can do, any compiler settings to try to see if I can get it to work again I do know that There uses the standard Flash player, as when I check my There version in my AS2 (working) compass, it reports the latest version. Obviously this is a major roadblock to me getting on with the main development work, and I would prefer to develop in Flex if possible, but will go to straight AS3 code (in Flash) if necessary. I would even prefer to do AS3 coding in Flex, but that's the problem, since nothing I compile in Flex will work right in There. I have tried seeing if using a preloader would make a difference, it did not. Any insight is sincerely appreciated.
VIEWS ON THIS POST

76

Posted on:

Thursday 25th October 2012
View Replies!

Switching between Hi/Lo bandwidth video

I have a 2 hour long show that users will view online. I have a high bandwidth version and a low bandwidth version. I noticed when switching between the high and low bitrates, it shows the first half second or so of the newly loaded FLV and then skips to the time they were at. Anybody know what would cause that Here is my function that toggles quality: Code: function toggleQuality():void { var currentTime:Number = vid.playheadTime; if (currentQuality == "low") { trace("switching to high"); qualityBtn.txt.text = "Std-Res"; vid.stop(); currentQuality = "high"; vid.source = p._high; addCuePoints(); vid.bufferTime = 3; vid.playheadTime = currentTime; } else { trace("switching to low"); qualityBtn.txt.text = "Hi-Res"; vid.stop(); currentQuality = "low"; vid.source = p._low; addCuePoints(); vid.bufferTime = 3; vid.playheadTime = currentTime; } }
VIEWS ON THIS POST

81

Posted on:

Thursday 25th October 2012
View Replies!

Trouble communicating between classes.

I'm having a little trouble with adapting to AS3. I'm trying to call a function from a class that I've instantiated on the main timeline from another class that I've also instantiated on the timeline. The function I'm trying to call adds a line to a string that acts as a game terminal so that even if the game glitches for someone without the source code, it would be possible to read the variable changes and functions called. (it also doubles up as an input for unlocking characters and levels that are otherwise hidden) Main Timeline: Code: import britland.Character; import game.terminal; var GameTerm=new Terminal(); var TeaGirl=new Character("Tea Girl"); game.terminal.as: Code: package game{ class terminal { var termData:String; var termComm:Array; public function terminal():void { this.addEntry("Terminal Initiated."); } public function addEntry(input:String) { termData+=("\n"+input); trace(termData); } } } britland.character.as Code: package britland{ public class Character { var charName:String; var charHP:int; var charHit:int; var charKick:int; var charSpec:int; var charBlock:int; public function Character(CName:String) { charName=CName; //trace("Character Created:"+charName); (*see note).GameTerm.addEntry("Character: "+charName+" created."); } } } * I've tried both "flash.display.DisplayObject.stage" and "this.parent.parent" here after discovered that "_root" has been removed and "root" doesn't work in the same way.
VIEWS ON THIS POST

72

Posted on:

Thursday 25th October 2012
View Replies!

how to reduce the gaps between vertical column in flex 3 charts

hi, I am using flex 3 column charts.I want that the vertical columns in the column charts should have no gaps between them i.e. they should be adjacent.Is that possible How
VIEWS ON THIS POST

128

Posted on:

Thursday 25th October 2012
View Replies!

Event propagation between classes? [AS3]

, I've been reading up on Event's in AS3 today, and... I don't grasp it completely... Actually I fail pretty bad . Anyway, is it possible to accomplish event propagation between classes If it is, say I have a Class called CustomClass and it creates a instance of another Class, CustomSubClass in it, would propagation be possible in such a manner And if it is, would those custom classes need to extend EventDispatcher or similar
VIEWS ON THIS POST

67

Posted on:

Thursday 25th October 2012
View Replies!

Listener between two .swf files is a bit touchy...

So I am going off of an example I believe was in the tip of the day thread, although I could be mistaken. It is a fairly trivial example (I removed the non-essential modifications I've been adding to this) for loading one movie from another. The problem I am having is when I click on the movie, I get a rather generic error: Error #2044: Unhandled StatusEvent:. level=error, code= I tried using some try-catch logic, but wasn't able to figure out what the problem was. Any advice Code: // FILE 1 // AS2animation.fla // one movie clip animation named animation_mc on the timeline // local connection instance to receive events var AVM_lc:LocalConnection = new LocalConnection(); // stopAnimation event handler AVM_lc.stopAnimation = function(){ animation_mc.stop(); } // listen for events for "AVM2toAVM1" AVM_lc.connect("AVM2toAVM1"); //FILE 2 // AS2loader.fla import flash.net.LocalConnection; // local connection instance to communicate to AVM1 movie var AVM_lc:LocalConnection = new LocalConnection(); // loader loads AVM1 movie var loader:Loader = new Loader(); loader.load(new URLRequest("AS2animation.swf")); addChild(loader); // when AVM1 movie is clicked, call stopPlayback loader.addEventListener(MouseEvent.CLICK, stopPlayback); function stopPlayback(event:MouseEvent):void { // send stopAnimation event to "AVM2toAVM1" connection AVM_lc.send("AVM2toAVM1", "stopAnimation"); trace("Should be stopping now"); }
VIEWS ON THIS POST

73

Posted on:

Thursday 25th October 2012
View Replies!

nested importing between .as files

I'm used to C++ and AS2, really enjoying AS3 but I need to know how close to C-like structure I can go: Can you nest calls to import classes between .as files, like you would with header files in a C++ app For example, if I have one class like so: Code: package { import flash.display.MovieClip; class MyClip extends MovieClip { /* etc etc etc */}} and another like so: Code: package { import MyClip; public class MyClass { }} Is there a way to get the second file, the one that imports MyClip, to also import MovieClip by extension, since MyClip has the import call in its own code I want to avoid having to write lots of repetitive import statements for every class I define.
VIEWS ON THIS POST

87

Posted on:

Thursday 25th October 2012
View Replies!

[Q] Difference between XML, XMLList and XMLDocument?

Hi all Could any body explain .. what is the difference between XML, XMLList, and XMLDocument Code: var theList:XML = new XML(theXML.data); As the above syntax can retrieve the XML data, why we still have to use XMLList \t
VIEWS ON THIS POST

68

Posted on:

Thursday 25th October 2012
View Replies!

passing variables between swf files

In file1 I have a variable called myvar; I load file2 using the Loader class using code below. What do I need to do to get the value of myvar from file2\t Just a plain old trace(myvar) in file2 doesnt work. Code: var myvar:String="hello"; var myloader:Loader= new Loader(); addChild (myloader); var request:URLRequest = new URLRequest("file2.swf"); myButton.addEventListener(MouseEvent.CLICK, loadIt); function loadIt(event:MouseEvent):void { myloader.load(request); }
VIEWS ON THIS POST

59

Posted on:

Thursday 25th October 2012
View Replies!

Turn off throttle down/sleep mechanism in Flash Player 10.1?

I am wondering if any of you know of a way to turn the throttle down (sleep) mechanism off when a C++ app is hosting the flash activeX control. The flash control is invisible in this case and so the flash app will throttle down. Tinic Uro does not seem to be answering questions related to work arounds for apps that might not want flash to throttle down. This is especially annoying when you are hosting the flash control in your own application.
VIEWS ON THIS POST

52

Posted on:

Monday 29th October 2012
View Replies!

loader class for image and video

Hi i wanted to load image and video using loader class.The reason for this is , the xml which i am loading i, is using same tag for video and image so i cannot decide which thing will be loaded. Although i have a code for loading the two using loader class but the problem arises when i want to add cue points for the video. Given below is snippet of my code var imageLoader:Loader = new Loader(); imageLoader.load(new URLRequest(url)); imageLoader.contentLoaderInfo.addEventListener(Eve nt.INIT, imageLoaded); var mcInst1:MovieClip = new MovieClip(); addChild(mcInst1); mcInst1.addChild(imageLoader); This is able to load swf (for video) and image. But how to add cuepoint for video Even if it is not possible to add cue point using loader class, what other alternative is there to support these requirements (loading both video and image using common method) and adding cue points for video
VIEWS ON THIS POST

88

Posted on:

Monday 29th October 2012
View Replies!

1120:Access of undefined property button.

Please .. i dont get what im doing wrong. AS3 Doc with 2 mc's with instances on stage"box1" , "box2" getting this error cant past trough it.. cant figure out what im doing wrong. Any help would be appreciated 1120: Access of undefined property button. button.addEventListener(MouseEvent.ROLL_OVER, overHandler); PHP Code: importcom.greensock.*;importcom.greensock.easing.*;importflash.events.MouseEvent;vartimeline:TimelineLite=newTimelineLite();timeline.append(newTweenLite(box1,1,{y:"-100"}));timeline.append(newTweenLite(box2,1,{y:"-100"}));button.addEventListener(MouseEvent.ROLL_OVER,overHandler);button.addEventListener(MouseEvent.ROLL_OUT,outHandler);functionoverHandler(event:MouseEvent):void{\t\ttimeline.reverse();}functionoutHandler(event:MouseEvent):void{\t\ttimeline.play();}
VIEWS ON THIS POST

56

Posted on:

Monday 29th October 2012
View Replies!

Dictionary good practice

Hi! A few questions about dictionary: 1. Is anything wrong in doing something like this: Code: var mc = new MovieClip(); dictionary[mc] = mc; //in other words, the same mc as key AND value I mean, any particular implication on performance is it a bad practice 2. Does it cause performance or memory problems to use moviclips as keys instead of primitive values 3. Is is a good practice doing something like this: Code: private function prepare(){ fxArray = new Array(); fxDictionary = new Dictionary(); } public function addFxListener(fx){ fxArray.push(fx); fxDictionary[fx] = fxArray.length-1; fxArray[fxDictionary[fx]].addEventListener(PageEvent.TRANS_IN_FINISHED,notifyPageEvent); fxArray[fxDictionary[fx]].addEventListener(PageEvent.TRANS_OUT_FINISHED,notifyPageEvent); } Where fx are classes extending Movieclip, fxArray is an array where I store fx referencies and fxDictionary is a dictionary where I store indexes of the fxArray, using the relative fx as key. What do you think about this kind of usage also another question: 4. Does a code like this create a reference to mc (along with events and so on): Code: dictionary[mc] = 7 //(the value is a primitive) I mean, if I then destroy mc, the line above will still keep it somehow alive Ooops... Maybe I should move this thread to the AS3 forum\t Could the administrator do it maybe Sorry..
VIEWS ON THIS POST

49

Posted on:

Monday 29th October 2012
View Replies!

Calling function on main stage from within a movieclip

Hi I'm new to as3 and going round in circles. I want to make 5 buttons visible after a logo has animated. I have a function called vis that successfully makes the buttons visible. How do I call this from within the movie clip (instance name 'logo') first frame of main timeline code: stop(); function vis () { webMC.visible = true; animMC.visible = true; interactMC.visible = true; dMC.visible = true; soundMC.visible = true; cvMC.visible = true; contactMC.visible = true; } webMC.visible = false; animMC.visible = false; interactMC.visible = false; dMC.visible = false; soundMC.visible = false; cvMC.visible = false; contactMC.visible = false; code on last frame of logo movie clip: stop(); this.parent.logo.vis();
VIEWS ON THIS POST

81

Posted on:

Monday 29th October 2012
View Replies!

AS3 Button Events to load external SWF's into mc on stage

I have been trying to pick up more as3 lately, also have been converting some of my sites from as2 to as3. So I've seen alot of threads regarding my problem, but no clear concise solution. Here's what I desperately need help understanding. In as2 I could create 3 menu buttons and save them in a mc- lets call it menu_mc. This menu_mc sits on my main stage. I have also placed a mc on stage to hold anything that I load. Lets call it holder_mc. So I figured out how to get my email button to work using this: email_mc.addEventListener(MouseEvent.CLICK, mailto); function mailto(event:MouseEvent):void { var email:URLRequest = new URLRequest("mailto:myemail@mail.com"); navigateToURL(email, "_blank"); } That's fine. What I can't for the life of me figure out is understanding how to click on one of my menu buttons and load a swf into my holder_mc on stage. In as2 I could use this code on a button : on (release) { //load Movie Behavior if(this.my_holder == Number(this.my_holder)){ loadMovieNum("test.swf",this.my_holder); } else { this.my_holder.loadMovie("test.swf"); } //End Behavior } Can someone please help me. Teaching myself is not easy and I am sure there's alot I am missing, even though I watch alot of tutorials, I haven't found any that do what I am trying to do. You can see what I am trying to do here: http://shareeneff.com/NEW.html
VIEWS ON THIS POST

55

Posted on:

Monday 29th October 2012
View Replies!

Embed swf into exisiting HTML page

Hi I have only just started using Flash today and created a quick countdown timer for my website. After looking for ways to embed the swf file into the top banner of the website i found a piece of code but everytime i entered the page it always asked me download flash player even though i have it installed, i then asked a couple friends to try and they got the same. Below is the code i am using
VIEWS ON THIS POST

51

Posted on:

Monday 19th November 2012
View Replies!

creating good fill rate with ads on mobile apps using cs5

I think this would be better in the seo/advertising forumn, but it keeps telling me I cant start a new post in that section and this is quite urgent. I am developing apps using flash cs5.5 and want to incorporate ads into it. I found what people are saying a "hack" to do this using stageview, and have inserted the code and it works beautifully. I am using admob test ads and everything works, but when I go live the fillrate is something like 11%. I understand about network mediation, and all of the ad networks out there, but am wondering if anyone could tell me their experiences or ideas how to get a fillrate of 100%.
VIEWS ON THIS POST

167

Posted on:

Monday 19th November 2012
View Replies!

Flex dateField problem

Not sure if I'm in the right place, but half my problem is AS3 so I figure somebody in hear may have some sort of response. I'm having a weird problem with the Flex dateField. I created a little test app just to better demonstrate what is happening. I have the following. Now, my problem is that, although I have not bound the datePicker and the testDate together, they still seem to be bound. For example, if I chose April 1, 2010, instead of tracing back April 1, 2010 for the datePicker.selectedDate and April 2, 2010 for the testDate like you would think (or at least I would think), the trace comes out April 2, 2010 for both of them, and from there just keeps incrementing from April 3 to 4, etc. each time I click 'Submit'. I hope that makes sense. I'm wondering if there is some simple explanation for this that I'm overlooking as I am pretty new to Flex. I'm using Flex 4 if that makes any difference. This post has been edited by grandmoffspiker: 23 June 2010 - 03:23 PM
VIEWS ON THIS POST

80

Posted on:

Friday 30th November 2012
View Replies!

AS3 full window scaling problem with swfObject

Hi - I've run into a problem with scaling some video on the stage using AS3. Basically, things generally seem to work - however the proportions of the browser window are the proportions that the video object scales to - not the proportions of the video itself. So if the video loads in to an especially narrow or elogated window, the view will be squint, and use these proportions for scaling. I want the script to sense the proportions of the video and then use these to scale and or crop the video if needed to maintain full window and image proportions. see what I mean here: http://orionrush.nfshost.com/test/ any thoughts would be very appreciated. . . The AS3 Script: //variables //Video var video = Video; var nc; var ns; var videoToPlay = "lunarpass.flv"; //Function Declarations //The stage function initStage():void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.addEventListener(Event.RESIZE, onStageResize); scaleVid(); } //Video loding function playVideo( videoToPlay ) { nc = new NetConnection(); nc.connect( null ); ns = new NetStream( nc ); ns.client = this; video = new Video ( stage.stageWidth, stage.stageHeight ); addChildAt(video, 0); video.attachNetStream(ns); ns.play( videoToPlay ); } //Scale Video function scaleVid():void { video.width=stage.stageWidth; video.height=stage.stageHeight; video.scaleX > video.scaleY video.scaleY = video.scaleX : video.scaleX = video.scaleY; } //run on start up playVideo( videoToPlay ); initStage(); //Stage Listener and resizeing function onStageResize(e:Event):void { scaleVid(); }; The HTML generated by swfObj generator 2.1 var flashvars = {}; var params = {}; params.menu = "false"; params.scale = "noscale"; params.salign = "tl"; params.wmode = "opaque"; var attributes = {}; swfobject.embedSWF("scaling_video.swf", "myFlashContent", "550", "400", "9.0.0", false, flashvars, params, attributes); html { height:100%; width:100%; } body { margin:0px; padding:0px; background-color:blue; height:100%; width: 100%; text-align:center; } #myFlashContent { height:100%; width: 100%; z-index: 0; } Many
VIEWS ON THIS POST

58

Posted on:

Friday 30th November 2012
View Replies!

Send variables

gareth@email.com i've made a simple form to send emails from my flash movie - but i'm having problems becuase the variable sent to my php script is including all the html tags (see above) - how can i make it only send the required text in this csae - gareth@email.com hope you can help Gareth
VIEWS ON THIS POST

47

Posted on:

Friday 30th November 2012
View Replies!

Error #1053: Illegal override

I have a very basic Flash movie that includes an FLVPlayback 2.5 component on the stage, using the following Actionscript to stream an FLV: Code: import fl.video.*; var flvDirectory:String = "/flash/flv/"; var flvFileName:String = "37-224"; var flvContentPath:String = flvDirectory + flvFileName + ".flv"; flvPlayer.source = flvContentPath; flvPlayer.scaleMode = VideoScaleMode.EXACT_FIT; flvPlayer.width = 640; function flvLoop(event:VideoEvent):void{ flvPlayer.play(); } flvPlayer.addEventListener(VideoEvent.COMPLETE, flvLoop); It tests fine in Firefox, but when run in IE9 the page crashes with the following error: VerifyError: Error #1053: Illegal override of play2 in fl.video.DynamicStream Can anyone shed some light on why a fairly straightforward movie should crash like this
VIEWS ON THIS POST

189

Posted on:

Friday 28th December 2012
View Replies!

Import from Class to AS3?

I trying to learn and follow some tutorials about classes and stuff like that. If you look att my code I have posted a object called "FallingObject" falls every third second in the speed of "y += 10;" Now here is my problem. I want my falling object to increase the speed every 20 second. How do I do that ACTIONSCRIPT 3 PHP Code: varTimerFallingObject:Timer=newTimer(3000);TimerFallingObject.addEventListener(TimerEvent.TIMER,OnStartFallingObject);TimerFallingObject.start();functionOnStartFallingObject(e:Event){\t\tvaraf:Sprite=newFallingObject();\t\taf.x=Math.random()*640;\t\taddChild(af);} THE CLASS OF "FALLINGOBJECT": PHP Code: package{\t\timportflash.events.Event;\t\timportflash.utils.Timer;\t\timportflash.events.TimerEvent;\t\timportflash.display.MovieClip;\t\timportflash.display.Sprite;\t\timportflash.text.TextField;\t\tpublicclassFallingObjectextendsSprite{\t\t\t\tprivatevarcore:Object;\t\t\t\tvarspeedY:Number=0;\t\t\t\tpublicfunctionFallingObject(){\t\t\t\t\t\taddEventListener(Event.ADDED_TO_STAGE,onadd);\t\t\t\t}\t\t\t\t\t\t\t\tprivatefunctiononadd(e:Event){\t\t\t\t\t\t\t\tcore=MovieClip(root);\t\t\t\t\t\taddEventListener(Event.ENTER_FRAME,loop);\t\t\t\t}\t\t\t\t\t\t\t\t\t\t\t\tprivatefunctionloop(e:Event){\t\t\t\ty+=10;\t\t\t\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\tpublicfunctionremoveListeners():void{\t\t\t\t\t\tremoveEventListener(Event.ENTER_FRAME,loop);\t\t\t\t\t\t}\t\t}}
VIEWS ON THIS POST

33

Posted on:

Sunday 30th December 2012
View Replies!