ActionScript 3.0 :: Sending A Value From A Class Back To The Maintime Line & Calling A Method
Sep 22, 2009
I'm now finding the great need for classes as my current project is getting quite gummed up with too much scripting in the main document. Becoming a real pain to find stuff with in my code.
So I started writing a class to takes an id passed to it from the main time line, accesses my mySql DB, pulls the related info and the processes it. What I can't seem to figure out, is how to pass a variable back to the main time line. The traces all work, so I know my class works. I've searched here and via google, but I must not be searching the right stuff because I get a lot of results with are usually very complicated questions that don't yield the answers I need.
so here we go. my main.fla (and question):
Code:
import Name;
var theUserName:String = "Joe";
var processName:Name = new Name(theUserName);
[Code]....
ps: what's it called when trying to call a method from the main time line? or passing a property back to the main? are there specific terms for these?
I have some movieclips on my main timeline with a class to extend these movieclips
[code]...
But the I can't 'reach' the testing function. I get this error: "1061: Call to a possibly undefined method testing through a reference with static type flash.display:DisplayObjectContainer."
On a recent discussion I had a problem accessing a function on my main timeline from an external SWF. Muzak gave me the answer using eventDispatcher from que external SWF. Ok everything works fine. But when I test my website on my localhost embedding my SWF using swfobject it stops working.
I have two classes. The Main class calls a function, which is defined in a Second class.I'm getting the following error:Error 1120: Access of undefined property myFunctionBasically, I am creating buttons in the Main class that will add a corresponding Child to an Object in the Second class (if you click one button, child x1 will be added, if you click another button, child x2 will be added, and so forth).Here's the relevant code for the Main.as file:
I have a rather silly question but as3's document class always gets me confused.I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
I have tried everything and nothing seems to work. How do I do this?
I have two classes, in one (the Start class) I want to run a function I created in another (the Brown class). I commented in Start where I want to call the "addBrownListen" method. I tried doing it with the line: Brown.addBrownListen(); But that didnt work.
Here are the two classes: package { import flash.display.MovieClip; import flash.events.Event; public class Brown extends Rebounders { [Code] ......
If all I have is an instance of an object, can I call a static method of its class? For fun, let's say I don't know what the name of the class is, only the name of the static method.
My method has been passed a class instance, but it was typed through an interface so I'm not 100% sure what class it is. I'd like to attempt call a static method on that instance's Class.. is there an easy way to do this without being forced to pass the class along as well?
Something like this:
ActionScript Code: public function foo(myBarInstance:IBar):void { var barClassPointer:Class = getClass(myBarInstance); try {
I've always just developed my projects in as3 instead of mxml and I usually just setup my application to run a main actionscript file as my main doc root, sort of like how you do it in flash but in flash builder I do something like this:[code] how can I call place a call to that function hitme() within the call_from_outside() function between the <fx:Script> tags?The reason why I'm doing this is because I have some flash swfs that I load into another swf file and I can access the top level public functions of those flash swfs, however the top level of the flash builder/flex swfs is the main mxml file not my fake as3 class root. Of course I should think there is a way for me to access the as3 class methods of the mxml component but for keeping things with the same structure, I can bypass having to modify my loader scripts.
I am trying to call a method that has some xml functionality and It keeps coming up null.What I am trying to do is; I have a page that has four dynamic text fields that get their content from an xml file. I would like to create a method that will output the contents to display in the dynamic field. Maybe my approach is WAY off here, but my supervisor wants all xml related tasks contained in a xml.as fileMain.as
Is it possible to call a function defined in a movie clip from a class?Here's a sample project setup I'm trying to achieve this simple feat:
func.fla - Has one movieclip "fooinst" which is library item "foo". - The "foo" library item has linkage is to the "Foo" class - The "foo" library item has one script on it's first frame:
I have a GUI using Flex. I have a condition like i need to execute some command line arguments in the local machine and get the results back or output back to a textbox area. How can i do a button on submit, execute command in the local machine and return the output?Command to execute example:
echo logfile.log | grep username
Code:
button1.onRelease = function () { // in this computer, it will now run a command, please wait. }
getUser was already in UserService.java. I just created getUser2 and it's identical to getUser. When I try to call getUser2, i get the "Cannot invoke method" error. question: Do I need to specify getUser2 in some other file? like in some configuration file? if so, which one and how do I do it.
Code: class A{ function A(){ trace("construct"); } private function moo(){
[code]....
yet this doesn't, I'd expect it to: construct, start mooing, moo!, moo!, moo!, ...yet the moo! moo! moo! doesn't appear, as if moo() never gets called it all.
I succeeded in sending typed objects from a PHP application to a flex front-end using Zend_AMF as per this question. The problem I am facing now is that I would like to send a typed object from flex to PHP and on the PHP side, be able to receive it as a typed object instead of stdClass.
Here is the class in flex: package com.mysite{ [Bindable] [RemoteClass(alias="CTest")] public class CTest { public var stuff1:String; [Code] .....
After some testing, I removed the namespace from the PHP object and moved it into the global namespace. This seems to have resolved the issue. I have tried setting RemoteClass to modules estingCTest and also modules.testing.CTest. $_eplicitType was then set to the same value for both tests. The result is that when I use modules.testing.CTest, this is the classname that Zend_AMF sees. If I use namespace notation, Zend_AMF sees modulestestingCTest, as all the slashes get stripped out. But how can I get this working with php namespaces?
I've got a problem with the LocalConnection. I've got 2 swf's and I call one to get a value which then sends it back to the first. It's working, but it seems like the 2nd swf, which is called remote.swf, is sending the value back to the player.swf twice. I've pasted the codes form each swf below. The first is the player.swf which is asking for the value, and the second is from remote.swf which is generating the code:
ActionScript Code: var comPlayLC = new LocalConnection(); comPlayLC.send("rpLC", "received"); comPlayLC2 = new LocalConnection(); comPlayLC2.received = function(val) { info = val.split("|"); [Code] .....
Basically I have a little app where a pop up palette contains dragable movie clips that then are placed on the main stage. However when the palette pops up for a second time it remains behind the placed movie clips. The clips have to be on top of the palette initially, but something like on release swapDepths?
I've created a rectangular box with actionscript (code follows) and I need to make sure this stays in the background - so all other movieclips and symbols are visible when they are positioned over the top of it. I guess it's using the swapDepths function although not sure?
basically im making an image gallery this is what ive done so far imported all of my images that i wanted to use and converted them to movie clips ive put these movie clips in another movie clip which is masked with an instance name of master_mcthe images are placed on top of each other so it looks like a stack of photos what i want to do is when the user clicks the image on the top it should send it to the back of the stack of images and continue to do this for all photos
Basically I have a little app where a pop up palette contains dragable movie clips that then are placed on the main stage. However when the palette pops up for a second time it remains behind the placed movie clips.
The clips have to be on top of the palette initially, but something like on release swapDepths?
In our application we have an embedded Flash control (in a HTML file in our Browser control) that shows some games. I looking for some way to call / notify this Flash control from C++ or JavaScript when some events are happening outside of it in order to display something / set it's internal values.
how (if possible) this could be acheived? I think there is an option to call JavaScript from C++ and then JavaScript call Flash, but that's looks a bit tricky to me. is there is a way to "call" the Flash control "directly" or send a message to it.
Is there any way to send data back to flash after using a FileReference upload? Basically I'm uploading an image and I want my PHP script to return some information back to flash after the upload.
In my code there's a function that shows an image on the screen (or loads the image and shows a progress bar). This function is called by clicking on a thumbnail, and it uses a parameter [e.target.name] refering to the property "name" of the thumbnail clicked, which is an integer (or I believe so). The thumbnails are placed inside the cointaner_mc MovieClip.
Code: container_mc.addEventListener(MouseEvent.CLICK, clickThumb); function clickThumb(e:MouseEvent):void{ if (my_full_images[e.target.name] == undefined){[code]...
but I want to call this function by clicking on a button, which would need to pass another type of parameter, in this case, a variable which refers to the number of the image displayed on the screen plus one.I tried this:
Code: clickThumb(image_num + 1); But it doesn't work, I get the following error:
1067: Implicit coercion of a value of type Number to an unrelated type flash.events:MouseEvent.
How could I call the function clickThumb and make it use "image_num + 1" instead of "e.target.name" ?
Could I dispatch the event (MouseEvent.CLICK, clickThumb), passing this value "image_num + 1" ?
I am new with ActionScript 3, trying to apply a few things I have done in C++.Does anyone know where I can find examples of event handling inside of a class method?Specifically how to call that method and send the event parameter to the method..heres my package / class (BTW I am just trying to make a circle move around when you press the arrow keys)[code]I can't figure out how to get the event passed into HandleKeyDown()
sent form data in Flash to a PHP script before and then read in a variable (say a user id) that gets passed back by the PHP. simple enough.but if the script passes back XML, how do i read that in?elow is the code i've used to send PHP a name and an email address and get back a userid, but i'm not sure how to go about writing the code if the script is passing flash a chunk of XML instead?
ActionScript Code: var userRequest:URLRequest = new URLRequest("saveUser.php"); var userLoader:URLLoader = new URLLoader();
I had posted this in the PHP section but think it may be more relevant in Flash as have'nt had any replies yet..I have been asked to create a photo canvas website that allows users to upload an image, then apply several effects such as re-sizing/cropping/desaturate, then viewing the updated image on a generic wall and going to check out to buy the canvas.I am pretty new to web developing/designing, i am confident with html,css and actionscript to an extent, but have only used small parts of php before.My biggest worry is how to go between html > php >flash >back to html again.From what i understand i need to create the following functions:
1. Create a general html website which will store the upload form and flash photo editor swf on, when the user first access's the site i start the php session...
2. The user then uploads there image to the server using a simple php upload form which will store the file and create a unique named file also on the server...
3. The flash editor swf will then load up on the html page. Inside the actionscript of the swf i will tell flash to continue with the php session by calling it again and call users image on the server with the 'file reference' command. The editing functions such as cropping, canvas size will all have variables to mark what the user has chosen and these varaibles will get ent back to the html page using php to keep track of them for the checkout process...
4. Once the editing has finished the user will click 'finish' in the swf taking them to the php shopping basket/checkout which will call the variables sent in flash to determine final cost depending on what effects chosen.
Is the above correct and more importantly is it possible? The main part i am struggling to get my head around is editing in flash (say changing the uploaded image to 20 x 26) and then saving this back to the server and sending the new settings back into the html/php page.Is this all possible without using database and tables such as MySql?