2nd day
July 6th, 2008, 07:23 PM
Hi there,
when I picked up a flash project recently I could notice that I havent been using Flash / Actionscript for a long time. I took a lot of time for things I used to do much quicker. Now Im busy trying some other flash project and I thought it was a good idea to totally forget AS1.0 and just learn AS3. Now I also havent used classes in Flash, but after some php project where I did use classes i thought that would be handy as well...
Well... I actually got 3 problems...
1. I get an error about arguments (0 expected) This is when I create a new Post object
2. In the main function of a class I have a trace function wich isnt executed
3. some problems with dynamic variables / arrays... In a for function I want to shorten down a array to a variable like this:
var a:Array = this["post+i"];
trace (a[0]);
but that doesnt work...
Here's the code I use:
// code from Post.as
package {
import flash.display.*;
import flash.events.*;
public class Post extends MovieClip {
var background_color:String;
var title_txt:String;
var post_txt:String;
var id:Number;
var order:Number;
public function Post(colorP:String, titleP:String, postP:String, idP:Number, orderP:Number) {
background_color = colorP;
title_txt = titleP;
post_txt = postP;
id = idP;
order = orderP;
trace("This code runs when the Test class is instantiated");
}
function move_up():Void {
_parent.reorder(this.order, 1);
}
function move_down():Void {
_parent.reorder(this.order, 0);
}
function change_order(order:Number):Void {
trace(this.order);
this.order = order;
}
}
}
// code from my .fla file
var post0:Array = new Array(1, 1, "Testpost", "Dit is een test post");
var post1:Array = new Array(2, 2, "Testpost2", "Dit is nog een test post");
var post2:Array = new Array(3, 3, "Testpost3", "Dit is de laatste test post");
var postarray:Array = new Array(post0, post1, post2);
for(var i = 0; i<postarray.length; i++){
//var a:Array = this["post+i"];
//trace (a[0]);
var newitem:Post = new Post("black", this["post+i"][2], this["post+i"][3], this["post+i"][0], this["post+i"][1]);
list.addChild(newitem);
}
I hope you guys can help me out...
when I picked up a flash project recently I could notice that I havent been using Flash / Actionscript for a long time. I took a lot of time for things I used to do much quicker. Now Im busy trying some other flash project and I thought it was a good idea to totally forget AS1.0 and just learn AS3. Now I also havent used classes in Flash, but after some php project where I did use classes i thought that would be handy as well...
Well... I actually got 3 problems...
1. I get an error about arguments (0 expected) This is when I create a new Post object
2. In the main function of a class I have a trace function wich isnt executed
3. some problems with dynamic variables / arrays... In a for function I want to shorten down a array to a variable like this:
var a:Array = this["post+i"];
trace (a[0]);
but that doesnt work...
Here's the code I use:
// code from Post.as
package {
import flash.display.*;
import flash.events.*;
public class Post extends MovieClip {
var background_color:String;
var title_txt:String;
var post_txt:String;
var id:Number;
var order:Number;
public function Post(colorP:String, titleP:String, postP:String, idP:Number, orderP:Number) {
background_color = colorP;
title_txt = titleP;
post_txt = postP;
id = idP;
order = orderP;
trace("This code runs when the Test class is instantiated");
}
function move_up():Void {
_parent.reorder(this.order, 1);
}
function move_down():Void {
_parent.reorder(this.order, 0);
}
function change_order(order:Number):Void {
trace(this.order);
this.order = order;
}
}
}
// code from my .fla file
var post0:Array = new Array(1, 1, "Testpost", "Dit is een test post");
var post1:Array = new Array(2, 2, "Testpost2", "Dit is nog een test post");
var post2:Array = new Array(3, 3, "Testpost3", "Dit is de laatste test post");
var postarray:Array = new Array(post0, post1, post2);
for(var i = 0; i<postarray.length; i++){
//var a:Array = this["post+i"];
//trace (a[0]);
var newitem:Post = new Post("black", this["post+i"][2], this["post+i"][3], this["post+i"][0], this["post+i"][1]);
list.addChild(newitem);
}
I hope you guys can help me out...