Problem Creating Classes / Xml Import
I am trying to create a class. In a small test I cannnot succeed in creating an instance of my newly created class, and import some XML data into it.
I can import xml data into a prototype, but some how the instance does not get this info.
Can anyone help me with a suggestion?
I have a zip with the testfiles (fla, .as and xml): http://www.flashfocus.nl/forum/attachment.php?attachmentid=5646
Thanks in advance for the help,
Adobe > ActionScript 1 and 2
Posted on: 01/23/2007 07:23:19 AM
View Complete Forum Thread with Replies
Sponsored Links:
When Is Necessary To Use Import Statements To Import Classes?
Hi,
I'm sure that it must be necessary to use import statements in some situations, I'm finding that my code often works fine without them. For example, some instructions will say it is necessary to use import.flash.events.MouseEvent; before MouseEvent.CLICK will work, or that I must import the loader class before loading an SWF, but I'm finding that I can skip timporting and it works fine. Could anyone please explain why this it, and give me some idea of how to knew when to import and when I don't have to?
Thank you in advance!
View Replies !
View Related
[F8] Import Classes
Im trying to import the JavaScript and Flash Intergration Kit class but when I create an instance of the JavaScriptProxy I get this error
Code:
**Error** C:Documents and Settingsadansky.SD5042DesktopJavaScript InterfaceactionscriptcommacromediajavascriptJavaScriptProxy.as: Line 67: The class being compiled, 'com.macromedia.javascript.JavaScriptProxy', does not match the class that was imported, 'actionscript.com.macromedia.javascript.JavaScriptProxy'.
{
here is my code
Code:
import actionscript.com.macromedia.javascript.*;
var proxy:JavaScriptProxy = new JavaScriptProxy(_root.lcId, this);
function addItem(item:Object):Void{
list.addItem(item);
};
function transferItemToJavaScript():Void{
if(list.selectedItem != null){
proxy.call("addItem", list.selectedItem);
list.removeItemAt(list.selectedIndex);
}
}
View Replies !
View Related
Import New Classes In Swc?
Hello guys! I have this little problem, i have created a class and this class imports some classes, then the class has been exported as swc, so now i have a component but not always i will be using the classes inside the swc, sometimes i will create new classes and would like to have the swc implements those new and external classes too..... any ideas guys!
thanx in advance!!
View Replies !
View Related
Import Classes
XML file:
<modifiers>
<modifier class="com.whitecitysoft.modifiers.Reverse">Revers ed</modifier>
<modifier class=" com.whitecitysoft.modifiers.Capitalize">Capitalize d</modifier>
<modifier class="com.whitecitysoft.modifiers.Scramble" >Scrambled</modifier>
</modifiers>
I have to load all of these classes and apply their effect on some string.Classes are .swf files in libs subfolder with package structure and they all contain one static method 'run'.
For example: public static run(text:String) : String
My code so far:
data = new XML();
data.ignoreWhite = true;
data.load("xml/modifiers.xml"); //ok
data.onLoad = function(success) {
if (success) {
if (data.status == 0) {
newClassArray = new Array();
l = data.childNodes[0].childNodes.length;
for (i=0; i<l; i++) {
newClassArray[i] = data.childNodes[0].childNodes[i].attributes["class"];
}
// problem with import
// this is just an example
var t:String = newClassArray[0].toString();
t = 'lib.'+t;
import t; // I can't load these classes
var my_string:String = 'This is a simple text.';
my_string = Reverse.run(my_string);
trace('Reversed: '+my_string);
} else {
trace("Parse Error:"+data.status);
}
} else {
// could not get the XML
trace("Load Error");
}
};
View Replies !
View Related
Cannot Import Some Classes
I am using Flash CS3. I have Flash installed in /Applications/CS3/Adobe Flash CS3. The box is a G4 MDD with adequate specifications.
Anyway, I have been experiencing issues with importing a few classes. I have been using a copy of the ActionScript 3.0 Language and Components Reference as detailed here:
http://livedocs.adobe.com/flash/9.0/...riptLangRefV3/
I am trying specifically to import fl.containers.ScrollPane and fl.control.TextArea. I import them as is normal:
import fl.control.TextArea;
fl.containers.ScrollPane;
And I am informed that every function I call is a reference to a possibly undefined function etc...
Could this be an issue with a improperly set classpath? My classpath is set as such:
"$(AppConfig)/ActionScript 3.0/Classes"
and
"."
Might it be the "." that is setting the thing off?
I am inclined to think not, because if I import, for instance, flash.display.MovieClip, it works perfectly.
Thanks for your help.
View Replies !
View Related
When To Import Classes?
I have a simple project in Flash CS3 where I've added an event listener to trigger a function at the end of an flv file (code attached). I kept getting the following error:
1046: Type was not found or was not a compile-time constant: VideoEvent.
Attach Code
stop();
myPlayback.x = (stage.stageWidth / 2) - (myPlayback.width / 2);
myPlayback.y = (stage.stageHeight / 2) - (myPlayback.height / 2);
//import fl.video.VideoEvent;
myPlayback.addEventListener(VideoEvent.COMPLETE, nextMovie);
function nextMovie(evt:VideoEvent):void
{
trace("Finally, you can go home!");
}
View Replies !
View Related
Why Import Classes?
stupid question #(how many posts do i have?),
although i can get around with oop as3, im wondering... say i write a class (lets call it Subclass) that is instantiated by another class (Mainclass). for what reasons would i need to actually do this?:
Code:
package
{
import Subclass;
public class Mainclass extends something
{
public function Mainclass()
{
var subclass = new Subclass();
}
}
}
i mean,i know that i can instantiate Subclass without importing it into Mainclass, but does importing give me some sort of advantages?
View Replies !
View Related
Importing Classes- Why Not Import Them All?
hi guys...i am playing with filters...now, to do this, i know i have import them
Code:
import flash.filters.DropShadowFilter //if it is a drop shadow
but this got me thinking...what are the negative effects of just importing ALL the filters
Code:
import flash.filters.*
will it make my swf big? slow?
View Replies !
View Related
[basic] Import Classes
Hi, I imported the class using the Document class field:
com.myname.Application
what about if I want to import other classes?
I tried with:
import com.myname.Application
but doesn't work...I'm a little bit confused! :|
View Replies !
View Related
How Can I Force Classes To Import?
I'm making a dynamic slideshow which is configurable via a php file. What I'm trying to allow is the ability to assign either Tween or 1 of the 9 transition classes (Blinds, Fly, Pixel Dissolve, etc.) to the slideshow via configurable variables in the php file.
I've come to find out that Flash doesn't automatically include these classes in the exported swf, but rather UPON export. My assumption is that is checks the AS for class definitions/constructors and imports only what it needs (to keep file size low). However, since this slideshow is dynamic, any type of transition will be needed.
What I need to do: FORCE any/all transition classes to be imported into the exported swf.
I've managed to force the easing classes (Bounce, Elastic, Strong, etc.) and apply them dynamically via this code in my Tween function:
ActionScript Code:
function transTween() {
import mx.transitions.Tween;
import mx.transitions.easing.*;
//
// force classes to be imported by using fake constructors
var force:Tween = new Tween(xxx, "_x", Back.easeOut, x, x, x, true);
var force:Tween = new Tween(xxx, "_x", Bounce.easeOut, x, x, x, true);
var force:Tween = new Tween(xxx, "_x", Elastic.easeOut, x, x, x, true);
var force:Tween = new Tween(xxx, "_x", Regular.easeOut, x, x, x, true);
var force:Tween = new Tween(xxx, "_x", Strong.easeOut, x, x, x, true);
var force:Tween = new Tween(xxx, "_x", None.easeNone, x, x, x, true);
//
eClass = new String(tParamAr[1]); // tParamAr[1] is the name of the easing class defined in the php file
eMeth = new String(tParamAr[2]); // tParamAr[2] is the name of the easing method defined in the php file
//
// {... deleted code, used to position movieclips based on loaded parameters ...}
//
tweenIn(1);
}
function tweenIn(num) {
var pTw:Tween = new Tween(imgWell["img"+num], tParamAr[0], mx.transitions.easing[eClass][eMeth], begin, midVal, duration, true);
pTw.onMotionFinished = function() {
ID = setInterval(tweenOut, delay, num);
};
}
//
function tweenOut(num) {
clearInterval(ID);
var pTw:Tween = new Tween(imgWell["img"+num], tParamAr[0], mx.transitions.easing[eClass][eMeth], midVal, finish, duration, true);
pTw.onMotionFinished = function() {
num++;
if (num>maxImages) {
num = 1;
}
tweenIn(num);
};
}
As seen in the code above, everything in the Tween constructor is dynamic. However, as I tried this with the Blinds transition, it failed to work properly.
ActionScript Code:
// 'tParamAr' is the array that contains the transition's paramaters
// this works
myTransitionManager.startTransition({type:Blinds, direction:Transition[direct], duration:tParamAr[1], easing:Strong[eMeth], numStrips:parseInt(tParamAr[4]), dimension:1});
// this doesn't
myTransitionManager.startTransition({type:Blinds, direction:Transition[direct], duration:tParamAr[1], easing:[eClass][eMeth], numStrips:parseInt(tParamAr[4]), dimension:parseInt(tParamAr[5])});
I've even gone so far as to include multiple TransitionManager constructors in a switch-case statement, but it seems to fail altogether if I have more then one constructor in my code.
View Replies !
View Related
Can't Import Two Classes At Same Time
I know it sounds weird, but I've not being able to import these two simple classes to a third one. I have simplified the code to bare traces and it still doesn't work. The strange thing is, if I import only ONE of the classes I hit control+T and presto, the error is gone, doesn't matter which one.
The three classes are in the same directory.
Any help would be greatly appreciated,
Thanks.
This is the main class (Three.as)
import One.as
import Two.as
class Three {
function Three(){
trace("Three");
}
}
---------------------------
(One.as)
class One {
function One(){
trace("One");
}
}
---------------------------
(Two.as)
class Two {
function Two(){
trace("Two");
}
}
View Replies !
View Related
Import Classes Strucutre
Is it possible to put my .as files in a folder and load the ones from another???
In the following folder is the class Example.
c:flashExampleClass
Code:
class Example {
public var nNumber:Number;
}
and I want to load the class "Example" from:
c:flash
so I thought I could do something like that:
Code:
import ExampleClass.Example;
class Another {
public var ex:Example;
}
Thanks
View Replies !
View Related
Import Classes Not Working
Today Flash decided to stop importing any of my classes. Everything worked fine yesterday. I came in today and it can't find anything. I know the files are there.
Code:
import com.mine.Test;
var t:Test = new Test();
Outputs "1172: Definition com.mine:Test could not be found.
View Replies !
View Related
AS3 - What Is The Best Method To Know What Classes To Import
Does anyone know if there's a list or a chart that lists all of the built-in classes, and packages?
Basically, I want to be able to minimize the KB size of my movie - and instead of importing the entire text class for example (import flash.text.*) I want to import only the specific files that I need for that class. is there a simple way to list them, so I can pick and choose?
View Replies !
View Related
Import Classes Syntax Problem
I'm trying to import a class and all the classes in that directory. Here is my syntax:
import mx.events.EventDispatcher.*;
But Im getting this error message:
**Error** Scene=Scene 1, layer=Layer 3, frame=1:Line 1: Syntax error.
import mx.events.EventDispatcher.*;
Total ActionScript Errors: 1 Reported Errors: 1
And Im using AS 2.0...any answers? Thanks...
View Replies !
View Related
List Of Import Classes And Descriptions
OK, we just got CS3 installed at work, and we're starting to learn the new AS3. So far we love it... but we want to know ALL the import classes and descriptions of what they are. is there a list anywhere? I've searched the help, searched the web, can't seem to find anything.
something like:
flash.events. // used for blah blah blah
flash.events.x // blah blah blah
is there any list like this?
View Replies !
View Related
Import Classes Syntax Problem
I'm trying to import a class and all the classes in that directory. Here is my syntax:
import mx.events.EventDispatcher.*;
But Im getting this error message:
**Error** Scene=Scene 1, layer=Layer 3, frame=1:Line 1: Syntax error.
import mx.events.EventDispatcher.*;
Total ActionScript Errors: 1 Reported Errors: 1
And Im using AS 2.0...any answers? Thanks...
View Replies !
View Related
Does Flash Import Unused Classes?
Like a lot of you I have a growing library of custom components and util classes. Now what I'm wondering is if I use a class which imports a number of other classes(an obvious one would be a custom tweening util class importing Robert Penner’s AS2.0 classes), and some of these imported classes are never used in the published file, are they still added to the published movie increasing its file size? If so WHY?!
Sorry if this has been asked before! I did do a search first.
View Replies !
View Related
Include Or Import Other Classes Inside Of Another Class?
I'm creating a component and a class for that component using the new 2.0 OOP methods. I need to use the Robert Penner movieclip Tween class calls with in my class, which means I have to import or include that class in order the use it. But I can't seem to find a way to do it. Both include and import return errors, stating that that it is not allowed within a class definition. Is this just not possible? Any help?
View Replies !
View Related
Selecting The Classes/packages To Import At Runtime
Before starting an class or code, you should put all your import statements..
Now I have flash application, which offers a search feature which relies on some pretty huge classes. The user is unlikely to use this feature. However, importing those classes anyway adds some pretty large kbs to my application. Is there a way to import these classes at runtime ONLY IF the user chooses to use this feature?
Thanks
View Replies !
View Related
Import MovieClips/Classes From External File
Hey All,
I'm working on an OOP/Class based application. In order to save on filesize, I have some of my assets in another swf file, with their linkage properties set to classes that give them properties and actions:
Class: src.BLNavStation_Circle
Base class: flash.display.MovieClip
View Replies !
View Related
Creating New Classes
Code:
var tempRef="item"+i
tempRef:Item = new Item(ixxx, 0, -290)
I want to be able to talk backwards to these things so I want the following refferences creating
Item0
Item1...
cant seem to get this right in as 3 before In 2 I would just do
this["Item"+i]=new Item(....
thanks
View Replies !
View Related
Help With Creating Objects And Classes
Hey all, it's been a reeeeal long time since I've posted here - and I apolygize. School just kills me sometimes : ( Anyway, I'll get to it. I've been having a hard time wrapping my brain around some complex (to me) issues with objects, subclasses, and superclasses.
Here's what I'm trying to do: I have a song name, band name, and file name variables. I'm trying to create a class that will not only allow me to play the sound but can also return attributes such as the song name and band name of the specific song object created from the Song class. So I first did this:
var Songs = []
Songs[0] = new Song ("Band Name", "SongName", "../media/someMP3.mp3")
function Song (band, title, file) { // create the song subclass
super (band, title, file) // add values supplied as arguments to the Sound superclass?
this.band=band
this.title=title
this.file=file
this.song = new Sound();
this.song.loadSound(this.file, true);
this.song.stop();
}
Song.prototype.playSong = function () {
this.song.start();
}
//Song.prototype = new Sound () // add all Sound superclass attributes to our Song subclass
After tonight I'm assuming I can't use a predefined class like "Sound" or "MovieClip" as a superclass for a subclass called "Song," lets say. Because I couldn't get it to wok
PHP Code:
songList = new XML ()
View Replies !
View Related
Help With Creating Objects And Classes
Hey all, it's been a reeeeal long time since I've posted here - and I apolygize. School just kills me sometimes : ( Anyway, I'll get to it. I've been having a hard time wrapping my brain around some complex (to me) issues with objects, subclasses, and superclasses.
Here's what I'm trying to do: I have a song name, band name, and file name variables. I'm trying to create a class that will not only allow me to play the sound but can also return attributes such as the song name and band name of the specific song object created from the Song class. So I first did this:
var Songs = []
Songs[0] = new Song ("Band Name", "SongName", "../media/someMP3.mp3")
Songs[0].onLoad = function () {
this.start()
}
trace(Songs [0].band)
trace(Songs [0].title)
function Song (band, title, file) { // create the song subclass
super (band, title, file)
this.band=band
this.title=title
this.file=file
this.song = new Sound();
this.song.loadSound(this.file, true);
this.song.stop();
}
Song.prototype = new Sound ()
But I'm pretty sure this is completely wrong. Because I'm assuming I can't use a predefined class like "Sound" or "MovieClip" as a superclass for my subclass, "Song." So then I tried this, still without any luck:
var Songs = []
Songs[0] = new Song ("Band Name", "SongName", "../media/someMP3.mp3")
Songs[0].onLoad = function () {
this.start()
}
trace(Songs [0].band)
trace(Songs [0].title)
function Song (band, title, file) {
this.band=band
this.title=title
this.file=file
this.song = new Sound();
}
Song.prototype.loadSong = function () {
this.song.loadSound(this.file, true);
this.song.onLoad = function() {
this.song.stop();
return true
}
}
Song.prototype.playSong = function () {
this.song.start();
}
Now, in any case I'm *really* trying to do all this this most advanced oop way possible (flash mx). So if I'm WAY off just let me know. I hope someone can help me figure this out... you guys are the best : )
-Dave
View Replies !
View Related
Creating Objects In Classes
I already tried to post this once, but it didn't work for some reason.All I am trying to do is define an object in a class, but the syntax has me wound around a gear here. No matter where I define it, I'm getting barked at by the compiler this is basically what I'm trying to do:
class Card{
public var _systemID:String;
public var _type:String;
public _PRIMARY_AUDIO_GEN = new PRIMARY_AUDIO_GEN();
function Card(systemID:String, cardType:String){
_systemID = systemID;
_type = cardType;
function PRIMARY_AUDIO_GEN {
var status:String;
var flashcard:Boolean;
}
}
View Replies !
View Related
Creating Objects In Classes
Is it possible to create objects in Classes? For example, if I'd like to create a TextField in a class, what would the syntax be?
I would like to create a class that will allow me to create text fields dynamically when needed.
View Replies !
View Related
Creating A Class Using Other Classes...
Ok i am creating a class that includes file Reference but i cant make it to
start working... What do i do wrong???
//file starts here:
import flash.net.FileReference
//System.security.allowDomain(path);
class fileUploader
{
private var fileUpload : FileReference = new FileReference ();
this line throws me an error.
is a lot more of code but i need to fix this only....
Thank you
View Replies !
View Related
Creating External Classes
I have some working main timeline AS 3.0 code that I need to turn into an external class (or multiple classes). But I don't have any experience writing external classes. What's the best way of going about this?
Code:
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.display.StageDisplayState;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextLineMetrics;
import flash.text.AntiAliasType;
import flash.text.TextFormat;
//----------------------------------------------------------------
import flash.utils.getDefinitionByName;
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
//----------------------------------------------------------------
stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.NO_SCALE;
//----------------------------------------------------------------
content_tb.embedFonts = true;
content_tb.selectable = false;
//----------------------------------------------------------------
var clickSound:Sound;
var librarySoundOne:Class = getDefinitionByName ( "Click" ) as Class;
clickSound = new librarySoundOne();
var clickChannel:SoundChannel;
//----------------------------------------------------------------
var dingSound:Sound;
var librarySoundTwo:Class = getDefinitionByName ( "Ding" ) as Class;
dingSound = new librarySoundTwo();
var dingChannel:SoundChannel;
//----------------------------------------------------------------
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("xml/modernism.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
LoadContent(xmlData);
}
//----------------------------------------------------------------
function LoadContent(textData:XML):void {
//CONTENT TO BE DISPLAYED ON INITIAL LOAD
var defaultText = textData.item[0].content.text();
var pageTitle_text = textData.item.label.text()[0];
pageTitle_tb.htmlText = "<b>" + pageTitle_text + "</b>";
var formatSpacing:TextFormat = new TextFormat();
formatSpacing.letterSpacing = 4;
pageTitle_tb.setTextFormat(formatSpacing);
//----------------------------------------
function setPage(page:Number):void {
field.scrollV = (page - 1) * linesPerPage + 1;
}
// Assigns the text field that is on the stage to a local variable
var field:TextField = content_tb; //Added "TextField" type
field.embedFonts = true;
// Assign the content to the text field
field.htmlText = defaultText;
// Extracts the text format and line height properties
var format:TextFormat = field.getTextFormat(); //Added "TextFormat" type
var leading = int(format.leading);
var extent:TextLineMetrics = field.getLineMetrics(0);
var ascent = extent.ascent;
var descent = extent.descent;
// FIRST CALCULATE THIS NUMBER USING BODY TEXT OF THE SAME FONT SIZE
// IF HTML TEXT INCLUDES HEADINGS OF DIFFERING SIZES THE NUMBERS WILL BE SKEWED
//var lineHeight = ascent + descent + leading;
var lineHeight = 16;
var linesPerPage = Math.floor((field.height - 4 + leading) / lineHeight);
var lineCount = (field.maxScrollV - 1) + linesPerPage;
var pageCount = Math.ceil(lineCount / linesPerPage);
var offset = (linesPerPage * pageCount) - lineCount + 1;
var lineBreak:String = "<br />";
//var lineBreak:String = "
";
for (var i = 0; i < offset; i++) {
defaultText.htmlText += lineBreak;
}
//LINE BELOW IS A NECESSARY REPEAT
field.htmlText = defaultText;
var panelNum = pageCount;
var curNum = 1;
pageNum.htmlText = "<b>" + curNum + "</b>";
pageTotal.htmlText = "<b>" + panelNum + "</b>";
prevButton_mc.visible = false;
function NextOnClick(event:MouseEvent):void {
curNum++;
pageNum.htmlText = "<b>" + curNum + "</b>";
setPage(curNum);
if (curNum == 2) {
prevButton_mc.visible = true;
clickChannel = clickSound.play();
} else if (curNum == panelNum) {
event.currentTarget.visible = false;
curNum = panelNum;
dingChannel = dingSound.play();
} else {
clickChannel = clickSound.play();
}
}
nextButton_mc.buttonMode = true;
nextButton_mc.addEventListener(MouseEvent.CLICK, NextOnClick);
function PrevOnClick(event:MouseEvent):void {
curNum--;
pageNum.htmlText = "<b>" + curNum + "</b>";
setPage(curNum);
if (curNum == 1) {
setPage(curNum);
event.currentTarget.visible = false;
curNum = 1;
dingChannel = dingSound.play();
} else {
clickChannel = clickSound.play();
}
nextButton_mc.visible = true;
}
prevButton_mc.buttonMode = true;
prevButton_mc.addEventListener(MouseEvent.CLICK, PrevOnClick);
}
Oh yes, there's a textfield on the stage named "content_tb" and a next and previous button set. And a textfield that holds the page title: "pageTitle_tb"
View Replies !
View Related
Creating Classes And Prototypes And Uhhhh
Yeah hi. I really don't understand any of this class sh*t.
I've got a timeline menu. In it, I've got various buttons for various years. I don't want to use traditional buttons, I need the extra functionality of "buttonized" movie clips. So I need a new prototype. Right?
The thing is, I don't want ALL movie clips to act as timeline buttons, so I need to create a new class, right?!
Anyway, here's what I've got.
Code:
timelineButton = function () {
}
timelineButton.prototype.setButtons = function() {
var b1997 = this.btn1997;
var b1998 = this.btn1998;
var b1999 = this.btn1999;
var b2000 = this.btn2000;
};
timelineButton.prototype.test = function() {
trace("test");
};
timelineButton.prototype.onRelease = test;
I'm basically trying to say "here's my timeline interface, in it I need a certain number of buttons, here are their instance names, and when each one is clicked, I want to call the "test" function."
How's my Actionscript, folks?!
View Replies !
View Related
Creating New Classes In Loop Issue
Hi,
Here's what I want to do and I have no idea how...
Version: Flash 8 Basic (PC)
Question: How do you create a class file and have that class file load an image into it so that when you create a instance of the class on the root, you get a movieclip on the screen?
Need: Using a For loop, I want to create movieclips on the root using a movieclip in the library as a base. The source movieclip is sitting in the library with a linkage id of "mcButton". mcButton right now is a blank movieclip with a tie to a class file.
What I did: I created a class file that I tied to this movieclip (specified at the same place where you specify linkage id). I create a new class in actionscript on the root. Example:
code:
var oButton:Button = new Button("test.jpg");
In the initialization of the class, it calls for a filename which then it creates a movieclip and loads that graphic into it.
Issue: When I test it, the loop runs and the classes seem to be creating but I see nothing on the screen. I don't really understand how I should approach this and what to do.
Help is much appreciated!
Thanks!
View Replies !
View Related
Dynamically Creating Properties Within Classes
hi all,
so i'm attempting to go full on into the as2 realm (yes a couple years late, i know) and i feel like i'm losing items from my bag of tricks instead of gaining.
specifically, how can i dynamically create properties for a generic object?
old way...
Code:
myObj:Object;
for( var i:Number = 0; i < someArray.length; i++){
myObj.clip = "this is a clip ref";
myObj.descrip = "here's some info";
}
something.onRelease = function(){
someText_txt.text = myObj.descrip;
}
how can i simulate this in a class?
it's seems every property needs to be defined in the class, is this true?
if it is, can i just reassign while iterating through a loop and push that value into a predefined object?
if you've accomplished this in a class (on root doesn't count) i would appreciate to the tenth degree any help or links or leads to a solution
i've sifting through blogs, forums, and colleauges patience to get this and nothing has been working up to this point.
thanks
View Replies !
View Related
Creating Packages And Importing Classes
Why do I get the error "1084: Expecting identifier before as."
I have a flash file here: Exampleflash.fla
I have a class file here: ExamplePackageNamePackageName.as
In the flash file I write:
ActionScript Code:
import PackageName.PackageName.as
In the class file I write:
ActionScript Code:
package PackageName
{
public Class ClassName {
}
}
View Replies !
View Related
Dynamically Creating New Instances Of Classes?
I was just wondering is it was possible to do something like this (it works well) in an easier way:
Code:
function getVakNumberClip(index:int):Object{
switch (index){
case 1: return new _1();
case 2: return new _2();
case 3: return new _3();
case 4: return new _4();
case 5: return new _5();
case 6: return new _6();
case 7: return new _7();
case 8: return new _8();
case 9: return new _9();
default: return new _0();
}
}
I have 10 objects in my library, "_0" to "_9", containing vector-stuff representing the numbers, and would like to call them seperately, depending on a variable. In AS 2.0 it was pretty easy: "attachMovie("_"+variable, ...", but I don't see a way to do that in AS 3.0, things like:
Code:
var test:["_"+variable] = new ["_"+variable]();
don't seem to work..
View Replies !
View Related
[F8] Creating Code That Will Import File
I need to create a set of code that will read this file. These are just x,y coordinates. The first is a square, then a circle, and then a triangle. I need to be able to import this file into flash and flash will the plug in all the information and create what is on the file. How do I do this?
(VR2 V00.34)
(NamedView -186352,183508 265712,-66188 Initial)
(View -186352,183508 265712,-66188)
(Background 0)
C 3
P 5 0,0 0,122880 122880,122880 122880,0
0,0
P 37 -12587,58659 -13906,73739 -17822,88362 -24217,102083
-32896,114486 -43596,125195 -55992,133884 -69708,140289
-84328,144217 -99407,145547 -114488,144241 -129114,140336
-142840,133953 -155250,125284 -165967,114592 -174666,102203
-181082,88492 -185022,73875 -186364,58797 -185070,43715
-181177,29086 -174804,15355 -166145,2938 -155462,-7788
-143080,-16496 -129374,-22924 -114760,-26875 -99683,-28229
-84600,-26947 -69968,-23065 -56232,-16704 -43808,-8054
-33074,2620 -24356,14995 -17917,28696 -13955,43306
-12588,58383
P 4 142892,-6950 204332,115930 265772,-6950 142892,-6950
(EndOfDWF)
View Replies !
View Related
[F8] Creating A Function Similar To OnLoad Through Classes
How would I go about creating a function similar to an onLoad event where it listens for an event and then returns its value in the arguments portion of the function.
So, for example, let's say I have a function called helloWorld()
Right now, my code looks like this:
Code:
-----------
FIRST FRAME
-----------
function helloWorld(myText:String)
{trace(myText);
onHelloWorld();
}
function onHelloWorld()
{
}
---------
IN BUTTON
---------
_root.onHelloWorld = function()
{trace("Working...");
}
_root.helloWorld("hello");
This basic layout initiates the onHelloWorld = function() event, but I want it so it raises a function like _root.onHelloWorld(myText:String) and I can read myText. Like onLoad's success boolean variable.
Thank you for any help you can provide.
View Replies !
View Related
Other Ways Of Creating Classes Other Than Document Class
Is there another way to create/define a class other than the Document Class?
It's really annoying to have to create and entire file for one class, then name that file the same as the class name. O'Reillys AS3 book only talks about the Document class in the OOP section, so that's the limit to my understanding of how classes are defined.
How can do keep all my classes in one file, then have flash import that file.
Something like multiple packages per file, or multiple classes per package?
View Replies !
View Related
Syntax For Dynamically Creating Custom Classes
Hi there, I am trying to load 4 custom classes from my library that are movieclip symbols and I want to be able to do this dynamically without having to hard-code each instance.
At the moment I am writing the code like this:
ActionScript Code:
var my1:S1 = new S1();var my2:S2 = new S2();var my3:S3 = new S3();var my4:S4 = new S4();function addMys() { for (var i=0; i<4; i++) { var myS:Sprite = this["my"+(i+1)] this.addChild(myS); }}
I would like to create the instances of the sprites within my loop but I'm not sure of the syntax, if someone could show me how to write this I would be really grateful.
Thanks!
Schm
View Replies !
View Related
Problem With Creating Text Via Classes Inside Packages.
Hi all
Im pretty new to actionscript 3 (more of a lingo programmer and i foolishly though the migration would be easy). Im trying to make a class which as part of its constructor calls a function to put some text on the stage. However while code compiles and all the trace statements are outputed showing that the code is exicuted but nothing appears on screen. Im guessing its to do with the addChild(txtSprite) on line 22 but have no idea what that should be.
The code start by creating a new instance of the quizControl class on frame 1 of the time line with the code :
import MathsQuiz.*;
var mainQuizControl:QuizControl = new QuizControl();
stop();
The code for the quizControl is in the package MathsQuiz (most of it is to do with text formating):
package MathsQuiz{
import flash.display.*;
import flash.text.*;
// A class that controls the swtiching of the lights.
public class QuizControl extends MovieClip {
// Vars
private var txtFormat:TextFormat;
private var txtSprite:Sprite;
private var txtField: TextField;
// Constructor
public function QuizControl():void {
trace("QuizControl Sucessfuly Constructed");
txtSprite = new Sprite();
addChild(txtSprite);
txtFormat = new TextFormat("Arial",24,0x330000,true,false,false,nu ll,null,"center");
txtField = this.makeText("YO DUDES",txtFormat,txtSprite,0,60,550);
}
private function makeText(newText:String, tf:TextFormat, s:Sprite,x,y:Number, width:Number):TextField {
var tField:TextField = new TextField();
tField.x = x;
tField.y = y;
tField.width = width;
tField.defaultTextFormat = tf;
tField.selectable = false;
tField.multiline = true;
tField.wordWrap = true;
if (tf.align == "left") {
tField.autoSize = TextFieldAutoSize.LEFT;
} else {
tField.autoSize = TextFieldAutoSize.CENTER;
}
tField.text = newText;
s.addChild(tField);
trace ("MakeText finished");
return tField;
}
}
}
ive probably done something realy stupid or fundamentaly flawed but any help you can give me would be greatly appreciated. Thanks
Ionic234
View Replies !
View Related
How Would I Go About Creating A Movie With A Transparent Background N Import In Flash
Hello,
I would like to create animated 3d object, and use it within my flash. I was thinking of using blender3d.org to create a moving arm.
However I have no idea how I would make it have a transparent background, so i can put it in flash.
I'm not even sure if this is possible and i've been googling for hours. What program would be needed, and what would the process be to create a 3d object... and import it into flash with a transparent background?
I want the object to move over content in the flash, but in my mind i invision the 3d object inside of a solid square, and thats not what I want.
If anyone could point me into the right direction on what to search for, or where to begin... that would be great...
Thank you in advance
View Replies !
View Related
Simple But Eluding Problem With Creating Classes Extending UIObject Or MovieClip
I recently started to make custom classes in actionscript, I'm not new to programming but what has so far confused me is how I actually instance an object visually.
for example;
var Com1 = new MyComponent();
This works, and indeed creates an instance of my class, but since the object is also required visually, how do I add this to the controls of; for example, the root.
I'm sure it's not complicated, but I just can't see how, the actionscript really appears to be coded heavily to creating movieclips only as visual.
Sorry this is my first post, and I am asking a lot, but I thought this forum would be the best place to go for my problem.
Hope that makes sense, and thanks in advance.
Stevo.
View Replies !
View Related
How Do I "import" The Classes?
Hi guys...I'm giving Lee Brimelows "cube" paper vision tut a go...seems all pretty straight forward as always he is clear and step by step...however he brushes over the very start about how to ge the paper vision stuff into flash....I cant find my "snippets" window in flash!!!!!
I have followed the other threads on here and have all the classes in a folder called greatwhite......
Now what?????
Slightly confused!!
View Replies !
View Related
Custom Classes: One Class Tracks Multiple Other Classes?
I'm working on a coloring that allows kids to place objects on a scene and then color them so the image can be printed out. So assume you have sky background, the child can select a bird object, drag it into place and once they have it in place, color everything on the page (with a given palette of colors.)
So far it going great. However I want to track what objects have been added to the drawing on the fly. I have a potential solution using arrays but I'm thinking this is perfect opportunity to start using custom classes.
I'm thinking that I'd create a new instantiate a copy of the object class each time an object is added to the scene. However to track the objects added to the scene I'm thinking I'll also use an listing class to track them.
What I'm not sure about is the would the listing class simply contain an array of object identifiers? Any thoughts on the structure of the listing class?
I'm very new to oop as I've mainly been doing procedural programming up to this point but I'm eager to give this a shot.
Thanks!
View Replies !
View Related
Bulk Import Statments Vs. Specific Import Statements...any Performance Difference?
Lets say I have 20 classes located at nl/amsterdam/simulation/model/. Now I'm writing another class that is going to use some of those 20 classes. Is there any performance difference in the compiled swf if I import them all using a wildcard:
Code:
package nl.amsterdam.simulation.view
{
import nl.amsterdam.simulation.*
...
versus importing each specific one that I need?:
Code:
package nl.amsterdam.simulation.view
{
import nl.amsterdam.simulation.model.Tulip;
import nl.amsterdam.simulation.model.Canal;
import nl.amsterdam.simulation.model.Prostitute;
import nl.amsterdam.simulation.model.StonedTourist;
import nl.amsterdam.simulation.model.BuisnessMan;
import nl.amsterdam.simulation.model.Windmill;
import nl.amsterdam.simulation.model.CoffeeShop;
import nl.amsterdam.simulation.model.SkinnyBuilding;
...
Or is there only a difference in the time it takes to compile, not the time it takes to execute?
View Replies !
View Related
Using Flex Classes In Classes Linked To Symbols
Hi all
I have a fla file where I link a symbol to an action script class. This action script classes references mx.collections.ArrayCollection; so when I attempt to publish the fla file, I get the error message:
1017: The definition of base class ArrayCollection was not found.
I then tried to add a class path (this folder contains the mx... classes):
C:Program FilesAdobeFlex Builder 3sdks3.0.0frameworksprojectsframeworksrc
and the the above error 1017 wasresolved, but now I get the error:
Version.as, line 18 1004: Namespace was not found or is not a compile-time constant.
So now I am pretty much stuck. What do I need to do for this to work ? Please note that the code compiles fine in flex, so it is not som basic coding error ?
View Replies !
View Related
|