Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asfunction pulling image dynamically

Status
Not open for further replies.

wrighterb

Programmer
Feb 20, 2007
80
0
0
US

I have a movie

Inside this movie I have another movie and text fields pulling in text from the database dynamically.

I created a button, that when pushed will pull the url (via variable from txt doc) of the image and diplay it. Works fine. Everything is dynamic from a database

Now
I want the image to show up as soon as the movie loads just like the text fields do. I was told about asfunction but looked at it and have no where to begin.

Brain Block

 

Tried that a few places, in the main movie and the movie inside the movie

in the first frame etc


onClipEvent (load) {
function getImage() {
mcImage.loadMovie(txtImageURL.text);
}
}

Only seems to work when I do an on (press) to a button.

Its driving me nuts

:)

 
I put that in the main time line
nothing

I put it in the time line of the first movie
nothing

I put it in the movie
nothing.

I know it possible cause I am getting it on press

check it out.

click view beauty and you get the dynamic image.
 
Hey hey

I experimented a little, this is on my main movie clip, this drives the wheel to spin. Look at if (dr>=30) part, the image loads after the wheel stops. Any Ideas?

onClipEvent (load) {
num = Math.round(Math.random()*360);
targetRotation = num;
spinCount = 4;
targetRotation += spinCount*360;
spinSpeed = spinCount*20;
currentRotation = this._rotation;

function spin() {
dr = targetRotation-currentRotation;
currentRotation += dr/spinSpeed;
this._rotation = currentRotation;
if (dr<=165) {
this._rotation = num-164;
}
if (dr>=30) {
mcImage.loadMovie(txtImageURL.text);
}

}
}
onClipEvent (enterFrame) {
spin();
}




 
dr = 1440 to start

so i set it to

if (dr>=1500) {
mcImage.loadMovie(txtImageURL.text);
}

The image comes right away, so to stop it from firing the movie on each frame, what to do?



 


I put this in at the end out of the enterframe

onClipEvent (data) {
mcImage.loadMovie(txtImageURL.text);
}

Never used (data) before
 
Trying to flag it, not getting it to work.

Does onClipEvent (data) ok to use or is it loading the image everytime.

onClipEvent (load) {
num = Math.round(Math.random()*360);
targetRotation = num;
spinCount = 4;
targetRotation += spinCount*360;
spinSpeed = spinCount*20;
currentRotation = this._rotation;
gotit = true;

function spin() {
dr = targetRotation-currentRotation;
currentRotation += dr/spinSpeed;
this._rotation = currentRotation;
if (dr<=165) {
this._rotation = num-164;
}
if (gotit == true) {
mcImage.loadMovie(txtImageURL.text);
gotit = false;
}
}
}

onClipEvent (enterFrame) {
spin();
}
 

The onload doesn't work on the movie clip and it won't work in the root timeline either, don't know why.

I works on the movie with onClipEvent(data) is that ok?


Also I want to find out what part of the wheel it ends
The anchor would be at 45 degrees, I want to see where the wheel actually ends. Does that make sense.
 


How Can i display the Value of dr as the wheel spins.

 
Ok num represents the degree (0-360) that the wheel will stop at, I have the wheel broken down in 12 slices 30 degrees a piece.

I keep putting in

if (num>=360) {
loadMovieNum(" 2);
}

But I am getting nothing.
 
This is placed on the main movie.

Look for if (dr<=90) cause that is at what speed it should stop. then I check for the num variable.

onClipEvent (load) {
num = Math.round(Math.random()*360);
targetRotation = num;
spinCount = 4;
targetRotation += spinCount*360;
spinSpeed = spinCount*20;
currentRotation = this._rotation;
//gotit = true;
//mcImage.loadMovie(txtImageURL.text);

function spin() {
dr = targetRotation-currentRotation;
// (targetRotation + " : " + currentRotation + " : " + dr);
currentRotation += dr/spinSpeed;
this._rotation = currentRotation;
if (dr<=165) {
this._rotation = num-164;
}
if (dr<=90) {
if(num<=360 and num>=0) {
loadMovieNum(" }
}
}
}
onClipEvent (enterFrame) {
spin();
}
 
Again, you are firing "loadMovieNum" again and again forever. If you do that you'll never see the loaded picture.
Code:
onClipEvent (load) {
	num = Math.round(Math.random()*360);
	targetRotation = num;
	spinCount = 4;
	targetRotation += spinCount*360;
	spinSpeed = spinCount*20;
	currentRotation = this._rotation;
	gotit = true;

	function spin() {
		dr = targetRotation-currentRotation;
		currentRotation += dr/spinSpeed;
		this._rotation = currentRotation;
		if (dr<=165) {
			this._rotation = num-164;
		}
		if (dr<=90) {
			if (num<=360 and num>=0) {
				gotit = false;
				loadMovieNum("[URL unfurl="true"]http://www.wrighter.com/hotsluts/images/1.jpg",[/URL] 2);
			}
		}
	}
}

onClipEvent (enterFrame) {
	if (gotit) {
		spin();
	}
}

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top