Oop As2 - Component - Problem With Referring Class To Itself
hello, im currently creating a component which calls on an xml file. i want a function from the class to be called once the xml is loaded, but i cant seem to target the function. Code: class className { // variable var inputXML:XML; // constructor public function className () { this.init (); } // initialization private function init () { this.inputXML = new XML (); this.inputXML.ignoreWhite = true; this.inputXML.load ("xmlfile.xml"); this.inputXML.onLoad = function (success) { if (success){ this._parent.setContent (this); } } } // functions private function setContent (xml:XML) { trace (xml); }} logic suggests that since inputXML belongs to the class, it's parent should be the class. however, with the onload, it seems that it cannot reach its parent. i even tried without relating to the class (setContent (this) instead of this._parent.setContent (this)) and still doesnt workwhat should i look for?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 07-18-2007, 01:48 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Referring To A Class?
hello,
how do you refer to a class by name? I know how to get the class to do all sorts of stuff from inside the class constructor using the keyword "this". However how do you get the entire class to respond to a button press as the keyword "this" when on a button event handler refers to clip containing the button? right?
Referring To A Class Dynamically
I need to create a new instance of a class. I have the name of the class stored as a string, but how do I instantiate the class!? I should use the array access i.e.
var className:String = "MyClass";
var myInstance = new myPackage[className]();
but as you can see, I have to hardcode the package name, which in my case doesn't work. Another unclarity regarding the same problem is, wether I can type a variable dynamically i.e.
var className:String = "MyClass";
var myInstance:[className] = new myPackage[className]();
Is there a neat way to solve this dynamic referring, or do I need to start building work-arounds...
Cheers!
Referring From Class To Scene
I have constructed a rough game which is about catching 2 kinds of objects.
An object that increase score, and one that increases your teachers rage(its a game that will be about our school).
My problem lies in makin the Rage-bar, health-bar and score-increase when an object is caught.
If someone has a moment to take a look at it, it would be much appreciated.
I believe my main problem is that i can not refer the class to objects on the scene.
I uploaded the files to make it easier for you to point out my problem
http://www.casperholden.dk/files/flashkit.rar/
Thanks in advance.
Referring From Class To Scene
I have constructed a rough game which is about catching 2 kinds of objects.
An object that increase score, and one that increases your teachers rage(its a game that will be about our school).
My problem lies in makin the Rage-bar, health-bar and score-increase when an object is caught.
If someone has a moment to take a look at it, it would be much appreciated.
I believe my main problem is that i can not refer the class to objects on the scene.
I uploaded the files to make it easier for you to point out my problem
http://www.casperholden.dk/files/flashkit.rar (.rar)
http://www.casperholden.dk/files/flashkit.zip (.zip)
Thanks in advance.
Creating A Component Within A Component Class
Basically I have a component with I have associated a class with - and then attached it to stage using attachMovie and make references to it using its linked name which works great. However within this class I want to attach another movie clip component - which works however how to I reference this second component from this class using linkage doesnt work neither does assigning it to variable. The only way is to call the class - which gives undesired results.
What is the proper way to have a component within a component?
Initializing A Class/Component - Am I Doing This Right?
I'm trying to build a standard Pop Up confirmation window that I can use throughout my application. I created a MovieClip Symbol in the library called PopUpBox, and then I put this actionscript on it's first frame so I can use it as a class and call methods on it like 'setLabel()'.
Right now I'm just setting a default label in the init function, but that's not showing up in the window. I'm also trying to call the setLabel method from my main movie, but that's not working either. Can somebody have a look-see and tell me what I might be doing wrong?
Code:
#initclip
function PopUpClass(){
this.init();
}
Object.registerClass("PopUpBox",PopUpClass);
PopUpClass.prototype=newMovieClip();
PopUpClass.prototype.init=function(){
this.txtLabel.text = 'wuz up mang';
}
PopUpClass.prototype.setLabel = function(lbl){
this.txtLabel.text = lbl;
}
PopUpClass.prototype.getLabel = function(){
return this.txtLabel.text;
}
#endinitclip
stop();
Thanks, Adam.
Class/Component Question
I am making a class that is suppose to control key board mapping. I want to use the onClipEvent(keyDown) function for and instance of this class. I can't seem to get it to work. I can use AppSimClass.porotype.onEnterFrame = function () {} but I tried this approach before and it is too sensitive to key presses. Is there any way to use an onClipEvent for a instance of a class?
How To Get Event In Component Class?
Hello,
I want to make ActionScript 2 component. I have one movie clip (my component). Inside it I have ComboBox with instance name myMovieClip. The class associated with component is
Code:
class mypackage.MyComponent extends Object{
static var symbolName:String = "parser.Deroulateur";
static var symbolOwner:Object = parser.Deroulateur;
private var myMovieClip:MovieClip;
function MyComponent(){
}
function change():Void{
trace("change");
}
}
I want to work with event change of the ComboBox. If I put it on the ComboBOx instance like this:
Code:
on(change){
trace("change");
}
it works OK but how to get it in my class? I tried with method
Code:
function change():Void{
trace("change");
}
but it just doesn't work
Please help.
Thank you
Using Tree Component In Class
Hi,
I am trying to use a tree component in flash mx 2004.
I am able to populate a tree compoenent with XML data.
On clicking of a leaf node I am updating the contents of the leaf node in a datagrid.
Alls happening fine as long as I code it in an fla document.
The moment I convert the code into a class nothing seems to happen.
Infact the constructor of the class is also not getting called. Neither can I set an breakpoints in debugg mode.
Heres the code
--------------------------------------------------------------------------
Code:
import mx.controls.Tree;
import mx.controls.DataGrid;
class treeNav extends MovieClip {
private var listArray:Array;
private var xml:XML;
private var myTree:Tree;
public function treeNav() {
var temp = this;
listArray = new Array();
xml = new XML();
xml.ignoreWhite = true;
xml.load("contact info.xml");
xml.onLoad = function() {
temp.createTree(this);
};
trace(this);
}
private function createTree(x:XML) {
myTree.dataProvider = x.firstChild.firstChild.firstChild;
trace(x);
}
public function createdata(x:XMLNode) {
var a = new Array();
for (var i in x.attributes) {
a[i] = x.attributes[i];
}
listArray[0] = a;
}
}
I have created a tree component on stage inside a movieclip and attached the above class to the movieclip.
The problem seems to be at line number 6 "private var myTree:Tree;" where I am storing a refernce to the tree compoenent on stage by the name "myTree". The moment I comment this line the constructor is called.
Not sure what is this issue,
please help.
Component And Tween Class Help
Hi All,
I have a simple component which is dynamically added to a movieClip (‘parent_mc’) and is then made a listener of that movieClip. I’m creating 5 different component instances and each one is given a unique ‘id_number’. The component uses a tween calss function for moving to a different x position. The ‘parent_mc’ broadcasts a message (this.broadcastMessage("moveComp", compId, newX); and only the component with the matching id moves to the new position.
Everything works as expected but the problem I’m having is trying to call a function to let the 'parent_mc' know when the tween has finished. Can anyone help??
Thanks,
Ty
This is a cut down of the components script.
Attach Code
#initclip
import mx.transitions.Tween;
import mx.transitions.easing.*;
//
myCom.prototype.moveComp = function(compId, newX) {
if (compId == this.id_number) {
trace("moving component "+this.id_number);
var myTweenX = new Tween(this, "_x", Regular.easeOut, this._x, newX, 0.2, true);
myTweenX.onMotionFinished = function() {
// trace works but the id_number is undefned
trace(“move finished”+this.id_number);
// calling a ‘parent_mc’ function or a function in the component doesn’t work!!
this._parent.moveFinished(this.id_number);
this.moveFinished();
};
}
};
//
myComp.prototype.moveFinished = function() {
trace (“finish moving ”+this.id_number);
};
//
Using Tween Class In A Component
hi, I have made a list menu component and it uses transitions.Back tween when open and close. Before compiling as SWC, that is as a movieclip, the component works well but after compiling as swc and import in another document, tween functions does not work. Why can I not use this classes in a component? Here is the code :
#initclip
import mx.transitions.Tween;
import com.robertpenner.easing.*;
//---------------------------------------------------------------------------------------
//constructor
function MultiListMenuClass() {
this.isOpen = false;
this.columnNumber = -1;
}
//---------------------------------------------------------------------------------------
//inherit from the MovieClip Class
MultiListMenuClass.prototype = new MovieClip();
//---------------------------------------------------------------------------------------
//methods
MultiListMenuClass.prototype.open = function() {
openTween = new Tween(this, "_y", Back.easeOut, this._y, this._height-40, 0.5, true);
this.isOpen = true;
};
MultiListMenuClass.prototype.close = function() {
closeTween = new Tween(this, "_y", Back.easeIn, this._y, 0, 0.5, true);
this.isOpen = false;
};
Attach Component Within A Class
Hello,
i'm looking for a way to add an instance to a component from a class...
Something like
Code:
class myClass extends MovieClip{
function myClass(){
}
function addComponent(){
attachMovie(thecomponent, "compoInstance", 0, 0, 1);
}
}
but i dont know about the "thecomponent" part.. i tried "textInput" but it doesn't work.. any idea?
Help With Component And Tween Class
Hi All,
I have main movieClip which creates several instances of a library component each with a different id_number variable. The components are made listeners of the main movieClip so when it broadcasts moveComp(id_number,newX) only the matching component respond and moves to the new x location.
Everything works fine but the problem I have is trying get the tween class onMotionFinished to call a function either in the parent movieClip or a function in the component itself. What am I doing wrong? Can anyone help??
Many Thanks,
Ty
This is the relevant bit of the components script.
Code:
//---------8<-----
myCom.prototype.moveComp = function(compId, newX) {
if (compId == this.id_number) {
trace("moving component "+this.id_number);
var myTweenX = new Tween(this, "_x", Regular.easeOut, this._x, newX, 0.2, true);
myTweenX.onMotionFinished = function() {
// trace works but the id_number is undefned
trace(move finished - +this.id_number);
// calling a parent_mc function or a function in the component doesnt work!!
this._parent.moveFinished(this.id_number);
this.moveFinished();
};
}
};
//
myComp.prototype.moveFinished = function() {
trace(move finished - +this.id_number);
};
//---------8<-----
Component Add In A Class And Use Object
Hi
I m creating a common class of component which i want to use in different class .
In My project i have a color.as class in which i had create a colorPicker and added it.Now i want to use it into many class where i could access all method of colorPicker without adding colorPicker Component into all class . Can it possible
Thanks
How To Get Event In Component Class?
Hello,
I want to make ActionScript 2 component. I have one movie clip (my component). Inside it I have ComboBox with instance name myMovieClip. The class associated with component is
class mypackage.MyComponent extends Object{
static var symbolName:String = "parser.Deroulateur";
static var symbolOwner:Object = parser.Deroulateur;
private var myMovieClip:MovieClip;
function MyComponent(){
}
function change():Void{
trace("change");
}
}
I want to work with event change of the ComboBox. If I put it on the ComboBOx instance like this:
on(change){
trace("change");
}
it works OK but how to get it in my class? I tried with method
function change():Void{
trace("change");
}
but it just doesn't work
Please help.
Thank you
Component Instance Name In A Class?
I am a longtime user of a very useful tool http://www.slideshowpro.net a slideshow component that has a really great API.
To use it you need to drag the component to the stage and give it an instance name in the properties pane, I'm using my_ssp. I have always coded this stuff on the first frame of the time line, such as setting the position of a TextField in relation to the component instance on the stage.
Code:
_galleryTextField.x = my_ssp.x;
_galleryTextField.y = my_ssp.y - (_galleryTextField.textHeight * 2) ;
So I had the need to create a class that will create the TextField "_galleryTextField" so I can access it as a public var in other places of my project. Here's the problem, now that I need to access the my_ssp instance name inside of this new class, It becomes an undefined property. I have imported the appropriate package, but trying to figure out how to tell this class what my_ssp is? Normally I set the Linkage in the library to make it available, like with a MovieClip, but this is a component and I can't do that in the Library. I'm thinking I need to declare it as a public var in the document class, but then I'm not sure what to set the type to? Can I make a component's instance name available to a class or am I going about this completely wrong?
I hope this makes some sense, thanks for any help.
AS 2.0 AttachMovie In Component Class Function
I am trying to attach a movie dynamically to the stage and reference its variables from a response from a php script. This method works fine in regular timeline coding, but when it is in a component class, it wont attach the movies dynamically when the component loads up. Please help.
code:
import mx.core.*;
import mx.containers.*;
import mx.controls.*;
import mx.transitions.easing.*;
//Associate custom component image
[IconFile("Menu.png")]
//declare the class and identify the parent class
dynamic class mx.controls.Menu.phpMenu extends mx.core.UIComponent{
//identify the symbol name that this class is bound to
static var symbolName:String = "phpMenu";
//identify the fully qualified package name of the symbol owner
static var symbolOwner:Object = Object(mx.controls.Menu.phpMenu);
//provide the className variable
var className:String = "phpMenu";
//Declare all movieclips and properties going to be used in component
private var mainCategoryLoader:LoadVars;
private var subCategoryLoader:LoadVars;
private var mcHolder:MovieClip;
private var backGround:MovieClip;
private var scroller:ScrollPane;
private var scrollPaneContent:MovieClip;
private var subCategory:String;
private var i:Number;
private var nexty:Number;
private var randInt:Number;
private var _rootURL:String;
private var _fileName:String;
public var statusBox:String;
public var headerBox:TextField;
//constructor
function phpMenu(){}
//Create children
private function createChildren():Void{
}
//define init method for this component, and initialize super class
public function init(Void):Void {
super.init();
randInt = int(Math.random() * 123456789);
loadMainCategories(_rootURL, _fileName, randInt);
}
//Draw
private function draw():Void{
super.draw();
this.scroller.contentPath = "scrollPaneContent";
}
//Introduce property inspector parameters
[Inspectable(defaultValue="menuLoad.php")]
public function set fileName(theFile:String){
if(theFile == ""){
trace("Please fill in a file name");
}else{
_fileName = theFile;
trace("file name is " + _fileName);
}
}
[Inspectable(defaultValue="http://")]
public function set rootURL(theRoot:String){
if(theRoot == "http://"){
trace("Please fill in a root directory.");
}else{
_rootURL = theRoot;
trace("root URL is " + _rootURL);
}
}
//declare main menu load function
public function loadMainCategories(u,f,r):Void{
mainCategoryLoader = new LoadVars();
mainCategoryLoader.handler = this;
mainCategoryLoader.sendAndLoad(u + f + "?" + r, mainCategoryLoader, "POST");
mainCategoryLoader.onLoad = function(success){
if(this.status = "ok"){
trace("loaded successfully");
trace("url is " + u + f + "?" + r);
nexty = 0;
trace("nexty is set to " + nexty);
this.headerBox.text = this.header;
for(i=0;i<this.mainCategoryCount;i++){
trace("i = " + i);
trace("header = " + this.header);
trace(this["mcHolder" + i]);
trace("nexty is set to " + nexty);
scroller.content.attachMovie("mcHolder", "mcHolder" + i, getNextHighestDepth());
//scroller.content["mcHolder"+i].subCategory.text = this["mainCategory" + i];
setProperty(scroller.content["mcHolder"+i],_y,nexty);
scroller.invalidate();
trace(scroller.content["mcHolder"+i]._height);
}
}else if(mainCategoryLoader.status = "error"){
trace("Sorry, loaded unsuccessfully");
statusBox = mainCategoryLoader.error;
}else{
trace("No response from Database");
statusBox = "Loading Menu...";
}
}
}
}
Using Component Inside Custom Class
Hi,
I'm creating a registration form that contains a ComboBox component.
This component works as expected on its own:
code:
import mx.controls.ComboBox;
for (var i = 1930; i <= 1990; i++)
{
year_cb.addItem({data:i, label:i});
}
var year_cbListener:Object = new Object();
year_cbListener.change = function(evt_obj:Object)
{
var item_obj:Object = year_cb.selectedItem;
trace(item_obj.data);
};
year_cb.addEventListener("change", year_cbListener);
But when I try to use it inside my custom class (wich will handle all the data of the registration), it simply doesn't work. The ComboBox doesn't even get populated:
code:
import mx.controls.ComboBox;
//
class Registration extends MovieClip
{
private var year_cb : ComboBox;
private var year_cbListener : Object
//
public function Registration ()
{
myInit ();
}
//
private function myInit ()
{
trace (year_cb); // works
for (var i = 1930; i <= 1990; i ++)
{
year_cb.addItem (
{
data : i, label : i
});
}
year_cbListener = new Object ();
year_cbListener.change = function (evt_obj : Object)
{
var item_obj : Object = year_cb.selectedItem;
trace (item_obj.data);
};
year_cb.addEventListener ("change", year_cbListener);
}
}
Here are the files (combobox working alone, and the class files).
Any ideas?
Thanks.
Getter/Setter Within A Class With A Component
I have a class file which loads comboboxes on the stage. In the interaction various things happen which need to be recorded, and I had done this in the past by setting properties on movie clips. I.E. -
mc1.propertyName = true/false;
I try to do that with a component and get a message saying that the property can't be created on fl.controls.ComboBox.
The property name is: isRed. It's being set like this:
combo1.isRed = true/false;
Here's the getter/setter:
public function get isRed():Boolean {
return _isRed;
}
public function set isRed(value:Boolean):void {
_isRed = value;
}
Also tried this:
[Inspectable(defaultValue=false)]
public function get isRed():Boolean {
return _isRed;
}
public function set isRed(value:Boolean):void {
_isRed = value;
}
Any ideas? Thanks.
Instantiating MXML Component Within AS3 Class
I have a MXML component that is pretty much this:
MXML Component name is "TestPlan.mxml"
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
</mx:Canvas>
inside my AS3 I do this
pt:TestPlan = new TestPlan()
hbox.addChild(pt);
I get a TypeError #1009.
Can anyone help?
Accessing A Class Inside Of A Component
I would like to give the users of a component, that I am making, access to some of the classes being used inside of the component.
Is there a way to do this without distributing the source of this class?
Thanks.
How To Add Parameters To Component W/class Path
Hi, I'm new to Flash 9 and I don't know how to add parameters to a Flash 9 component I create via the Component Definition dialog box if my component uses a class file.
The second I enter a class path for the component, it wipes out any created variables. I'm trying to create a simple label component that's not based on the fl.core.UIComponent class. I just want to see what's the simplest component I can create.
All I want the component to do is display a colored background with a text field on top whose value I can change from the inspector. It doesn't need to resize, change state or anything. I figured I could do this without the overhead of the UIComponent, more as a learning exercise, but I've had no luck and would appreciate any help.
I assume if I were basing this on UIComponent, I could take advantage of the Inspectable metadata structure, but I suspect I don't have that route.
Thanks,
Jennifer
Targetting Problem In Class (Component)
So here we go. I'm kind of a stuck on creating AS2 component. Its my first one and I think thats probaply the reason im stuck in this stubid situation.
So lets move to the point. I have created Mouse listener which is working fine, only thing I just cant understand is how can I target to something inside of the listener when event is launched from it.
Heres a small example:
Code:
Class ..... extends MovieClip {
var changeMe:Number;
var theListener:Object = new Object();
function constructor(){
createMouseEvents();
}
function createMouseEvents() {
Mouse.addListener(theListener);
theListener.onRelease = function(){
// Here comes the problem
// For example im trying to give "changeMe" variable a new value
// but i cant target it.
changeMe = 10; // no luck
this._parent.changeMe = 10; // no luck
trace(this); // Equals to: [object Object] thats correct
trace(_parent); // Equals to: undefined
trace(this._parent) // Equals to: undefined
}
}
} // class ends
I hope I just havent missed anything cause im getting tired with this. I dont know are there other threads about this cause I cant get in my mind any search words for this.
Thanks in advance. Ill hope heres some AS hero (I know heres many).
And btw. love your tutorials. User them alot when I started with Flash and AS.
AS2 Class And Component Loading Problem
Hi all,
I'm testing this movie in flash 8. Here's how it's set up.
*I have a one frame preloader that works in the first frame.
*I'm exporting my AS2 classes to the second frame.
*I have all my components thrown inside a movieclip on the 11th frame so I don't have to export them to the first frame.
When I test the movie for high bandwidth, It goes to the frame that it's supposed to go, it connects to my remoting gateway, but the components don't show up. However, if I test the movie for 56k, the components show up, but it won't connect to my remoting gateway.
I've attached the zipped fla for your viewing enjoyment.
I've spent about 3 days on this problem, so any help will likely make me weep with joy.
Any Ideas?
Dynamically Attaching A Component To Another Components Class
Basically I have a component and a class - in it I want to attach another custom component within it
my classes extend UIObject and have set size, init draw and createchildren in
And in the createchildren method I do this
this inst = createClassObject(myClass, "MyNewComponent", this.getNextHighestDepth());
I only works if second component is a compiled clip.
However repeatingly goes into second components constructor method
Has anyone had experience of attaching a user created component within a component???
Class Files And List Component Variables...
Hey everyone!
Has any of you came across the error:
The class 'List' could not be loaded.
var fileList:List;
I've got a class file and this is just a variable declared at the top as I'm wanting to make the list component named "fileList" accessible and need to declare it.
A solution would be greatly appreciated cos this is for a final year uni assignment due in next week
unless someone wants to send me a media player that has video, audio and images using class files and gets data from xml
Sounds simple but I've got 5 other assignments...
Thanks!!
Dan
Problem On Accessing A Component Class Methods
Hello. I'm developing a component which incorporates standart Button and TextInput components. To handle those components events, for example "click" or "change" event, i'm creating an object in main class, and creating functions attached to that object. When coding in this object scope, "this" statement for main class becoming unaccessible and pointing to current object context. Is there a way to access class dynamic methods or variables from sub-object context? Example:
class something extends UIComponent {
...
private var btnOk:Button;
private var btnOkEvent:Object;
public function something() {
...
}
public function init() {
btnOkEvent.click = function(objEv) {
//In this context "this" statement does not point to
//something class. I mean i couldn't call beginDraw()
//method from here.
//(I know, if beginDraw method begins with static
//keyword, i can call it like something.beginDraw() )
}
btnOk = Create("Button"); //Sample
btnOk.addEventListener(btnOkEvent);
}
private function beginDraw() {
...
}
/*
I know, i can use class it self with event-name functions to handle
other components events but there must be an another way.
public function init() {
...
btnOk.addEventListener(this);
}
private function click(objEv) {
...
}
*/
}
This is a general question/problem for me. Perhaps it has a very simple answer, but i don't know. Is there a way? If so, how? Please help!
MediaPlayback Component Problems When Using NetStream Class
I am using the mediaPlayback component to play external .flv files. First problem I had was that they were stopping intermittently when loaded to the server.. so I read up on the netStream class and attached this basic code...
var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStream:NetStream = new NetStream(netConn);
//my_video is the name of the component instance on the stage
my_video.attachVideo(netStream);
netStream.setBufferTime(20);
netStream.play("introDemo.flv");
Now.. the audio plays but no video plays and the controls on the component do not work now... ie.. can't pause it. or adjust the volume.
MXML Component As Actionscript Class Property
I am trying to create a custom actionscript component that has an HTTPService property that I define in MXML and pass to the "service" property of a DatabaseNavigator component. However I keep getting null object errors. Here is my code:
index.mxml
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:db="database.containers.*" layout="absolute" width="700" height="700">
<mx:Style source="assetscss
scsadmin.css"></mx:Style>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.IndexChangedEvent;
import database.containers.DatabaseNavigator;
]]>
</mx:Script>
<mx:Fade id="fader" duration="1000" alphaFrom="1.0" alphaTo="0.0"/>
<mx:HTTPService id="databaseService" resultFormat="xml" method="POST" />
<db:DatabaseNavigator service="{databaseService}" host="localhost"/>
</mx:Application>
DatabaseNavigator.as
Code:
package database.containers
{
import mx.containers.TabNavigator;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.mxml.HTTPService;
public class DatabaseNavigator extends TabNavigator
{
private var _host:String;
private var _username:String;
private var _password:String;
private var _database:String;
private var _service:HTTPService;
private var metaData:XMLList;
private var params:Object;
public function DatabaseNavigator()
{
super();
params = new Object();
addEventListener(FlexEvent.INITIALIZE, superInitHandler);
}
public function get host():String {
return _host;
}
public function set host(value:String):void {
_host = value;
}
public function get username():String {
return _username;
}
public function set username(value:String):void {
_username = value;
}
public function get password():String {
return _password;
}
public function set password(value:String):void {
_password = value;
}
public function get database():String {
return _database;
}
public function set database(value:String):void {
_database = value;
}
public function get service():HTTPService {
return _service;
}
public function set service(value:HTTPService):void {
_service = value;
}
private function superInitHandler(event:FlexEvent):void {
params.host = host;
params.username = username;
params.password = password;
params.database = database;
try {
if(!service) {
throw(new Error("Error: Databse service not specified"));
} else {
service.addEventListener(ResultEvent.RESULT, serviceResultHandler);
service.send(params);
}
} catch (error:Error) {
Alert.show(error.message);
}
}
private function serviceResultHandler(event:ResultEvent):void {
Alert.show(event.result.toString());
}
}
}
Flex Actionscript Class & MXML Component
Hi all,
I was using AS3 projects in Flex for a year and started playing with Flex recently.
I am not infront of a Dec PC but i was wondering if someone can confirm this correct?
If i make an actionscript class called MyClass.
class MyClass
{
public var justaproperty:int = 0;
public function MyClass()
{
trace("a new class was created");
}
}
Does that mean that i can automatically use a flex component like this or is there more to it?
<local:MyClass id="myClass" justaproperty="15" />
Thanks.
MediaPlayback Component Problems When Using NetStream Class
I am using the mediaPlayback component to play external .flv files. First problem I had was that they were stopping intermittently when loaded to the server.. so I read up on the netStream class and attached this basic code...
var netConn:NetConnection = new NetConnection();
netConn.connect(null);
var netStream:NetStream = new NetStream(netConn);
//my_video is the name of the component instance on the stage
my_video.attachVideo(netStream);
netStream.setBufferTime(20);
netStream.play("introDemo.flv");
Now.. the audio plays but no video plays and the controls on the component do not work now... ie.. can't pause it. or adjust the volume.
Including Own Class Kills Button Component
Hi Guys,
I hope you can help me out here, since i have few hairs on my head left. It's driving me crazy.
I have a simple stage with 3 components on it, a combobox, a textfield and a button. (all v2).
on the button i say :
Code:
on(click) {
trace("A");
}
If i export, everything goes ok, if i click the button, it traces A.
But here it comes, if i use a custom created class inside this swf, the button stops sending the trace command!! In other words, the click event is not being called .
The code in my class which creates this error is :
Code:
mx.events.EventDispatcher.initialise(this);
Commenting this lin in my class makes my button work ok again.
Anybody know of a solution? And if there are other things i should know when using components with a custom preloader? (swf containing comp is loaded inside other swf -> this is btw not the case in above error)
tnx in advance!
Referring To Sub Mc
Hi
I have this problem. I am trying to refer to a sub movie clip.
The code goes like this.
_root["nodeText"+j].["node"+j]._width = node_size_x;[as]
the path goes like this but i want "j" to save me haveing to type...
_root.nodeText0.node0._witdth = ....
_root.nodeText1.node1._witdth = ....
_root.nodeText2.node2._witdth = ....
Cheers
Referring To Instances Through A Var?
Does anyone know of a way to refer to instances through a variable name?
i.e., if I have created an instance using
(where var_name = "instancename")
duplicateMovieClip(target, var_name, 1);
But now I want to immediately access the movie clip who's instance name is "instancename" (stored in var_name), but I can't just use var_name.text_name, because the AS will look for a movie clip named "var_name".
I want to name a text box "instancename" in the newly constructed movie clip, also called "instancename". So is there a way to do something like this?:
var_name.text_name = var_name;
^
|
|
do something to this so the compiler 'reads' it as "instancename" instead of "var_name"
Thanks.
Greg
When Referring To _levels
Hey there,
If you've set the level for a movie to be loaded onto as '8', when you want to refer to that level, do you say
code:
8.play()
or do you still have to say
code:
_level8.play();
Just wondering.
Thanks
[F8] Referring To Objects
Hi
I have loaded in a symbol with a linkage name of image using attach movie. It loads in fine, but how do I refer to it to to do things like modify its position etc.
Thanks
sand_monkey
Swf And Referring Domain
Is there a way to find the domain of the page that loads my swf. For example, someone embeds an swf served from my server on their www.myspace.com page. Is there is way for me to determine that the request is coming from myspace.com at runtime?
I have the option of using AS 3 if it provides a solution.
Referring To Functions
I have created a button within a movieclip and the following script appears in the button. This movieclip/button combination is added to the Flash game I am creating programatically:
ActionScript Code:
on (press) {
startDrag(this);
}
on (release) {
stopDrag();
if (eval(this._droptarget) == _root.garbage) {
actions.search_for_coin(this._name);
this.removeMovieClip();
}
}
I am trying to refer to a function that resides in a movieClip called "actions" which is at the root level. I can't seem to get to the "search_for_coin" function. What am I doing wrong?
Swf And Referring Domain
Is there a way to find the domain of the page that loads my swf. For example, someone embeds an swf served from my server on their www.myspace.com page. Is there is way for me to determine that the request is coming from myspace.com at runtime?
Referring A Mc Inside A Mc
i have a parentmc and a childmc.
parentmc.onRelease=function(){
trace("parentmc was clicked");
}
parentmc.childmc.onRelease=function(){
trace("the child was clicked");
}
what can i do to make it work?
Edited: 03/16/2008 at 12:58:38 PM by elic05
Referring To Many Things At Once
Just learning actionscript. (I'm a better programmer than visual artist)
I have a question in 2 parts.
Is it possible to either
refer to all m.c.s at once
or
dynamically (additively) group m.c.s
essentially, I am trying to replicate radiate accretive growth in Flash.
however, I need to add objects dynamically and be able to check the bounds of all objects.
ANy help will be appreciated.
Referring To Different MC's With Variables
What's the syntax to use objects, like a movieclip, with variables that increment. For example:
movieClip_counter_mc._visible = true;
where counter is a variable that changes throughout the script. So sometimes movieClip_1_mc will be visible, and other times movieClip_4_mc will be visible, and so on.
Any help is much appreciated.
Simple ; Referring To Another MC... HELP
Really simple question but I'm really rusty with flash;
I've got this setup; One MC with a text box to load external txt into... another MC ontop with a drop down menu to select the title of what is to be loaded...
Basically ; I need to know how to use the following...
Code:
on (release) {
loadText = new loadVars();
loadText.load("ourartists.txt");
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.plass;
}
};
}
but to load the data into the 'newsBox' on the MC named "CONTENTartists"
I'm sure it's as simple as doing
Code:
CONTENTartists.newsBox.html = true;
or something, but can't for the life of me even remember what this is called so can't even search for an answer!!!
Referring To A Movieclip
Code:
var l = 2;
duplicateMovieClip(button, "button"+l, this.getNextHighestDepth());
"button"+l._x = 300;
The last line of code is faulty... how to fix it ?
Referring To A Mc Inside An Mc
Well, the title really states what I want to know. If you have a Movie clip inside another Movie clip. Can you refer to that one from another movie clip on the screen.
eg.
1. A MC called "Player"
- inside "Player" is another MC called "weapon"
2. Player is placed onto the screen and another MC is placed on the screen called "sword"
3. When the player touches the MC called "sword". The movieclip called "weapon" - gotoAndPlays frame 2 inside it.
Note: I haven't really made a flash like above. It's just an example.
I refer to _root.sword from inside the MC called "weapon" but how can I refer to the MC called "sword" from inside the MC "weapon".
Does it use a file path? eg. _root.Player/weapon?
Does anyone know?
Referring To Many Things At Once
Just learning actionscript. (I'm a better programmer than visual artist)
I have a question in 2 parts.
Is it possible to either
refer to all m.c.s at once
or
dynamically (additively) group m.c.s
essentially, I am trying to replicate radiate accretive growth in Flash.
however, I need to add objects dynamically and be able to check the bounds of all objects.
ANy help will be appreciated.
Referring To Different MC's With Variables
What's the syntax to use objects, like a movieclip, with variables that increment. For example:
movieClip_counter_mc._visible = true;
where counter is a variable that changes throughout the script. So sometimes movieClip_1_mc will be visible, and other times movieClip_4_mc will be visible, and so on.
Any help is much appreciated.
Referring Variables In AS 3.0
Hi,
I'm learning AS 3.0 and little familiar with AS 1.0 and AS 2.0. I'm really confused when i try to refer a variable which I defined in a root layer, frame one inside a movie clip which is coming after the 40 frame.
this is a bit of my code in the root:
Code:
var randomListMsg:String = msgListGroup[xmlListRand(msgListGroup)];
trace (randomListMsg);
and it traces well.
but if I try to trace or put it in a text box inside a movie clip with this code: Code:
text1.msg_txt.text = MovieClip(parent).randomListMsg; // fails
text1.msg_txt.text = parent.randomListMsg; // fails
trace(stage.randomListMsg); //fails
trace(MovieClip(parent).randomListMsg); //fails
Can anybody guide me how to refer it inside a movieclip? and what is the normal referring system in AS 3.0 ?
Thanks in Advance.
Regards.
Referring To Loaded Swf In A Movie
Hi,
I have loaded a swf into a movie clip in my movie using the loadMovie function.
Now I have a button which is in my movie clip and when it is clicked i would like the loaded swf to movie to frame 50, for example.
If have tried: (empty is the empty movie clip i loaded the swf into)
with ("../empty") {
gotoAndPlay (50);
}
but it doesnt do anything.
What would be the correct actionscript for this?
|