ActionScript 3.0 :: Assign A Value To A Property From Within A Method?
May 27, 2009
The question is exactly as the title of this thread states, how do I assign a value to a property from within a method? Before I go into detail, please take into consideration I'm new to actionscript 3.0 and its concept of object oriented programming. Actually I'm not that advanced with actionscript all together.Basically I have two classes, "Main" and "XMLHandler". The purpose of the class XMLHandler is to recieve the file path of an xml file and load it, and then to store the data from the xml file in a property ("_xml") within a class. Main is the document class for my main flash file. In Main I make a instance of XMLHandler and assign the file path via the constructor (I have no idea If I said that right).This is the code from my XMLHandler class:
I would like to know if it is the same to assign properties to my custom component in its own class, or from the parent document. Here I assign the property bottom in my custom component class:
Given a dynamic or non-dynamic class like the following: package { public class MyClass { public var myProperty:String; public var myBooleanProperty:Boolean; public function MyClass() {} }}
Flex 3 allows you to assign a value to myProperty like this: myClassInstance["myProperty"] = "myValue"; myClassInstance["myBooleanProperty"] = true;
I regularly parse XML to get property names and their values then update correlated classes using this technique; however, Flex 4 no longer allows assigning the boolean property. I don't have a work-around.
If you trace the results: trace(myClassInstance.myProperty) // Returns "myValue" trace(myClassInstance.myBooleanProperty) // Returns null
I am building a Flex application with ActionScript 3. Unfortunately I've hit a wall with this one...I would like to be able to apply an upSkin to my dynamically generated button like this:
//this theSkin variable is dynamic in my app, but for this example it's a simple string var theSkin:String = "http://www.mypicturedomain.com/images/myimage.gif"; var navBtn:Button = new Button(); navBtn.id = "thumb1";
[code]....
When I attempt this, I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@3dac941 to Class.
How do I skin this button with my image dynamically? A couple of things to consider:The upSkin image must be remote. It can't be local.The button must be generated dynamically (it's in a for loop).
I have written a framework that facilitates RPC calls between AS3 and PHP 5 called FlashMOG. I recently got a forum request that has introduced a pretty bizarre question regarding access control. This will be a lot easier to discuss if you have access to the FlashMOG 0.3.1 client source which is here:
[code]...
The basic idea is that I have a FlashMOGService class which has an RPCSocket member that it may share with other FlashMOGService objects. The idea is that you can create two distinct FlashMOGService objects and have them both connect to the same host/port via socket. I use my special RPCSocket class for two reasons:
1) Let developers use one port but separate functionality into two distinct services...a form of multiplexing i guess
2) RPCSocket adds functionality to the standard Socket class that works to serialize and unserialize data and get it where it needs to go. The essence of the problem here is that created a class with a FlashMOGService object as a member and has tried to assign a private method of his class as an event handler to the FlashMOGService object:
[Code]....
My initial thought is that this should be fine because it's all done within the class. However, when I consider the monkey chain that results in this function being called, it seems almost logical that it wouldn't work. The problem is that the browser freezes when a socket message arrives that tries to call the service's client method, _service.client.firstClientMethod. This client firstClientMethod is attempted when data arrives from the server on the Socket (an RPCSocket, actually). The RPCSocket class deserializes the socket data and extracts an array with a service name, a method name, and an array of arguments. It looks into its own private class variable (an array of services using the RPCSocket) and tries to invoke whatever function was assigned thusly:
[Code]....
I'm guessing there's some kind of infinite loop going on to check access control for the various intertwined classes.
Here's the context of the problem, in which I will try to include as much information as possible while keeping the explanation brief.
I am trying to make a portfolio website (architectural design + concept art). Flash / programing are not my focus and this is my first go at learning the software. Due to the nature of the content and my (lack) of ability in AS3, I want the the coding to be really simple and still let the site look good. The way the site is currently structured:
1) Basic menu buttons that navigate to sections of the site (brings up a new page).
2) Example, clicking on <Graphics> takes you to a new page and a sub-menu animates in (simple motion tween for the buttons to cascade down). This animation is a movie clip placed on the main timeline.
3) On the screen is also a slideshow for all the images within <Graphics>.Instead of multiple small slideshows, I combined them all into one, so as to avoid complications with add / remove from stage. There are prev / next buttons that keep images within their sub section (ie 1->2->3->1). The sub-menu buttons are suppose to link to the start of each sub section, much like chapters on a DVD. (The slideshow is a movieclip sub-nested in the menu movieclip).
I've got on main timeline (on frame 10) buttons, when I click one of them it goes to its currentLabel"". On curerntLabel at frame20 "racerButton" where I've got some tweening. At currentLabel "boardButton" at frame30 I load external swf.The problem I've got is when I press any button everything works fine. But when I first press button "boardButton" at frame30 the ext.swf shows up fine, but when next I click the button"racerButton" at frame20 the tweening doesn't work there and it gives me error.[code]when I press any button everything works fine except from bordButton to racerButton
[code]Is my code and when adding the backtostart function i always get the error if i remove the back and backtostart parts of the code it runs fine any help?
Created preloader, and after flash loaded want stop on label 'welcomeSite'. And on that label will have button, after click this button what play code from function 'irisDescription'.
But see error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at FlashSite/flashSiteLoading()[FlashSite.as:28]
code: package { import flash.display.MovieClip; import flash.events.*; import flash.text.*; public class FlashSite extends MovieClip [Code] ..... 27 line is: irisBtn.addEventListener(MouseEvent.CLICK, irisDescription);
I have seen InBufferSeek property of NetStream , useful for seeking or steping video from buffer.. Which I use with Step() method to forward and rewind functions for my Custom Player. When user select to make fastForward I set, below variables
netStream.inBufferSeek = true; // to make step from buffer and not from server netStream.pause(); // pause video as suggested by adobe for using step() netStream.maxPauseBufferTime = 3600; // allow stream to buffer more data in pause Mode
After that I call a Function in Regular interval which steps vide netStream.step(75); This works fine.. but my vidoes PlayHeadtime not get updated with this.
one thing i've never really understood about AS3 is that you can't have a private set method and a public get method together. from within my class i would like to assign values that would call a private set function:
[Code]...
is there no way to use the set keyword on a private function?
function getFlashMovieObject(movieName) { debugger; if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName] } else { return document[movieName] } } function helloJS() { I am calling action script function this way, this is working fine in mozilla but throwing error in IE.
I want to create an array of strings in a text class that I can access with the main document class. Then I'll be able to populate a text field with items in the array. The purpose of this is to avoid having massive lines of text in my main document... but I can't even get my test to work. The compiler is telling me that the array (txt1) is undefined. First here's my code for the array:
To my knowledge, there are 3 options:1 - parent.publicPropertyOrMethod.2 - using static vars/methods.3 - dispatching events.Under best practise for OOP development, which is the "best" method? Are there any more?I dislike #1 and never use it as it and can easily descend into hideous parent.parent.parent references that are easily broken. #2 has it's own problems whereby attempting to get/set instance variables doesn't always work through a static function (I am yet to completely understand this). #3 is great for triggering methods (I use this the most) but sucks for altering class properties and suchlike.
"Cannot access a property or method of a null object reference."I'm trying to get a button to go to a frame in my movie and stop. The code I am using is
Code:
btn1_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler5); function mouseDownHandler5(event:MouseEvent):void { gotoAndStop(19); }
I have a slight problem. 3 scenes one named home , gallery and profile . 3 buttons each named after the scene. Whenever i test it and click a button to go to another scene i get this TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/frame2() at flash.display::MovieClip/gotoAndPlay() at Untitled_fla::MainTimeline/buttonClick1()
I have been trying to design a maze game for college project but I seem to be stuck and hoping someone can help me out. Get error:1009: Cannot access a property or method of a null object reference.at code::Game1$iinit()New to flash so not sure what this means. [code]
well i have a problem with my analog clock. i have it in my homepage and now it's working fine, but when i test my movie and click in my portfolio, for example, my output windows gives me this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at index_fla::MainTimeline/clock() i don't understand because even when i change from page to page (or frames) the clock is still working and everything is ok... but the message keeps appearing till i close my test movie window... and i've noticed that when i go online, there are some files missing that weren't till i had the clock on my homepage.[code]
I am just trying to watch television episodes on my laptop. this error has been popping up for the last couple weeks for no apparent reason. At first, it also said the Flash Player didn't work with 64 bit whatever with IE8. The error said a patch was not yet made and to use IE 32 bit. I did this and am still getting the error. I have uninstalled flash player and reinstallaed it to no avail. This error led to further problems on my laptop resulting in a total crash. Fortunately, I was able to back up all my files before they disappeared. I restored the computer to a time before I started watching television programs on XFinity.com (about a couple months ago) and it seemed corrected for a while and then the error started again. I am given the option to continue or dismiss. either button allows me to continue watching the program, but then repeatedly appears even when I quit XFinity and watch the shows directly from the network websites.
I'm programming a kind of "Lights Off" game in Flash Professional (not Flash/Flex Builder)and it would be very nice if I could manage on/off state in a grphically designed Symbol like this[code]...
For example, if an application uses class, method, or property which is supported only by Flash Player10.When you run the application on Flash Player9, what will happen? Flash Player will be crashed? Or Flash Player will show you a message screen to upgrade your Flash Player? Or the application will normally run and will ignore the part which uses the unsupported class, method, or property? Or the application will cause a runtime error when the unsupported class, method, or property are called?
Code: Select allTypeError: Error #1009: Cannot access a property or method of a null object reference. at main::as/menuFeatOn()
here is my code
Code: Select allmenu_feature1z.addEventListener(MouseEvent.MOUSE_OVER, menuFeatOn); menu_feature1z.addEventListener(MouseEvent.MOUSE_OUT, menuFeatOff); function menuFeatOn(event:MouseEvent):void{
[Code].....
menu_featurez is a box i created on the main timeline for people to mouseover on top of the button. the button itself is a movie clip with the transition tween inside called menu_feat1.
I'm trying to create a simple user name and passwor screen which will link to a menu and in the menu will have a choice of three games to play.frame 1 is the logon screen. Frame 2 the menu. Frames 3,4 and 5 the games.I managed to create the logon screen, the menu and the first game but the error below appears when clicking on the button to go to the first game in frame 3
Cannot access a property or method of a null object reference. at logon_Scene1_fla::MainTimeline/init() at logon_Scene1_fla::MainTimeline/frame3()
I have a mutiple choice quiz which is spread across a number of frames, the same script is used for each frame only using different named variables.The code works fine on the first frame but I get the Runtime error 1009 on the 2nd, 3rd etc frame.My guess is it's to do with the way i've declared the next_btn, but im not sure.[code]
AS3 and object oriented script. My issue involves instantiating movieClips and referencing them correctly to avoid:Error #1009: Cannot access a property or method of a null object reference.I've spent hours researching this and know I am referencing an object that is not there but I don't understand how to instantiate the movieClip (I think I need to generate a class for the main movieClip?) I am such a noob and really apologize for the lame question. my file is hereThe file works but I know I'm doing it wrong and really would love to know the right way!Here's the full error:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at problem_file_fla::avalanch_holder_6/frame200()[problem_file_fla.avalanch_holder_6::frame200:4]