Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 4th, 2003, 03:42 PM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
variables across levels?

I've got into a twist over levels and roots and I'm hoping someone can help. I've loaded some variables into the root from a button within a movie clip on the stage.

I think it goes _root/movieclip/button which I believe is 2 levels? I've loaded variables into _root but I want to look at them on frame 1 of the movieclip as well. How do I do that?

The name of the variable I want to look at is 'picture' so I thought that to reference that variable I go:
_root.picture but that doesn't seem to work. I've checked that the variable exists at level 0 and it does.

What am I doing wrong?

(full script below from the button itself)

Code:
on (press) {

	loadVariablesNum("query.php?id=12", 0);

		_root.createTextField("theTextBox", 20, 385, 100, 350, 520);
		_root.theTextBox.background = true;
		_root.theTextBox.border = true;
		_root.theTextBox.backgroundColor = 0xFFFFFF;
		//white
		_root.theTextBox.borderColor = 0x666666;
		//black
		_root.theTextBox.multiline = true;
		_root.theTextBox.wordWrap = true;
		_root.theTextBox.html = true;
		_root.theTextBox.variable = "storyField";
		//create some formatting for our text box
		_root.myTextFormat = new TextFormat();
		_root.myTextFormat.font = "Arial";
		_root.myTextFormat.size = 12;
		_root.myTextFormat.color = 0x000000;
		//black
		//format our text box
		_root.theTextBox.setNewTextFormat(myTextFormat);
		
		//create image holders
		_root.createEmptyMovieClip("imageHolder1", 200);
		_root.createEmptyMovieClip("imageHolder2", 201);
		_root.imageHolder1._x = 100;
		_root.imageHolder1._y = 100;
		_root.imageHolder2._x = 100;
		_root.imageHolder2._y = 350;
	
	//load the content from database
	_root.imageHolder1.loadMovie(_root.picture);
	_root.imageHolder2.loadMovie(_root.picture);

}

Reply With Quote
  #2  
Old December 5th, 2003, 06:10 AM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 49 m 36 sec
Reputation Power: 534
Facebook MySpace
Hi, just a thought but try moving loadVariablesNum("query.php?id=12", 0); to the root first frame. This could be a problem with the data not being fully read by the time you use loadmovie. If it works after this then you know you need to make a check to ensure all the data is read prior to trying to load the pictures.
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old December 5th, 2003, 07:10 AM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Thanks, I'll try that but it won't solve my problem ultimately because the loadvariables has to happen on the button because I'm making a different query on the database/loading a different set of variables for each individual button press.

If I do a trace of the variables then I find that they are all currently undefined within the movieclip that contains the button.

Reply With Quote
  #4  
Old December 5th, 2003, 07:47 AM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 49 m 36 sec
Reputation Power: 534
Facebook MySpace
Hi, I only suggested the above as a testing practise. Someone else had similar problems and found the solution to be that the data hadnt loaded fully prior to trying to use it. The results were the same as yours currently are.

Try something like this:

make a new movie in root. give it the instance name dbaccess. make it two keyframes long. in the first kf have:

function readTheData(idNumber)
{
_root.completed = false;
loadVariablesNum("query.php?id="+idNumber, 0);
}

if(_root.completed)
{
//load the content from database
_root.imageHolder1.loadMovie(_root.picture);
_root.imageHolder2.loadMovie(_root.picture);
stop();
}


in the second kf have:

gotoAndPlay(1);

Now remove the loadvars and image loading bit from your buttons.

and use:

_root.dbaccess.readTheData(12);

I'm not sure how your database data is fed back. if you use arrays or objects simply add a new variable called completed and set it to true.

I wrote all that in here and not in flash so I havent tested it but I'm pretty sure that will work fine.

If you need to use different values or more than one var for different buttons simply add more functions to the dbaccess movie or expand the current one. i.e.

function readTheNews(topicNumber, topicCount, topicContent)
{
_root.completed = false;
loadVariablesNum("query.php?id="+idNumber+"&count="+topicCount+"&content="topicContent, 0);
}

I think you can work it all out from here. You can even specify a target clip (i think) to load into.

I really hope this helps cos I know db's can be a pain!

Reply With Quote
  #5  
Old December 5th, 2003, 05:36 PM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
This works great - the first time you click the button! If you click another button (different id number) or reclick that button the text reloads in the text box but the images don't reload - they dissappear.

Puzzling!

Reply With Quote
  #6  
Old December 6th, 2003, 06:59 AM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 49 m 36 sec
Reputation Power: 534
Facebook MySpace

Reply With Quote
  #7  
Old December 6th, 2003, 10:39 AM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
That's useful. I still seem to have the same problem though despite adding in -
Code:
		delete _root.imageHolder1;
		delete _root.imageHolder2;

	   _root.unloadMovieNum("imageHolder1");
	   _root.unloadMovieNum("imageHolder2");

		_root.createEmptyMovieClip("imageHolder1", 200);
		_root.createEmptyMovieClip("imageHolder2", 201);


Another question - whats the difference between these three lines of code?

Code:
loadVariablesNum("http://192.168.0.1/playout/query.php?id="+idNumber, _level0);

loadVariablesNum("http://192.168.0.1/playout/query.php?id="+idNumber, 0);

loadVariablesNum("http://192.168.0.1/playout/query.php?id="+idNumber, _root);

Last edited by Matt Phelps : December 6th, 2003 at 10:42 AM.

Reply With Quote
  #8  
Old December 6th, 2003, 10:52 AM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 49 m 36 sec
Reputation Power: 534
Facebook MySpace
Hi, I dont use delete that often. If I want to get rid of a movie clip I usually use:

_root.imageHolder1.unloadMovie();
_root.imageHolder2.unloadMovie();

Try removing the delete statements and swapping the relevant lines with the above.

As for part 2 of your question, this link has more information.

Reply With Quote
  #9  
Old December 6th, 2003, 10:59 AM
Matt Phelps Matt Phelps is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 33 Matt Phelps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
does unloadmovie delete the contents of the clip or remove the whole movie from the stage? I think it's the later...right?

Reply With Quote
  #10  
Old December 6th, 2003, 11:11 AM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 49 m 36 sec
Reputation Power: 534
Facebook MySpace
bingo

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > variables across levels?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |