Actionscript 3 :: Require A Method Argument To Implement Multiple Interfaces?
May 4, 2010
The argument to my method func() must implement the two unrelated interfaces IFoo and IBar. Is there a better way of doing this than declaring another interface only for this purpose that inherits from IFoo and IBar and using that interface as the argument type?
There are many times that I've needed to execute some code after a number of events have fired, and I've come up with counters and such but I feel there must be a better way.For example, say five files need to be loaded, after which a UI component will become active.If I set up a counter that increments each time a file is requested, then decrements each time one has loaded, I run the risk that the first two or three files may somehow get completely loaded before my code gets around to requesting the fourth and fifth, which would mean that my counter would be at zero when I still have two files to load, thus allowing the UI component to be prematurely activated.
There are some cases where you could know the number that need to be loaded before the requests go out, but it's possible that the first file contains the paths (and therefore the number of) files.And this file-loading scenario is only an example of the pattern I'm trying to explain.)
I'm reading up on interfaces and to me I don't see the point in using them? I understand they follow a certain structure but I don't see the use of it in real world usage?
I know it is impossible to extend two classes in the same .as file, but, after some extensive googling, I see that it is possible to implement more than one interface in the same package.
How many instances of Video, NetStream and NetConnection would be needed for multiple videos?Not sure that's the right question but essentially here's the objective:Currently, I'm working on an interactive product tour, parts of which are to consist of short video clips, each covering a feature. While only one such clip will be playing at any given time, I'd like put them all at the application's fingertips as part of the initial preloading process before launching into it. The idea is to provide a seamless instant-play user experience without hitting the breaks before individual segments.Honestly, I hate pre-caching crap into user's memory, especially when some of that content may be potentially ignored. However, given the target audience, it is reasonable to predict that all features will be explored most of the time, so it's a fair compromise to me. Besides, I went to great lengths to keep the mp4s' sizes to the minimum.Anyway, I'm guessing you don't really need more than one instance of the Video class but how many NetStreams and NetConnections do I you need, probably one of each per video, ha?
How many instances of Video, NetStream and NetConnection would be needed for multiple videos? Not sure that's the right question but essentially here's the objective:
Currently, I'm working on an interactive product tour, parts of which are to consist of short video clips, each covering a feature. While only one such clip will be playing at any given time, I'd like put them all at the application's fingertips as part of the initial preloading process before launching into it. The idea is to provide a seamless instant-play user experience without hitting the breaks before individual segments.
it most used on network accesses. But now, I have a class that will do several things, including but not limited to network accessing, many many single loops within a huge code(maybe). The return time is unspecific, so I think about using an async method. However, when I run my program, I found that all things in call stack are stuck when the loop running. I made a short version of my code. First, the weird AsyncClass.as class is like this:
I'm trying to write a custom fadeTo(component, x, y):void method, which takes an arbitrary Flex Component as an argument and moves it to a given location, but smoothly.
The problem I'm running into is the following.
I want to send the component itself as argument, like this: (using Button as an example only)
fadeTo(myButton, 200, 500);
(this should move myButton smoothly from its current position to the position indicated as parameter)
However, I don't really know what type an arbitrary Flex Component is. How should I handle that?
Actually, I already know the answer. The main reason I'm posting it here is for Google searchers, and if I copy and paste the post into my blog, my ActionScript code gets formatted all pretty, when all I have to do is add "as" tags here.
Error: Error #2069: The Loader class does not implement this method. at Error$/throwError() at flash.display::Loader/addChild()
I'm having some trouble implementing a "virtual" camera for use in game development with Flash CS4 ActionScript 3.0.Basically, what I'm trying to accomplish is to have a camera that moves about the main stage so that my character can traverse the level which is much larger in size than the stage itself.I've been using Sham Bhangal's virtual camera script, and when I implemented it by sticking the code into the first frame of a movie clip, it worked great!
From there, I moved the code into a document class that i could instantiate and then drop onto the stage as a child.Finally, I wanted to have a main "builder" document class that would be added to the main stage as a child, and within THIS class I wanted an instance of the virtual camera. This is where I hit some obstacles.how to properly instantiate the virtual camera within the builder class which is then added to the main stage. I have a Stage reference that is being passed to the main builder, but I don't know where to go from here. To what do I add the virtual camera to as a child? To the Stage reference in the main builder class? To the main builder class itself?The main issue is that when I export my movie with the virtual camera added as a child to the Stage reference within the main builder class, it complains that I'm not allowed to access certain values.
Code: Error: Error #2071: The Stage class does not implement this property or method. at Error$/throwError() at flash.display::Stage/set x()
This happens when I try to access parent.x from within the virtual camera class. I assume this fails because "parent" from this perspective is the main builder class, but using the Stage reference produces this same error.I am, of course, willing to provide more detail if something I've written is confusing, and I will gladly provide a detailed fix for those seeking to use a similar solution in the future.
So I've been trying to move the stage's X and Y position and keep on getting this error:
Code: Error: Error #2071: The Stage class does not implement this property or method. at Error$/throwError() at flash.display::Stage/set y() at Main/scroll()
As for why I'm trying to move the stage, I have a movieclip which moves according to keyboard input and i want the stage/Background to always center on him.
I had a class that I was passing a simple argument to like so:
var quiz_1_2:CaseStudyQuiz = new CaseStudyQuiz(2); addChild(quiz_1_2);
I now would like to use this class for multiple MCs in my library. I thought I could let Flash create a class for each of them and specifying the CaseStudyQuiz class as the Base class. When I do that, I get the following error:
I'm developing a Flex/AIR application that's growing big, and some of the components need to be seen from different points of view (i.e Admin, Staff, User, Guest). I've seen myself placing code in those components to handle what the user can and can't see. But it's becoming unmanageable as the code and the roles grow bigger. I was wondering what's the best way to implement multiple views inside the components while keeping them as reusable as possible.
How do you use a for loop to clear the draw method of multiple mcs?
i guess what i need to know is how to make the for loop increment through the different instance names. they are in the format curve1, curve2... curve3.
say i have a method "btnClick", and i have 5 buttons: btn01,btn02,etc.. how do i apply this method/function to the 5 buttons through code? here is what i am trying to do(this is just pseudocode):
The section in my code that does the rotating is in _root.onEnterFrame. Each movieclip is moved up/down an notch at a time within a 'for' loop. this loop is within a larger 'for' loop depending how many catagories to move up/down. I shall include this section of code for; i hope, better understanding
Trying to use the setMask method and having trouble. I have it working on my dynamic text, but I am trying to mask the movieclip that is loading my image from the server. I have a moviclip called Comments. And in it I have movieclips called textbox and image
I have one setMask AS like this for the textbox this.textbox.setMask(this.mc_mask2); - this one works
But for image I have the same thing and it doesn't work. I have this.image.setMask(this.mc_mask);
I am writing a program that requires the use of 36 boolean variables with different names (e.g. box1, box2...): does anyone know of a quick way to optimize this program.
I have a game that will work better in Flash Player 11 (with Molehill) but also works in 10.3. I'd like to get players to automatically update to 11 with express install as much as possible (after it's released, of course), but don't want to force them.I tried this way of embedding it with SWFObject:
I built a simple jpg comp click-through as a software demo, and inserted flash movies to simulate interative buttons (hover styles basically). I am using the SWFobject script to load the swfs, and they render properly. However, they seem to need a single click within the swf to "activate" them. This not the IE click to activate issue. They look correct. They just don't interact with the mouse until I have clicked inside the SWF once. This has the effect of making all the button require a double-click to work, and means that when I hover on them, they do not animate until after I have clicked inside.
This only seems to happen in Firefox... FF 3.6.3 and Flash Player 10,0,45,2
I have been trying to embed fonts for a program for the last couple of days. I have found many places that explain how to do it, but none of them have worked. I am wondering, do I have to use Flex SDK to embed fonts?I need to embed 18 fonts in a program, and I have even tried adding 18 textFields off of the stage, each with text in one of the 18 fonts and embeding the fonts via the properties panel. That doesn't seem to work either
I'm integrating a Flash-free web site with Facebook Connect.Loading it in Internet Explorer 7 (only in IE 7, not IE 6 nor IE 8) I get the famous IE information bar saying that the current web site requires the Adobe Flash Player and asks me if I want to install it.
If I remove the code needed to the Facebook Connect integration (some facebook-hosted javascript files), IE does not ask me to install Flash anymore.As I've already said my web site does not require Flash at all and with IE 6, IE 8, Firefox or any other browser I'm not asked to install the Adobe Flash Player.Is this normal? Does Facebook Connect require Flash? Does it need Flash only with IE7?
Solution: if you have the same problem, addElement() instead of addChild() is what did it
I'm trying to move away from mxml to actionsctipt. I have a <s:Rect> that I've created and set its properties, but having trouble adding it.
var aRect:Rect = new Rect(); //set properties like aRect.x, aRect.y, aRect.width, aRect.height //tried adding it various ways addChild(aRect); Application.addChild(aRect);
new to as3 is there already built in libraries that allow for connecting to remote shares that require authentication?searching for as3 and smb is swarmed with results for a game written in flash called SMB, so i am not having any luck finding any info on google.