Trying to go to the next page when a listing is clicked, but i think the name of object at the moment is not correct. I am not very sure on why the listing on stage won't be removed, i added it on a if statement.If i click it, it doesnt do anything, and if i do removeChild(newListing) then it gives me an error of access of undefined property, so i think because thats not the properties name. If i remove everything off the stage using
if(stage.numChildren > 0)
{
stage.removeChildAt(0);
}
then it disappear, but it doesn't add the next Child.
package com.clark
{
import com.clark.VectorTest;
import flash.display.*;
import flash.net.*;
import flash.events.*;
import flash.text.TextField;
import com.clark.TouchScroller;
import com.clark.Viewport;
import flash.display.Sprite;
import flash.events.Event;
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Stage;
import fl.controls.Button;
import flash.display.MovieClip;
public class Autoresult extends MovieClip {
public var s1:Autoresult2 = new Autoresult2 ();
public var s3:VectorTest= new VectorTest(new Vector.<Auto>);
public function Autoresult()
addEventListener(Event.ADDED_TO_STAGE, onadded);
function onadded (event:Event):void{
addChild(s1);
}
s1.ARhome.addEventListener(MouseEvent.CLICK,home);
s1.ARauto.addEventListener(MouseEvent.CLICK, auto);
s1.ARsearch.addEventListener(MouseEvent.CLICK,searchss);
if( s3.lists.length > 0 )
{
// get the first listing in the listing array
var newListing:Listing9 = s3.lists[0];
newListing.addEventListener(MouseEvent.CLICK, gotoscener);
}
}
private function home (event:MouseEvent):void{
var s5:Account = new Account ();
removeChild(s1);
removeChild(newListing);
addChild(s5);
}
private function auto (event:MouseEvent):void{
var s4:Auto = new Auto ();
removeChild(s1);
addChild(s4);
}
}
}
VectorTest.as
package com.clark
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class VectorTest extends MovieClip
{
public var lists:Vector.<Listing9>;
public function VectorTest(tests:Vector.<Auto>)
{
for (var j:int = 0; j < tests.length; j++)
{
trace(tests[j].nobed);
trace(tests[j].zip);
trace(tests[j].rangelow);
trace(tests[j].rangehigh);
}
var ben:int = tests ? tests.length : 0;
lists = new Vector.<Listing9>(ben, true);
var currentYs:int = 120;
for (var k:int = 0; k < tests.length; k++)
{
var Bolder:Listing9 = new Listing9();
Bolder.x=40;
var tf:TextField = new TextField();
var tf1:TextField = new TextField();
var tf2:TextField = new TextField();
var tf3:TextField = new TextField();
tf3.width = 100;
tf.defaultTextFormat = new TextFormat("Arial", 12, 0, null, null, null, null, null, TextFormatAlign.CENTER);
tf.width = 100;
tf.autoSize = TextFieldAutoSize.CENTER;
tf1.width = 100;
tf1.autoSize = TextFieldAutoSize.CENTER;
tf2.autoSize = TextFieldAutoSize.CENTER;
tf3.autoSize = TextFieldAutoSize.CENTER;
tf3.width = 100;
tf1.y= tf.height+5;
tf.text = tests[k].nobed;
tf1.text = tests[k].zip;
tf2.text = tests[k].rangelow;
tf3.text = tests[k].rangehigh;
tf.x = (Bolder.height-tf.height)*.2
Bolder.addChild(tf);
Bolder.addChild(tf1);
Bolder.addChild(tf2);
Bolder.addChild(tf3);
// position the object based on the accumulating variable.
Bolder.y = currentYs;
addChild(Bolder);
Bolder.mouseChildren = false; // ignore children mouseEvents
Bolder.mouseEnabled = true; // enable mouse on the object - normally set to true by default
Bolder.useHandCursor = true; // add hand cursor on mouse over
Bolder.buttonMode = true;
lists[k] = Bolder;
currentYs += Bolder.height + 10;
}
if( lists.length > 0 )
{
lists[0].addEventListener(MouseEvent.CLICK,gotoscener);
lists[1].addEventListener(MouseEvent.CLICK,gotoscener1);
lists[2].addEventListener(MouseEvent.CLICK,gotoscener2);
}
}
private function gotoscener(event:MouseEvent):void{
var s9:Autodetail = new Autodetail ();
addChild(s9);
}
private function gotoscener1(event:MouseEvent):void{
var s9:Autodetail = new Autodetail ();
addChild(s9);
}
private function gotoscener2(event:MouseEvent):void{
var s9:Autodetail = new Autodetail ();
addChild(s9);
}
}
}
Autoresult
listing nothing about it. Also you removenewListing
from the display list, but I can't see any code about adding it. – Nicolas Siver